From: Chris Hanson Date: Sat, 13 May 1995 11:10:10 +0000 (+0000) Subject: Don't use WinQueryFocus to decide whether the cursor has been created. X-Git-Tag: 20090517-FFI~6316 X-Git-Url: https://birchwood-abbey.net/git?a=commitdiff_plain;h=b79473ef07dd55c244cc0b3618b006ef3389e1ed;p=mit-scheme.git Don't use WinQueryFocus to decide whether the cursor has been created. There is a short period of time in which it answers "yes" when in fact the answer is "no", which can result in errors from WinShowCursor. --- diff --git a/v7/src/microcode/os2pm.c b/v7/src/microcode/os2pm.c index c564b4387..0a6d21464 100644 --- a/v7/src/microcode/os2pm.c +++ b/v7/src/microcode/os2pm.c @@ -1,6 +1,6 @@ /* -*-C-*- -$Id: os2pm.c,v 1.13 1995/05/10 21:27:03 cph Exp $ +$Id: os2pm.c,v 1.14 1995/05/13 11:10:10 cph Exp $ Copyright (c) 1994-95 Massachusetts Institute of Technology @@ -73,7 +73,8 @@ typedef struct _window_t qid_t qid; /* qid to send commands to */ qid_t event_qid; /* qid to send input events to */ wid_t id; /* wid for this window */ - unsigned int cursor_shownp : 1; /* nonzero if cursor is visible */ + unsigned int cursor_createdp : 1; /* nonzero if cursor created */ + unsigned int cursor_enabledp : 1; /* nonzero if cursor enabled */ unsigned int minimizingp : 1; /* nonzero if window being minimized */ unsigned int minimizedp : 1; /* nonzero if window is minimized */ unsigned int permanentp : 1; /* nonzero means don't close on reload */ @@ -91,7 +92,8 @@ typedef struct _window_t #define WINDOW_QID(window) ((window) -> qid) #define WINDOW_EVENT_QID(window) ((window) -> event_qid) #define WINDOW_ID(window) ((window) -> id) -#define WINDOW_CURSOR_SHOWNP(window) ((window) -> cursor_shownp) +#define WINDOW_CURSOR_CREATEDP(window) ((window) -> cursor_createdp) +#define WINDOW_CURSOR_ENABLEDP(window) ((window) -> cursor_enabledp) #define WINDOW_MINIMIZINGP(window) ((window) -> minimizingp) #define WINDOW_MINIMIZEDP(window) ((window) -> minimizedp) #define WINDOW_PERMANENTP(window) ((window) -> permanentp) @@ -737,7 +739,7 @@ static void show_window (window_t *, int); static void move_cursor (window_t *, short, short); static void shape_cursor (window_t *, unsigned short, unsigned short, unsigned short); -static void show_cursor (window_t *, int); +static void enable_cursor (window_t *, int); static void recreate_cursor (window_t *); static void activate_cursor (window_t *); static void deactivate_cursor (window_t *); @@ -1546,8 +1548,8 @@ static void handle_window_show_cursor_request (msg_t * message) { qid_t sender = (MSG_SENDER (message)); - show_cursor ((SM_SHOW_CURSOR_WINDOW (message)), - (SM_SHOW_CURSOR_SHOWP (message))); + enable_cursor ((SM_SHOW_CURSOR_WINDOW (message)), + (SM_SHOW_CURSOR_SHOWP (message))); OS2_destroy_message (message); simple_reply (sender); } @@ -2546,7 +2548,8 @@ make_window (qid_t qid, qid_t event_qid) (WINDOW_QID (window)) = qid; (WINDOW_EVENT_QID (window)) = event_qid; (WINDOW_ID (window)) = (allocate_id ((& wid_table), window)); - (WINDOW_CURSOR_SHOWNP (window)) = 0; + (WINDOW_CURSOR_CREATEDP (window)) = 0; + (WINDOW_CURSOR_ENABLEDP (window)) = 0; (WINDOW_MINIMIZINGP (window)) = 0; (WINDOW_MINIMIZEDP (window)) = 0; (WINDOW_PERMANENTP (window)) = 0; @@ -2568,31 +2571,33 @@ show_window (window_t * window, int showp) if (!WinShowWindow ((WINDOW_FRAME (window)), showp)) window_warning (WinShowWindow); } - -/* These two procedures are patches to work around bugs in the OS/2 PM - API. There are sporadic error return codes being generated by - these bugs, and IBM tech support suggested these patches as a - temporary solution. */ - + static void win_create_cursor (HWND client, LONG x, LONG y, LONG cx, LONG cy, ULONG fs, PRECTL clip_rectl) { - while (!WinCreateCursor (client, x, y, cx, cy, fs, clip_rectl)) - ; + if (!WinCreateCursor (client, x, y, cx, cy, fs, clip_rectl)) + window_warning (WinCreateCursor); +} + +static void +win_destroy_cursor (HWND client) +{ + if (!WinDestroyCursor (client)) + window_warning (WinDestroyCursor); } static void win_show_cursor (HWND client, BOOL showp) { - while (!WinShowCursor (client, showp)) - ; + if (!WinShowCursor (client, showp)) + window_warning (WinShowCursor); } static void move_cursor (window_t * window, short x, short y) { - if (window_focusp (window)) + if (WINDOW_CURSOR_CREATEDP (window)) win_create_cursor ((WINDOW_CLIENT (window)), x, y, 0, 0, CURSOR_SETPOS, 0); } @@ -2603,18 +2608,17 @@ shape_cursor (window_t * window, unsigned short width, unsigned short height, (WINDOW_CURSOR_WIDTH (window)) = width; (WINDOW_CURSOR_HEIGHT (window)) = height; (WINDOW_CURSOR_STYLE (window)) = style; - if (window_focusp (window)) + if (WINDOW_CURSOR_CREATEDP (window)) recreate_cursor (window); } static void -show_cursor (window_t * window, int showp) +enable_cursor (window_t * window, int showp) { - if (showp != 0) - showp = 1; - if ((window_focusp (window)) && (showp != (WINDOW_CURSOR_SHOWNP (window)))) + if ((WINDOW_CURSOR_CREATEDP (window)) + && ((showp != 0) != (WINDOW_CURSOR_ENABLEDP (window)))) win_show_cursor ((WINDOW_CLIENT (window)), showp); - (WINDOW_CURSOR_SHOWNP (window)) = showp; + (WINDOW_CURSOR_ENABLEDP (window)) = (showp != 0); } static void @@ -2627,24 +2631,25 @@ recreate_cursor (window_t * window) (WINDOW_CURSOR_HEIGHT (window)), (WINDOW_CURSOR_STYLE (window)), 0); - if (WINDOW_CURSOR_SHOWNP (window)) + (WINDOW_CURSOR_CREATEDP (window)) = 1; + if (WINDOW_CURSOR_ENABLEDP (window)) win_show_cursor ((WINDOW_CLIENT (window)), TRUE); } static void activate_cursor (window_t * window) { - if ((WINDOW_CURSOR_SHOWNP (window)) && (window_focusp (window))) + if ((WINDOW_CURSOR_CREATEDP (window)) && (WINDOW_CURSOR_ENABLEDP (window))) win_show_cursor ((WINDOW_CLIENT (window)), TRUE); } static void deactivate_cursor (window_t * window) { - if ((WINDOW_CURSOR_SHOWNP (window)) && (window_focusp (window))) + if ((WINDOW_CURSOR_CREATEDP (window)) && (WINDOW_CURSOR_ENABLEDP (window))) win_show_cursor ((WINDOW_CLIENT (window)), FALSE); } - + static void scroll_rectangle (window_t * window, short x_delta, short y_delta, PRECTL rectl) @@ -3476,8 +3481,8 @@ window_procedure (HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) recreate_cursor (window); else { - if (!WinDestroyCursor (WINDOW_CLIENT (window))) - window_warning (WinDestroyCursor); + win_destroy_cursor (WINDOW_CLIENT (window)); + (WINDOW_CURSOR_CREATEDP (window)) = 0; } SEND_EVENT (window, (make_focus_event ((WINDOW_ID (window)), @@ -3556,10 +3561,10 @@ window_procedure (HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) (WINDOW_MINIMIZEDP (window)) = 1; break; } - if (window_focusp (window)) + if (WINDOW_CURSOR_CREATEDP (window)) { - if (!WinDestroyCursor (WINDOW_CLIENT (window))) - window_warning (WinDestroyCursor); + win_destroy_cursor (WINDOW_CLIENT (window)); + (WINDOW_CURSOR_CREATEDP (window)) = 0; (WINDOW_CURSOR_X (window)) = 0; (WINDOW_CURSOR_Y (window)) = 0; recreate_cursor (window);