keyboard: allow applying keyboard layout per window

Fixes #1076

It can be enabled with a config like

~/.config/labwc/rc.xml:
<keyboard layoutScope="window">

~/.config/labwc/environment:
XKB_DEFAULT_LAYOUT=de,us
XKB_DEFAULT_OPTIONS=grp:alt_shift_toggle,grp_led:scroll

With a configuration like this each window should now remember
the active keyboard layout when switching between windows.

By default, the keyboard layout keeps being a global state.
This commit is contained in:
Consolatis 2023-09-07 16:41:47 +02:00 committed by Johan Malm
parent f1c2664ad1
commit 984aeb0b0b
9 changed files with 66 additions and 3 deletions

View file

@ -6,6 +6,7 @@
#include "common/match.h"
#include "common/mem.h"
#include "common/scene-helpers.h"
#include "input/keyboard.h"
#include "labwc.h"
#include "menu/menu.h"
#include "regions.h"
@ -266,6 +267,17 @@ view_set_activated(struct view *view, bool activated)
wlr_foreign_toplevel_handle_v1_set_activated(
view->toplevel.handle, activated);
}
if (rc.kb_layout_per_window) {
if (!activated) {
/* Store configured keyboard layout per view */
view->keyboard_layout =
view->server->seat.keyboard_group->keyboard.modifiers.group;
} else {
/* Switch to previously stored keyboard layout */
keyboard_update_layout(&view->server->seat, view->keyboard_layout);
}
}
}
void