aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Kirill Primak <vyivel@eclair.cafe>2023-01-09 18:28:59 +0300
committerLibravatar Simon Zeni <simon@bl4ckb0ne.ca>2023-01-16 15:37:59 -0500
commit53c9a4a6438824abfb3d539bf55aec92074977e0 (patch)
tree1a98f99cdc1fc1857d4d211c8c128add7c26af3a
parentswaynag: call swaynag_destroy on clean exit (diff)
downloadsway-53c9a4a6438824abfb3d539bf55aec92074977e0.tar.gz
sway-53c9a4a6438824abfb3d539bf55aec92074977e0.tar.zst
sway-53c9a4a6438824abfb3d539bf55aec92074977e0.zip
input/tablet: handle focusing NULL surface
Additionally, rename the function responsible for switching focus to match its behavior better.
-rw-r--r--include/sway/input/tablet.h2
-rw-r--r--sway/input/seat.c8
-rw-r--r--sway/input/tablet.c12
3 files changed, 9 insertions, 13 deletions
diff --git a/include/sway/input/tablet.h b/include/sway/input/tablet.h
index c0a5aff7..2fa5db6d 100644
--- a/include/sway/input/tablet.h
+++ b/include/sway/input/tablet.h
@@ -63,7 +63,7 @@ void sway_configure_tablet_pad(struct sway_tablet_pad *tablet_pad);
63 63
64void sway_tablet_pad_destroy(struct sway_tablet_pad *tablet_pad); 64void sway_tablet_pad_destroy(struct sway_tablet_pad *tablet_pad);
65 65
66void sway_tablet_pad_notify_enter(struct sway_tablet_pad *tablet_pad, 66void sway_tablet_pad_set_focus(struct sway_tablet_pad *tablet_pad,
67 struct wlr_surface *surface); 67 struct wlr_surface *surface);
68 68
69#endif 69#endif
diff --git a/sway/input/seat.c b/sway/input/seat.c
index 151303a9..18b63715 100644
--- a/sway/input/seat.c
+++ b/sway/input/seat.c
@@ -177,11 +177,11 @@ static void seat_keyboard_notify_enter(struct sway_seat *seat,
177 state->pressed_keycodes, state->npressed, &keyboard->modifiers); 177 state->pressed_keycodes, state->npressed, &keyboard->modifiers);
178} 178}
179 179
180static void seat_tablet_pads_notify_enter(struct sway_seat *seat, 180static void seat_tablet_pads_set_focus(struct sway_seat *seat,
181 struct wlr_surface *surface) { 181 struct wlr_surface *surface) {
182 struct sway_seat_device *seat_device; 182 struct sway_seat_device *seat_device;
183 wl_list_for_each(seat_device, &seat->devices, link) { 183 wl_list_for_each(seat_device, &seat->devices, link) {
184 sway_tablet_pad_notify_enter(seat_device->tablet_pad, surface); 184 sway_tablet_pad_set_focus(seat_device->tablet_pad, surface);
185 } 185 }
186} 186}
187 187
@@ -205,7 +205,7 @@ static void seat_send_focus(struct sway_node *node, struct sway_seat *seat) {
205#endif 205#endif
206 206
207 seat_keyboard_notify_enter(seat, view->surface); 207 seat_keyboard_notify_enter(seat, view->surface);
208 seat_tablet_pads_notify_enter(seat, view->surface); 208 seat_tablet_pads_set_focus(seat, view->surface);
209 sway_input_method_relay_set_focus(&seat->im_relay, view->surface); 209 sway_input_method_relay_set_focus(&seat->im_relay, view->surface);
210 210
211 struct wlr_pointer_constraint_v1 *constraint = 211 struct wlr_pointer_constraint_v1 *constraint =
@@ -1322,7 +1322,7 @@ void seat_set_focus_surface(struct sway_seat *seat,
1322 } 1322 }
1323 1323
1324 sway_input_method_relay_set_focus(&seat->im_relay, surface); 1324 sway_input_method_relay_set_focus(&seat->im_relay, surface);
1325 seat_tablet_pads_notify_enter(seat, surface); 1325 seat_tablet_pads_set_focus(seat, surface);
1326} 1326}
1327 1327
1328void seat_set_focus_layer(struct sway_seat *seat, 1328void seat_set_focus_layer(struct sway_seat *seat,
diff --git a/sway/input/tablet.c b/sway/input/tablet.c
index a62e77ec..f979bc68 100644
--- a/sway/input/tablet.c
+++ b/sway/input/tablet.c
@@ -342,14 +342,10 @@ static void handle_pad_tablet_surface_destroy(struct wl_listener *listener,
342 struct sway_tablet_pad *tablet_pad = 342 struct sway_tablet_pad *tablet_pad =
343 wl_container_of(listener, tablet_pad, surface_destroy); 343 wl_container_of(listener, tablet_pad, surface_destroy);
344 344
345 wlr_tablet_v2_tablet_pad_notify_leave(tablet_pad->tablet_v2_pad, 345 sway_tablet_pad_set_focus(tablet_pad, NULL);
346 tablet_pad->current_surface);
347 wl_list_remove(&tablet_pad->surface_destroy.link);
348 wl_list_init(&tablet_pad->surface_destroy.link);
349 tablet_pad->current_surface = NULL;
350} 346}
351 347
352void sway_tablet_pad_notify_enter(struct sway_tablet_pad *tablet_pad, 348void sway_tablet_pad_set_focus(struct sway_tablet_pad *tablet_pad,
353 struct wlr_surface *surface) { 349 struct wlr_surface *surface) {
354 if (!tablet_pad || !tablet_pad->tablet) { 350 if (!tablet_pad || !tablet_pad->tablet) {
355 return; 351 return;
@@ -368,7 +364,8 @@ void sway_tablet_pad_notify_enter(struct sway_tablet_pad *tablet_pad,
368 tablet_pad->current_surface = NULL; 364 tablet_pad->current_surface = NULL;
369 } 365 }
370 366
371 if (!wlr_surface_accepts_tablet_v2(tablet_pad->tablet->tablet_v2, surface)) { 367 if (surface == NULL ||
368 !wlr_surface_accepts_tablet_v2(tablet_pad->tablet->tablet_v2, surface)) {
372 return; 369 return;
373 } 370 }
374 371
@@ -376,7 +373,6 @@ void sway_tablet_pad_notify_enter(struct sway_tablet_pad *tablet_pad,
376 tablet_pad->tablet->tablet_v2, surface); 373 tablet_pad->tablet->tablet_v2, surface);
377 374
378 tablet_pad->current_surface = surface; 375 tablet_pad->current_surface = surface;
379 wl_list_remove(&tablet_pad->surface_destroy.link);
380 tablet_pad->surface_destroy.notify = handle_pad_tablet_surface_destroy; 376 tablet_pad->surface_destroy.notify = handle_pad_tablet_surface_destroy;
381 wl_signal_add(&surface->events.destroy, &tablet_pad->surface_destroy); 377 wl_signal_add(&surface->events.destroy, &tablet_pad->surface_destroy);
382} 378}