|
|
@ -12,11 +12,14 @@ enum operation {
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// pointer_constraint [enable|disable|escape]
|
|
|
|
// 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;
|
|
|
|
struct cmd_results *error = NULL;
|
|
|
|
if ((error = checkarg(argc, "pointer_constraint", EXPECTED_EQUAL_TO, 1))) {
|
|
|
|
if ((error = checkarg(argc, "pointer_constraint", EXPECTED_EQUAL_TO, 1))) {
|
|
|
|
return error;
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!config->handler_context.seat_config) {
|
|
|
|
|
|
|
|
return cmd_results_new(CMD_FAILURE, "No seat defined");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
enum operation op;
|
|
|
|
enum operation op;
|
|
|
|
if (strcmp(argv[0], "enable") == 0) {
|
|
|
|
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.");
|
|
|
|
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 = config->handler_context.seat_config;
|
|
|
|
struct seat_config *seat_config = seat_get_config(cursor->seat);
|
|
|
|
|
|
|
|
switch (op) {
|
|
|
|
switch (op) {
|
|
|
|
case OP_ENABLE:
|
|
|
|
case OP_ENABLE:
|
|
|
|
seat_config->allow_constrain = true;
|
|
|
|
seat_config->allow_constrain = CONSTRAIN_ENABLE;
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case OP_DISABLE:
|
|
|
|
case OP_DISABLE:
|
|
|
|
seat_config->allow_constrain = false;
|
|
|
|
seat_config->allow_constrain = CONSTRAIN_DISABLE;
|
|
|
|
/* fallthrough */
|
|
|
|
/* fallthrough */
|
|
|
|
case OP_ESCAPE:
|
|
|
|
case OP_ESCAPE:;
|
|
|
|
sway_cursor_constrain(cursor, NULL);
|
|
|
|
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;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return cmd_results_new(CMD_SUCCESS, NULL);
|
|
|
|
return cmd_results_new(CMD_SUCCESS, NULL);
|
|
|
|
}
|
|
|
|
}
|