diff options
Diffstat (limited to 'sway/input/tablet.c')
-rw-r--r-- | sway/input/tablet.c | 49 |
1 files changed, 26 insertions, 23 deletions
diff --git a/sway/input/tablet.c b/sway/input/tablet.c index 26e86e36..902cb7ed 100644 --- a/sway/input/tablet.c +++ b/sway/input/tablet.c | |||
@@ -1,6 +1,6 @@ | |||
1 | #define _POSIX_C_SOURCE 200809L | 1 | #define _POSIX_C_SOURCE 200809L |
2 | #include <stdlib.h> | 2 | #include <stdlib.h> |
3 | #include <wlr/backend/libinput.h> | 3 | #include <wlr/config.h> |
4 | #include <wlr/types/wlr_tablet_v2.h> | 4 | #include <wlr/types/wlr_tablet_v2.h> |
5 | #include <wlr/types/wlr_tablet_tool.h> | 5 | #include <wlr/types/wlr_tablet_tool.h> |
6 | #include <wlr/types/wlr_tablet_pad.h> | 6 | #include <wlr/types/wlr_tablet_pad.h> |
@@ -9,6 +9,10 @@ | |||
9 | #include "sway/input/seat.h" | 9 | #include "sway/input/seat.h" |
10 | #include "sway/input/tablet.h" | 10 | #include "sway/input/tablet.h" |
11 | 11 | ||
12 | #if WLR_HAS_LIBINPUT_BACKEND | ||
13 | #include <wlr/backend/libinput.h> | ||
14 | #endif | ||
15 | |||
12 | static void handle_pad_tablet_destroy(struct wl_listener *listener, void *data) { | 16 | static void handle_pad_tablet_destroy(struct wl_listener *listener, void *data) { |
13 | struct sway_tablet_pad *pad = | 17 | struct sway_tablet_pad *pad = |
14 | wl_container_of(listener, pad, tablet_destroy); | 18 | wl_container_of(listener, pad, tablet_destroy); |
@@ -54,15 +58,14 @@ void sway_configure_tablet(struct sway_tablet *tablet) { | |||
54 | tablet->seat_device->input_device->wlr_device; | 58 | tablet->seat_device->input_device->wlr_device; |
55 | struct sway_seat *seat = tablet->seat_device->sway_seat; | 59 | struct sway_seat *seat = tablet->seat_device->sway_seat; |
56 | 60 | ||
57 | if ((seat->wlr_seat->capabilities & WL_SEAT_CAPABILITY_POINTER) == 0) { | 61 | seat_configure_xcursor(seat); |
58 | seat_configure_xcursor(seat); | ||
59 | } | ||
60 | 62 | ||
61 | if (!tablet->tablet_v2) { | 63 | if (!tablet->tablet_v2) { |
62 | tablet->tablet_v2 = | 64 | tablet->tablet_v2 = |
63 | wlr_tablet_create(server.tablet_v2, seat->wlr_seat, device); | 65 | wlr_tablet_create(server.tablet_v2, seat->wlr_seat, device); |
64 | } | 66 | } |
65 | 67 | ||
68 | #if WLR_HAS_LIBINPUT_BACKEND | ||
66 | /* Search for a sibling tablet pad */ | 69 | /* Search for a sibling tablet pad */ |
67 | if (!wlr_input_device_is_libinput(device)) { | 70 | if (!wlr_input_device_is_libinput(device)) { |
68 | /* We can only do this on libinput devices */ | 71 | /* We can only do this on libinput devices */ |
@@ -87,6 +90,7 @@ void sway_configure_tablet(struct sway_tablet *tablet) { | |||
87 | break; | 90 | break; |
88 | } | 91 | } |
89 | } | 92 | } |
93 | #endif | ||
90 | } | 94 | } |
91 | 95 | ||
92 | void sway_tablet_destroy(struct sway_tablet *tablet) { | 96 | void sway_tablet_destroy(struct sway_tablet *tablet) { |
@@ -196,7 +200,7 @@ static void handle_tablet_pad_attach(struct wl_listener *listener, | |||
196 | 200 | ||
197 | static void handle_tablet_pad_ring(struct wl_listener *listener, void *data) { | 201 | static void handle_tablet_pad_ring(struct wl_listener *listener, void *data) { |
198 | struct sway_tablet_pad *pad = wl_container_of(listener, pad, ring); | 202 | struct sway_tablet_pad *pad = wl_container_of(listener, pad, ring); |
199 | struct wlr_event_tablet_pad_ring *event = data; | 203 | struct wlr_tablet_pad_ring_event *event = data; |
200 | 204 | ||
201 | if (!pad->current_surface) { | 205 | if (!pad->current_surface) { |
202 | return; | 206 | return; |
@@ -210,7 +214,7 @@ static void handle_tablet_pad_ring(struct wl_listener *listener, void *data) { | |||
210 | 214 | ||
211 | static void handle_tablet_pad_strip(struct wl_listener *listener, void *data) { | 215 | static void handle_tablet_pad_strip(struct wl_listener *listener, void *data) { |
212 | struct sway_tablet_pad *pad = wl_container_of(listener, pad, strip); | 216 | struct sway_tablet_pad *pad = wl_container_of(listener, pad, strip); |
213 | struct wlr_event_tablet_pad_strip *event = data; | 217 | struct wlr_tablet_pad_strip_event *event = data; |
214 | 218 | ||
215 | if (!pad->current_surface) { | 219 | if (!pad->current_surface) { |
216 | return; | 220 | return; |
@@ -224,7 +228,7 @@ static void handle_tablet_pad_strip(struct wl_listener *listener, void *data) { | |||
224 | 228 | ||
225 | static void handle_tablet_pad_button(struct wl_listener *listener, void *data) { | 229 | static void handle_tablet_pad_button(struct wl_listener *listener, void *data) { |
226 | struct sway_tablet_pad *pad = wl_container_of(listener, pad, button); | 230 | struct sway_tablet_pad *pad = wl_container_of(listener, pad, button); |
227 | struct wlr_event_tablet_pad_button *event = data; | 231 | struct wlr_tablet_pad_button_event *event = data; |
228 | 232 | ||
229 | if (!pad->current_surface) { | 233 | if (!pad->current_surface) { |
230 | return; | 234 | return; |
@@ -246,6 +250,7 @@ struct sway_tablet_pad *sway_tablet_pad_create(struct sway_seat *seat, | |||
246 | return NULL; | 250 | return NULL; |
247 | } | 251 | } |
248 | 252 | ||
253 | tablet_pad->wlr = wlr_tablet_pad_from_input_device(device->input_device->wlr_device); | ||
249 | tablet_pad->seat_device = device; | 254 | tablet_pad->seat_device = device; |
250 | wl_list_init(&tablet_pad->attach.link); | 255 | wl_list_init(&tablet_pad->attach.link); |
251 | wl_list_init(&tablet_pad->button.link); | 256 | wl_list_init(&tablet_pad->button.link); |
@@ -260,40 +265,41 @@ struct sway_tablet_pad *sway_tablet_pad_create(struct sway_seat *seat, | |||
260 | } | 265 | } |
261 | 266 | ||
262 | void sway_configure_tablet_pad(struct sway_tablet_pad *tablet_pad) { | 267 | void sway_configure_tablet_pad(struct sway_tablet_pad *tablet_pad) { |
263 | struct wlr_input_device *device = | 268 | struct wlr_input_device *wlr_device = |
264 | tablet_pad->seat_device->input_device->wlr_device; | 269 | tablet_pad->seat_device->input_device->wlr_device; |
265 | struct sway_seat *seat = tablet_pad->seat_device->sway_seat; | 270 | struct sway_seat *seat = tablet_pad->seat_device->sway_seat; |
266 | 271 | ||
267 | if (!tablet_pad->tablet_v2_pad) { | 272 | if (!tablet_pad->tablet_v2_pad) { |
268 | tablet_pad->tablet_v2_pad = | 273 | tablet_pad->tablet_v2_pad = |
269 | wlr_tablet_pad_create(server.tablet_v2, seat->wlr_seat, device); | 274 | wlr_tablet_pad_create(server.tablet_v2, seat->wlr_seat, wlr_device); |
270 | } | 275 | } |
271 | 276 | ||
272 | wl_list_remove(&tablet_pad->attach.link); | 277 | wl_list_remove(&tablet_pad->attach.link); |
273 | tablet_pad->attach.notify = handle_tablet_pad_attach; | 278 | tablet_pad->attach.notify = handle_tablet_pad_attach; |
274 | wl_signal_add(&device->tablet_pad->events.attach_tablet, | 279 | wl_signal_add(&tablet_pad->wlr->events.attach_tablet, |
275 | &tablet_pad->attach); | 280 | &tablet_pad->attach); |
276 | 281 | ||
277 | wl_list_remove(&tablet_pad->button.link); | 282 | wl_list_remove(&tablet_pad->button.link); |
278 | tablet_pad->button.notify = handle_tablet_pad_button; | 283 | tablet_pad->button.notify = handle_tablet_pad_button; |
279 | wl_signal_add(&device->tablet_pad->events.button, &tablet_pad->button); | 284 | wl_signal_add(&tablet_pad->wlr->events.button, &tablet_pad->button); |
280 | 285 | ||
281 | wl_list_remove(&tablet_pad->strip.link); | 286 | wl_list_remove(&tablet_pad->strip.link); |
282 | tablet_pad->strip.notify = handle_tablet_pad_strip; | 287 | tablet_pad->strip.notify = handle_tablet_pad_strip; |
283 | wl_signal_add(&device->tablet_pad->events.strip, &tablet_pad->strip); | 288 | wl_signal_add(&tablet_pad->wlr->events.strip, &tablet_pad->strip); |
284 | 289 | ||
285 | wl_list_remove(&tablet_pad->ring.link); | 290 | wl_list_remove(&tablet_pad->ring.link); |
286 | tablet_pad->ring.notify = handle_tablet_pad_ring; | 291 | tablet_pad->ring.notify = handle_tablet_pad_ring; |
287 | wl_signal_add(&device->tablet_pad->events.ring, &tablet_pad->ring); | 292 | wl_signal_add(&tablet_pad->wlr->events.ring, &tablet_pad->ring); |
288 | 293 | ||
294 | #if WLR_HAS_LIBINPUT_BACKEND | ||
289 | /* Search for a sibling tablet */ | 295 | /* Search for a sibling tablet */ |
290 | if (!wlr_input_device_is_libinput(device)) { | 296 | if (!wlr_input_device_is_libinput(wlr_device)) { |
291 | /* We can only do this on libinput devices */ | 297 | /* We can only do this on libinput devices */ |
292 | return; | 298 | return; |
293 | } | 299 | } |
294 | 300 | ||
295 | struct libinput_device_group *group = | 301 | struct libinput_device_group *group = |
296 | libinput_device_get_device_group(wlr_libinput_get_device_handle(device)); | 302 | libinput_device_get_device_group(wlr_libinput_get_device_handle(wlr_device)); |
297 | struct sway_tablet *tool; | 303 | struct sway_tablet *tool; |
298 | wl_list_for_each(tool, &seat->cursor->tablets, link) { | 304 | wl_list_for_each(tool, &seat->cursor->tablets, link) { |
299 | struct wlr_input_device *tablet = | 305 | struct wlr_input_device *tablet = |
@@ -310,6 +316,7 @@ void sway_configure_tablet_pad(struct sway_tablet_pad *tablet_pad) { | |||
310 | break; | 316 | break; |
311 | } | 317 | } |
312 | } | 318 | } |
319 | #endif | ||
313 | } | 320 | } |
314 | 321 | ||
315 | void sway_tablet_pad_destroy(struct sway_tablet_pad *tablet_pad) { | 322 | void sway_tablet_pad_destroy(struct sway_tablet_pad *tablet_pad) { |
@@ -333,14 +340,10 @@ static void handle_pad_tablet_surface_destroy(struct wl_listener *listener, | |||
333 | struct sway_tablet_pad *tablet_pad = | 340 | struct sway_tablet_pad *tablet_pad = |
334 | wl_container_of(listener, tablet_pad, surface_destroy); | 341 | wl_container_of(listener, tablet_pad, surface_destroy); |
335 | 342 | ||
336 | wlr_tablet_v2_tablet_pad_notify_leave(tablet_pad->tablet_v2_pad, | 343 | sway_tablet_pad_set_focus(tablet_pad, NULL); |
337 | tablet_pad->current_surface); | ||
338 | wl_list_remove(&tablet_pad->surface_destroy.link); | ||
339 | wl_list_init(&tablet_pad->surface_destroy.link); | ||
340 | tablet_pad->current_surface = NULL; | ||
341 | } | 344 | } |
342 | 345 | ||
343 | void sway_tablet_pad_notify_enter(struct sway_tablet_pad *tablet_pad, | 346 | void sway_tablet_pad_set_focus(struct sway_tablet_pad *tablet_pad, |
344 | struct wlr_surface *surface) { | 347 | struct wlr_surface *surface) { |
345 | if (!tablet_pad || !tablet_pad->tablet) { | 348 | if (!tablet_pad || !tablet_pad->tablet) { |
346 | return; | 349 | return; |
@@ -359,7 +362,8 @@ void sway_tablet_pad_notify_enter(struct sway_tablet_pad *tablet_pad, | |||
359 | tablet_pad->current_surface = NULL; | 362 | tablet_pad->current_surface = NULL; |
360 | } | 363 | } |
361 | 364 | ||
362 | if (!wlr_surface_accepts_tablet_v2(tablet_pad->tablet->tablet_v2, surface)) { | 365 | if (surface == NULL || |
366 | !wlr_surface_accepts_tablet_v2(tablet_pad->tablet->tablet_v2, surface)) { | ||
363 | return; | 367 | return; |
364 | } | 368 | } |
365 | 369 | ||
@@ -367,7 +371,6 @@ void sway_tablet_pad_notify_enter(struct sway_tablet_pad *tablet_pad, | |||
367 | tablet_pad->tablet->tablet_v2, surface); | 371 | tablet_pad->tablet->tablet_v2, surface); |
368 | 372 | ||
369 | tablet_pad->current_surface = surface; | 373 | tablet_pad->current_surface = surface; |
370 | wl_list_remove(&tablet_pad->surface_destroy.link); | ||
371 | tablet_pad->surface_destroy.notify = handle_pad_tablet_surface_destroy; | 374 | tablet_pad->surface_destroy.notify = handle_pad_tablet_surface_destroy; |
372 | wl_signal_add(&surface->events.destroy, &tablet_pad->surface_destroy); | 375 | wl_signal_add(&surface->events.destroy, &tablet_pad->surface_destroy); |
373 | } | 376 | } |