ToggleKeybinds per window

This commit is contained in:
Consolatis 2023-03-05 10:35:56 +01:00 committed by Johan Malm
parent b6dfffc782
commit 235a8ad9bc
12 changed files with 84 additions and 5 deletions

View 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:
{

View 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;
}

View 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)
{

View 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);
}

View 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);