Commit c0840359e3086a23d74888ffb383ff4427b9a5e0
1 parent
0ceb5c27
Exists in
master
Callback de cursor mudado para a estrutura de sessão
Showing
8 changed files
with
46 additions
and
29 deletions
Show diff stats
latest/src/gtk2/gui.h
... | ... | @@ -57,7 +57,7 @@ |
57 | 57 | #include <lib3270.h> |
58 | 58 | #include <lib3270/toggle.h> |
59 | 59 | |
60 | - #define CURSOR_MODE_3270 (CURSOR_MODE_USER+9) | |
60 | + #define CURSOR_MODE_3270 (LIB3270_CURSOR_USER+9) | |
61 | 61 | |
62 | 62 | enum _drag_type |
63 | 63 | { |
... | ... | @@ -75,7 +75,7 @@ |
75 | 75 | }; |
76 | 76 | |
77 | 77 | LOCAL_EXTERN int drag_type; |
78 | - LOCAL_EXTERN CURSOR_MODE cursor_mode; | |
78 | + LOCAL_EXTERN LIB3270_CURSOR cursor_mode; | |
79 | 79 | |
80 | 80 | #define MAX_CHR_LENGTH 4 |
81 | 81 | typedef struct _element | ... | ... |
latest/src/gtk2/mouse.c
... | ... | @@ -721,7 +721,7 @@ |
721 | 721 | Trace("Type: %d",type); |
722 | 722 | |
723 | 723 | if(type >= 0) |
724 | - gdk_window_set_cursor(terminal->window,wCursor[CURSOR_MODE_USER+type]); | |
724 | + gdk_window_set_cursor(terminal->window,wCursor[LIB3270_CURSOR_USER+type]); | |
725 | 725 | else |
726 | 726 | gdk_window_set_cursor(terminal->window,wCursor[cursor_mode]); |
727 | 727 | } | ... | ... |
latest/src/gtk2/screen.c
... | ... | @@ -70,7 +70,7 @@ |
70 | 70 | |
71 | 71 | static int SetSuspended(int state); |
72 | 72 | static void SetScript(SCRIPT_STATE state); |
73 | - static void set_cursor(CURSOR_MODE mode); | |
73 | + static void set_cursor(H3270 *session, LIB3270_CURSOR mode); | |
74 | 74 | static void set_oia(H3270 *session, OIA_FLAG id, unsigned char on); |
75 | 75 | static void set_lu(H3270 *session, const char *lu); |
76 | 76 | // static void changed(int bstart, int bend); |
... | ... | @@ -140,6 +140,7 @@ |
140 | 140 | struct _view view = { 0 }; |
141 | 141 | char * charset = NULL; |
142 | 142 | char * window_title = PROGRAM_NAME; |
143 | + LIB3270_CURSOR cursor_mode = -1; | |
143 | 144 | |
144 | 145 | gboolean screen_updates_enabled = FALSE; |
145 | 146 | |
... | ... | @@ -514,7 +515,7 @@ |
514 | 515 | |
515 | 516 | if(id == LIB3270_STATUS_BLANK) |
516 | 517 | { |
517 | - set_cursor(CURSOR_MODE_NORMAL); | |
518 | + set_cursor(session,CURSOR_MODE_NORMAL); | |
518 | 519 | update_cursor_pixmap(); |
519 | 520 | } |
520 | 521 | else if(id >= LIB3270_STATUS_USER) |
... | ... | @@ -527,12 +528,10 @@ |
527 | 528 | |
528 | 529 | } |
529 | 530 | |
530 | - | |
531 | - CURSOR_MODE cursor_mode = -1; | |
532 | - | |
533 | - static void set_cursor(CURSOR_MODE mode) | |
531 | + static void set_cursor(H3270 *session, LIB3270_CURSOR mode) | |
534 | 532 | { |
535 | - if(mode == cursor_mode || mode > CURSOR_MODE_USER || !terminal || !terminal->window) | |
533 | + | |
534 | + if(mode == cursor_mode || mode > LIB3270_CURSOR_USER || !terminal || !terminal->window) | |
536 | 535 | return; |
537 | 536 | |
538 | 537 | cursor_mode = mode; | ... | ... |
latest/src/include/lib3270.h
... | ... | @@ -112,6 +112,24 @@ |
112 | 112 | |
113 | 113 | } LIB3270_FLAG; |
114 | 114 | |
115 | + | |
116 | + /** | |
117 | + * Cursor modes. | |
118 | + * | |
119 | + * Cursor modes set by library; an application can us it | |
120 | + * as a hint to change the mouse cursor based on connection status. | |
121 | + * | |
122 | + */ | |
123 | + typedef enum _LIB3270_CURSOR | |
124 | + { | |
125 | + LIB3270_CURSOR_NORMAL, /**< Ready for user actions */ | |
126 | + LIB3270_CURSOR_WAITING, /**< Waiting for host */ | |
127 | + LIB3270_CURSOR_LOCKED, /**< Locked, can't receive user actions */ | |
128 | + | |
129 | + LIB3270_CURSOR_USER | |
130 | + } LIB3270_CURSOR; | |
131 | + | |
132 | + | |
115 | 133 | /** |
116 | 134 | * connection state |
117 | 135 | */ | ... | ... |
latest/src/include/lib3270/api.h
... | ... | @@ -277,6 +277,7 @@ |
277 | 277 | void (*update_luname)(H3270 *session, const char *name); |
278 | 278 | void (*update_status)(H3270 *session, LIB3270_STATUS id); |
279 | 279 | void (*erase)(H3270 *session); |
280 | + void (*cursor)(H3270 *session, LIB3270_CURSOR id); | |
280 | 281 | |
281 | 282 | }; |
282 | 283 | |
... | ... | @@ -447,14 +448,10 @@ |
447 | 448 | |
448 | 449 | |
449 | 450 | /* Screen processing */ |
450 | - typedef enum _CURSOR_MODE | |
451 | - { | |
452 | - CURSOR_MODE_NORMAL, | |
453 | - CURSOR_MODE_WAITING, | |
454 | - CURSOR_MODE_LOCKED, | |
455 | 451 | |
456 | - CURSOR_MODE_USER | |
457 | - } CURSOR_MODE; | |
452 | + #define CURSOR_MODE_NORMAL LIB3270_CURSOR_NORMAL | |
453 | + #define CURSOR_MODE_WAITING LIB3270_CURSOR_WAITING | |
454 | + #define CURSOR_MODE_LOCKED LIB3270_CURSOR_LOCKED | |
458 | 455 | |
459 | 456 | typedef enum _SCRIPT_STATE |
460 | 457 | { |
... | ... | @@ -509,7 +506,7 @@ |
509 | 506 | void (*set_script)(SCRIPT_STATE state); |
510 | 507 | void (*reset)(int lock); |
511 | 508 | void (*status)(H3270 *session, LIB3270_STATUS id); |
512 | - void (*cursor)(CURSOR_MODE mode); | |
509 | + void (*cursor)(H3270 *session, LIB3270_CURSOR mode); | |
513 | 510 | void (*lu)(H3270 *session, const char *lu); |
514 | 511 | void (*set_oia)(H3270 *session, OIA_FLAG id, unsigned char on); |
515 | 512 | ... | ... |
latest/src/lib/kybd.c
... | ... | @@ -527,15 +527,15 @@ key_AID(unsigned char aid_code) |
527 | 527 | buffer_addr = h3270.cursor_addr; |
528 | 528 | } |
529 | 529 | if (!IN_SSCP || aid_code != AID_CLEAR) { |
530 | - status_twait(NULL); | |
530 | + status_twait(&h3270); | |
531 | 531 | mcursor_waiting(&h3270); |
532 | 532 | set_toggle(INSERT,0); |
533 | 533 | kybdlock_set(KL_OIA_TWAIT | KL_OIA_LOCKED, "key_AID"); |
534 | 534 | } |
535 | 535 | aid = aid_code; |
536 | 536 | ctlr_read_modified(aid, False); |
537 | - ticking_start(NULL,False); | |
538 | - status_ctlr_done(NULL); | |
537 | + ticking_start(&h3270,False); | |
538 | + status_ctlr_done(&h3270); | |
539 | 539 | } |
540 | 540 | |
541 | 541 | LIB3270_FKEY_ACTION( pfkey ) | ... | ... |
latest/src/lib/screen.c
... | ... | @@ -147,6 +147,9 @@ int screen_init(H3270 *session) |
147 | 147 | if(callbacks->erase) |
148 | 148 | session->erase = callbacks->erase; |
149 | 149 | |
150 | + if(callbacks->cursor) | |
151 | + session->cursor = callbacks->cursor; | |
152 | + | |
150 | 153 | if(callbacks->init()) |
151 | 154 | { |
152 | 155 | popup_an_error("Can't initialize terminal."); |
... | ... | @@ -539,16 +542,16 @@ void status_oerr(H3270 *session, int error_type) |
539 | 542 | |
540 | 543 | void status_resolving(H3270 *session, Boolean on) |
541 | 544 | { |
542 | - if(callbacks && callbacks->cursor) | |
543 | - callbacks->cursor(on ? CURSOR_MODE_LOCKED : CURSOR_MODE_NORMAL); | |
545 | + if(session->cursor) | |
546 | + session->cursor(session, on ? CURSOR_MODE_LOCKED : CURSOR_MODE_NORMAL); | |
544 | 547 | |
545 | 548 | status_changed(session, on ? LIB3270_STATUS_RESOLVING : LIB3270_STATUS_BLANK); |
546 | 549 | } |
547 | 550 | |
548 | 551 | void status_connecting(H3270 *session, Boolean on) |
549 | 552 | { |
550 | - if(callbacks && callbacks->cursor) | |
551 | - callbacks->cursor(on ? CURSOR_MODE_LOCKED : CURSOR_MODE_NORMAL); | |
553 | + if(session->cursor) | |
554 | + session->cursor(session,on ? CURSOR_MODE_LOCKED : CURSOR_MODE_NORMAL); | |
552 | 555 | |
553 | 556 | status_changed(session, on ? LIB3270_STATUS_CONNECTING : LIB3270_STATUS_BLANK); |
554 | 557 | } |
... | ... | @@ -822,12 +825,12 @@ void Warning(const char *fmt, ...) |
822 | 825 | |
823 | 826 | } |
824 | 827 | |
825 | -void mcursor_set(H3270 *session,CURSOR_MODE m) | |
828 | +void mcursor_set(H3270 *session,LIB3270_CURSOR m) | |
826 | 829 | { |
827 | 830 | CHECK_SESSION_HANDLE(session); |
828 | 831 | |
829 | - if(callbacks && callbacks->cursor) | |
830 | - callbacks->cursor(m); | |
832 | + if(session->cursor) | |
833 | + session->cursor(session,m); | |
831 | 834 | } |
832 | 835 | |
833 | 836 | /* | ... | ... |
latest/src/lib/screenc.h
... | ... | @@ -32,7 +32,7 @@ LIB3270_INTERNAL int screen_init(H3270 *session); |
32 | 32 | LIB3270_INTERNAL FILE *start_pager(void); |
33 | 33 | LIB3270_INTERNAL Boolean screen_new_display_charsets(char *cslist, char *csname); |
34 | 34 | |
35 | -LIB3270_INTERNAL void mcursor_set(H3270 *session,CURSOR_MODE m); | |
35 | +LIB3270_INTERNAL void mcursor_set(H3270 *session,LIB3270_CURSOR m); | |
36 | 36 | |
37 | 37 | #define mcursor_locked(x) mcursor_set(x,CURSOR_MODE_LOCKED) |
38 | 38 | #define mcursor_normal(x) mcursor_set(x,CURSOR_MODE_NORMAL) | ... | ... |