aboutsummaryrefslogtreecommitdiffstats
path: root/sway/input/seat.c
diff options
context:
space:
mode:
authorLibravatar Tadeo Kondrak <me@tadeo.ca>2019-10-28 18:26:00 -0600
committerLibravatar Simon Ser <contact@emersion.fr>2019-11-17 13:34:24 +0100
commit4829f1c26a521a4ef6659d91505112cc0be8d237 (patch)
tree4e0987c668241600401755630afe40c3879ca06a /sway/input/seat.c
parentxwayland: get_constraints using size hints (diff)
downloadsway-4829f1c26a521a4ef6659d91505112cc0be8d237.tar.gz
sway-4829f1c26a521a4ef6659d91505112cc0be8d237.tar.zst
sway-4829f1c26a521a4ef6659d91505112cc0be8d237.zip
Implement input map_to_region command
Diffstat (limited to 'sway/input/seat.c')
-rw-r--r--sway/input/seat.c29
1 files changed, 28 insertions, 1 deletions
diff --git a/sway/input/seat.c b/sway/input/seat.c
index dc21ce61..5fc23a19 100644
--- a/sway/input/seat.c
+++ b/sway/input/seat.c
@@ -576,6 +576,7 @@ static void seat_reset_input_config(struct sway_seat *seat,
576static void seat_apply_input_config(struct sway_seat *seat, 576static void seat_apply_input_config(struct sway_seat *seat,
577 struct sway_seat_device *sway_device) { 577 struct sway_seat_device *sway_device) {
578 const char *mapped_to_output = NULL; 578 const char *mapped_to_output = NULL;
579 struct wlr_box *mapped_to_region = NULL;
579 580
580 struct input_config *ic = input_device_get_config( 581 struct input_config *ic = input_device_get_config(
581 sway_device->input_device); 582 sway_device->input_device);
@@ -583,12 +584,31 @@ static void seat_apply_input_config(struct sway_seat *seat,
583 sway_log(SWAY_DEBUG, "Applying input config to %s", 584 sway_log(SWAY_DEBUG, "Applying input config to %s",
584 sway_device->input_device->identifier); 585 sway_device->input_device->identifier);
585 586
587 // We use an empty string as a marker to clear the mapped_to_output
588 // property, because a NULL set in a handler_context isn't preserved.
589 if (ic->mapped_to_output != NULL && ic->mapped_to_output[0] == '\0') {
590 free(ic->mapped_to_output);
591 ic->mapped_to_output = NULL;
592 wlr_cursor_map_input_to_output(seat->cursor->cursor,
593 sway_device->input_device->wlr_device, NULL);
594 }
595
586 mapped_to_output = ic->mapped_to_output; 596 mapped_to_output = ic->mapped_to_output;
597 if (mapped_to_output != NULL) {
598 // Output has just been set, clear region setting.
599 free(ic->mapped_to_region);
600 ic->mapped_to_region = NULL;
601 wlr_cursor_map_input_to_region(seat->cursor->cursor,
602 sway_device->input_device->wlr_device, NULL);
603 }
604
605 mapped_to_region = ic->mapped_to_region;
587 } 606 }
588 607
589 if (mapped_to_output == NULL) { 608 if (mapped_to_output == NULL && mapped_to_region == NULL) {
590 mapped_to_output = sway_device->input_device->wlr_device->output_name; 609 mapped_to_output = sway_device->input_device->wlr_device->output_name;
591 } 610 }
611
592 if (mapped_to_output != NULL) { 612 if (mapped_to_output != NULL) {
593 sway_log(SWAY_DEBUG, "Mapping input device %s to output %s", 613 sway_log(SWAY_DEBUG, "Mapping input device %s to output %s",
594 sway_device->input_device->identifier, mapped_to_output); 614 sway_device->input_device->identifier, mapped_to_output);
@@ -604,6 +624,13 @@ static void seat_apply_input_config(struct sway_seat *seat,
604 sway_device->input_device->wlr_device, output->wlr_output); 624 sway_device->input_device->wlr_device, output->wlr_output);
605 sway_log(SWAY_DEBUG, "Mapped to output %s", output->wlr_output->name); 625 sway_log(SWAY_DEBUG, "Mapped to output %s", output->wlr_output->name);
606 } 626 }
627 } else if (mapped_to_region != NULL) {
628 sway_log(SWAY_DEBUG, "Mapping input device %s to %d,%d %dx%d",
629 sway_device->input_device->identifier,
630 mapped_to_region->x, mapped_to_region->y,
631 mapped_to_region->width, mapped_to_region->height);
632 wlr_cursor_map_input_to_region(seat->cursor->cursor,
633 sway_device->input_device->wlr_device, mapped_to_region);
607 } 634 }
608} 635}
609 636