mirror of
https://github.com/swaywm/sway.git
synced 2024-11-10 20:44:01 +01:00
Merge pull request #3337 from RedSoxFan/fix-seat-cmd-cursor
seat_cmd_cursor: work on seat name provided
This commit is contained in:
commit
353d9ed74f
@ -17,18 +17,8 @@ static const char *expected_syntax = "Expected 'cursor <move> <x> <y>' or "
|
||||
"'cursor <set> <x> <y>' or "
|
||||
"'curor <press|release> <left|right|1|2|3...>'";
|
||||
|
||||
struct cmd_results *seat_cmd_cursor(int argc, char **argv) {
|
||||
struct cmd_results *error = NULL;
|
||||
if ((error = checkarg(argc, "cursor", EXPECTED_AT_LEAST, 2))) {
|
||||
return error;
|
||||
}
|
||||
struct sway_seat *seat = config->handler_context.seat;
|
||||
if (!seat) {
|
||||
return cmd_results_new(CMD_FAILURE, "cursor", "No seat defined");
|
||||
}
|
||||
|
||||
struct sway_cursor *cursor = seat->cursor;
|
||||
|
||||
static struct cmd_results *handle_command(struct sway_cursor *cursor,
|
||||
int argc, char **argv) {
|
||||
if (strcasecmp(argv[0], "move") == 0) {
|
||||
if (argc < 3) {
|
||||
return cmd_results_new(CMD_INVALID, "cursor", expected_syntax);
|
||||
@ -50,6 +40,7 @@ struct cmd_results *seat_cmd_cursor(int argc, char **argv) {
|
||||
if (argc < 2) {
|
||||
return cmd_results_new(CMD_INVALID, "cursor", expected_syntax);
|
||||
}
|
||||
struct cmd_results *error = NULL;
|
||||
if ((error = press_or_release(cursor, argv[0], argv[1]))) {
|
||||
return error;
|
||||
}
|
||||
@ -58,6 +49,40 @@ struct cmd_results *seat_cmd_cursor(int argc, char **argv) {
|
||||
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
|
||||
}
|
||||
|
||||
struct cmd_results *seat_cmd_cursor(int argc, char **argv) {
|
||||
struct cmd_results *error = NULL;
|
||||
if ((error = checkarg(argc, "cursor", EXPECTED_AT_LEAST, 2))) {
|
||||
return error;
|
||||
}
|
||||
struct seat_config *sc = config->handler_context.seat_config;
|
||||
if (!sc) {
|
||||
return cmd_results_new(CMD_FAILURE, "cursor", "No seat defined");
|
||||
}
|
||||
|
||||
if (config->reading || !config->active) {
|
||||
return cmd_results_new(CMD_DEFER, NULL, NULL);
|
||||
}
|
||||
|
||||
if (strcmp(sc->name, "*") != 0) {
|
||||
struct sway_seat *seat = input_manager_get_seat(sc->name);
|
||||
if (!seat) {
|
||||
return cmd_results_new(CMD_FAILURE, "cursor",
|
||||
"Failed to get seat");
|
||||
}
|
||||
error = handle_command(seat->cursor, argc, argv);
|
||||
} else {
|
||||
struct sway_seat *seat = NULL;
|
||||
wl_list_for_each(seat, &server.input->seats, link) {
|
||||
error = handle_command(seat->cursor, argc, argv);
|
||||
if ((error && error->status != CMD_SUCCESS)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return error ? error : cmd_results_new(CMD_SUCCESS, NULL, NULL);
|
||||
}
|
||||
|
||||
static struct cmd_results *press_or_release(struct sway_cursor *cursor,
|
||||
char *action, char *button_str) {
|
||||
enum wlr_button_state state;
|
||||
|
Loading…
Reference in New Issue
Block a user