Handle button release events
This enables the --release switch on mouse button bindings.
This commit is contained in:
parent
3f126c61c4
commit
c815fc798d
|
@ -404,17 +404,18 @@ can configure mouse bindings in a similar way to key bindings.
|
||||||
|
|
||||||
*Syntax*:
|
*Syntax*:
|
||||||
----------------------------------
|
----------------------------------
|
||||||
bindsym [--whole-window] [Modifiers+]button[n] command
|
bindsym [--release] [--whole-window] [Modifiers+]button[n] command
|
||||||
----------------------------------
|
----------------------------------
|
||||||
|
|
||||||
By default, the binding will only run when you click on the titlebar of the
|
By default, the binding will only run when you click on the titlebar of the
|
||||||
window. If the +--whole-window+ flag is given, it will run when any part of the
|
window. If the +--whole-window+ flag is given, it will run when any part of the
|
||||||
window is clicked.
|
window is clicked. If the +--release+ flag is given, it will run when the mouse
|
||||||
|
button is released.
|
||||||
|
|
||||||
*Examples*:
|
*Examples*:
|
||||||
--------------------------------
|
--------------------------------
|
||||||
# The middle button over a titlebar kills the window
|
# The middle button over a titlebar kills the window
|
||||||
bindsym button2 kill
|
bindsym --release button2 kill
|
||||||
|
|
||||||
# The middle button and a modifer over any part of the window kills the window
|
# The middle button and a modifer over any part of the window kills the window
|
||||||
bindsym --whole-window $mod+button2 kill
|
bindsym --whole-window $mod+button2 kill
|
||||||
|
|
14
src/click.c
14
src/click.c
|
@ -200,6 +200,11 @@ static int route_click(Con *con, xcb_button_press_event_t *event, const bool mod
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* There is no default behavior for button release events so we are done. */
|
||||||
|
if (event->response_type == XCB_BUTTON_RELEASE) {
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
|
||||||
/* Any click in a workspace should focus that workspace. If the
|
/* Any click in a workspace should focus that workspace. If the
|
||||||
* workspace is on another output we need to do a workspace_show in
|
* workspace is on another output we need to do a workspace_show in
|
||||||
* order for i3bar (and others) to notice the change in workspace. */
|
* order for i3bar (and others) to notice the change in workspace. */
|
||||||
|
@ -336,9 +341,10 @@ done:
|
||||||
*/
|
*/
|
||||||
int handle_button_press(xcb_button_press_event_t *event) {
|
int handle_button_press(xcb_button_press_event_t *event) {
|
||||||
Con *con;
|
Con *con;
|
||||||
DLOG("Button %d pressed on window 0x%08x (child 0x%08x) at (%d, %d) (root %d, %d)\n",
|
DLOG("Button %d %s on window 0x%08x (child 0x%08x) at (%d, %d) (root %d, %d)\n",
|
||||||
event->state, event->event, event->child, event->event_x, event->event_y,
|
event->state, (event->response_type == XCB_BUTTON_PRESS ? "press" : "release"),
|
||||||
event->root_x, event->root_y);
|
event->event, event->child, event->event_x, event->event_y, event->root_x,
|
||||||
|
event->root_y);
|
||||||
|
|
||||||
last_timestamp = event->time;
|
last_timestamp = event->time;
|
||||||
|
|
||||||
|
@ -351,7 +357,7 @@ int handle_button_press(xcb_button_press_event_t *event) {
|
||||||
if (!(con = con_by_frame_id(event->event))) {
|
if (!(con = con_by_frame_id(event->event))) {
|
||||||
/* If the root window is clicked, find the relevant output from the
|
/* If the root window is clicked, find the relevant output from the
|
||||||
* click coordinates and focus the output's active workspace. */
|
* click coordinates and focus the output's active workspace. */
|
||||||
if (event->event == root) {
|
if (event->event == root && event->response_type == XCB_BUTTON_PRESS) {
|
||||||
Con *output, *ws;
|
Con *output, *ws;
|
||||||
TAILQ_FOREACH(output, &(croot->nodes_head), nodes) {
|
TAILQ_FOREACH(output, &(croot->nodes_head), nodes) {
|
||||||
if (con_is_internal(output) ||
|
if (con_is_internal(output) ||
|
||||||
|
|
|
@ -1257,6 +1257,7 @@ void handle_event(int type, xcb_generic_event_t *event) {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case XCB_BUTTON_PRESS:
|
case XCB_BUTTON_PRESS:
|
||||||
|
case XCB_BUTTON_RELEASE:
|
||||||
handle_button_press((xcb_button_press_event_t *)event);
|
handle_button_press((xcb_button_press_event_t *)event);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue