diff --git a/docs/labwc-actions.5.scd b/docs/labwc-actions.5.scd index 1027096b..0beedf62 100644 --- a/docs/labwc-actions.5.scd +++ b/docs/labwc-actions.5.scd @@ -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. + ** 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 diff --git a/docs/labwc-theme.5.scd b/docs/labwc-theme.5.scd index 9402e41a..905c5ff2 100644 --- a/docs/labwc-theme.5.scd +++ b/docs/labwc-theme.5.scd @@ -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 diff --git a/docs/themerc b/docs/themerc index 2e7e4f6b..2062256c 100644 --- a/docs/themerc +++ b/docs/themerc @@ -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 diff --git a/include/labwc.h b/include/labwc.h index d2d16aeb..dffb4595 100644 --- a/include/labwc.h +++ b/include/labwc.h @@ -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; diff --git a/include/ssd.h b/include/ssd.h index 4ccc0ef3..5e82be2c 100644 --- a/include/ssd.h +++ b/include/ssd.h @@ -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); diff --git a/include/theme.h b/include/theme.h index 5d3e848b..c78afb26 100644 --- a/include/theme.h +++ b/include/theme.h @@ -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]; diff --git a/include/view.h b/include/view.h index 0ea80167..e5e5d36f 100644 --- a/include/view.h +++ b/include/view.h @@ -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); diff --git a/src/action.c b/src/action.c index 36f1f997..04abe1c6 100644 --- a/src/action.c +++ b/src/action.c @@ -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: { diff --git a/src/keyboard.c b/src/keyboard.c index 3f69c8bc..f7b3629d 100644 --- a/src/keyboard.c +++ b/src/keyboard.c @@ -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; } diff --git a/src/ssd/ssd.c b/src/ssd/ssd.c index fbe5ea3e..3cd9b875 100644 --- a/src/ssd/ssd.c +++ b/src/ssd/ssd.c @@ -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) { diff --git a/src/theme.c b/src/theme.c index 8e5b7f80..e7ed3e89 100644 --- a/src/theme.c +++ b/src/theme.c @@ -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); } diff --git a/src/view.c b/src/view.c index 77a8cdcc..f41e0784 100644 --- a/src/view.c +++ b/src/view.c @@ -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);