aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Brian Ashworth <bosrsf04@gmail.com>2019-12-15 01:33:33 -0500
committerLibravatar Drew DeVault <sir@cmpwn.com>2019-12-16 12:03:11 -0500
commit452a615bb8f546fbeaddd7bacc71b5c597ab5629 (patch)
treea8a2b726fd510e906f7c27eb8510eae2bdd986b3
parentinput/seatop_default: fix focusing floating titles (diff)
downloadsway-452a615bb8f546fbeaddd7bacc71b5c597ab5629.tar.gz
sway-452a615bb8f546fbeaddd7bacc71b5c597ab5629.tar.zst
sway-452a615bb8f546fbeaddd7bacc71b5c597ab5629.zip
seat_cmd_keyboard_grouping: change keymap to smart
This removes `seat <seat> keyboard_grouping keymap` and replaces it with `seat <seat> keyboard_grouping smart`. The smart keyboard grouping will group based on both the keymap and repeat info. The reasoning for this is that deciding what the repeat info should be for a group is either arbitrary or non-deterministic when multiple keyboards in the group have repeat info configured (unless somehow exposed to the user in a reproducible uniquely identifiable fashion).
-rw-r--r--include/sway/config.h4
-rw-r--r--include/sway/input/keyboard.h3
-rw-r--r--sway/commands/seat/keyboard_grouping.c6
-rw-r--r--sway/input/keyboard.c46
-rw-r--r--sway/sway-input.5.scd14
5 files changed, 45 insertions, 28 deletions
diff --git a/include/sway/config.h b/include/sway/config.h
index 3e3d2725..aef6694d 100644
--- a/include/sway/config.h
+++ b/include/sway/config.h
@@ -177,9 +177,9 @@ enum seat_config_allow_constrain {
177}; 177};
178 178
179enum seat_keyboard_grouping { 179enum seat_keyboard_grouping {
180 KEYBOARD_GROUP_DEFAULT, // the default is currently keymap 180 KEYBOARD_GROUP_DEFAULT, // the default is currently smart
181 KEYBOARD_GROUP_NONE, 181 KEYBOARD_GROUP_NONE,
182 KEYBOARD_GROUP_KEYMAP 182 KEYBOARD_GROUP_SMART // keymap and repeat info
183}; 183};
184 184
185enum sway_input_idle_source { 185enum sway_input_idle_source {
diff --git a/include/sway/input/keyboard.h b/include/sway/input/keyboard.h
index 72a29ba6..13fcafcc 100644
--- a/include/sway/input/keyboard.h
+++ b/include/sway/input/keyboard.h
@@ -54,6 +54,9 @@ struct sway_keyboard {
54 struct xkb_keymap *keymap; 54 struct xkb_keymap *keymap;
55 xkb_layout_index_t effective_layout; 55 xkb_layout_index_t effective_layout;
56 56
57 int32_t repeat_rate;
58 int32_t repeat_delay;
59
57 struct wl_listener keyboard_key; 60 struct wl_listener keyboard_key;
58 struct wl_listener keyboard_modifiers; 61 struct wl_listener keyboard_modifiers;
59 62
diff --git a/sway/commands/seat/keyboard_grouping.c b/sway/commands/seat/keyboard_grouping.c
index 959c6f94..5ad0f408 100644
--- a/sway/commands/seat/keyboard_grouping.c
+++ b/sway/commands/seat/keyboard_grouping.c
@@ -15,11 +15,11 @@ struct cmd_results *seat_cmd_keyboard_grouping(int argc, char **argv) {
15 struct seat_config *seat_config = config->handler_context.seat_config; 15 struct seat_config *seat_config = config->handler_context.seat_config;
16 if (strcmp(argv[0], "none") == 0) { 16 if (strcmp(argv[0], "none") == 0) {
17 seat_config->keyboard_grouping = KEYBOARD_GROUP_NONE; 17 seat_config->keyboard_grouping = KEYBOARD_GROUP_NONE;
18 } else if (strcmp(argv[0], "keymap") == 0) { 18 } else if (strcmp(argv[0], "smart") == 0) {
19 seat_config->keyboard_grouping = KEYBOARD_GROUP_KEYMAP; 19 seat_config->keyboard_grouping = KEYBOARD_GROUP_SMART;
20 } else { 20 } else {
21 return cmd_results_new(CMD_INVALID, 21 return cmd_results_new(CMD_INVALID,
22 "Expected syntax `keyboard_grouping none|keymap`"); 22 "Expected syntax `keyboard_grouping none|smart`");
23 } 23 }
24 24
25 return cmd_results_new(CMD_SUCCESS, NULL); 25 return cmd_results_new(CMD_SUCCESS, NULL);
diff --git a/sway/input/keyboard.c b/sway/input/keyboard.c
index f71a7909..2cfcd126 100644
--- a/sway/input/keyboard.c
+++ b/sway/input/keyboard.c
@@ -659,6 +659,11 @@ static bool keymaps_match(struct xkb_keymap *km1, struct xkb_keymap *km2) {
659 return result; 659 return result;
660} 660}
661 661
662static bool repeat_info_match(struct sway_keyboard *a, struct wlr_keyboard *b) {
663 return a->repeat_rate == b->repeat_info.rate &&
664 a->repeat_delay == b->repeat_info.delay;
665}
666
662static void destroy_empty_wlr_keyboard_group(void *data) { 667static void destroy_empty_wlr_keyboard_group(void *data) {
663 wlr_keyboard_group_destroy(data); 668 wlr_keyboard_group_destroy(data);
664} 669}
@@ -711,9 +716,10 @@ static void sway_keyboard_group_remove_invalid(struct sway_keyboard *keyboard) {
711 sway_keyboard_group_remove(keyboard); 716 sway_keyboard_group_remove(keyboard);
712 break; 717 break;
713 case KEYBOARD_GROUP_DEFAULT: /* fallthrough */ 718 case KEYBOARD_GROUP_DEFAULT: /* fallthrough */
714 case KEYBOARD_GROUP_KEYMAP:; 719 case KEYBOARD_GROUP_SMART:;
715 struct wlr_keyboard_group *group = wlr_keyboard->group; 720 struct wlr_keyboard_group *group = wlr_keyboard->group;
716 if (!keymaps_match(keyboard->keymap, group->keyboard.keymap)) { 721 if (!keymaps_match(keyboard->keymap, group->keyboard.keymap) ||
722 !repeat_info_match(keyboard, &group->keyboard)) {
717 sway_keyboard_group_remove(keyboard); 723 sway_keyboard_group_remove(keyboard);
718 } 724 }
719 break; 725 break;
@@ -741,9 +747,10 @@ static void sway_keyboard_group_add(struct sway_keyboard *keyboard) {
741 // Nothing to do. This shouldn't even be reached 747 // Nothing to do. This shouldn't even be reached
742 return; 748 return;
743 case KEYBOARD_GROUP_DEFAULT: /* fallthrough */ 749 case KEYBOARD_GROUP_DEFAULT: /* fallthrough */
744 case KEYBOARD_GROUP_KEYMAP:; 750 case KEYBOARD_GROUP_SMART:;
745 struct wlr_keyboard_group *wlr_group = group->wlr_group; 751 struct wlr_keyboard_group *wlr_group = group->wlr_group;
746 if (keymaps_match(keyboard->keymap, wlr_group->keyboard.keymap)) { 752 if (keymaps_match(keyboard->keymap, wlr_group->keyboard.keymap) &&
753 repeat_info_match(keyboard, &wlr_group->keyboard)) {
747 sway_log(SWAY_DEBUG, "Adding keyboard %s to group %p", 754 sway_log(SWAY_DEBUG, "Adding keyboard %s to group %p",
748 device->identifier, wlr_group); 755 device->identifier, wlr_group);
749 wlr_keyboard_group_add_keyboard(wlr_group, wlr_keyboard); 756 wlr_keyboard_group_add_keyboard(wlr_group, wlr_keyboard);
@@ -767,6 +774,8 @@ static void sway_keyboard_group_add(struct sway_keyboard *keyboard) {
767 } 774 }
768 sway_group->wlr_group->data = sway_group; 775 sway_group->wlr_group->data = sway_group;
769 wlr_keyboard_set_keymap(&sway_group->wlr_group->keyboard, keyboard->keymap); 776 wlr_keyboard_set_keymap(&sway_group->wlr_group->keyboard, keyboard->keymap);
777 wlr_keyboard_set_repeat_info(&sway_group->wlr_group->keyboard,
778 keyboard->repeat_rate, keyboard->repeat_delay);
770 sway_log(SWAY_DEBUG, "Created keyboard group %p", sway_group->wlr_group); 779 sway_log(SWAY_DEBUG, "Created keyboard group %p", sway_group->wlr_group);
771 780
772 sway_group->seat_device = calloc(1, sizeof(struct sway_seat_device)); 781 sway_group->seat_device = calloc(1, sizeof(struct sway_seat_device));
@@ -836,14 +845,30 @@ void sway_keyboard_configure(struct sway_keyboard *keyboard) {
836 keyboard->keymap ? !keymaps_match(keyboard->keymap, keymap) : true; 845 keyboard->keymap ? !keymaps_match(keyboard->keymap, keymap) : true;
837 bool effective_layout_changed = keyboard->effective_layout != 0; 846 bool effective_layout_changed = keyboard->effective_layout != 0;
838 847
839 if (keymap_changed || config->reloading) { 848 int repeat_rate = 25;
849 if (input_config && input_config->repeat_rate != INT_MIN) {
850 repeat_rate = input_config->repeat_rate;
851 }
852 int repeat_delay = 600;
853 if (input_config && input_config->repeat_delay != INT_MIN) {
854 repeat_delay = input_config->repeat_delay;
855 }
856
857 bool repeat_info_changed = keyboard->repeat_rate != repeat_rate ||
858 keyboard->repeat_delay != repeat_delay;
859
860 if (keymap_changed || repeat_info_changed || config->reloading) {
840 xkb_keymap_unref(keyboard->keymap); 861 xkb_keymap_unref(keyboard->keymap);
841 keyboard->keymap = keymap; 862 keyboard->keymap = keymap;
842 keyboard->effective_layout = 0; 863 keyboard->effective_layout = 0;
864 keyboard->repeat_rate = repeat_rate;
865 keyboard->repeat_delay = repeat_delay;
843 866
844 sway_keyboard_group_remove_invalid(keyboard); 867 sway_keyboard_group_remove_invalid(keyboard);
845 868
846 wlr_keyboard_set_keymap(wlr_device->keyboard, keyboard->keymap); 869 wlr_keyboard_set_keymap(wlr_device->keyboard, keyboard->keymap);
870 wlr_keyboard_set_repeat_info(wlr_device->keyboard,
871 keyboard->repeat_rate, keyboard->repeat_delay);
847 872
848 if (!wlr_device->keyboard->group) { 873 if (!wlr_device->keyboard->group) {
849 sway_keyboard_group_add(keyboard); 874 sway_keyboard_group_add(keyboard);
@@ -890,17 +915,6 @@ void sway_keyboard_configure(struct sway_keyboard *keyboard) {
890 } 915 }
891 } 916 }
892 917
893 int repeat_rate = 25;
894 if (input_config && input_config->repeat_rate != INT_MIN) {
895 repeat_rate = input_config->repeat_rate;
896 }
897 int repeat_delay = 600;
898 if (input_config && input_config->repeat_delay != INT_MIN) {
899 repeat_delay = input_config->repeat_delay;
900 }
901 wlr_keyboard_set_repeat_info(wlr_device->keyboard, repeat_rate,
902 repeat_delay);
903
904 struct wlr_seat *seat = keyboard->seat_device->sway_seat->wlr_seat; 918 struct wlr_seat *seat = keyboard->seat_device->sway_seat->wlr_seat;
905 wlr_seat_set_keyboard(seat, wlr_device); 919 wlr_seat_set_keyboard(seat, wlr_device);
906 920
diff --git a/sway/sway-input.5.scd b/sway/sway-input.5.scd
index e1ae6781..a0f155fe 100644
--- a/sway/sway-input.5.scd
+++ b/sway/sway-input.5.scd
@@ -230,15 +230,15 @@ correct seat.
230 "keyboard", "pointer", "touchpad", "touch", "tablet pad", "tablet tool", 230 "keyboard", "pointer", "touchpad", "touch", "tablet pad", "tablet tool",
231 and "switch". The default behavior is to wake from idle on any event. 231 and "switch". The default behavior is to wake from idle on any event.
232 232
233*seat* <name> keyboard_grouping none|keymap 233*seat* <name> keyboard_grouping none|smart
234 Set how the keyboards in the seat are grouped together. Currently, there 234 Set how the keyboards in the seat are grouped together. Currently, there
235 are two options. _none_ will disable all keyboard grouping. This will make 235 are two options. _none_ will disable all keyboard grouping. This will make
236 it so each keyboard device has its own isolated state. _keymap_ will 236 it so each keyboard device has its own isolated state. _smart_ will
237 group the keyboards in the seat by their keymap. This is useful for when 237 group the keyboards in the seat by their keymap and repeat info. This is
238 the keyboard appears as multiple separate input devices. In this mode, 238 useful for when the keyboard appears as multiple separate input devices.
239 the effective layout and repeat info are also synced between the keyboards 239 In this mode, the effective layout is synced between the keyboards in the
240 in the group. The default is _keymap_. To restore the behavior of older 240 group. The default is _smart_. To restore the behavior of older versions
241 versions of sway, use _none_. 241 of sway, use _none_.
242 242
243*seat* <name> pointer_constraint enable|disable|escape 243*seat* <name> pointer_constraint enable|disable|escape
244 Enables or disables the ability for clients to capture the cursor (enabled 244 Enables or disables the ability for clients to capture the cursor (enabled