diff options
author | Kirill Primak <vyivel@eclair.cafe> | 2023-01-09 18:28:59 +0300 |
---|---|---|
committer | Simon Ser <contact@emersion.fr> | 2023-02-10 18:12:12 +0100 |
commit | 41e473f8c0d79b1a6026c85949bdbd1aa0788a16 (patch) | |
tree | 047fe77d90fb14b469b7f876412e8b3d7d7c55ef /sway/input/tablet.c | |
parent | warp_to_constraint_cursor_hint: Handle NULL view (diff) | |
download | sway-41e473f8c0d79b1a6026c85949bdbd1aa0788a16.tar.gz sway-41e473f8c0d79b1a6026c85949bdbd1aa0788a16.tar.zst sway-41e473f8c0d79b1a6026c85949bdbd1aa0788a16.zip |
input/tablet: handle focusing NULL surface
Additionally, rename the function responsible for switching focus to
match its behavior better.
(cherry picked from commit 53c9a4a6438824abfb3d539bf55aec92074977e0)
Diffstat (limited to 'sway/input/tablet.c')
-rw-r--r-- | sway/input/tablet.c | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/sway/input/tablet.c b/sway/input/tablet.c index 92ede3fa..884eba74 100644 --- a/sway/input/tablet.c +++ b/sway/input/tablet.c | |||
@@ -334,14 +334,10 @@ static void handle_pad_tablet_surface_destroy(struct wl_listener *listener, | |||
334 | struct sway_tablet_pad *tablet_pad = | 334 | struct sway_tablet_pad *tablet_pad = |
335 | wl_container_of(listener, tablet_pad, surface_destroy); | 335 | wl_container_of(listener, tablet_pad, surface_destroy); |
336 | 336 | ||
337 | wlr_tablet_v2_tablet_pad_notify_leave(tablet_pad->tablet_v2_pad, | 337 | sway_tablet_pad_set_focus(tablet_pad, NULL); |
338 | tablet_pad->current_surface); | ||
339 | wl_list_remove(&tablet_pad->surface_destroy.link); | ||
340 | wl_list_init(&tablet_pad->surface_destroy.link); | ||
341 | tablet_pad->current_surface = NULL; | ||
342 | } | 338 | } |
343 | 339 | ||
344 | void sway_tablet_pad_notify_enter(struct sway_tablet_pad *tablet_pad, | 340 | void sway_tablet_pad_set_focus(struct sway_tablet_pad *tablet_pad, |
345 | struct wlr_surface *surface) { | 341 | struct wlr_surface *surface) { |
346 | if (!tablet_pad || !tablet_pad->tablet) { | 342 | if (!tablet_pad || !tablet_pad->tablet) { |
347 | return; | 343 | return; |
@@ -360,7 +356,8 @@ void sway_tablet_pad_notify_enter(struct sway_tablet_pad *tablet_pad, | |||
360 | tablet_pad->current_surface = NULL; | 356 | tablet_pad->current_surface = NULL; |
361 | } | 357 | } |
362 | 358 | ||
363 | if (!wlr_surface_accepts_tablet_v2(tablet_pad->tablet->tablet_v2, surface)) { | 359 | if (surface == NULL || |
360 | !wlr_surface_accepts_tablet_v2(tablet_pad->tablet->tablet_v2, surface)) { | ||
364 | return; | 361 | return; |
365 | } | 362 | } |
366 | 363 | ||
@@ -368,7 +365,6 @@ void sway_tablet_pad_notify_enter(struct sway_tablet_pad *tablet_pad, | |||
368 | tablet_pad->tablet->tablet_v2, surface); | 365 | tablet_pad->tablet->tablet_v2, surface); |
369 | 366 | ||
370 | tablet_pad->current_surface = surface; | 367 | tablet_pad->current_surface = surface; |
371 | wl_list_remove(&tablet_pad->surface_destroy.link); | ||
372 | tablet_pad->surface_destroy.notify = handle_pad_tablet_surface_destroy; | 368 | tablet_pad->surface_destroy.notify = handle_pad_tablet_surface_destroy; |
373 | wl_signal_add(&surface->events.destroy, &tablet_pad->surface_destroy); | 369 | wl_signal_add(&surface->events.destroy, &tablet_pad->surface_destroy); |
374 | } | 370 | } |