mirror of
https://github.com/swaywm/sway.git
synced 2026-03-27 07:58:40 -04:00
Implement input map_to_region command
This commit is contained in:
parent
df1a046875
commit
4829f1c26a
8 changed files with 97 additions and 2 deletions
|
|
@ -576,6 +576,7 @@ static void seat_reset_input_config(struct sway_seat *seat,
|
|||
static void seat_apply_input_config(struct sway_seat *seat,
|
||||
struct sway_seat_device *sway_device) {
|
||||
const char *mapped_to_output = NULL;
|
||||
struct wlr_box *mapped_to_region = NULL;
|
||||
|
||||
struct input_config *ic = input_device_get_config(
|
||||
sway_device->input_device);
|
||||
|
|
@ -583,12 +584,31 @@ static void seat_apply_input_config(struct sway_seat *seat,
|
|||
sway_log(SWAY_DEBUG, "Applying input config to %s",
|
||||
sway_device->input_device->identifier);
|
||||
|
||||
// We use an empty string as a marker to clear the mapped_to_output
|
||||
// property, because a NULL set in a handler_context isn't preserved.
|
||||
if (ic->mapped_to_output != NULL && ic->mapped_to_output[0] == '\0') {
|
||||
free(ic->mapped_to_output);
|
||||
ic->mapped_to_output = NULL;
|
||||
wlr_cursor_map_input_to_output(seat->cursor->cursor,
|
||||
sway_device->input_device->wlr_device, NULL);
|
||||
}
|
||||
|
||||
mapped_to_output = ic->mapped_to_output;
|
||||
if (mapped_to_output != NULL) {
|
||||
// Output has just been set, clear region setting.
|
||||
free(ic->mapped_to_region);
|
||||
ic->mapped_to_region = NULL;
|
||||
wlr_cursor_map_input_to_region(seat->cursor->cursor,
|
||||
sway_device->input_device->wlr_device, NULL);
|
||||
}
|
||||
|
||||
mapped_to_region = ic->mapped_to_region;
|
||||
}
|
||||
|
||||
if (mapped_to_output == NULL) {
|
||||
if (mapped_to_output == NULL && mapped_to_region == NULL) {
|
||||
mapped_to_output = sway_device->input_device->wlr_device->output_name;
|
||||
}
|
||||
|
||||
if (mapped_to_output != NULL) {
|
||||
sway_log(SWAY_DEBUG, "Mapping input device %s to output %s",
|
||||
sway_device->input_device->identifier, mapped_to_output);
|
||||
|
|
@ -604,6 +624,13 @@ static void seat_apply_input_config(struct sway_seat *seat,
|
|||
sway_device->input_device->wlr_device, output->wlr_output);
|
||||
sway_log(SWAY_DEBUG, "Mapped to output %s", output->wlr_output->name);
|
||||
}
|
||||
} else if (mapped_to_region != NULL) {
|
||||
sway_log(SWAY_DEBUG, "Mapping input device %s to %d,%d %dx%d",
|
||||
sway_device->input_device->identifier,
|
||||
mapped_to_region->x, mapped_to_region->y,
|
||||
mapped_to_region->width, mapped_to_region->height);
|
||||
wlr_cursor_map_input_to_region(seat->cursor->cursor,
|
||||
sway_device->input_device->wlr_device, mapped_to_region);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue