diff --git a/events.cpp b/events.cpp index 13ed239b0e..23e2c5e98a 100644 --- a/events.cpp +++ b/events.cpp @@ -911,10 +911,7 @@ void Client::grabButton(int modifier) for (int i = 0; i < 8; ++i) - XGrabButton(display(), AnyButton, - modifier | mods[ i ], - wrapperId(), false, ButtonPressMask, - GrabModeSync, GrabModeAsync, None, None); + m_wrapper.grabButton(XCB_GRAB_MODE_SYNC, XCB_GRAB_MODE_ASYNC, modifier | mods[ i ]); } void Client::ungrabButton(int modifier) @@ -951,10 +948,7 @@ void Client::updateMouseGrab() } if (isActive() && !workspace()->forcedGlobalMouseGrab()) { // see Workspace::establishTabBoxGrab() // first grab all modifier combinations - XGrabButton(display(), AnyButton, AnyModifier, wrapperId(), false, - ButtonPressMask, - GrabModeSync, GrabModeAsync, - None, None); + m_wrapper.grabButton(XCB_GRAB_MODE_SYNC, XCB_GRAB_MODE_ASYNC); // remove the grab for no modifiers only if the window // is unobscured or if the user doesn't want click raise // (it is unobscured if it the topmost in the unconstrained stacking order, i.e. it is @@ -970,10 +964,7 @@ void Client::updateMouseGrab() } else { m_wrapper.ungrabButton(); // simply grab all modifier combinations - XGrabButton(display(), AnyButton, AnyModifier, wrapperId(), false, - ButtonPressMask, - GrabModeSync, GrabModeAsync, - None, None); + m_wrapper.grabButton(XCB_GRAB_MODE_SYNC, XCB_GRAB_MODE_ASYNC); } } diff --git a/xcbutils.h b/xcbutils.h index 117cce9b84..fd16c851e1 100644 --- a/xcbutils.h +++ b/xcbutils.h @@ -438,6 +438,13 @@ public: void reparent(xcb_window_t parent, int x = 0, int y = 0); void deleteProperty(xcb_atom_t property); void setBorderWidth(uint32_t width); + void grabButton(uint8_t pointerMode, uint8_t keyboardmode, + uint16_t modifiers = XCB_MOD_MASK_ANY, + uint8_t button = XCB_BUTTON_INDEX_ANY, + uint16_t eventMask = XCB_EVENT_MASK_BUTTON_PRESS, + xcb_window_t confineTo = XCB_WINDOW_NONE, + xcb_cursor_t cursor = XCB_CURSOR_NONE, + bool ownerEvents = false); void ungrabButton(uint16_t modifiers = XCB_MOD_MASK_ANY, uint8_t button = XCB_BUTTON_INDEX_ANY); /** * Clears the window area. Same as xcb_clear_area with x, y, width, height being @c 0. @@ -644,6 +651,18 @@ void Window::setBorderWidth(uint32_t width) xcb_configure_window(connection(), m_window, XCB_CONFIG_WINDOW_BORDER_WIDTH, &width); } +inline +void Window::grabButton(uint8_t pointerMode, uint8_t keyboardmode, uint16_t modifiers, + uint8_t button, uint16_t eventMask, xcb_window_t confineTo, + xcb_cursor_t cursor, bool ownerEvents) +{ + if (!isValid()) { + return; + } + xcb_grab_button(connection(), ownerEvents, m_window, eventMask, + pointerMode, keyboardmode, confineTo, cursor, button, modifiers); +} + inline void Window::ungrabButton(uint16_t modifiers, uint8_t button) {