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

@ -63,6 +63,7 @@ struct rcxml {
int repeat_rate;
int repeat_delay;
bool kb_numlock_enable;
bool kb_layout_per_window;
struct wl_list keybinds; /* struct keybind.link */
/* mouse */

View file

@ -3,6 +3,7 @@
#define LABWC_KEYBOARD_H
#include <stdbool.h>
#include <xkbcommon/xkbcommon.h>
struct seat;
struct keyboard;
@ -13,6 +14,7 @@ void keyboard_finish(struct seat *seat);
void keyboard_setup_handlers(struct keyboard *keyboard);
void keyboard_set_numlock(struct wlr_keyboard *keyboard);
void keyboard_update_layout(struct seat *seat, xkb_layout_index_t layout);
void keyboard_cancel_keybind_repeat(struct keyboard *keyboard);
bool keyboard_any_modifiers_pressed(struct wlr_keyboard *keyboard);

View file

@ -39,7 +39,6 @@
#include <wlr/types/wlr_virtual_pointer_v1.h>
#include <wlr/types/wlr_virtual_keyboard_v1.h>
#include <wlr/util/log.h>
#include <xkbcommon/xkbcommon.h>
#include "config/keybind.h"
#include "config/rcxml.h"
#include "input/cursor.h"

View file

@ -7,6 +7,7 @@
#include <stdint.h>
#include <wayland-util.h>
#include <wlr/util/box.h>
#include <xkbcommon/xkbcommon.h>
#define LAB_MIN_VIEW_WIDTH 100
#define LAB_MIN_VIEW_HEIGHT 60
@ -143,6 +144,7 @@ struct view {
bool fullscreen;
enum view_edge tiled;
bool inhibits_keybinds;
xkb_layout_index_t keyboard_layout;
/* Pointer to an output owned struct region, may be NULL */
struct region *tiled_region;