+const ScreenInfo* Display::screenInfo(int snum) const
+{
+ assert(snum >= 0);
+ assert(snum < (signed) ScreenCount(_display));
+ return _screeninfo_list[snum];
+}
+
+
+const ScreenInfo* Display::findScreen(Window root) const
+{
+ for (int i = 0; i < ScreenCount(_display); ++i)
+ if (_screeninfo_list[i]->rootWindow() == root)
+ return _screeninfo_list[i];
+ return 0;
+}
+
+
+const RenderControl *Display::renderControl(int snum) const
+{
+ assert(snum >= 0);
+ assert(snum < (signed) ScreenCount(_display));
+ return _rendercontrol_list[snum];
+}
+
+
+void Display::setIgnoreErrors(bool t)
+{
+ _ignore_errors = t;
+ // sync up so that anything already sent is/isn't ignored!
+ XSync(_display, false);
+}
+
+void Display::grab()
+{
+ if (_grab_count == 0) {
+ XGrabServer(_display);
+ XSync(_display, false); // make sure it kicks in
+ }
+ _grab_count++;
+}
+
+
+void Display::ungrab()
+{
+ if (_grab_count == 0) return;
+ _grab_count--;
+ if (_grab_count == 0) {
+ XUngrabServer(_display);
+ XFlush(_display); // ungrab as soon as possible
+ }
+}
+
+
+
+
+
+
+
+/*
+ * 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 Display::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) const
+{
+ unsigned int length = (allow_scroll_lock) ? 8 / 2:
+ 8;
+ for (size_t cnt = 0; cnt < length; ++cnt)
+ XGrabButton(_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 Display::ungrabButton(unsigned int button, unsigned int modifiers,
+ Window grab_window) const
+{
+ for (size_t cnt = 0; cnt < 8; ++cnt)
+ XUngrabButton(_display, button, modifiers | _mask_list[cnt],
+ grab_window);
+}
+
+void Display::grabKey(unsigned int keycode, unsigned int modifiers,
+ Window grab_window, bool owner_events,
+ int pointer_mode, int keyboard_mode,
+ bool allow_scroll_lock) const
+{
+ unsigned int length = (allow_scroll_lock) ? 8 / 2:
+ 8;
+ for (size_t cnt = 0; cnt < length; ++cnt)
+ XGrabKey(_display, keycode, modifiers | _mask_list[cnt],
+ grab_window, owner_events, pointer_mode, keyboard_mode);
+}
+
+void Display::ungrabKey(unsigned int keycode, unsigned int modifiers,
+ Window grab_window) const
+{
+ for (size_t cnt = 0; cnt < 8; ++cnt)
+ XUngrabKey(_display, keycode, modifiers | _mask_list[cnt],
+ grab_window);
+}
+