aboutsummaryrefslogtreecommitdiff
path: root/sway/commands
diff options
context:
space:
mode:
authorBrian Ashworth <bosrsf04@gmail.com>2019-01-31 22:58:52 -0500
committerBrian Ashworth <bosrsf04@gmail.com>2019-01-31 22:58:52 -0500
commitebe5399ed6bfa59f5f5d289bf3d46b08f60787b3 (patch)
treeca0bff9d26283b0fa790855e7379e8da2e89166b /sway/commands
parent204e1f47122d5a48865802dd1fb94fe0f05c2401 (diff)
downloadsway-ebe5399ed6bfa59f5f5d289bf3d46b08f60787b3.tar.xz
pointer_constraint: change to a seat subcommand
This changes the `pointer_constraint` command to be a subcommand of seat to allow for per-seat settings. The current implementation that is not a seat subcommand will only operate on the current seat and will segfault in the config due to `config->handler_context.seat` only being set at runtime. This also allows for the wildcard identifier to be used to alter the pointer constraint settings on all seats and allows for the setting to be merged with the rest of the seat config.
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[] = {
{ "cursor", seat_cmd_cursor },
{ "fallback", seat_cmd_fallback },
{ "hide_cursor", seat_cmd_hide_cursor },
+ { "pointer_constraint", seat_cmd_pointer_constraint },
};
struct 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 {
};
// pointer_constraint [enable|disable|escape]
-struct cmd_results *cmd_pointer_constraint(int argc, char **argv) {
+struct cmd_results *seat_cmd_pointer_constraint(int argc, char **argv) {
struct cmd_results *error = NULL;
if ((error = checkarg(argc, "pointer_constraint", EXPECTED_EQUAL_TO, 1))) {
return error;
}
+ if (!config->handler_context.seat_config) {
+ return cmd_results_new(CMD_FAILURE, "No seat defined");
+ }
enum operation op;
if (strcmp(argv[0], "enable") == 0) {
@@ -33,19 +36,23 @@ struct cmd_results *cmd_pointer_constraint(int argc, char **argv) {
return cmd_results_new(CMD_FAILURE, "Can only escape at runtime.");
}
- struct sway_cursor *cursor = config->handler_context.seat->cursor;
- struct seat_config *seat_config = seat_get_config(cursor->seat);
+ struct seat_config *seat_config = config->handler_context.seat_config;
switch (op) {
case OP_ENABLE:
- seat_config->allow_constrain = true;
+ seat_config->allow_constrain = CONSTRAIN_ENABLE;
break;
case OP_DISABLE:
- seat_config->allow_constrain = false;
+ seat_config->allow_constrain = CONSTRAIN_DISABLE;
/* fallthrough */
- case OP_ESCAPE:
- sway_cursor_constrain(cursor, NULL);
+ case OP_ESCAPE:;
+ bool wildcard = !strcmp(seat_config->name, "*");
+ struct sway_seat *seat = NULL;
+ wl_list_for_each(seat, &server.input->seats, link) {
+ if (wildcard || !strcmp(seat->wlr_seat->name, seat_config->name)) {
+ sway_cursor_constrain(seat->cursor, NULL);
+ }
+ }
break;
}
-
return cmd_results_new(CMD_SUCCESS, NULL);
}