mirror of
https://github.com/swaywm/sway.git
synced 2026-04-28 06:46:26 -04:00
implemented seat detach command
This commit is contained in:
parent
f5190d1f79
commit
afd66d63cc
7 changed files with 49 additions and 0 deletions
|
|
@ -265,6 +265,7 @@ sway_cmd output_cmd_transform;
|
|||
|
||||
sway_cmd seat_cmd_attach;
|
||||
sway_cmd seat_cmd_cursor;
|
||||
sway_cmd seat_cmd_detach;
|
||||
sway_cmd seat_cmd_fallback;
|
||||
sway_cmd seat_cmd_hide_cursor;
|
||||
sway_cmd seat_cmd_pointer_constraint;
|
||||
|
|
|
|||
|
|
@ -571,6 +571,9 @@ struct seat_attachment_config *seat_config_get_attachment(
|
|||
|
||||
struct seat_config *store_seat_config(struct seat_config *seat);
|
||||
|
||||
void seat_config_remove_attachment(
|
||||
struct seat_config *seat_config, char *identifier);
|
||||
|
||||
int output_name_cmp(const void *item, const void *data);
|
||||
|
||||
void output_get_identifier(char *identifier, size_t len,
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@
|
|||
static struct cmd_handler seat_handlers[] = {
|
||||
{ "attach", seat_cmd_attach },
|
||||
{ "cursor", seat_cmd_cursor },
|
||||
{ "detach", seat_cmd_detach },
|
||||
{ "fallback", seat_cmd_fallback },
|
||||
{ "hide_cursor", seat_cmd_hide_cursor },
|
||||
{ "pointer_constraint", seat_cmd_pointer_constraint },
|
||||
|
|
|
|||
27
sway/commands/seat/detach.c
Normal file
27
sway/commands/seat/detach.c
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
#define _XOPEN_SOURCE 700
|
||||
#include <string.h>
|
||||
#include "sway/commands.h"
|
||||
#include "sway/config.h"
|
||||
|
||||
struct cmd_results *seat_cmd_detach(int argc, char **argv) {
|
||||
struct cmd_results *error = NULL;
|
||||
if ((error = checkarg(argc, "detach", EXPECTED_AT_LEAST, 1))) {
|
||||
return error;
|
||||
}
|
||||
struct seat_config *current_seat_config = config->handler_context.seat_config;
|
||||
if (!current_seat_config) {
|
||||
return cmd_results_new(CMD_FAILURE, "detach", "No seat defined");
|
||||
}
|
||||
|
||||
int i;
|
||||
i = list_seq_find(config->seat_configs, seat_name_cmp, current_seat_config->name);
|
||||
if (i >= 0) {
|
||||
struct seat_config *sc = config->seat_configs->items[i];
|
||||
seat_config_remove_attachment(sc, strdup(argv[0]));
|
||||
}
|
||||
|
||||
if (!config->validating) {
|
||||
input_manager_apply_seat_config(new_seat_config(current_seat_config->name));
|
||||
}
|
||||
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
|
||||
}
|
||||
|
|
@ -191,3 +191,14 @@ struct seat_attachment_config *seat_config_get_attachment(
|
|||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void seat_config_remove_attachment(struct seat_config *seat_config, char *identifier) {
|
||||
for (int i = 0; i < seat_config->attachments->length; ++i) {
|
||||
struct seat_attachment_config *attachment = seat_config->attachments->items[i];
|
||||
if (strcmp(attachment->identifier, identifier) == 0) {
|
||||
list_del(seat_config->attachments, i);
|
||||
seat_attachment_config_free(attachment);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -82,6 +82,7 @@ sway_sources = files(
|
|||
'commands/seat.c',
|
||||
'commands/seat/attach.c',
|
||||
'commands/seat/cursor.c',
|
||||
'commands/seat/detach.c',
|
||||
'commands/seat/fallback.c',
|
||||
'commands/seat/hide_cursor.c',
|
||||
'commands/seat/pointer_constraint.c',
|
||||
|
|
|
|||
|
|
@ -150,6 +150,11 @@ sitting in their own "seat").
|
|||
Attach an input device to this seat by its input identifier. A special
|
||||
value of "\*" will attach all devices to the seat.
|
||||
|
||||
*seat* <name> detach <input\_identifier>
|
||||
Detaches an input device from this seat by its input identifier.
|
||||
|
||||
Note: the fallback seat will catch input devices with no seat.
|
||||
|
||||
*seat* <seat> cursor move|set <x> <y>
|
||||
Move specified seat's cursor relative to current position or wrap to
|
||||
absolute coordinates (with respect to the global coordinate space).
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue