aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Brian Ashworth <bosrsf04@gmail.com>2019-02-22 02:48:57 -0500
committerLibravatar Drew DeVault <sir@cmpwn.com>2019-02-25 17:10:04 -0500
commit344c312cdc0943954e3f32a7e9c93d5595953422 (patch)
tree83c55a30b48d9f4ceb6ea30ebe6684129703816e
parentmove scratchpad: hide visible scratchpad container (diff)
downloadsway-344c312cdc0943954e3f32a7e9c93d5595953422.tar.gz
sway-344c312cdc0943954e3f32a7e9c93d5595953422.tar.zst
sway-344c312cdc0943954e3f32a7e9c93d5595953422.zip
input/cursor: allow whole-window bindings on ws
To match i3's behavior, this allows mouse bindings to be triggered over a workspace when `--whole-window` is given.
-rw-r--r--sway/input/cursor.c23
-rw-r--r--sway/sway.5.scd6
2 files changed, 18 insertions, 11 deletions
diff --git a/sway/input/cursor.c b/sway/input/cursor.c
index 3236c74a..fb1edd0b 100644
--- a/sway/input/cursor.c
+++ b/sway/input/cursor.c
@@ -552,10 +552,11 @@ static void state_add_button(struct sway_cursor *cursor, uint32_t button) {
552static struct sway_binding* get_active_mouse_binding( 552static struct sway_binding* get_active_mouse_binding(
553 const struct sway_cursor *cursor, list_t *bindings, uint32_t modifiers, 553 const struct sway_cursor *cursor, list_t *bindings, uint32_t modifiers,
554 bool release, bool on_titlebar, bool on_border, bool on_content, 554 bool release, bool on_titlebar, bool on_border, bool on_content,
555 const char *identifier) { 555 bool on_workspace, const char *identifier) {
556 uint32_t click_region = (on_titlebar ? BINDING_TITLEBAR : 0) | 556 uint32_t click_region =
557 (on_border ? BINDING_BORDER : 0) | 557 ((on_titlebar || on_workspace) ? BINDING_TITLEBAR : 0) |
558 (on_content ? BINDING_CONTENTS : 0); 558 ((on_border || on_workspace) ? BINDING_BORDER : 0) |
559 ((on_content || on_workspace) ? BINDING_CONTENTS : 0);
559 560
560 struct sway_binding *current = NULL; 561 struct sway_binding *current = NULL;
561 for (int i = 0; i < bindings->length; ++i) { 562 for (int i = 0; i < bindings->length; ++i) {
@@ -564,6 +565,8 @@ static struct sway_binding* get_active_mouse_binding(
564 cursor->pressed_button_count != (size_t)binding->keys->length || 565 cursor->pressed_button_count != (size_t)binding->keys->length ||
565 release != (binding->flags & BINDING_RELEASE) || 566 release != (binding->flags & BINDING_RELEASE) ||
566 !(click_region & binding->flags) || 567 !(click_region & binding->flags) ||
568 (on_workspace &&
569 (click_region & binding->flags) != click_region) ||
567 (strcmp(binding->input, identifier) != 0 && 570 (strcmp(binding->input, identifier) != 0 &&
568 strcmp(binding->input, "*") != 0)) { 571 strcmp(binding->input, "*") != 0)) {
569 continue; 572 continue;
@@ -629,6 +632,7 @@ void dispatch_cursor_button(struct sway_cursor *cursor,
629 find_resize_edge(cont, cursor) : WLR_EDGE_NONE; 632 find_resize_edge(cont, cursor) : WLR_EDGE_NONE;
630 bool on_border = edge != WLR_EDGE_NONE; 633 bool on_border = edge != WLR_EDGE_NONE;
631 bool on_contents = cont && !on_border && surface; 634 bool on_contents = cont && !on_border && surface;
635 bool on_workspace = node && node->type == N_WORKSPACE;
632 bool on_titlebar = cont && !on_border && !surface; 636 bool on_titlebar = cont && !on_border && !surface;
633 637
634 // Handle mouse bindings 638 // Handle mouse bindings
@@ -642,11 +646,13 @@ void dispatch_cursor_button(struct sway_cursor *cursor,
642 state_add_button(cursor, button); 646 state_add_button(cursor, button);
643 binding = get_active_mouse_binding(cursor, 647 binding = get_active_mouse_binding(cursor,
644 config->current_mode->mouse_bindings, modifiers, false, 648 config->current_mode->mouse_bindings, modifiers, false,
645 on_titlebar, on_border, on_contents, device_identifier); 649 on_titlebar, on_border, on_contents, on_workspace,
650 device_identifier);
646 } else { 651 } else {
647 binding = get_active_mouse_binding(cursor, 652 binding = get_active_mouse_binding(cursor,
648 config->current_mode->mouse_bindings, modifiers, true, 653 config->current_mode->mouse_bindings, modifiers, true,
649 on_titlebar, on_border, on_contents, device_identifier); 654 on_titlebar, on_border, on_contents, on_workspace,
655 device_identifier);
650 state_erase_button(cursor, button); 656 state_erase_button(cursor, button);
651 } 657 }
652 free(device_identifier); 658 free(device_identifier);
@@ -836,6 +842,7 @@ void dispatch_cursor_axis(struct sway_cursor *cursor,
836 bool on_titlebar_border = cont && on_border && 842 bool on_titlebar_border = cont && on_border &&
837 cursor->cursor->y < cont->content_y; 843 cursor->cursor->y < cont->content_y;
838 bool on_contents = cont && !on_border && surface; 844 bool on_contents = cont && !on_border && surface;
845 bool on_workspace = node && node->type == N_WORKSPACE;
839 float scroll_factor = 846 float scroll_factor =
840 (ic == NULL || ic->scroll_factor == FLT_MIN) ? 1.0f : ic->scroll_factor; 847 (ic == NULL || ic->scroll_factor == FLT_MIN) ? 1.0f : ic->scroll_factor;
841 848
@@ -854,7 +861,7 @@ void dispatch_cursor_axis(struct sway_cursor *cursor,
854 state_add_button(cursor, button); 861 state_add_button(cursor, button);
855 binding = get_active_mouse_binding(cursor, 862 binding = get_active_mouse_binding(cursor,
856 config->current_mode->mouse_bindings, modifiers, false, 863 config->current_mode->mouse_bindings, modifiers, false,
857 on_titlebar, on_border, on_contents, dev_id); 864 on_titlebar, on_border, on_contents, on_workspace, dev_id);
858 if (binding) { 865 if (binding) {
859 seat_execute_command(seat, binding); 866 seat_execute_command(seat, binding);
860 handled = true; 867 handled = true;
@@ -895,7 +902,7 @@ void dispatch_cursor_axis(struct sway_cursor *cursor,
895 // Handle mouse bindings - x11 mouse buttons 4-7 - release event 902 // Handle mouse bindings - x11 mouse buttons 4-7 - release event
896 binding = get_active_mouse_binding(cursor, 903 binding = get_active_mouse_binding(cursor,
897 config->current_mode->mouse_bindings, modifiers, true, 904 config->current_mode->mouse_bindings, modifiers, true,
898 on_titlebar, on_border, on_contents, dev_id); 905 on_titlebar, on_border, on_contents, on_workspace, dev_id);
899 state_erase_button(cursor, button); 906 state_erase_button(cursor, button);
900 if (binding) { 907 if (binding) {
901 seat_execute_command(seat, binding); 908 seat_execute_command(seat, binding);
diff --git a/sway/sway.5.scd b/sway/sway.5.scd
index 76467d23..1affca5f 100644
--- a/sway/sway.5.scd
+++ b/sway/sway.5.scd
@@ -310,9 +310,9 @@ runtime.
310 conjunction with any other option to specify that the titlebar should be 310 conjunction with any other option to specify that the titlebar should be
311 excluded from the region of consideration. 311 excluded from the region of consideration.
312 312
313 There is currently, however, no way to execute a mouse binding over a layer 313 If _--whole-window_ is given, the command can be triggered when the cursor
314 surface (which includes the background of an empty workspace). This behaviour 314 is over an empty workspace. Using a mouse binding over a layer surface's
315 is carried over from i3. 315 exclusive region is not currently possible.
316 316
317 Example: 317 Example:
318``` 318```