+bool Bindings::grabKeyboard(int screen, PyObject *callback)
+{
+ assert(callback);
+ if (_keybgrab_callback) return false; // already grabbed
+
+ int i;
+ for (i = 0; i < openbox->screenCount(); ++i)
+ if (openbox->screen(screen)->number() == screen)
+ break;
+ if (i >= openbox->screenCount())
+ return false; // couldn't find the screen.. it's not managed
+
+ Window root = otk::display->screenInfo(i)->rootWindow();
+ if (XGrabKeyboard(**otk::display, root, false, GrabModeAsync,
+ GrabModeSync, CurrentTime))
+ return false;
+ printf("****GRABBED****\n");
+ _keybgrab_callback = callback;
+ return true;
+}
+
+
+void Bindings::ungrabKeyboard()
+{
+ if (!_keybgrab_callback) return; // not grabbed
+
+ _keybgrab_callback = 0;
+ XUngrabKeyboard(**otk::display, CurrentTime);
+ printf("****UNGRABBED****\n");
+}
+
+