- if (--kgrabs == 0) {
- g_message("UNGRABBING KEYBOARD %d", kgrabs);
- XUngrabKeyboard(ob_display, CurrentTime);
- } else
- g_message("NOT UNGRABBING KEYBOARD %d", kgrabs);
+ if (--kgrabs == 0)
+ XUngrabKeyboard(ob_display, event_lasttime);
+ ret = TRUE;
+ }
+
+ return ret;
+}
+
+gboolean grab_pointer(gboolean grab, ObCursor cur)
+{
+ static guint pgrabs = 0;
+ gboolean ret = FALSE;
+
+ if (grab) {
+ if (pgrabs++ == 0)
+ ret = XGrabPointer(ob_display, RootWindow(ob_display, ob_screen),
+ False, GRAB_PTR_MASK, GrabModeAsync,
+ GrabModeAsync, FALSE,
+ ob_cursor(cur), event_lasttime) == Success;
+ else
+ ret = TRUE;
+ } else if (pgrabs > 0) {
+ if (--pgrabs == 0)
+ XUngrabPointer(ob_display, event_lasttime);
+ ret = TRUE;