]> git.mdlowis.com Git - proto/labwc.git/commitdiff
cursor: also toggle mousebinds with ToggleKeybinds
authortokyo4j <hrak1529@gmail.com>
Thu, 24 Jul 2025 02:08:03 +0000 (11:08 +0900)
committerHiroaki Yamamoto <hrak1529@gmail.com>
Sun, 27 Jul 2025 15:06:52 +0000 (00:06 +0900)
Mousebinds can still be applied when the cursor is over their decoration

docs/labwc-actions.5.scd
include/view.h
src/input/cursor.c
src/input/keyboard.c
src/view.c

index 52a3d2fb83dd8d00c502faa28c943cf301edfc65..604a8468dd351fa8e8a12277ed883f12bc12cea0 100644 (file)
@@ -227,10 +227,10 @@ Actions are used in menus and keyboard/mouse bindings.
        window.
 
 *<action name="ToggleKeybinds" />*
-       Stop handling keybinds other than ToggleKeybinds itself.
-       This can be used to allow A-Tab and similar keybinds to be delivered
-       to Virtual Machines, VNC clients or nested compositors.
-       A second call will restore all original keybinds.
+       Stop handling keybinds/mousebinds other than ToggleKeybinds itself.
+       This can be used to allow A-Tab and similar keybinds/mousebinds to be
+       delivered to Virtual Machines, VNC clients or nested compositors.
+       A second call will restore all original keybinds/mousebinds.
 
        This action will only affect the window that had keyboard focus when
        the binding was executed. Thus when switching to another window, all
index 1e54f898442fc9fc0ac2c11d4f070a1bbb1799cf..5e1c5baf0e483bfa57c4a74786672ef37b7ea15d 100644 (file)
@@ -229,7 +229,7 @@ struct view {
        bool visible_on_all_workspaces;
        enum view_edge tiled;
        uint32_t edges_visible;  /* enum wlr_edges bitset */
-       bool inhibits_keybinds;
+       bool inhibits_keybinds; /* also inhibits mousebinds */
        xkb_layout_index_t keyboard_layout;
 
        /* Pointer to an output owned struct region, may be NULL */
@@ -526,6 +526,7 @@ void mappable_connect(struct mappable *mappable, struct wlr_surface *surface,
 void mappable_disconnect(struct mappable *mappable);
 
 void view_toggle_keybinds(struct view *view);
+bool view_inhibits_actions(struct view *view, struct wl_list *actions);
 
 void view_set_activated(struct view *view, bool activated);
 void view_set_output(struct view *view, struct output *output);
index d55e6bc0e6da46480dc4b0dec52d1f25dff58b53..6ce81dab80a5aa48c431abe6c30bc0a4565b127f 100644 (file)
@@ -610,6 +610,10 @@ cursor_process_motion(struct server *server, uint32_t time, double *sx, double *
 
        struct mousebind *mousebind;
        wl_list_for_each(mousebind, &rc.mousebinds, link) {
+               if (ctx.type == LAB_SSD_CLIENT
+                               && view_inhibits_actions(ctx.view, &mousebind->actions)) {
+                       continue;
+               }
                if (mousebind->mouse_event == MOUSE_ACTION_DRAG
                                && mousebind->pressed_in_context) {
                        /*
@@ -949,6 +953,10 @@ process_release_mousebinding(struct server *server,
        uint32_t modifiers = keyboard_get_all_modifiers(&server->seat);
 
        wl_list_for_each(mousebind, &rc.mousebinds, link) {
+               if (ctx->type == LAB_SSD_CLIENT
+                               && view_inhibits_actions(ctx->view, &mousebind->actions)) {
+                       continue;
+               }
                if (ssd_part_contains(mousebind->context, ctx->type)
                                && mousebind->button == button
                                && modifiers == mousebind->modifiers) {
@@ -1016,6 +1024,10 @@ process_press_mousebinding(struct server *server, struct cursor_context *ctx,
        uint32_t modifiers = keyboard_get_all_modifiers(&server->seat);
 
        wl_list_for_each(mousebind, &rc.mousebinds, link) {
+               if (ctx->type == LAB_SSD_CLIENT
+                               && view_inhibits_actions(ctx->view, &mousebind->actions)) {
+                       continue;
+               }
                if (ssd_part_contains(mousebind->context, ctx->type)
                                && mousebind->button == button
                                && modifiers == mousebind->modifiers) {
index 676366d905fc6c12a33bdd70c85c09d9411a1ffb..0739529d0af38e1b82a20b96138c6593a8ae4993 100644 (file)
@@ -211,9 +211,7 @@ match_keybinding_for_sym(struct server *server, uint32_t modifiers,
                if (modifiers ^ keybind->modifiers) {
                        continue;
                }
-               if (server->active_view
-                               && server->active_view->inhibits_keybinds
-                               && !actions_contain_toggle_keybinds(&keybind->actions)) {
+               if (view_inhibits_actions(server->active_view, &keybind->actions)) {
                        continue;
                }
                if (sym == XKB_KEY_NoSymbol) {
index bc3cf35cc9d2d367e3e37b9b71e1af99d0ebc710..3a6fa0bd148e59239a2984bd79caa2e8a577b4cb 100644 (file)
@@ -4,6 +4,7 @@
 #include <strings.h>
 #include <wlr/types/wlr_output_layout.h>
 #include <wlr/types/wlr_security_context_v1.h>
+#include "action.h"
 #include "buffer.h"
 #include "common/box.h"
 #include "common/list.h"
@@ -2444,6 +2445,12 @@ view_toggle_keybinds(struct view *view)
        }
 }
 
+bool
+view_inhibits_actions(struct view *view, struct wl_list *actions)
+{
+       return view && view->inhibits_keybinds && !actions_contain_toggle_keybinds(actions);
+}
+
 void
 mappable_connect(struct mappable *mappable, struct wlr_surface *surface,
                wl_notify_func_t notify_map, wl_notify_func_t notify_unmap)
@@ -2614,10 +2621,6 @@ view_destroy(struct view *view)
                zfree(view->tiled_region_evacuate);
        }
 
-       if (view->inhibits_keybinds) {
-               view->inhibits_keybinds = false;
-       }
-
        osd_on_view_destroy(view);
        undecorate(view);