mirror of
https://github.com/swaywm/sway.git
synced 2026-04-27 06:46:25 -04:00
add an option to manage when keyboard layout is changed
This patch adds an option, but the actual functional for it to control
being added in next one.
To keep keyboard layout per window add in sway config:
seat * keep_keyboard_layout per_window
To keep keyboard layout globally either do not add anything (it's the
default), or to explicitly enable it use the following:
seat * keep_keyboard_layout global
Signed-off-by: Konstantin Kharlamov <Hi-Angel@yandex.ru>
This commit is contained in:
parent
4925882920
commit
481accca2a
6 changed files with 42 additions and 0 deletions
|
|
@ -277,6 +277,7 @@ sway_cmd seat_cmd_attach;
|
||||||
sway_cmd seat_cmd_cursor;
|
sway_cmd seat_cmd_cursor;
|
||||||
sway_cmd seat_cmd_fallback;
|
sway_cmd seat_cmd_fallback;
|
||||||
sway_cmd seat_cmd_hide_cursor;
|
sway_cmd seat_cmd_hide_cursor;
|
||||||
|
sway_cmd seat_cmd_keep_keyboard_layout;
|
||||||
sway_cmd seat_cmd_pointer_constraint;
|
sway_cmd seat_cmd_pointer_constraint;
|
||||||
|
|
||||||
sway_cmd cmd_ipc_cmd;
|
sway_cmd cmd_ipc_cmd;
|
||||||
|
|
|
||||||
|
|
@ -41,6 +41,12 @@ enum binding_flags {
|
||||||
BINDING_CODE=32, // keyboard only; convert keysyms into keycodes
|
BINDING_CODE=32, // keyboard only; convert keysyms into keycodes
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum sway_keep_keyboard_layout {
|
||||||
|
KEYBOARD_LAYOUT_UNDEFINED = 0,
|
||||||
|
KEYBOARD_LAYOUT_GLOBAL,
|
||||||
|
KEYBOARD_LAYOUT_PER_WINDOW
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A key binding and an associated command.
|
* A key binding and an associated command.
|
||||||
*/
|
*/
|
||||||
|
|
@ -165,6 +171,7 @@ struct seat_config {
|
||||||
list_t *attachments; // list of seat_attachment configs
|
list_t *attachments; // list of seat_attachment configs
|
||||||
int hide_cursor_timeout;
|
int hide_cursor_timeout;
|
||||||
enum seat_config_allow_constrain allow_constrain;
|
enum seat_config_allow_constrain allow_constrain;
|
||||||
|
enum sway_keep_keyboard_layout keep_keyboard_layout;
|
||||||
};
|
};
|
||||||
|
|
||||||
enum config_dpms {
|
enum config_dpms {
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,7 @@ static struct cmd_handler seat_handlers[] = {
|
||||||
{ "cursor", seat_cmd_cursor },
|
{ "cursor", seat_cmd_cursor },
|
||||||
{ "fallback", seat_cmd_fallback },
|
{ "fallback", seat_cmd_fallback },
|
||||||
{ "hide_cursor", seat_cmd_hide_cursor },
|
{ "hide_cursor", seat_cmd_hide_cursor },
|
||||||
|
{ "keep_keyboard_layout", seat_cmd_keep_keyboard_layout },
|
||||||
{ "pointer_constraint", seat_cmd_pointer_constraint },
|
{ "pointer_constraint", seat_cmd_pointer_constraint },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
29
sway/commands/seat/keep_keyboard_layout.c
Normal file
29
sway/commands/seat/keep_keyboard_layout.c
Normal file
|
|
@ -0,0 +1,29 @@
|
||||||
|
#include "log.h"
|
||||||
|
#include "sway/commands.h"
|
||||||
|
#include "sway/config.h"
|
||||||
|
#include "sway/input/input-manager.h"
|
||||||
|
|
||||||
|
struct cmd_results *seat_cmd_keep_keyboard_layout(int argc, char **argv) {
|
||||||
|
const char *STR_LAYOUT_GLOBAL = "global",
|
||||||
|
*STR_LAYOUT_PER_WINDOW = "per_window";
|
||||||
|
struct cmd_results *error = NULL;
|
||||||
|
if ((error = checkarg(argc, "keep_keyboard_layout", EXPECTED_EQUAL_TO, 1))) {
|
||||||
|
return error;
|
||||||
|
}
|
||||||
|
if (!config->handler_context.seat_config) {
|
||||||
|
return cmd_results_new(CMD_FAILURE, "No seat defined");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!strcmp(argv[0], STR_LAYOUT_GLOBAL)) {
|
||||||
|
config->handler_context.seat_config->keep_keyboard_layout
|
||||||
|
= KEYBOARD_LAYOUT_GLOBAL;
|
||||||
|
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
|
||||||
|
} else if (!strcmp(argv[0], STR_LAYOUT_PER_WINDOW)) {
|
||||||
|
config->handler_context.seat_config->keep_keyboard_layout
|
||||||
|
= KEYBOARD_LAYOUT_PER_WINDOW;
|
||||||
|
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
|
||||||
|
} else {
|
||||||
|
return cmd_results_new(CMD_FAILURE, "keep_keyboard_layout",
|
||||||
|
"Expected 'keep_keyboard_layout global|per_window");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -88,6 +88,7 @@ sway_sources = files(
|
||||||
'commands/seat/cursor.c',
|
'commands/seat/cursor.c',
|
||||||
'commands/seat/fallback.c',
|
'commands/seat/fallback.c',
|
||||||
'commands/seat/hide_cursor.c',
|
'commands/seat/hide_cursor.c',
|
||||||
|
'commands/seat/keep_keyboard_layout.c',
|
||||||
'commands/seat/pointer_constraint.c',
|
'commands/seat/pointer_constraint.c',
|
||||||
'commands/set.c',
|
'commands/set.c',
|
||||||
'commands/show_marks.c',
|
'commands/show_marks.c',
|
||||||
|
|
|
||||||
|
|
@ -201,6 +201,9 @@ correct seat.
|
||||||
disables hiding the cursor. The minimal timeout is 100 and any value less
|
disables hiding the cursor. The minimal timeout is 100 and any value less
|
||||||
than that (aside from 0), will be increased to 100.
|
than that (aside from 0), will be increased to 100.
|
||||||
|
|
||||||
|
*seat* <name> keep_keyboard_layout global|per_window
|
||||||
|
Controls whether to keep keyboard layout per window. Default is _global_.
|
||||||
|
|
||||||
*seat* <name> pointer_constraint enable|disable|escape
|
*seat* <name> pointer_constraint enable|disable|escape
|
||||||
Enables or disables the ability for clients to capture the cursor (enabled
|
Enables or disables the ability for clients to capture the cursor (enabled
|
||||||
by default) for the seat. This is primarily useful for video games. The
|
by default) for the seat. This is primarily useful for video games. The
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue