aboutsummaryrefslogtreecommitdiffstats
path: root/sway/commands
diff options
context:
space:
mode:
Diffstat (limited to 'sway/commands')
-rw-r--r--sway/commands/seat.c1
-rw-r--r--sway/commands/seat/pointer_constraint.c (renamed from sway/commands/pointer_constraint.c)23
2 files changed, 16 insertions, 8 deletions
diff --git a/sway/commands/seat.c b/sway/commands/seat.c
index 69000b57..81bb5f5d 100644
--- a/sway/commands/seat.c
+++ b/sway/commands/seat.c
@@ -11,6 +11,7 @@ static struct cmd_handler seat_handlers[] = {
11 { "cursor", seat_cmd_cursor }, 11 { "cursor", seat_cmd_cursor },
12 { "fallback", seat_cmd_fallback }, 12 { "fallback", seat_cmd_fallback },
13 { "hide_cursor", seat_cmd_hide_cursor }, 13 { "hide_cursor", seat_cmd_hide_cursor },
14 { "pointer_constraint", seat_cmd_pointer_constraint },
14}; 15};
15 16
16struct cmd_results *cmd_seat(int argc, char **argv) { 17struct cmd_results *cmd_seat(int argc, char **argv) {
diff --git a/sway/commands/pointer_constraint.c b/sway/commands/seat/pointer_constraint.c
index 2dda0776..3890ebde 100644
--- a/sway/commands/pointer_constraint.c
+++ b/sway/commands/seat/pointer_constraint.c
@@ -12,11 +12,14 @@ enum operation {
12}; 12};
13 13
14// pointer_constraint [enable|disable|escape] 14// pointer_constraint [enable|disable|escape]
15struct cmd_results *cmd_pointer_constraint(int argc, char **argv) { 15struct cmd_results *seat_cmd_pointer_constraint(int argc, char **argv) {
16 struct cmd_results *error = NULL; 16 struct cmd_results *error = NULL;
17 if ((error = checkarg(argc, "pointer_constraint", EXPECTED_EQUAL_TO, 1))) { 17 if ((error = checkarg(argc, "pointer_constraint", EXPECTED_EQUAL_TO, 1))) {
18 return error; 18 return error;
19 } 19 }
20 if (!config->handler_context.seat_config) {
21 return cmd_results_new(CMD_FAILURE, "No seat defined");
22 }
20 23
21 enum operation op; 24 enum operation op;
22 if (strcmp(argv[0], "enable") == 0) { 25 if (strcmp(argv[0], "enable") == 0) {
@@ -33,19 +36,23 @@ struct cmd_results *cmd_pointer_constraint(int argc, char **argv) {
33 return cmd_results_new(CMD_FAILURE, "Can only escape at runtime."); 36 return cmd_results_new(CMD_FAILURE, "Can only escape at runtime.");
34 } 37 }
35 38
36 struct sway_cursor *cursor = config->handler_context.seat->cursor; 39 struct seat_config *seat_config = config->handler_context.seat_config;
37 struct seat_config *seat_config = seat_get_config(cursor->seat);
38 switch (op) { 40 switch (op) {
39 case OP_ENABLE: 41 case OP_ENABLE:
40 seat_config->allow_constrain = true; 42 seat_config->allow_constrain = CONSTRAIN_ENABLE;
41 break; 43 break;
42 case OP_DISABLE: 44 case OP_DISABLE:
43 seat_config->allow_constrain = false; 45 seat_config->allow_constrain = CONSTRAIN_DISABLE;
44 /* fallthrough */ 46 /* fallthrough */
45 case OP_ESCAPE: 47 case OP_ESCAPE:;
46 sway_cursor_constrain(cursor, NULL); 48 bool wildcard = !strcmp(seat_config->name, "*");
49 struct sway_seat *seat = NULL;
50 wl_list_for_each(seat, &server.input->seats, link) {
51 if (wildcard || !strcmp(seat->wlr_seat->name, seat_config->name)) {
52 sway_cursor_constrain(seat->cursor, NULL);
53 }
54 }
47 break; 55 break;
48 } 56 }
49
50 return cmd_results_new(CMD_SUCCESS, NULL); 57 return cmd_results_new(CMD_SUCCESS, NULL);
51} 58}