Only grab scrollwheel buttons if necessary.
With this patch, we only grab the scrollwheel buttons (4 and 5) when managing a window if a whole window key binding exists for these buttons. This allows both of these usecases: - Bindings to scrollwheel buttons using --whole-window (see #1701). - Scrolling in a window without focusing it if no such binding exists (see #2049). Furthermore, we drop all button grabs and regrab them after a config reload in order to reevaluate the new bindings correctly. fixes #2049
This commit is contained in:
15
src/xcb.c
15
src/xcb.c
@ -324,8 +324,19 @@ release_grab:
|
||||
* Grab the specified buttons on a window when managing it.
|
||||
*
|
||||
*/
|
||||
void xcb_grab_buttons(xcb_connection_t *conn, xcb_window_t window, uint8_t* buttons) {
|
||||
for (int i = 0; i < sizeof(buttons) / sizeof(uint8_t); i++) {
|
||||
void xcb_grab_buttons(xcb_connection_t *conn, xcb_window_t window, bool bind_scrollwheel) {
|
||||
uint8_t buttons[3];
|
||||
int num = 0;
|
||||
|
||||
if (bind_scrollwheel) {
|
||||
buttons[num++] = XCB_BUTTON_INDEX_ANY;
|
||||
} else {
|
||||
buttons[num++] = XCB_BUTTON_INDEX_1;
|
||||
buttons[num++] = XCB_BUTTON_INDEX_2;
|
||||
buttons[num++] = XCB_BUTTON_INDEX_3;
|
||||
}
|
||||
|
||||
for (int i = 0; i < num; i++) {
|
||||
xcb_grab_button(conn, false, window, XCB_EVENT_MASK_BUTTON_PRESS, XCB_GRAB_MODE_SYNC,
|
||||
XCB_GRAB_MODE_ASYNC, root, XCB_NONE, buttons[i], XCB_BUTTON_MASK_ANY);
|
||||
}
|
||||
|
Reference in New Issue
Block a user