diff options
author | Olivier Fourdan <ofourdan@redhat.com> | 2020-03-11 15:03:03 +0100 |
---|---|---|
committer | Drew DeVault <sir@cmpwn.com> | 2020-03-12 18:02:09 +0100 |
commit | 7dd9cd29a6cb0f075f7face47f8a0629bf13f0c6 (patch) | |
tree | 0d67adb7580c75a199683e105bed8bb18d4be405 | |
parent | readme: git is an optional dependency (diff) | |
download | sway-7dd9cd29a6cb0f075f7face47f8a0629bf13f0c6.tar.gz sway-7dd9cd29a6cb0f075f7face47f8a0629bf13f0c6.tar.zst sway-7dd9cd29a6cb0f075f7face47f8a0629bf13f0c6.zip |
input: Avoid creating the PAD device multiple times
If a pad device for a tablet exists, reloading the configuration,
removing/reading the device or even suspending the system will recreate
the same Wayland input device multiple times.
Make sure we don't re-create the same Wayland device more than
necessary.
Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
-rw-r--r-- | sway/input/seat.c | 2 | ||||
-rw-r--r-- | sway/input/tablet.c | 12 |
2 files changed, 9 insertions, 5 deletions
diff --git a/sway/input/seat.c b/sway/input/seat.c index 6739c163..920742e9 100644 --- a/sway/input/seat.c +++ b/sway/input/seat.c | |||
@@ -723,7 +723,7 @@ static void seat_configure_tablet_tool(struct sway_seat *seat, | |||
723 | 723 | ||
724 | static void seat_configure_tablet_pad(struct sway_seat *seat, | 724 | static void seat_configure_tablet_pad(struct sway_seat *seat, |
725 | struct sway_seat_device *sway_device) { | 725 | struct sway_seat_device *sway_device) { |
726 | if (!sway_device->tablet) { | 726 | if (!sway_device->tablet_pad) { |
727 | sway_device->tablet_pad = sway_tablet_pad_create(seat, sway_device); | 727 | sway_device->tablet_pad = sway_tablet_pad_create(seat, sway_device); |
728 | } | 728 | } |
729 | sway_configure_tablet_pad(sway_device->tablet_pad); | 729 | sway_configure_tablet_pad(sway_device->tablet_pad); |
diff --git a/sway/input/tablet.c b/sway/input/tablet.c index b0d4d0c6..8d6e95b3 100644 --- a/sway/input/tablet.c +++ b/sway/input/tablet.c | |||
@@ -56,8 +56,10 @@ void sway_configure_tablet(struct sway_tablet *tablet) { | |||
56 | seat_configure_xcursor(seat); | 56 | seat_configure_xcursor(seat); |
57 | } | 57 | } |
58 | 58 | ||
59 | tablet->tablet_v2 = | 59 | if (!tablet->tablet_v2) { |
60 | wlr_tablet_create(server.tablet_v2, seat->wlr_seat, device); | 60 | tablet->tablet_v2 = |
61 | wlr_tablet_create(server.tablet_v2, seat->wlr_seat, device); | ||
62 | } | ||
61 | 63 | ||
62 | /* Search for a sibling tablet pad */ | 64 | /* Search for a sibling tablet pad */ |
63 | if (!wlr_input_device_is_libinput(device)) { | 65 | if (!wlr_input_device_is_libinput(device)) { |
@@ -238,8 +240,10 @@ void sway_configure_tablet_pad(struct sway_tablet_pad *tablet_pad) { | |||
238 | tablet_pad->seat_device->input_device->wlr_device; | 240 | tablet_pad->seat_device->input_device->wlr_device; |
239 | struct sway_seat *seat = tablet_pad->seat_device->sway_seat; | 241 | struct sway_seat *seat = tablet_pad->seat_device->sway_seat; |
240 | 242 | ||
241 | tablet_pad->tablet_v2_pad = | 243 | if (!tablet_pad->tablet_v2_pad) { |
242 | wlr_tablet_pad_create(server.tablet_v2, seat->wlr_seat, device); | 244 | tablet_pad->tablet_v2_pad = |
245 | wlr_tablet_pad_create(server.tablet_v2, seat->wlr_seat, device); | ||
246 | } | ||
243 | 247 | ||
244 | wl_list_remove(&tablet_pad->attach.link); | 248 | wl_list_remove(&tablet_pad->attach.link); |
245 | tablet_pad->attach.notify = handle_tablet_pad_attach; | 249 | tablet_pad->attach.notify = handle_tablet_pad_attach; |