mirror of
https://github.com/labwc/labwc.git
synced 2025-10-29 05:40:24 -04:00
ToggleKeybinds per window
This commit is contained in:
parent
b6dfffc782
commit
235a8ad9bc
12 changed files with 84 additions and 5 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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];
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
35
src/view.c
35
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);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue