mirror of
https://github.com/swaywm/sway
synced 2024-11-18 04:33:59 +01:00
seat configuration
This commit is contained in:
parent
538903bc5a
commit
c173d30b92
@ -180,6 +180,7 @@ sway_cmd bar_colors_cmd_statusline;
|
||||
sway_cmd bar_colors_cmd_focused_statusline;
|
||||
sway_cmd bar_colors_cmd_urgent_workspace;
|
||||
|
||||
sway_cmd input_cmd_seat;
|
||||
sway_cmd input_cmd_accel_profile;
|
||||
sway_cmd input_cmd_click_method;
|
||||
sway_cmd input_cmd_drag_lock;
|
||||
|
@ -69,6 +69,7 @@ struct input_config {
|
||||
|
||||
bool capturable;
|
||||
struct wlr_box region;
|
||||
char *seat;
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -123,6 +123,7 @@ static int handler_compare(const void *_a, const void *_b) {
|
||||
return strcasecmp(a->command, b->command);
|
||||
}
|
||||
|
||||
// must be in order for the bsearch
|
||||
static struct cmd_handler input_handlers[] = {
|
||||
{ "accel_profile", input_cmd_accel_profile },
|
||||
{ "click_method", input_cmd_click_method },
|
||||
@ -134,6 +135,7 @@ static struct cmd_handler input_handlers[] = {
|
||||
{ "natural_scroll", input_cmd_natural_scroll },
|
||||
{ "pointer_accel", input_cmd_pointer_accel },
|
||||
{ "scroll_method", input_cmd_scroll_method },
|
||||
{ "seat", input_cmd_seat },
|
||||
{ "tap", input_cmd_tap },
|
||||
};
|
||||
|
||||
|
28
sway/commands/input/seat.c
Normal file
28
sway/commands/input/seat.c
Normal file
@ -0,0 +1,28 @@
|
||||
#define _XOPEN_SOURCE 700
|
||||
#include <string.h>
|
||||
#include <strings.h>
|
||||
#include "sway/commands.h"
|
||||
#include "sway/input/input-manager.h"
|
||||
#include "log.h"
|
||||
|
||||
struct cmd_results *input_cmd_seat(int argc, char **argv) {
|
||||
sway_log(L_DEBUG, "seat for device: %d %s",
|
||||
current_input_config==NULL, current_input_config->identifier);
|
||||
struct cmd_results *error = NULL;
|
||||
if ((error = checkarg(argc, "seat", EXPECTED_AT_LEAST, 1))) {
|
||||
return error;
|
||||
}
|
||||
if (!current_input_config) {
|
||||
return cmd_results_new(CMD_FAILURE, "seat",
|
||||
"No input device defined.");
|
||||
}
|
||||
struct input_config *new_config =
|
||||
new_input_config(current_input_config->identifier);
|
||||
|
||||
// TODO validate seat name
|
||||
free(new_config->seat);
|
||||
new_config->seat = strdup(argv[0]);
|
||||
|
||||
input_cmd_apply(new_config);
|
||||
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
|
||||
}
|
@ -300,6 +300,7 @@ void free_input_config(struct input_config *ic) {
|
||||
return;
|
||||
}
|
||||
free(ic->identifier);
|
||||
free(ic->seat);
|
||||
free(ic);
|
||||
}
|
||||
|
||||
|
@ -104,7 +104,9 @@ static void input_add_notify(struct wl_listener *listener, void *data) {
|
||||
}
|
||||
}
|
||||
|
||||
struct sway_seat *seat = input_manager_get_seat(input, default_seat);
|
||||
const char *seat_name =
|
||||
(sway_device->config ? sway_device->config->seat : default_seat);
|
||||
struct sway_seat *seat = input_manager_get_seat(input, seat_name);
|
||||
sway_seat_add_device(seat, sway_device);
|
||||
}
|
||||
|
||||
@ -176,9 +178,9 @@ void sway_input_manager_set_focus(struct sway_input_manager *input,
|
||||
}
|
||||
|
||||
void sway_input_manager_apply_config(struct sway_input_manager *input,
|
||||
struct input_config *config) {
|
||||
struct input_config *input_config) {
|
||||
struct sway_input_device *sway_device =
|
||||
input_sway_device_from_config(input, config);
|
||||
input_sway_device_from_config(input, input_config);
|
||||
if (!sway_device) {
|
||||
return;
|
||||
}
|
||||
@ -188,7 +190,8 @@ void sway_input_manager_apply_config(struct sway_input_manager *input,
|
||||
sway_seat_remove_device(seat, sway_device);
|
||||
}
|
||||
|
||||
seat = input_manager_get_seat(input, default_seat);
|
||||
const char *seat_name = (input_config->seat ? input_config->seat : default_seat);
|
||||
seat = input_manager_get_seat(input, seat_name);
|
||||
sway_seat_add_device(seat, sway_device);
|
||||
}
|
||||
|
||||
|
@ -11,6 +11,7 @@ sway_sources = files(
|
||||
'commands/exec_always.c',
|
||||
'commands/include.c',
|
||||
'commands/input.c',
|
||||
'commands/input/seat.c',
|
||||
'commands/input/accel_profile.c',
|
||||
'commands/input/click_method.c',
|
||||
'commands/input/drag_lock.c',
|
||||
|
Loading…
Reference in New Issue
Block a user