diff --git a/latest/src/gtk2/gui.h b/latest/src/gtk2/gui.h index 477142e..499e52f 100644 --- a/latest/src/gtk2/gui.h +++ b/latest/src/gtk2/gui.h @@ -57,7 +57,7 @@ #include #include - #define CURSOR_MODE_3270 (CURSOR_MODE_USER+9) + #define CURSOR_MODE_3270 (LIB3270_CURSOR_USER+9) enum _drag_type { @@ -75,7 +75,7 @@ }; LOCAL_EXTERN int drag_type; - LOCAL_EXTERN CURSOR_MODE cursor_mode; + LOCAL_EXTERN LIB3270_CURSOR cursor_mode; #define MAX_CHR_LENGTH 4 typedef struct _element diff --git a/latest/src/gtk2/mouse.c b/latest/src/gtk2/mouse.c index 15bd750..10f60ce 100644 --- a/latest/src/gtk2/mouse.c +++ b/latest/src/gtk2/mouse.c @@ -721,7 +721,7 @@ Trace("Type: %d",type); if(type >= 0) - gdk_window_set_cursor(terminal->window,wCursor[CURSOR_MODE_USER+type]); + gdk_window_set_cursor(terminal->window,wCursor[LIB3270_CURSOR_USER+type]); else gdk_window_set_cursor(terminal->window,wCursor[cursor_mode]); } diff --git a/latest/src/gtk2/screen.c b/latest/src/gtk2/screen.c index 7f9391b..98c2b6f 100644 --- a/latest/src/gtk2/screen.c +++ b/latest/src/gtk2/screen.c @@ -70,7 +70,7 @@ static int SetSuspended(int state); static void SetScript(SCRIPT_STATE state); - static void set_cursor(CURSOR_MODE mode); + static void set_cursor(H3270 *session, LIB3270_CURSOR mode); static void set_oia(H3270 *session, OIA_FLAG id, unsigned char on); static void set_lu(H3270 *session, const char *lu); // static void changed(int bstart, int bend); @@ -140,6 +140,7 @@ struct _view view = { 0 }; char * charset = NULL; char * window_title = PROGRAM_NAME; + LIB3270_CURSOR cursor_mode = -1; gboolean screen_updates_enabled = FALSE; @@ -514,7 +515,7 @@ if(id == LIB3270_STATUS_BLANK) { - set_cursor(CURSOR_MODE_NORMAL); + set_cursor(session,CURSOR_MODE_NORMAL); update_cursor_pixmap(); } else if(id >= LIB3270_STATUS_USER) @@ -527,12 +528,10 @@ } - - CURSOR_MODE cursor_mode = -1; - - static void set_cursor(CURSOR_MODE mode) + static void set_cursor(H3270 *session, LIB3270_CURSOR mode) { - if(mode == cursor_mode || mode > CURSOR_MODE_USER || !terminal || !terminal->window) + + if(mode == cursor_mode || mode > LIB3270_CURSOR_USER || !terminal || !terminal->window) return; cursor_mode = mode; diff --git a/latest/src/include/lib3270.h b/latest/src/include/lib3270.h index e52721b..55c43e6 100644 --- a/latest/src/include/lib3270.h +++ b/latest/src/include/lib3270.h @@ -112,6 +112,24 @@ } LIB3270_FLAG; + + /** + * Cursor modes. + * + * Cursor modes set by library; an application can us it + * as a hint to change the mouse cursor based on connection status. + * + */ + typedef enum _LIB3270_CURSOR + { + LIB3270_CURSOR_NORMAL, /**< Ready for user actions */ + LIB3270_CURSOR_WAITING, /**< Waiting for host */ + LIB3270_CURSOR_LOCKED, /**< Locked, can't receive user actions */ + + LIB3270_CURSOR_USER + } LIB3270_CURSOR; + + /** * connection state */ diff --git a/latest/src/include/lib3270/api.h b/latest/src/include/lib3270/api.h index a7f09ae..17df3ee 100644 --- a/latest/src/include/lib3270/api.h +++ b/latest/src/include/lib3270/api.h @@ -277,6 +277,7 @@ void (*update_luname)(H3270 *session, const char *name); void (*update_status)(H3270 *session, LIB3270_STATUS id); void (*erase)(H3270 *session); + void (*cursor)(H3270 *session, LIB3270_CURSOR id); }; @@ -447,14 +448,10 @@ /* Screen processing */ - typedef enum _CURSOR_MODE - { - CURSOR_MODE_NORMAL, - CURSOR_MODE_WAITING, - CURSOR_MODE_LOCKED, - CURSOR_MODE_USER - } CURSOR_MODE; + #define CURSOR_MODE_NORMAL LIB3270_CURSOR_NORMAL + #define CURSOR_MODE_WAITING LIB3270_CURSOR_WAITING + #define CURSOR_MODE_LOCKED LIB3270_CURSOR_LOCKED typedef enum _SCRIPT_STATE { @@ -509,7 +506,7 @@ void (*set_script)(SCRIPT_STATE state); void (*reset)(int lock); void (*status)(H3270 *session, LIB3270_STATUS id); - void (*cursor)(CURSOR_MODE mode); + void (*cursor)(H3270 *session, LIB3270_CURSOR mode); void (*lu)(H3270 *session, const char *lu); void (*set_oia)(H3270 *session, OIA_FLAG id, unsigned char on); diff --git a/latest/src/lib/kybd.c b/latest/src/lib/kybd.c index 3da4c0b..8bab3e5 100644 --- a/latest/src/lib/kybd.c +++ b/latest/src/lib/kybd.c @@ -527,15 +527,15 @@ key_AID(unsigned char aid_code) buffer_addr = h3270.cursor_addr; } if (!IN_SSCP || aid_code != AID_CLEAR) { - status_twait(NULL); + status_twait(&h3270); mcursor_waiting(&h3270); set_toggle(INSERT,0); kybdlock_set(KL_OIA_TWAIT | KL_OIA_LOCKED, "key_AID"); } aid = aid_code; ctlr_read_modified(aid, False); - ticking_start(NULL,False); - status_ctlr_done(NULL); + ticking_start(&h3270,False); + status_ctlr_done(&h3270); } LIB3270_FKEY_ACTION( pfkey ) diff --git a/latest/src/lib/screen.c b/latest/src/lib/screen.c index 2961238..c92bc5c 100644 --- a/latest/src/lib/screen.c +++ b/latest/src/lib/screen.c @@ -147,6 +147,9 @@ int screen_init(H3270 *session) if(callbacks->erase) session->erase = callbacks->erase; + if(callbacks->cursor) + session->cursor = callbacks->cursor; + if(callbacks->init()) { popup_an_error("Can't initialize terminal."); @@ -539,16 +542,16 @@ void status_oerr(H3270 *session, int error_type) void status_resolving(H3270 *session, Boolean on) { - if(callbacks && callbacks->cursor) - callbacks->cursor(on ? CURSOR_MODE_LOCKED : CURSOR_MODE_NORMAL); + if(session->cursor) + session->cursor(session, on ? CURSOR_MODE_LOCKED : CURSOR_MODE_NORMAL); status_changed(session, on ? LIB3270_STATUS_RESOLVING : LIB3270_STATUS_BLANK); } void status_connecting(H3270 *session, Boolean on) { - if(callbacks && callbacks->cursor) - callbacks->cursor(on ? CURSOR_MODE_LOCKED : CURSOR_MODE_NORMAL); + if(session->cursor) + session->cursor(session,on ? CURSOR_MODE_LOCKED : CURSOR_MODE_NORMAL); status_changed(session, on ? LIB3270_STATUS_CONNECTING : LIB3270_STATUS_BLANK); } @@ -822,12 +825,12 @@ void Warning(const char *fmt, ...) } -void mcursor_set(H3270 *session,CURSOR_MODE m) +void mcursor_set(H3270 *session,LIB3270_CURSOR m) { CHECK_SESSION_HANDLE(session); - if(callbacks && callbacks->cursor) - callbacks->cursor(m); + if(session->cursor) + session->cursor(session,m); } /* diff --git a/latest/src/lib/screenc.h b/latest/src/lib/screenc.h index e366d23..bef0389 100644 --- a/latest/src/lib/screenc.h +++ b/latest/src/lib/screenc.h @@ -32,7 +32,7 @@ LIB3270_INTERNAL int screen_init(H3270 *session); LIB3270_INTERNAL FILE *start_pager(void); LIB3270_INTERNAL Boolean screen_new_display_charsets(char *cslist, char *csname); -LIB3270_INTERNAL void mcursor_set(H3270 *session,CURSOR_MODE m); +LIB3270_INTERNAL void mcursor_set(H3270 *session,LIB3270_CURSOR m); #define mcursor_locked(x) mcursor_set(x,CURSOR_MODE_LOCKED) #define mcursor_normal(x) mcursor_set(x,CURSOR_MODE_NORMAL) -- libgit2 0.21.2