aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Simon Ser <contact@emersion.fr>2023-11-16 14:56:46 +0100
committerLibravatar Kenny Levinsen <kl@kl.wtf>2023-11-16 16:29:07 +0100
commit7036769bea886ab1f9d627785f14cea9e25b16f7 (patch)
tree73df7ae212c8f2587abd9860bcb54be3c831a6fb
parentinput/seat: rename seat_apply_input_config (diff)
downloadsway-7036769bea886ab1f9d627785f14cea9e25b16f7.tar.gz
sway-7036769bea886ab1f9d627785f14cea9e25b16f7.tar.zst
sway-7036769bea886ab1f9d627785f14cea9e25b16f7.zip
Only reconfigure input mappings on output change
Fully reconfiguring all input devices on output change takes a loooong time. Let's just reconfigure what we need: only mappings depend on outputs.
-rw-r--r--include/sway/input/input-manager.h2
-rw-r--r--include/sway/input/seat.h3
-rw-r--r--sway/config/output.c2
-rw-r--r--sway/input/input-manager.c10
-rw-r--r--sway/input/seat.c24
-rw-r--r--sway/tree/output.c2
6 files changed, 38 insertions, 5 deletions
diff --git a/include/sway/input/input-manager.h b/include/sway/input/input-manager.h
index b651e3dd..6652d60c 100644
--- a/include/sway/input/input-manager.h
+++ b/include/sway/input/input-manager.h
@@ -47,6 +47,8 @@ void input_manager_apply_input_config(struct input_config *input_config);
47 47
48void input_manager_configure_all_inputs(void); 48void input_manager_configure_all_inputs(void);
49 49
50void input_manager_configure_all_input_mappings(void);
51
50void input_manager_reset_input(struct sway_input_device *input_device); 52void input_manager_reset_input(struct sway_input_device *input_device);
51 53
52void input_manager_reset_all_inputs(void); 54void input_manager_reset_all_inputs(void);
diff --git a/include/sway/input/seat.h b/include/sway/input/seat.h
index 35a96ace..97e81c19 100644
--- a/include/sway/input/seat.h
+++ b/include/sway/input/seat.h
@@ -168,6 +168,9 @@ void seat_add_device(struct sway_seat *seat,
168void seat_configure_device(struct sway_seat *seat, 168void seat_configure_device(struct sway_seat *seat,
169 struct sway_input_device *device); 169 struct sway_input_device *device);
170 170
171void seat_configure_device_mapping(struct sway_seat *seat,
172 struct sway_input_device *input_device);
173
171void seat_reset_device(struct sway_seat *seat, 174void seat_reset_device(struct sway_seat *seat,
172 struct sway_input_device *input_device); 175 struct sway_input_device *input_device);
173 176
diff --git a/sway/config/output.c b/sway/config/output.c
index eefde22b..3316085a 100644
--- a/sway/config/output.c
+++ b/sway/config/output.c
@@ -590,7 +590,7 @@ bool apply_output_config(struct output_config *oc, struct sway_output *output) {
590 // Reconfigure all devices, since input config may have been applied before 590 // Reconfigure all devices, since input config may have been applied before
591 // this output came online, and some config items (like map_to_output) are 591 // this output came online, and some config items (like map_to_output) are
592 // dependent on an output being present. 592 // dependent on an output being present.
593 input_manager_configure_all_inputs(); 593 input_manager_configure_all_input_mappings();
594 // Reconfigure the cursor images, since the scale may have changed. 594 // Reconfigure the cursor images, since the scale may have changed.
595 input_manager_configure_xcursor(); 595 input_manager_configure_xcursor();
596 return true; 596 return true;
diff --git a/sway/input/input-manager.c b/sway/input/input-manager.c
index db82bb4c..5300919a 100644
--- a/sway/input/input-manager.c
+++ b/sway/input/input-manager.c
@@ -571,6 +571,16 @@ void input_manager_configure_all_inputs(void) {
571 } 571 }
572} 572}
573 573
574void input_manager_configure_all_input_mappings(void) {
575 struct sway_input_device *input_device;
576 wl_list_for_each(input_device, &server.input->devices, link) {
577 struct sway_seat *seat;
578 wl_list_for_each(seat, &server.input->seats, link) {
579 seat_configure_device_mapping(seat, input_device);
580 }
581 }
582}
583
574void input_manager_apply_input_config(struct input_config *input_config) { 584void input_manager_apply_input_config(struct input_config *input_config) {
575 struct sway_input_device *input_device = NULL; 585 struct sway_input_device *input_device = NULL;
576 bool wildcard = strcmp(input_config->identifier, "*") == 0; 586 bool wildcard = strcmp(input_config->identifier, "*") == 0;
diff --git a/sway/input/seat.c b/sway/input/seat.c
index bafdbcf3..f73946b1 100644
--- a/sway/input/seat.c
+++ b/sway/input/seat.c
@@ -710,6 +710,15 @@ static void seat_apply_input_mapping(struct sway_seat *seat,
710 struct input_config *ic = 710 struct input_config *ic =
711 input_device_get_config(sway_device->input_device); 711 input_device_get_config(sway_device->input_device);
712 712
713 switch (sway_device->input_device->wlr_device->type) {
714 case WLR_INPUT_DEVICE_POINTER:
715 case WLR_INPUT_DEVICE_TOUCH:
716 case WLR_INPUT_DEVICE_TABLET_TOOL:
717 break;
718 default:
719 return; // these devices don't support mappings
720 }
721
713 sway_log(SWAY_DEBUG, "Applying input mapping to %s", 722 sway_log(SWAY_DEBUG, "Applying input mapping to %s",
714 sway_device->input_device->identifier); 723 sway_device->input_device->identifier);
715 724
@@ -799,7 +808,6 @@ static void seat_configure_pointer(struct sway_seat *seat,
799 } 808 }
800 wlr_cursor_attach_input_device(seat->cursor->cursor, 809 wlr_cursor_attach_input_device(seat->cursor->cursor,
801 sway_device->input_device->wlr_device); 810 sway_device->input_device->wlr_device);
802 seat_apply_input_mapping(seat, sway_device);
803 wl_event_source_timer_update( 811 wl_event_source_timer_update(
804 seat->cursor->hide_source, cursor_get_timeout(seat->cursor)); 812 seat->cursor->hide_source, cursor_get_timeout(seat->cursor));
805} 813}
@@ -841,7 +849,6 @@ static void seat_configure_touch(struct sway_seat *seat,
841 struct sway_seat_device *sway_device) { 849 struct sway_seat_device *sway_device) {
842 wlr_cursor_attach_input_device(seat->cursor->cursor, 850 wlr_cursor_attach_input_device(seat->cursor->cursor,
843 sway_device->input_device->wlr_device); 851 sway_device->input_device->wlr_device);
844 seat_apply_input_mapping(seat, sway_device);
845} 852}
846 853
847static void seat_configure_tablet_tool(struct sway_seat *seat, 854static void seat_configure_tablet_tool(struct sway_seat *seat,
@@ -852,7 +859,6 @@ static void seat_configure_tablet_tool(struct sway_seat *seat,
852 sway_configure_tablet(sway_device->tablet); 859 sway_configure_tablet(sway_device->tablet);
853 wlr_cursor_attach_input_device(seat->cursor->cursor, 860 wlr_cursor_attach_input_device(seat->cursor->cursor,
854 sway_device->input_device->wlr_device); 861 sway_device->input_device->wlr_device);
855 seat_apply_input_mapping(seat, sway_device);
856} 862}
857 863
858static void seat_configure_tablet_pad(struct sway_seat *seat, 864static void seat_configure_tablet_pad(struct sway_seat *seat,
@@ -909,6 +915,18 @@ void seat_configure_device(struct sway_seat *seat,
909 seat_configure_tablet_pad(seat, seat_device); 915 seat_configure_tablet_pad(seat, seat_device);
910 break; 916 break;
911 } 917 }
918
919 seat_apply_input_mapping(seat, seat_device);
920}
921
922void seat_configure_device_mapping(struct sway_seat *seat,
923 struct sway_input_device *input_device) {
924 struct sway_seat_device *seat_device = seat_get_device(seat, input_device);
925 if (!seat_device) {
926 return;
927 }
928
929 seat_apply_input_mapping(seat, seat_device);
912} 930}
913 931
914void seat_reset_device(struct sway_seat *seat, 932void seat_reset_device(struct sway_seat *seat,
diff --git a/sway/tree/output.c b/sway/tree/output.c
index 0960f413..4aa3a7fe 100644
--- a/sway/tree/output.c
+++ b/sway/tree/output.c
@@ -277,7 +277,7 @@ void output_disable(struct sway_output *output) {
277 // Reconfigure all devices, since devices with map_to_output directives for 277 // Reconfigure all devices, since devices with map_to_output directives for
278 // an output that goes offline should stop sending events as long as the 278 // an output that goes offline should stop sending events as long as the
279 // output remains offline. 279 // output remains offline.
280 input_manager_configure_all_inputs(); 280 input_manager_configure_all_input_mappings();
281} 281}
282 282
283void output_begin_destroy(struct sway_output *output) { 283void output_begin_destroy(struct sway_output *output) {