aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Kirill Primak <vyivel@eclair.cafe>2023-01-09 18:28:59 +0300
committerLibravatar Simon Ser <contact@emersion.fr>2023-02-10 18:12:12 +0100
commit41e473f8c0d79b1a6026c85949bdbd1aa0788a16 (patch)
tree047fe77d90fb14b469b7f876412e8b3d7d7c55ef
parentwarp_to_constraint_cursor_hint: Handle NULL view (diff)
downloadsway-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)
-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 646f3866..0bd33581 100644
--- a/sway/input/seat.c
+++ b/sway/input/seat.c
@@ -176,11 +176,11 @@ static void seat_keyboard_notify_enter(struct sway_seat *seat,
176 state->pressed_keycodes, state->npressed, &keyboard->modifiers); 176 state->pressed_keycodes, state->npressed, &keyboard->modifiers);
177} 177}
178 178
179static void seat_tablet_pads_notify_enter(struct sway_seat *seat, 179static void seat_tablet_pads_set_focus(struct sway_seat *seat,
180 struct wlr_surface *surface) { 180 struct wlr_surface *surface) {
181 struct sway_seat_device *seat_device; 181 struct sway_seat_device *seat_device;
182 wl_list_for_each(seat_device, &seat->devices, link) { 182 wl_list_for_each(seat_device, &seat->devices, link) {
183 sway_tablet_pad_notify_enter(seat_device->tablet_pad, surface); 183 sway_tablet_pad_set_focus(seat_device->tablet_pad, surface);
184 } 184 }
185} 185}
186 186
@@ -204,7 +204,7 @@ static void seat_send_focus(struct sway_node *node, struct sway_seat *seat) {
204#endif 204#endif
205 205
206 seat_keyboard_notify_enter(seat, view->surface); 206 seat_keyboard_notify_enter(seat, view->surface);
207 seat_tablet_pads_notify_enter(seat, view->surface); 207 seat_tablet_pads_set_focus(seat, view->surface);
208 sway_input_method_relay_set_focus(&seat->im_relay, view->surface); 208 sway_input_method_relay_set_focus(&seat->im_relay, view->surface);
209 209
210 struct wlr_pointer_constraint_v1 *constraint = 210 struct wlr_pointer_constraint_v1 *constraint =
@@ -1313,7 +1313,7 @@ void seat_set_focus_surface(struct sway_seat *seat,
1313 } 1313 }
1314 1314
1315 sway_input_method_relay_set_focus(&seat->im_relay, surface); 1315 sway_input_method_relay_set_focus(&seat->im_relay, surface);
1316 seat_tablet_pads_notify_enter(seat, surface); 1316 seat_tablet_pads_set_focus(seat, surface);
1317} 1317}
1318 1318
1319void seat_set_focus_layer(struct sway_seat *seat, 1319void seat_set_focus_layer(struct sway_seat *seat,
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
344void sway_tablet_pad_notify_enter(struct sway_tablet_pad *tablet_pad, 340void 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}