/* -*-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
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 */
#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)
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 *);
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);
}
(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;
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. */
-
+\f
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);
}
(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
(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);
}
-
+\f
static void
scroll_rectangle (window_t * window, short x_delta, short y_delta,
PRECTL rectl)
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)),
(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);