diff options
-rw-r--r-- | include/sway/commands.h | 1 | ||||
-rw-r--r-- | include/sway/config.h | 1 | ||||
-rw-r--r-- | sway/commands.c | 2 | ||||
-rw-r--r-- | sway/commands/input/seat.c | 28 | ||||
-rw-r--r-- | sway/config.c | 1 | ||||
-rw-r--r-- | sway/input/input-manager.c | 11 | ||||
-rw-r--r-- | sway/meson.build | 1 |
7 files changed, 41 insertions, 4 deletions
diff --git a/include/sway/commands.h b/include/sway/commands.h index 138e3c29..75340e03 100644 --- a/include/sway/commands.h +++ b/include/sway/commands.h | |||
@@ -180,6 +180,7 @@ sway_cmd bar_colors_cmd_statusline; | |||
180 | sway_cmd bar_colors_cmd_focused_statusline; | 180 | sway_cmd bar_colors_cmd_focused_statusline; |
181 | sway_cmd bar_colors_cmd_urgent_workspace; | 181 | sway_cmd bar_colors_cmd_urgent_workspace; |
182 | 182 | ||
183 | sway_cmd input_cmd_seat; | ||
183 | sway_cmd input_cmd_accel_profile; | 184 | sway_cmd input_cmd_accel_profile; |
184 | sway_cmd input_cmd_click_method; | 185 | sway_cmd input_cmd_click_method; |
185 | sway_cmd input_cmd_drag_lock; | 186 | sway_cmd input_cmd_drag_lock; |
diff --git a/include/sway/config.h b/include/sway/config.h index d80f5a39..9fcecfd6 100644 --- a/include/sway/config.h +++ b/include/sway/config.h | |||
@@ -69,6 +69,7 @@ struct input_config { | |||
69 | 69 | ||
70 | bool capturable; | 70 | bool capturable; |
71 | struct wlr_box region; | 71 | struct wlr_box region; |
72 | char *seat; | ||
72 | }; | 73 | }; |
73 | 74 | ||
74 | /** | 75 | /** |
diff --git a/sway/commands.c b/sway/commands.c index 57f76ea9..6645436a 100644 --- a/sway/commands.c +++ b/sway/commands.c | |||
@@ -123,6 +123,7 @@ static int handler_compare(const void *_a, const void *_b) { | |||
123 | return strcasecmp(a->command, b->command); | 123 | return strcasecmp(a->command, b->command); |
124 | } | 124 | } |
125 | 125 | ||
126 | // must be in order for the bsearch | ||
126 | static struct cmd_handler input_handlers[] = { | 127 | static struct cmd_handler input_handlers[] = { |
127 | { "accel_profile", input_cmd_accel_profile }, | 128 | { "accel_profile", input_cmd_accel_profile }, |
128 | { "click_method", input_cmd_click_method }, | 129 | { "click_method", input_cmd_click_method }, |
@@ -134,6 +135,7 @@ static struct cmd_handler input_handlers[] = { | |||
134 | { "natural_scroll", input_cmd_natural_scroll }, | 135 | { "natural_scroll", input_cmd_natural_scroll }, |
135 | { "pointer_accel", input_cmd_pointer_accel }, | 136 | { "pointer_accel", input_cmd_pointer_accel }, |
136 | { "scroll_method", input_cmd_scroll_method }, | 137 | { "scroll_method", input_cmd_scroll_method }, |
138 | { "seat", input_cmd_seat }, | ||
137 | { "tap", input_cmd_tap }, | 139 | { "tap", input_cmd_tap }, |
138 | }; | 140 | }; |
139 | 141 | ||
diff --git a/sway/commands/input/seat.c b/sway/commands/input/seat.c new file mode 100644 index 00000000..9d86ac0e --- /dev/null +++ b/sway/commands/input/seat.c | |||
@@ -0,0 +1,28 @@ | |||
1 | #define _XOPEN_SOURCE 700 | ||
2 | #include <string.h> | ||
3 | #include <strings.h> | ||
4 | #include "sway/commands.h" | ||
5 | #include "sway/input/input-manager.h" | ||
6 | #include "log.h" | ||
7 | |||
8 | struct cmd_results *input_cmd_seat(int argc, char **argv) { | ||
9 | sway_log(L_DEBUG, "seat for device: %d %s", | ||
10 | current_input_config==NULL, current_input_config->identifier); | ||
11 | struct cmd_results *error = NULL; | ||
12 | if ((error = checkarg(argc, "seat", EXPECTED_AT_LEAST, 1))) { | ||
13 | return error; | ||
14 | } | ||
15 | if (!current_input_config) { | ||
16 | return cmd_results_new(CMD_FAILURE, "seat", | ||
17 | "No input device defined."); | ||
18 | } | ||
19 | struct input_config *new_config = | ||
20 | new_input_config(current_input_config->identifier); | ||
21 | |||
22 | // TODO validate seat name | ||
23 | free(new_config->seat); | ||
24 | new_config->seat = strdup(argv[0]); | ||
25 | |||
26 | input_cmd_apply(new_config); | ||
27 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); | ||
28 | } | ||
diff --git a/sway/config.c b/sway/config.c index 4bc74ee0..b77b8b4b 100644 --- a/sway/config.c +++ b/sway/config.c | |||
@@ -300,6 +300,7 @@ void free_input_config(struct input_config *ic) { | |||
300 | return; | 300 | return; |
301 | } | 301 | } |
302 | free(ic->identifier); | 302 | free(ic->identifier); |
303 | free(ic->seat); | ||
303 | free(ic); | 304 | free(ic); |
304 | } | 305 | } |
305 | 306 | ||
diff --git a/sway/input/input-manager.c b/sway/input/input-manager.c index b7f5615c..b07a733e 100644 --- a/sway/input/input-manager.c +++ b/sway/input/input-manager.c | |||
@@ -104,7 +104,9 @@ static void input_add_notify(struct wl_listener *listener, void *data) { | |||
104 | } | 104 | } |
105 | } | 105 | } |
106 | 106 | ||
107 | struct sway_seat *seat = input_manager_get_seat(input, default_seat); | 107 | const char *seat_name = |
108 | (sway_device->config ? sway_device->config->seat : default_seat); | ||
109 | struct sway_seat *seat = input_manager_get_seat(input, seat_name); | ||
108 | sway_seat_add_device(seat, sway_device); | 110 | sway_seat_add_device(seat, sway_device); |
109 | } | 111 | } |
110 | 112 | ||
@@ -176,9 +178,9 @@ void sway_input_manager_set_focus(struct sway_input_manager *input, | |||
176 | } | 178 | } |
177 | 179 | ||
178 | void sway_input_manager_apply_config(struct sway_input_manager *input, | 180 | void sway_input_manager_apply_config(struct sway_input_manager *input, |
179 | struct input_config *config) { | 181 | struct input_config *input_config) { |
180 | struct sway_input_device *sway_device = | 182 | struct sway_input_device *sway_device = |
181 | input_sway_device_from_config(input, config); | 183 | input_sway_device_from_config(input, input_config); |
182 | if (!sway_device) { | 184 | if (!sway_device) { |
183 | return; | 185 | return; |
184 | } | 186 | } |
@@ -188,7 +190,8 @@ void sway_input_manager_apply_config(struct sway_input_manager *input, | |||
188 | sway_seat_remove_device(seat, sway_device); | 190 | sway_seat_remove_device(seat, sway_device); |
189 | } | 191 | } |
190 | 192 | ||
191 | seat = input_manager_get_seat(input, default_seat); | 193 | const char *seat_name = (input_config->seat ? input_config->seat : default_seat); |
194 | seat = input_manager_get_seat(input, seat_name); | ||
192 | sway_seat_add_device(seat, sway_device); | 195 | sway_seat_add_device(seat, sway_device); |
193 | } | 196 | } |
194 | 197 | ||
diff --git a/sway/meson.build b/sway/meson.build index aa3dd2a7..fad1f88c 100644 --- a/sway/meson.build +++ b/sway/meson.build | |||
@@ -11,6 +11,7 @@ sway_sources = files( | |||
11 | 'commands/exec_always.c', | 11 | 'commands/exec_always.c', |
12 | 'commands/include.c', | 12 | 'commands/include.c', |
13 | 'commands/input.c', | 13 | 'commands/input.c', |
14 | 'commands/input/seat.c', | ||
14 | 'commands/input/accel_profile.c', | 15 | 'commands/input/accel_profile.c', |
15 | 'commands/input/click_method.c', | 16 | 'commands/input/click_method.c', |
16 | 'commands/input/drag_lock.c', | 17 | 'commands/input/drag_lock.c', |