And add the grabButton() to Xcb::Window

Again most of the arguments have a default value to ease the usage
inside KWin and remove the horrific long methods.
This commit is contained in:
Martin Gräßlin 2013-09-10 10:28:11 +02:00
parent f354b41680
commit 1fd857eecb
2 changed files with 22 additions and 12 deletions

View file

@ -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);
}
}

View file

@ -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)
{