+const ScreenInfo* OBDisplay::screenInfo(int snum) {
+ assert(snum >= 0);
+ assert(snum < static_cast<int>(_screenInfoList.size()));
+ return &_screenInfoList[snum];
+}
+
+
+const ScreenInfo* OBDisplay::findScreen(Window root)
+{
+ ScreenInfoList::iterator it, end = _screenInfoList.end();
+ for (it = _screenInfoList.begin(); it != end; ++it)
+ if (it->rootWindow() == root)
+ return &(*it);
+ return 0;
+}
+
+
+void OBDisplay::grab()
+{
+ if (_grab_count == 0)
+ XGrabServer(display);
+ _grab_count++;
+}
+
+
+void OBDisplay::ungrab()
+{
+ if (_grab_count == 0) return;
+ _grab_count--;
+ if (_grab_count == 0)
+ XUngrabServer(display);
+}
+
+
+
+
+
+
+
+/*
+ * Grabs a button, but also grabs the button in every possible combination
+ * with the keyboard lock keys, so that they do not cancel out the event.
+
+ * if allow_scroll_lock is true then only the top half of the lock mask
+ * table is used and scroll lock is ignored. This value defaults to false.
+ */
+void OBDisplay::grabButton(unsigned int button, unsigned int modifiers,
+ Window grab_window, bool owner_events,
+ unsigned int event_mask, int pointer_mode,
+ int keyboard_mode, Window confine_to,
+ Cursor cursor, bool allow_scroll_lock) {
+ unsigned int length = (allow_scroll_lock) ? 8 / 2:
+ 8;
+ for (size_t cnt = 0; cnt < length; ++cnt)
+ XGrabButton(otk::OBDisplay::display, button, modifiers | _mask_list[cnt],
+ grab_window, owner_events, event_mask, pointer_mode,
+ keyboard_mode, confine_to, cursor);
+}
+
+
+/*
+ * Releases the grab on a button, and ungrabs all possible combinations of the
+ * keyboard lock keys.
+ */
+void OBDisplay::ungrabButton(unsigned int button, unsigned int modifiers,
+ Window grab_window) {
+ for (size_t cnt = 0; cnt < 8; ++cnt)
+ XUngrabButton(otk::OBDisplay::display, button, modifiers | _mask_list[cnt],
+ grab_window);
+}
+
+void OBDisplay::grabKey(unsigned int keycode, unsigned int modifiers,
+ Window grab_window, bool owner_events,
+ int pointer_mode, int keyboard_mode,
+ bool allow_scroll_lock)
+{
+ unsigned int length = (allow_scroll_lock) ? 8 / 2:
+ 8;
+ for (size_t cnt = 0; cnt < length; ++cnt)
+ XGrabKey(otk::OBDisplay::display, keycode, modifiers | _mask_list[cnt],
+ grab_window, owner_events, pointer_mode, keyboard_mode);
+}
+
+void OBDisplay::ungrabKey(unsigned int keycode, unsigned int modifiers,
+ Window grab_window)
+{
+ for (size_t cnt = 0; cnt < 8; ++cnt)
+ XUngrabKey(otk::OBDisplay::display, keycode, modifiers | _mask_list[cnt],
+ grab_window);
+}
+