]> git.mdlowis.com Git - proto/labwc.git/commitdiff
ToggleKeybinds per window
authorConsolatis <35009135+Consolatis@users.noreply.github.com>
Sun, 5 Mar 2023 09:35:56 +0000 (10:35 +0100)
committerJohan Malm <johanmalm@users.noreply.github.com>
Thu, 6 Jul 2023 05:02:28 +0000 (06:02 +0100)
12 files changed:
docs/labwc-actions.5.scd
docs/labwc-theme.5.scd
docs/themerc
include/labwc.h
include/ssd.h
include/theme.h
include/view.h
src/action.c
src/keyboard.c
src/ssd/ssd.c
src/theme.c
src/view.c

index 1027096bcda600436ab9f8dd44b1686003af3177..0beedf62938879687171a4c1d7617d0931bf2de1 100644 (file)
@@ -105,6 +105,11 @@ Actions are used in menus and keyboard/mouse bindings.
        to Virtual Machines, VNC clients or nested compositors.
        A second call will restore all original keybinds.
 
+       This action will only affect the window that had keyboard focus when
+       the binding was executed. Thus when switching to another window, all
+       the usual keybinds will function again until switching back to the
+       original window. There can be multiple windows with this mode set.
+
 *<action name="FocusOutput" output="HDMI-A-1" />*
        Give focus to topmost window on given output and warp the cursor
        to the center of the window. If the given output does not contain
index 9402e41af76a8fa715a05b4933fbcc2cc45ff741..905c5ff213139c74e5f27ad1efaa4b7e0d174c8f 100644 (file)
@@ -78,6 +78,10 @@ labwc-config(5).
 *window.inactive.border.color*
        Border color of inactive window
 
+*window.active.indicator.toggled-keybind.color*
+       Status indicator for the ToggleKeybinds action. Can be set to the same
+       value as set for window.active.border.color to disable the status indicator.
+
 *window.active.title.bg.color*
        Background color for the focused window's titlebar
 
index 2e7e4f6be5541097e2d4a4cf30991452a7d69853..2062256c1456ed608123b72ec2e662d406bc263b 100644 (file)
@@ -13,6 +13,9 @@ padding.height: 3
 window.active.border.color: #dddad6
 window.inactive.border.color: #f6f5f4
 
+# ToggleKeybinds status indicator
+window.active.indicator.toggled-keybind.color: #ff0000
+
 # window titlebar background
 window.active.title.bg.color: #dddad6
 window.inactive.title.bg.color: #f6f5f4
index d2d16aeb1cffbf533bdbb25cc9d35dc53126ddbf..dffb4595d49de3d0852f167f1bb7800217cf679b 100644 (file)
@@ -121,7 +121,7 @@ struct seat {
        struct wlr_idle_inhibit_manager_v1 *wlr_idle_inhibit_manager;
 
        /* In support for ToggleKeybinds */
-       bool inhibit_keybinds;
+       uint32_t nr_inhibited_keybind_views;
 
        /* Used to hide the workspace OSD after switching workspaces */
        struct wl_event_source *workspace_osd_timer;
index 4ccc0ef33a80ee8cc9b6b28c42873844d648f513..5e82be2cae7c800d15e4ae66e48f792b8706ebad 100644 (file)
@@ -64,6 +64,8 @@ void ssd_update_title(struct ssd *ssd);
 void ssd_update_geometry(struct ssd *ssd);
 void ssd_destroy(struct ssd *ssd);
 
+void ssd_enable_keybind_inhibit_indicator(struct ssd *ssd, bool enable);
+
 struct ssd_hover_state *ssd_hover_state_new(void);
 void ssd_update_button_hover(struct wlr_scene_node *node,
        struct ssd_hover_state *hover_state);
index 5d3e848b916131b99367801cb81585f82f70e960..c78afb26a46e14233afcdda672b5267c8fafcedd 100644 (file)
@@ -27,6 +27,8 @@ struct theme {
        float window_active_border_color[4];
        float window_inactive_border_color[4];
 
+       float window_toggled_keybinds_color[4];
+
        float window_active_title_bg_color[4];
        float window_inactive_title_bg_color[4];
 
index 0ea801679c50885e3b12e20710cfb3d381eb11e7..e5e5d36fb112f4160fa9944c6078d61646086b7d 100644 (file)
@@ -82,6 +82,7 @@ struct view {
        bool maximized;
        bool fullscreen;
        uint32_t tiled;  /* private, enum view_edge in src/view.c */
+       bool inhibits_keybinds;
 
        /* Pointer to an output owned struct region, may be NULL */
        struct region *tiled_region;
@@ -146,6 +147,9 @@ struct xdg_toplevel_view {
        struct wl_listener new_popup;
 };
 
+bool view_inhibits_keybinds(struct view *view);
+void view_toggle_keybinds(struct view *view);
+
 void view_set_activated(struct view *view);
 void view_set_output(struct view *view, struct output *output);
 void view_close(struct view *view);
index 36f1f99777dd044a0a6aabb27731032f67e5718a..04abe1c661182faaaa361b5d6b799ad1b96e859f 100644 (file)
@@ -721,9 +721,9 @@ actions_run(struct view *activator, struct server *server,
                        }
                        break;
                case ACTION_TYPE_TOGGLE_KEYBINDS:
-                       server->seat.inhibit_keybinds = !server->seat.inhibit_keybinds;
-                       wlr_log(WLR_DEBUG, "%s keybinds",
-                               server->seat.inhibit_keybinds ? "Disabled" : "Enabled");
+                       if (view) {
+                               view_toggle_keybinds(view);
+                       }
                        break;
                case ACTION_TYPE_FOCUS_OUTPUT:
                        {
index 3f69c8bc94ca6d1bed93d98462543fa22be13392..f7b3629d89eb146ce99d3569cc89548b81a56a4f 100644 (file)
@@ -91,7 +91,8 @@ handle_keybinding(struct server *server, uint32_t modifiers, xkb_keysym_t sym)
                if (modifiers ^ keybind->modifiers) {
                        continue;
                }
-               if (server->seat.inhibit_keybinds
+               if (server->seat.nr_inhibited_keybind_views
+                               && view_inhibits_keybinds(desktop_focused_view(server))
                                && !actions_contain_toggle_keybinds(&keybind->actions)) {
                        continue;
                }
index fbe5ea3e543fadb6f55481e78b41cfcfd441e733..3cd9b875612ca6e96a3f2aa310d1ea11cbfe7e0a 100644 (file)
@@ -163,6 +163,7 @@ ssd_create(struct view *view, bool active)
        ssd_titlebar_create(ssd);
        ssd->margin = ssd_thickness(view);
        ssd_set_active(ssd, active);
+       ssd_enable_keybind_inhibit_indicator(ssd, view->inhibits_keybinds);
        ssd->state.geometry = view->current;
 
        return ssd;
@@ -272,6 +273,22 @@ ssd_set_active(struct ssd *ssd, bool active)
        wlr_scene_node_set_enabled(&ssd->titlebar.inactive.tree->node, !active);
 }
 
+void
+ssd_enable_keybind_inhibit_indicator(struct ssd *ssd, bool enable)
+{
+       if (!ssd) {
+               return;
+       }
+
+       float *color = enable
+               ? rc.theme->window_toggled_keybinds_color
+               : rc.theme->window_active_border_color;
+
+       struct ssd_part *part = ssd_get_part(&ssd->border.active.parts, LAB_SSD_PART_TOP);
+       struct wlr_scene_rect *rect = lab_wlr_scene_get_rect(part->node);
+       wlr_scene_rect_set_color(rect, color);
+}
+
 struct ssd_hover_state *
 ssd_hover_state_new(void)
 {
index 8e5b7f8077f656872abf6d9195b1adfa677b2676..e7ed3e891007a2259a562e8454f061be3960b2c9 100644 (file)
@@ -100,6 +100,8 @@ theme_builtin(struct theme *theme)
        parse_hexstr("#dddad6", theme->window_active_border_color);
        parse_hexstr("#f6f5f4", theme->window_inactive_border_color);
 
+       parse_hexstr("#ff0000", theme->window_toggled_keybinds_color);
+
        parse_hexstr("#dddad6", theme->window_active_title_bg_color);
        parse_hexstr("#f6f5f4", theme->window_inactive_title_bg_color);
 
@@ -195,6 +197,10 @@ entry(struct theme *theme, const char *key, const char *value)
                parse_hexstr(value, theme->window_inactive_border_color);
        }
 
+       if (match_glob(key, "window.active.indicator.toggled-keybind.color")) {
+               parse_hexstr(value, theme->window_toggled_keybinds_color);
+       }
+
        if (match_glob(key, "window.active.title.bg.color")) {
                parse_hexstr(value, theme->window_active_title_bg_color);
        }
index 77a8cdcc8a51c18f10114ed58345360dcf8589ee..f41e078494145698d5fe28635ff102307229c3de 100644 (file)
@@ -1088,6 +1088,36 @@ view_reload_ssd(struct view *view)
        }
 }
 
+static void
+inhibit_keybinds(struct view *view, bool inhibit)
+{
+       assert(view->inhibits_keybinds != inhibit);
+
+       view->inhibits_keybinds = inhibit;
+       if (inhibit) {
+               view->server->seat.nr_inhibited_keybind_views++;
+       } else {
+               view->server->seat.nr_inhibited_keybind_views--;
+       }
+
+       if (view->ssd_enabled) {
+               ssd_enable_keybind_inhibit_indicator(view->ssd, inhibit);
+       }
+}
+
+bool
+view_inhibits_keybinds(struct view *view)
+{
+       return view && view->inhibits_keybinds;
+}
+
+void
+view_toggle_keybinds(struct view *view)
+{
+       assert(view);
+       inhibit_keybinds(view, !view->inhibits_keybinds);
+}
+
 void
 view_destroy(struct view *view)
 {
@@ -1130,6 +1160,11 @@ view_destroy(struct view *view)
                zfree(view->tiled_region_evacuate);
        }
 
+       if (view->inhibits_keybinds) {
+               view->inhibits_keybinds = false;
+               server->seat.nr_inhibited_keybind_views--;
+       }
+
        osd_on_view_destroy(view);
        undecorate(view);