Commit e3108b0c42a2923372be7c87ebe9478abe3b045b
1 parent
ce8fb91e
Exists in
master
and in
5 other branches
Passando gerência do ponteiro do mouse para a lib3270
Showing
12 changed files
with
100 additions
and
116 deletions
Show diff stats
src/include/lib3270.h
... | ... | @@ -204,20 +204,33 @@ |
204 | 204 | |
205 | 205 | |
206 | 206 | /** |
207 | - * Cursor modes. | |
207 | + * Pointer modes. | |
208 | 208 | * |
209 | - * Cursor modes set by library; an application can us it | |
210 | - * as a hint to change the mouse cursor based on connection status. | |
209 | + * Pointer modes set by library; an application can use it | |
210 | + * as a hint to change the mouse pointer based on connection status. | |
211 | 211 | * |
212 | 212 | */ |
213 | - typedef enum _LIB3270_CURSOR | |
213 | + typedef enum _LIB3270_POINTER | |
214 | 214 | { |
215 | - LIB3270_CURSOR_EDITABLE, /**< Ready for user actions */ | |
216 | - LIB3270_CURSOR_WAITING, /**< Waiting for host */ | |
217 | - LIB3270_CURSOR_LOCKED, /**< Locked, can't receive user actions */ | |
215 | + LIB3270_POINTER_UNLOCKED, /**< Ready for user actions */ | |
216 | + LIB3270_POINTER_WAITING, /**< Waiting for host */ | |
217 | + LIB3270_POINTER_LOCKED, /**< Locked, can't receive user actions */ | |
218 | 218 | |
219 | - LIB3270_CURSOR_USER | |
220 | - } LIB3270_CURSOR; | |
219 | + LIB3270_POINTER_PROTECTED, | |
220 | + LIB3270_POINTER_MOVE_SELECTION, | |
221 | + LIB3270_POINTER_SELECTION_TOP_LEFT, | |
222 | + LIB3270_POINTER_SELECTION_TOP_RIGHT, | |
223 | + LIB3270_POINTER_SELECTION_TOP, | |
224 | + LIB3270_POINTER_SELECTION_BOTTOM_LEFT, | |
225 | + LIB3270_POINTER_SELECTION_BOTTOM_RIGHT, | |
226 | + LIB3270_POINTER_SELECTION_BOTTOM, | |
227 | + LIB3270_POINTER_SELECTION_LEFT, | |
228 | + LIB3270_POINTER_SELECTION_RIGHT, | |
229 | + LIB3270_POINTER_QUESTION, | |
230 | + | |
231 | + LIB3270_POINTER_COUNT | |
232 | + | |
233 | + } LIB3270_POINTER; | |
221 | 234 | |
222 | 235 | |
223 | 236 | /** |
... | ... | @@ -1118,6 +1131,9 @@ |
1118 | 1131 | |
1119 | 1132 | LIB3270_EXPORT const LIB3270_OPTION_ENTRY * lib3270_get_option_list(void); |
1120 | 1133 | |
1134 | + LIB3270_EXPORT LIB3270_POINTER lib3270_get_pointer(H3270 *hSession, int baddr); | |
1135 | + | |
1136 | + | |
1121 | 1137 | /** |
1122 | 1138 | * The host is TSO? |
1123 | 1139 | * | ... | ... |
src/include/lib3270/session.h
... | ... | @@ -58,7 +58,7 @@ |
58 | 58 | void (*erase)(H3270 *session); |
59 | 59 | void (*suspend)(H3270 *session); |
60 | 60 | void (*resume)(H3270 *session); |
61 | - void (*cursor)(H3270 *session, LIB3270_CURSOR id); | |
61 | + void (*cursor)(H3270 *session, LIB3270_POINTER id); | |
62 | 62 | void (*set_selection)(H3270 *session, unsigned char on); |
63 | 63 | void (*ctlr_done)(H3270 *session); |
64 | 64 | void (*autostart)(H3270 *session); | ... | ... |
src/lib3270/api.h
... | ... | @@ -253,9 +253,9 @@ |
253 | 253 | |
254 | 254 | /* Screen processing */ |
255 | 255 | |
256 | - #define CURSOR_MODE_NORMAL LIB3270_CURSOR_EDITABLE | |
257 | - #define CURSOR_MODE_WAITING LIB3270_CURSOR_WAITING | |
258 | - #define CURSOR_MODE_LOCKED LIB3270_CURSOR_LOCKED | |
256 | +// #define CURSOR_MODE_NORMAL LIB3270_CURSOR_EDITABLE | |
257 | +// #define CURSOR_MODE_WAITING LIB3270_CURSOR_WAITING | |
258 | +// #define CURSOR_MODE_LOCKED LIB3270_CURSOR_LOCKED | |
259 | 259 | |
260 | 260 | typedef enum _SCRIPT_STATE |
261 | 261 | { | ... | ... |
src/lib3270/private.h
src/lib3270/resolver.c
... | ... | @@ -180,28 +180,3 @@ static int cresolve_host_and_port(H3270 *h, struct parms *p) |
180 | 180 | return 0; |
181 | 181 | } */ |
182 | 182 | |
183 | -/* | |
184 | -int resolve_host_and_port(H3270 *hSession, const char *host, char *portname, unsigned short *pport,struct sockaddr *sa, socklen_t *sa_len, char *errmsg, int em_len) | |
185 | -{ | |
186 | - int rc; | |
187 | - LIB3270_MESSAGE saved_status = hSession->oia_status; | |
188 | - struct parms p = { sizeof(struct parms), host, portname, pport, sa, sa_len, errmsg, em_len }; | |
189 | - | |
190 | - trace("Calling resolver for %s status=%d", p.host, (int) saved_status); | |
191 | - | |
192 | - status_changed(hSession,LIB3270_MESSAGE_RESOLVING); | |
193 | - hSession->cursor(hSession,CURSOR_MODE_LOCKED); | |
194 | - | |
195 | - rc = lib3270_call_thread((int (*)(H3270 *, void *)) cresolve_host_and_port,hSession,&p); | |
196 | - | |
197 | - hSession->cursor(hSession,CURSOR_MODE_NORMAL); | |
198 | - | |
199 | - if(saved_status != -1) | |
200 | - status_changed(hSession,saved_status); | |
201 | - | |
202 | - trace("Calling resolver for %s exits with %d", p.host, rc); | |
203 | - | |
204 | - return rc; | |
205 | - | |
206 | -} | |
207 | -*/ | ... | ... |
src/lib3270/screen.c
... | ... | @@ -486,9 +486,7 @@ void status_oerr(H3270 *session, int error_type) |
486 | 486 | |
487 | 487 | void status_connecting(H3270 *session, Boolean on) |
488 | 488 | { |
489 | - if(session->cbk.cursor) | |
490 | - session->cbk.cursor(session,on ? CURSOR_MODE_LOCKED : CURSOR_MODE_NORMAL); | |
491 | - | |
489 | + mcursor_set(session,on ? LIB3270_POINTER_LOCKED : LIB3270_POINTER_UNLOCKED); | |
492 | 490 | status_changed(session, on ? LIB3270_MESSAGE_CONNECTING : LIB3270_MESSAGE_NONE); |
493 | 491 | } |
494 | 492 | |
... | ... | @@ -506,8 +504,7 @@ void status_reset(H3270 *session) |
506 | 504 | } |
507 | 505 | else |
508 | 506 | { |
509 | - if(session->cbk.cursor) | |
510 | - session->cbk.cursor(session,CURSOR_MODE_NORMAL); | |
507 | + mcursor_set(session,LIB3270_POINTER_UNLOCKED); | |
511 | 508 | status_changed(session,LIB3270_MESSAGE_NONE); |
512 | 509 | } |
513 | 510 | |
... | ... | @@ -736,12 +733,17 @@ void popup_system_error(H3270 *session, const char *title, const char *message, |
736 | 733 | va_end(args); |
737 | 734 | } |
738 | 735 | |
739 | -void mcursor_set(H3270 *session,LIB3270_CURSOR m) | |
736 | +void mcursor_set(H3270 *session,LIB3270_POINTER m) | |
740 | 737 | { |
741 | 738 | CHECK_SESSION_HANDLE(session); |
742 | 739 | |
743 | - if(session->cbk.cursor) | |
744 | - session->cbk.cursor(session,m); | |
740 | + if(session->pointer != ((unsigned short) m)) { | |
741 | + | |
742 | + // Pointer changed | |
743 | + session->pointer = (unsigned short) m; | |
744 | + session->cbk.cursor(session,m & 0x03); | |
745 | + | |
746 | + } | |
745 | 747 | } |
746 | 748 | |
747 | 749 | LIB3270_ACTION( testpattern ) | ... | ... |
src/lib3270/screenc.h
... | ... | @@ -42,11 +42,11 @@ |
42 | 42 | |
43 | 43 | LIB3270_INTERNAL int screen_init(H3270 *session); |
44 | 44 | // LIB3270_INTERNAL Boolean screen_new_display_charsets(char *cslist, char *csname); |
45 | -LIB3270_INTERNAL void mcursor_set(H3270 *session,LIB3270_CURSOR m); | |
45 | +LIB3270_INTERNAL void mcursor_set(H3270 *session,LIB3270_POINTER m); | |
46 | 46 | |
47 | -#define mcursor_locked(x) mcursor_set(x,CURSOR_MODE_LOCKED) | |
48 | -#define mcursor_normal(x) mcursor_set(x,CURSOR_MODE_NORMAL) | |
49 | -#define mcursor_waiting(x) mcursor_set(x,CURSOR_MODE_WAITING) | |
47 | +#define mcursor_locked(x) mcursor_set(x,LIB3270_POINTER_LOCKED) | |
48 | +#define mcursor_normal(x) mcursor_set(x,LIB3270_POINTER_UNLOCKED) | |
49 | +#define mcursor_waiting(x) mcursor_set(x,LIB3270_POINTER_WAITING) | |
50 | 50 | |
51 | 51 | LIB3270_INTERNAL void notify_toggle_changed(H3270 *session, LIB3270_TOGGLE ix, unsigned char value, LIB3270_TOGGLE_TYPE reason); |
52 | 52 | LIB3270_INTERNAL void set_viewsize(H3270 *session, int rows, int cols); | ... | ... |
src/lib3270/session.c
... | ... | @@ -140,7 +140,7 @@ static void update_selection(H3270 *session, int start, int end) |
140 | 140 | { |
141 | 141 | } |
142 | 142 | |
143 | -static void set_cursor(H3270 *session, LIB3270_CURSOR id) | |
143 | +static void set_cursor(H3270 *session, LIB3270_POINTER id) | |
144 | 144 | { |
145 | 145 | } |
146 | 146 | |
... | ... | @@ -241,6 +241,7 @@ static void lib3270_session_init(H3270 *hSession, const char *model, const char |
241 | 241 | hSession->colors = 16; |
242 | 242 | hSession->m3279 = 1; |
243 | 243 | hSession->unlock_delay_ms = 350; // 0.35s after last unlock |
244 | + hSession->pointer = (unsigned short) LIB3270_POINTER_LOCKED; | |
244 | 245 | |
245 | 246 | // CSD |
246 | 247 | for(f=0;f<4;f++) | ... | ... |
src/lib3270/util.c
... | ... | @@ -75,6 +75,7 @@ |
75 | 75 | #include "utilc.h" |
76 | 76 | #include "popupsc.h" |
77 | 77 | #include "api.h" |
78 | +#include <lib3270/selection.h> | |
78 | 79 | |
79 | 80 | #define my_isspace(c) isspace((unsigned char)c) |
80 | 81 | |
... | ... | @@ -1013,3 +1014,37 @@ int gettimeofday(struct timeval *tv, void *ignored) |
1013 | 1014 | } |
1014 | 1015 | |
1015 | 1016 | |
1017 | + LIB3270_EXPORT LIB3270_POINTER lib3270_get_pointer(H3270 *hSession, int baddr) | |
1018 | + { | |
1019 | + static const struct _ptr { | |
1020 | + unsigned short id; | |
1021 | + LIB3270_POINTER value; | |
1022 | + } ptr[] = { | |
1023 | + { 0x80, LIB3270_POINTER_MOVE_SELECTION }, | |
1024 | + { 0x82, LIB3270_POINTER_SELECTION_TOP }, | |
1025 | + { 0x86, LIB3270_POINTER_SELECTION_TOP_RIGHT }, | |
1026 | + { 0x84, LIB3270_POINTER_SELECTION_RIGHT }, | |
1027 | + { 0x81, LIB3270_POINTER_SELECTION_LEFT }, | |
1028 | + { 0x89, LIB3270_POINTER_SELECTION_BOTTOM_LEFT }, | |
1029 | + { 0x88, LIB3270_POINTER_SELECTION_BOTTOM }, | |
1030 | + { 0x8c, LIB3270_POINTER_SELECTION_BOTTOM_RIGHT }, | |
1031 | + { 0x83, LIB3270_POINTER_SELECTION_TOP_LEFT } | |
1032 | + }; | |
1033 | + | |
1034 | + int f; | |
1035 | + unsigned short id = lib3270_get_selection_flags(hSession,baddr) & 0x8f; | |
1036 | + | |
1037 | + if(!lib3270_connected(hSession) || baddr < 0) | |
1038 | + return LIB3270_POINTER_LOCKED; | |
1039 | + | |
1040 | + for(f = 0; f < (sizeof(ptr)/sizeof(ptr[0]));f++) | |
1041 | + { | |
1042 | + if(ptr[f].id == id) | |
1043 | + { | |
1044 | + return ptr[f].value; | |
1045 | + } | |
1046 | + } | |
1047 | + | |
1048 | + return hSession->pointer; | |
1049 | + | |
1050 | + } | ... | ... |
src/pw3270/v3270/mouse.c
... | ... | @@ -224,59 +224,12 @@ gboolean v3270_button_release_event(GtkWidget *widget, GdkEventButton*event) |
224 | 224 | static void update_mouse_pointer(GtkWidget *widget, int baddr) |
225 | 225 | { |
226 | 226 | v3270 * terminal = GTK_V3270(widget); |
227 | - int id = 0; | |
227 | +// int id = 0; | |
228 | 228 | |
229 | - if(baddr >= 0 && terminal->pointer_id == LIB3270_CURSOR_EDITABLE) | |
229 | + if(baddr >= 0 && terminal->pointer_id == LIB3270_POINTER_UNLOCKED) | |
230 | 230 | { |
231 | - | |
232 | - switch(lib3270_get_selection_flags(terminal->host,baddr) & 0x8f) | |
233 | - { | |
234 | - case 0x80: | |
235 | - id = V3270_CURSOR_MOVE_SELECTION; | |
236 | - break; | |
237 | - | |
238 | - case 0x82: | |
239 | - id = V3270_CURSOR_SELECTION_TOP; | |
240 | - break; | |
241 | - | |
242 | - case 0x86: | |
243 | - id = V3270_CURSOR_SELECTION_TOP_RIGHT; | |
244 | - break; | |
245 | - | |
246 | - case 0x84: | |
247 | - id = V3270_CURSOR_SELECTION_RIGHT; | |
248 | - break; | |
249 | - | |
250 | - case 0x81: | |
251 | - id = V3270_CURSOR_SELECTION_LEFT; | |
252 | - break; | |
253 | - | |
254 | - case 0x89: | |
255 | - id = V3270_CURSOR_SELECTION_BOTTOM_LEFT; | |
256 | - break; | |
257 | - | |
258 | - case 0x88: | |
259 | - id = V3270_CURSOR_SELECTION_BOTTOM; | |
260 | - break; | |
261 | - | |
262 | - case 0x8c: | |
263 | - id = V3270_CURSOR_SELECTION_BOTTOM_RIGHT; | |
264 | - break; | |
265 | - | |
266 | - case 0x83: | |
267 | - id = V3270_CURSOR_SELECTION_TOP_LEFT; | |
268 | - break; | |
269 | - | |
270 | - default: | |
271 | - id = lib3270_is_protected(terminal->host,baddr) ? V3270_CURSOR_PROTECTED : V3270_CURSOR_UNPROTECTED; | |
272 | - | |
273 | - } | |
274 | - | |
275 | - gdk_window_set_cursor(gtk_widget_get_window(widget),v3270_cursor[id]); | |
276 | - | |
231 | + gdk_window_set_cursor(gtk_widget_get_window(widget),v3270_cursor[lib3270_get_pointer(terminal->host,baddr)]); | |
277 | 232 | } |
278 | - | |
279 | - | |
280 | 233 | } |
281 | 234 | |
282 | 235 | void v3270_update_mouse_pointer(GtkWidget *widget) |
... | ... | @@ -298,7 +251,7 @@ gboolean v3270_motion_notify_event(GtkWidget *widget, GdkEventMotion *event) |
298 | 251 | |
299 | 252 | if(!lib3270_connected(terminal->host)) |
300 | 253 | { |
301 | - gdk_window_set_cursor(gtk_widget_get_window(widget),v3270_cursor[V3270_CURSOR_PROTECTED]); | |
254 | + gdk_window_set_cursor(gtk_widget_get_window(widget),v3270_cursor[LIB3270_POINTER_LOCKED]); | |
302 | 255 | return FALSE; |
303 | 256 | } |
304 | 257 | |
... | ... | @@ -323,30 +276,30 @@ gboolean v3270_motion_notify_event(GtkWidget *widget, GdkEventMotion *event) |
323 | 276 | } |
324 | 277 | else if(event->y >= terminal->oia_rect->y) |
325 | 278 | { |
326 | - int id = V3270_CURSOR_PROTECTED; | |
279 | + int id = LIB3270_POINTER_PROTECTED; | |
327 | 280 | |
328 | 281 | if(event->x >= terminal->oia_rect[V3270_OIA_SSL].x && event->x <= (terminal->oia_rect[V3270_OIA_SSL].x + terminal->oia_rect[V3270_OIA_SSL].width)) |
329 | 282 | { |
330 | 283 | switch(lib3270_get_secure(terminal->host)) |
331 | 284 | { |
332 | 285 | case LIB3270_SSL_UNSECURE: /**< No secure connection */ |
333 | - id = V3270_CURSOR_QUESTION; | |
286 | + id = LIB3270_POINTER_QUESTION; | |
334 | 287 | break; |
335 | 288 | |
336 | 289 | case LIB3270_SSL_NEGOTIATING: /**< Negotiating SSL */ |
337 | - id = V3270_CURSOR_WAITING; | |
290 | + id = LIB3270_POINTER_WAITING; | |
338 | 291 | break; |
339 | 292 | |
340 | 293 | case LIB3270_SSL_NEGOTIATED: /**< Connection secure, no CA or self-signed */ |
341 | - id = V3270_CURSOR_QUESTION; | |
294 | + id = LIB3270_POINTER_QUESTION; | |
342 | 295 | break; |
343 | 296 | |
344 | 297 | case LIB3270_SSL_SECURE: /**< Connection secure with CA check */ |
345 | - id = V3270_CURSOR_QUESTION; | |
298 | + id = LIB3270_POINTER_QUESTION; | |
346 | 299 | break; |
347 | 300 | |
348 | 301 | default: |
349 | - id = V3270_CURSOR_LOCKED; | |
302 | + id = LIB3270_POINTER_LOCKED; | |
350 | 303 | } |
351 | 304 | } |
352 | 305 | ... | ... |
src/pw3270/v3270/private.h
... | ... | @@ -88,6 +88,7 @@ G_BEGIN_DECLS |
88 | 88 | |
89 | 89 | /*--[ Globals ]--------------------------------------------------------------------------------------*/ |
90 | 90 | |
91 | +/* | |
91 | 92 | #define V3270_CURSOR_UNPROTECTED LIB3270_CURSOR_EDITABLE |
92 | 93 | #define V3270_CURSOR_WAITING LIB3270_CURSOR_WAITING |
93 | 94 | #define V3270_CURSOR_LOCKED LIB3270_CURSOR_LOCKED |
... | ... | @@ -105,7 +106,7 @@ G_BEGIN_DECLS |
105 | 106 | #define V3270_CURSOR_QUESTION LIB3270_CURSOR_USER+10 |
106 | 107 | |
107 | 108 | #define V3270_CURSOR_COUNT LIB3270_CURSOR_USER+11 |
108 | - | |
109 | +*/ | |
109 | 110 | |
110 | 111 | struct v3270_ssl_status_msg |
111 | 112 | { |
... | ... | @@ -146,7 +147,7 @@ G_BEGIN_DECLS |
146 | 147 | int baddr; /**< Selection addr */ |
147 | 148 | } selection; |
148 | 149 | |
149 | - LIB3270_CURSOR pointer_id; | |
150 | + LIB3270_POINTER pointer_id; | |
150 | 151 | unsigned char pointer; /**< Mouse pointer ID */ |
151 | 152 | |
152 | 153 | V3270_OIA_FIELD selected_field; /**< Clicked OIA field */ |
... | ... | @@ -226,7 +227,7 @@ G_BEGIN_DECLS |
226 | 227 | /*--[ Globals ]--------------------------------------------------------------------------------------*/ |
227 | 228 | |
228 | 229 | G_GNUC_INTERNAL guint v3270_widget_signal[LAST_SIGNAL]; |
229 | - G_GNUC_INTERNAL GdkCursor * v3270_cursor[V3270_CURSOR_COUNT]; | |
230 | + G_GNUC_INTERNAL GdkCursor * v3270_cursor[LIB3270_POINTER_COUNT]; | |
230 | 231 | G_GNUC_INTERNAL GParamSpec * v3270_properties[PROP_LAST]; |
231 | 232 | |
232 | 233 | /*--[ Prototipes ]-----------------------------------------------------------------------------------*/ | ... | ... |
src/pw3270/v3270/widget.c
... | ... | @@ -72,8 +72,8 @@ |
72 | 72 | |
73 | 73 | /*--[ Globals ]--------------------------------------------------------------------------------------*/ |
74 | 74 | |
75 | - guint v3270_widget_signal[LAST_SIGNAL] = { 0 }; | |
76 | - GdkCursor * v3270_cursor[V3270_CURSOR_COUNT] = { 0 }; | |
75 | + guint v3270_widget_signal[LAST_SIGNAL] = { 0 }; | |
76 | + GdkCursor * v3270_cursor[LIB3270_POINTER_COUNT] = { 0 }; | |
77 | 77 | |
78 | 78 | /*--[ Prototipes ]-----------------------------------------------------------------------------------*/ |
79 | 79 | |
... | ... | @@ -354,7 +354,7 @@ static void v3270_class_init(v3270Class *klass) |
354 | 354 | "help", // V3270_CURSOR_QUESTION |
355 | 355 | }; |
356 | 356 | #else |
357 | - static const int cr[V3270_CURSOR_COUNT] = | |
357 | + static const int cr[LIB3270_POINTER_COUNT] = | |
358 | 358 | { |
359 | 359 | GDK_XTERM, // V3270_CURSOR_UNPROTECTED |
360 | 360 | GDK_WATCH, // V3270_CURSOR_WAITING |
... | ... | @@ -375,7 +375,7 @@ static void v3270_class_init(v3270Class *klass) |
375 | 375 | |
376 | 376 | int f; |
377 | 377 | |
378 | - for(f=0;f<V3270_CURSOR_COUNT;f++) | |
378 | + for(f=0;f<LIB3270_POINTER_COUNT;f++) | |
379 | 379 | { |
380 | 380 | #ifdef WIN32 |
381 | 381 | v3270_cursor[f] = gdk_cursor_new_from_name(gdk_display_get_default(),cr[f]); |
... | ... | @@ -729,7 +729,7 @@ static void update_luname(H3270 *session, const char *name) |
729 | 729 | v3270_update_luname(GTK_WIDGET(lib3270_get_user_data(session)),name); |
730 | 730 | } |
731 | 731 | |
732 | -static void select_cursor(H3270 *session, LIB3270_CURSOR id) | |
732 | +static void select_cursor(H3270 *session, LIB3270_POINTER id) | |
733 | 733 | { |
734 | 734 | GtkWidget *widget = GTK_WIDGET(lib3270_get_user_data(session)); |
735 | 735 | ... | ... |