return FALSE if a grab fails

This commit is contained in:
Dana Jansens 2003-06-26 07:58:25 +00:00
parent da24f9156b
commit d3dd25a55c
2 changed files with 23 additions and 16 deletions

View file

@ -13,47 +13,54 @@
/*! A list of all possible combinations of keyboard lock masks */ /*! A list of all possible combinations of keyboard lock masks */
static unsigned int mask_list[MASK_LIST_SIZE]; static unsigned int mask_list[MASK_LIST_SIZE];
int grab_keyboard(gboolean grab) gboolean grab_keyboard(gboolean grab)
{ {
static guint kgrabs = 0; static guint kgrabs = 0;
gboolean ret = FALSE;
if (grab) { if (grab) {
if (kgrabs++ == 0) if (kgrabs++ == 0)
XGrabKeyboard(ob_display, ob_root, FALSE, GrabModeAsync, ret = XGrabKeyboard(ob_display, ob_root, FALSE, GrabModeAsync,
GrabModeAsync, event_lasttime); GrabModeAsync, event_lasttime) == Success;
} else if (kgrabs > 0) { } else if (kgrabs > 0) {
if (--kgrabs == 0) if (--kgrabs == 0)
XUngrabKeyboard(ob_display, event_lasttime); XUngrabKeyboard(ob_display, event_lasttime);
} }
return kgrabs; return ret;
} }
int grab_pointer(gboolean grab, Cursor cur) gboolean grab_pointer(gboolean grab, Cursor cur)
{ {
static guint pgrabs = 0; static guint pgrabs = 0;
gboolean ret = FALSE;
if (grab) { if (grab) {
if (pgrabs++ == 0) if (pgrabs++ == 0)
XGrabPointer(ob_display, ob_root, False, GRAB_PTR_MASK, ret = XGrabPointer(ob_display, ob_root, False, GRAB_PTR_MASK,
GrabModeAsync, GrabModeAsync, FALSE, cur, GrabModeAsync, GrabModeAsync, FALSE, cur,
event_lasttime); event_lasttime) == Success;
} else if (pgrabs > 0) { } else if (pgrabs > 0) {
if (--pgrabs == 0) if (--pgrabs == 0)
XUngrabPointer(ob_display, event_lasttime); XUngrabPointer(ob_display, event_lasttime);
} }
return pgrabs; return ret;
} }
int grab_pointer_window(gboolean grab, Cursor cur, Window win) gboolean grab_pointer_window(gboolean grab, Cursor cur, Window win)
{ {
static guint pgrabs = 0; static guint pgrabs = 0;
gboolean ret = FALSE;
if (grab) { if (grab) {
if (pgrabs++ == 0) if (pgrabs++ == 0)
XGrabPointer(ob_display, win, False, GRAB_PTR_MASK, GrabModeAsync, ret = XGrabPointer(ob_display, win, False, GRAB_PTR_MASK,
GrabModeAsync, TRUE, cur, event_lasttime); GrabModeAsync, GrabModeAsync, TRUE, cur,
event_lasttime) == Success;
} else if (pgrabs > 0) { } else if (pgrabs > 0) {
if (--pgrabs == 0) if (--pgrabs == 0)
XUngrabPointer(ob_display, event_lasttime); XUngrabPointer(ob_display, event_lasttime);
} }
return pgrabs; return ret;
} }
int grab_server(gboolean grab) int grab_server(gboolean grab)

View file

@ -7,9 +7,9 @@
void grab_startup(); void grab_startup();
void grab_shutdown(); void grab_shutdown();
int grab_keyboard(gboolean grab); gboolean grab_keyboard(gboolean grab);
void grab_pointer(gboolean grab, Cursor cur); gboolean grab_pointer(gboolean grab, Cursor cur);
void grab_pointer_window(gboolean grab, Cursor cur, Window win); gboolean grab_pointer_window(gboolean grab, Cursor cur, Window win);
void grab_server(gboolean grab); void grab_server(gboolean grab);
void grab_button(guint button, guint state, Window win, guint mask); void grab_button(guint button, guint state, Window win, guint mask);