aboutsummaryrefslogtreecommitdiffstats
path: root/sway
diff options
context:
space:
mode:
authorLibravatar Tony Crisci <tony@dubstepdish.com>2017-12-12 10:55:20 -0500
committerLibravatar Tony Crisci <tony@dubstepdish.com>2017-12-12 10:55:20 -0500
commitc173d30b9203520c274f34eb72fc787aa33ca211 (patch)
tree11a1090e2e582caf1c19521596925ed14e57a6e4 /sway
parentconfig cleanup (diff)
downloadsway-c173d30b9203520c274f34eb72fc787aa33ca211.tar.gz
sway-c173d30b9203520c274f34eb72fc787aa33ca211.tar.zst
sway-c173d30b9203520c274f34eb72fc787aa33ca211.zip
seat configuration
Diffstat (limited to 'sway')
-rw-r--r--sway/commands.c2
-rw-r--r--sway/commands/input/seat.c28
-rw-r--r--sway/config.c1
-rw-r--r--sway/input/input-manager.c11
-rw-r--r--sway/meson.build1
5 files changed, 39 insertions, 4 deletions
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
126static struct cmd_handler input_handlers[] = { 127static 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
8struct 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
178void sway_input_manager_apply_config(struct sway_input_manager *input, 180void 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',