From: Dana Jansens Date: Thu, 26 Jun 2003 07:58:25 +0000 (+0000) Subject: return FALSE if a grab fails X-Git-Url: https://git.brokenzipper.com/gitweb?a=commitdiff_plain;h=d3dd25a55cf7e1837eaf45b04ed2d20392eb559b;p=chaz%2Fopenbox return FALSE if a grab fails --- diff --git a/openbox/grab.c b/openbox/grab.c index dc743026..dd880c5f 100644 --- a/openbox/grab.c +++ b/openbox/grab.c @@ -13,47 +13,54 @@ /*! A list of all possible combinations of keyboard lock masks */ static unsigned int mask_list[MASK_LIST_SIZE]; -int grab_keyboard(gboolean grab) +gboolean grab_keyboard(gboolean grab) { static guint kgrabs = 0; + gboolean ret = FALSE; + if (grab) { if (kgrabs++ == 0) - XGrabKeyboard(ob_display, ob_root, FALSE, GrabModeAsync, - GrabModeAsync, event_lasttime); + ret = XGrabKeyboard(ob_display, ob_root, FALSE, GrabModeAsync, + GrabModeAsync, event_lasttime) == Success; } else if (kgrabs > 0) { if (--kgrabs == 0) 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; + gboolean ret = FALSE; + if (grab) { if (pgrabs++ == 0) - XGrabPointer(ob_display, ob_root, False, GRAB_PTR_MASK, - GrabModeAsync, GrabModeAsync, FALSE, cur, - event_lasttime); + ret = XGrabPointer(ob_display, ob_root, False, GRAB_PTR_MASK, + GrabModeAsync, GrabModeAsync, FALSE, cur, + event_lasttime) == Success; } else if (pgrabs > 0) { if (--pgrabs == 0) 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; + gboolean ret = FALSE; + if (grab) { if (pgrabs++ == 0) - XGrabPointer(ob_display, win, False, GRAB_PTR_MASK, GrabModeAsync, - GrabModeAsync, TRUE, cur, event_lasttime); + ret = XGrabPointer(ob_display, win, False, GRAB_PTR_MASK, + GrabModeAsync, GrabModeAsync, TRUE, cur, + event_lasttime) == Success; } else if (pgrabs > 0) { if (--pgrabs == 0) XUngrabPointer(ob_display, event_lasttime); } - return pgrabs; + return ret; } int grab_server(gboolean grab) diff --git a/openbox/grab.h b/openbox/grab.h index d6c149b3..78d7d264 100644 --- a/openbox/grab.h +++ b/openbox/grab.h @@ -7,9 +7,9 @@ void grab_startup(); void grab_shutdown(); -int grab_keyboard(gboolean grab); -void grab_pointer(gboolean grab, Cursor cur); -void grab_pointer_window(gboolean grab, Cursor cur, Window win); +gboolean grab_keyboard(gboolean grab); +gboolean grab_pointer(gboolean grab, Cursor cur); +gboolean grab_pointer_window(gboolean grab, Cursor cur, Window win); void grab_server(gboolean grab); void grab_button(guint button, guint state, Window win, guint mask);