Feature: implement mouse bindings
A configured mouse binding (for example `bindsym button3 kill`) runs its command when the mouse button is pressed over parts of a container. If the binding has no modifer, it will only run when the button is clicked on the window titlebar. Otherwise if the binding has a modifier, it will run over the titlebar or any part of the contained window. fixes #558
This commit is contained in:
committed by
Michael Stapelberg
parent
0bc73f526d
commit
0df172fd05
24
src/click.c
24
src/click.c
@ -177,6 +177,29 @@ static int route_click(Con *con, xcb_button_press_event_t *event, const bool mod
|
||||
if (con->parent->type == CT_DOCKAREA)
|
||||
goto done;
|
||||
|
||||
/* if the user has bound an action to this click, it should override the
|
||||
* default behavior. */
|
||||
if (dest == CLICK_DECORATION || dest == CLICK_INSIDE) {
|
||||
Binding *bind = get_binding_from_xcb_event((xcb_generic_event_t *)event);
|
||||
/* clicks over a window decoration will always trigger the binding and
|
||||
* clicks on the inside of the window will only trigger a binding if it
|
||||
* has modifiers. */
|
||||
if (bind && (dest == CLICK_DECORATION || (bind->mods && dest == CLICK_INSIDE))) {
|
||||
CommandResult *result = run_binding(bind, con);
|
||||
|
||||
/* ASYNC_POINTER eats the event */
|
||||
xcb_allow_events(conn, XCB_ALLOW_ASYNC_POINTER, event->time);
|
||||
xcb_flush(conn);
|
||||
|
||||
if (result->needs_tree_render)
|
||||
tree_render();
|
||||
|
||||
command_result_free(result);
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* Any click in a workspace should focus that workspace. If the
|
||||
* workspace is on another output we need to do a workspace_show in
|
||||
* order for i3bar (and others) to notice the change in workspace. */
|
||||
@ -300,6 +323,7 @@ done:
|
||||
xcb_allow_events(conn, XCB_ALLOW_REPLAY_POINTER, event->time);
|
||||
xcb_flush(conn);
|
||||
tree_render();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user