2017-12-15 03:11:56 +11:00
|
|
|
#include <string.h>
|
|
|
|
#include <strings.h>
|
|
|
|
#include "sway/commands.h"
|
|
|
|
#include "sway/input/input-manager.h"
|
2019-02-03 14:02:28 +11:00
|
|
|
#include "sway/input/seat.h"
|
2017-12-15 03:11:56 +11:00
|
|
|
#include "log.h"
|
2018-05-31 03:20:02 +10:00
|
|
|
#include "stringop.h"
|
|
|
|
|
|
|
|
// must be in order for the bsearch
|
2019-06-19 15:34:07 +10:00
|
|
|
// these handlers perform actions on the seat
|
|
|
|
static struct cmd_handler seat_action_handlers[] = {
|
|
|
|
{ "cursor", seat_cmd_cursor },
|
|
|
|
};
|
|
|
|
|
|
|
|
// must be in order for the bsearch
|
|
|
|
// these handlers alter the seat config
|
2018-05-31 03:20:02 +10:00
|
|
|
static struct cmd_handler seat_handlers[] = {
|
|
|
|
{ "attach", seat_cmd_attach },
|
|
|
|
{ "fallback", seat_cmd_fallback },
|
2018-12-27 16:32:15 +11:00
|
|
|
{ "hide_cursor", seat_cmd_hide_cursor },
|
2019-12-12 03:00:39 +11:00
|
|
|
{ "idle_inhibit", seat_cmd_idle_inhibit },
|
|
|
|
{ "idle_wake", seat_cmd_idle_wake },
|
2019-11-04 06:20:05 +11:00
|
|
|
{ "keyboard_grouping", seat_cmd_keyboard_grouping },
|
2019-02-01 14:58:52 +11:00
|
|
|
{ "pointer_constraint", seat_cmd_pointer_constraint },
|
2020-02-16 10:40:18 +11:00
|
|
|
{ "shortcuts_inhibitor", seat_cmd_shortcuts_inhibitor },
|
2019-06-02 05:05:09 +10:00
|
|
|
{ "xcursor_theme", seat_cmd_xcursor_theme },
|
2018-05-31 03:20:02 +10:00
|
|
|
};
|
2017-12-15 03:11:56 +11:00
|
|
|
|
2019-06-19 15:34:07 +10:00
|
|
|
static struct cmd_results *action_handlers(int argc, char **argv) {
|
|
|
|
struct cmd_results *res = config_subcommand(argv, argc,
|
|
|
|
seat_action_handlers, sizeof(seat_action_handlers));
|
|
|
|
free_seat_config(config->handler_context.seat_config);
|
|
|
|
config->handler_context.seat_config = NULL;
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct cmd_results *config_handlers(int argc, char **argv) {
|
|
|
|
struct cmd_results *res = config_subcommand(argv, argc,
|
|
|
|
seat_handlers, sizeof(seat_handlers));
|
|
|
|
if (res && res->status != CMD_SUCCESS) {
|
|
|
|
free_seat_config(config->handler_context.seat_config);
|
|
|
|
} else {
|
|
|
|
struct seat_config *sc =
|
|
|
|
store_seat_config(config->handler_context.seat_config);
|
|
|
|
if (!config->reading) {
|
|
|
|
input_manager_apply_seat_config(sc);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
config->handler_context.seat_config = NULL;
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2017-12-15 03:11:56 +11:00
|
|
|
struct cmd_results *cmd_seat(int argc, char **argv) {
|
|
|
|
struct cmd_results *error = NULL;
|
2018-09-09 04:51:38 +10:00
|
|
|
if ((error = checkarg(argc, "seat", EXPECTED_AT_LEAST, 2))) {
|
2017-12-15 03:11:56 +11:00
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
2019-02-03 14:02:28 +11:00
|
|
|
if (!strcmp(argv[0], "-")) {
|
|
|
|
if (config->reading) {
|
|
|
|
return cmd_results_new(CMD_FAILURE,
|
|
|
|
"Current seat alias (-) cannot be used in the config");
|
|
|
|
}
|
|
|
|
config->handler_context.seat_config =
|
|
|
|
new_seat_config(config->handler_context.seat->wlr_seat->name);
|
|
|
|
} else {
|
|
|
|
config->handler_context.seat_config = new_seat_config(argv[0]);
|
|
|
|
}
|
2018-05-31 03:20:02 +10:00
|
|
|
if (!config->handler_context.seat_config) {
|
2019-01-11 10:27:21 +11:00
|
|
|
return cmd_results_new(CMD_FAILURE, "Couldn't allocate config");
|
2017-12-15 03:11:56 +11:00
|
|
|
}
|
|
|
|
|
2019-06-19 15:34:07 +10:00
|
|
|
struct cmd_results *res = NULL;
|
|
|
|
if (find_handler(argv[1], seat_action_handlers,
|
|
|
|
sizeof(seat_action_handlers))) {
|
|
|
|
res = action_handlers(argc - 1, argv + 1);
|
|
|
|
} else {
|
|
|
|
res = config_handlers(argc - 1, argv + 1);
|
2019-01-09 16:57:23 +11:00
|
|
|
}
|
2019-02-11 19:26:12 +11:00
|
|
|
return res ? res : cmd_results_new(CMD_SUCCESS, NULL);
|
2017-12-15 03:11:56 +11:00
|
|
|
}
|