diff options
author | Tudor Brindus <me@tbrindus.ca> | 2020-04-19 22:49:19 -0400 |
---|---|---|
committer | Simon Ser <contact@emersion.fr> | 2020-04-22 17:30:08 +0200 |
commit | 44b2d3ad81cd11aa7f21a3954ce70a0c21adfa23 (patch) | |
tree | e6acae4b7308b641626cba77bdc8583a9e5caf27 | |
parent | input/cursor: fix jerky resizing of non-tablet_v2 surfaces (diff) | |
download | sway-44b2d3ad81cd11aa7f21a3954ce70a0c21adfa23.tar.gz sway-44b2d3ad81cd11aa7f21a3954ce70a0c21adfa23.tar.zst sway-44b2d3ad81cd11aa7f21a3954ce70a0c21adfa23.zip |
input/cursor: fix hide cursor timeouts on tablets and touchscreens
This commit refactors `cursor_handle_activity` to also take the idle
source, so that it can be reused for tablet and touch activity.
Previously, the timeouts would be tracked, but the cursor would never be
un-hidden for anything but pointers.
Fixes #5169.
-rw-r--r-- | include/sway/input/cursor.h | 3 | ||||
-rw-r--r-- | sway/input/cursor.c | 29 | ||||
-rw-r--r-- | sway/input/seat.c | 2 |
3 files changed, 19 insertions, 15 deletions
diff --git a/include/sway/input/cursor.h b/include/sway/input/cursor.h index 5b6f9a9f..35738894 100644 --- a/include/sway/input/cursor.h +++ b/include/sway/input/cursor.h | |||
@@ -85,7 +85,8 @@ struct sway_cursor *sway_cursor_create(struct sway_seat *seat); | |||
85 | void cursor_rebase(struct sway_cursor *cursor); | 85 | void cursor_rebase(struct sway_cursor *cursor); |
86 | void cursor_rebase_all(void); | 86 | void cursor_rebase_all(void); |
87 | 87 | ||
88 | void cursor_handle_activity(struct sway_cursor *cursor); | 88 | void cursor_handle_activity(struct sway_cursor *cursor, |
89 | enum sway_input_idle_source idle_source); | ||
89 | void cursor_unhide(struct sway_cursor *cursor); | 90 | void cursor_unhide(struct sway_cursor *cursor); |
90 | int cursor_get_timeout(struct sway_cursor *cursor); | 91 | int cursor_get_timeout(struct sway_cursor *cursor); |
91 | 92 | ||
diff --git a/sway/input/cursor.c b/sway/input/cursor.c index 186b4820..f2c91bab 100644 --- a/sway/input/cursor.c +++ b/sway/input/cursor.c | |||
@@ -241,11 +241,12 @@ int cursor_get_timeout(struct sway_cursor *cursor) { | |||
241 | return timeout; | 241 | return timeout; |
242 | } | 242 | } |
243 | 243 | ||
244 | void cursor_handle_activity(struct sway_cursor *cursor) { | 244 | void cursor_handle_activity(struct sway_cursor *cursor, |
245 | enum sway_input_idle_source idle_source) { | ||
245 | wl_event_source_timer_update( | 246 | wl_event_source_timer_update( |
246 | cursor->hide_source, cursor_get_timeout(cursor)); | 247 | cursor->hide_source, cursor_get_timeout(cursor)); |
247 | 248 | ||
248 | seat_idle_notify_activity(cursor->seat, IDLE_SOURCE_POINTER); | 249 | seat_idle_notify_activity(cursor->seat, idle_source); |
249 | if (cursor->hidden) { | 250 | if (cursor->hidden) { |
250 | cursor_unhide(cursor); | 251 | cursor_unhide(cursor); |
251 | } | 252 | } |
@@ -270,7 +271,7 @@ void cursor_unhide(struct sway_cursor *cursor) { | |||
270 | static void cursor_motion(struct sway_cursor *cursor, uint32_t time_msec, | 271 | static void cursor_motion(struct sway_cursor *cursor, uint32_t time_msec, |
271 | struct wlr_input_device *device, double dx, double dy, | 272 | struct wlr_input_device *device, double dx, double dy, |
272 | double dx_unaccel, double dy_unaccel) { | 273 | double dx_unaccel, double dy_unaccel) { |
273 | cursor_handle_activity(cursor); | 274 | cursor_handle_activity(cursor, IDLE_SOURCE_POINTER); |
274 | 275 | ||
275 | wlr_relative_pointer_manager_v1_send_relative_motion( | 276 | wlr_relative_pointer_manager_v1_send_relative_motion( |
276 | server.relative_pointer_manager, | 277 | server.relative_pointer_manager, |
@@ -353,7 +354,7 @@ static void handle_cursor_button(struct wl_listener *listener, void *data) { | |||
353 | } | 354 | } |
354 | } | 355 | } |
355 | 356 | ||
356 | cursor_handle_activity(cursor); | 357 | cursor_handle_activity(cursor, IDLE_SOURCE_POINTER); |
357 | dispatch_cursor_button(cursor, event->device, | 358 | dispatch_cursor_button(cursor, event->device, |
358 | event->time_msec, event->button, event->state); | 359 | event->time_msec, event->button, event->state); |
359 | transaction_commit_dirty(); | 360 | transaction_commit_dirty(); |
@@ -367,20 +368,20 @@ void dispatch_cursor_axis(struct sway_cursor *cursor, | |||
367 | static void handle_cursor_axis(struct wl_listener *listener, void *data) { | 368 | static void handle_cursor_axis(struct wl_listener *listener, void *data) { |
368 | struct sway_cursor *cursor = wl_container_of(listener, cursor, axis); | 369 | struct sway_cursor *cursor = wl_container_of(listener, cursor, axis); |
369 | struct wlr_event_pointer_axis *event = data; | 370 | struct wlr_event_pointer_axis *event = data; |
370 | cursor_handle_activity(cursor); | 371 | cursor_handle_activity(cursor, IDLE_SOURCE_POINTER); |
371 | dispatch_cursor_axis(cursor, event); | 372 | dispatch_cursor_axis(cursor, event); |
372 | transaction_commit_dirty(); | 373 | transaction_commit_dirty(); |
373 | } | 374 | } |
374 | 375 | ||
375 | static void handle_cursor_frame(struct wl_listener *listener, void *data) { | 376 | static void handle_cursor_frame(struct wl_listener *listener, void *data) { |
376 | struct sway_cursor *cursor = wl_container_of(listener, cursor, frame); | 377 | struct sway_cursor *cursor = wl_container_of(listener, cursor, frame); |
377 | cursor_handle_activity(cursor); | 378 | cursor_handle_activity(cursor, IDLE_SOURCE_POINTER); |
378 | wlr_seat_pointer_notify_frame(cursor->seat->wlr_seat); | 379 | wlr_seat_pointer_notify_frame(cursor->seat->wlr_seat); |
379 | } | 380 | } |
380 | 381 | ||
381 | static void handle_touch_down(struct wl_listener *listener, void *data) { | 382 | static void handle_touch_down(struct wl_listener *listener, void *data) { |
382 | struct sway_cursor *cursor = wl_container_of(listener, cursor, touch_down); | 383 | struct sway_cursor *cursor = wl_container_of(listener, cursor, touch_down); |
383 | seat_idle_notify_activity(cursor->seat, IDLE_SOURCE_TOUCH); | 384 | cursor_handle_activity(cursor, IDLE_SOURCE_TOUCH); |
384 | struct wlr_event_touch_down *event = data; | 385 | struct wlr_event_touch_down *event = data; |
385 | 386 | ||
386 | struct sway_seat *seat = cursor->seat; | 387 | struct sway_seat *seat = cursor->seat; |
@@ -415,7 +416,7 @@ static void handle_touch_down(struct wl_listener *listener, void *data) { | |||
415 | 416 | ||
416 | static void handle_touch_up(struct wl_listener *listener, void *data) { | 417 | static void handle_touch_up(struct wl_listener *listener, void *data) { |
417 | struct sway_cursor *cursor = wl_container_of(listener, cursor, touch_up); | 418 | struct sway_cursor *cursor = wl_container_of(listener, cursor, touch_up); |
418 | seat_idle_notify_activity(cursor->seat, IDLE_SOURCE_TOUCH); | 419 | cursor_handle_activity(cursor, IDLE_SOURCE_TOUCH); |
419 | struct wlr_event_touch_up *event = data; | 420 | struct wlr_event_touch_up *event = data; |
420 | struct wlr_seat *seat = cursor->seat->wlr_seat; | 421 | struct wlr_seat *seat = cursor->seat->wlr_seat; |
421 | // TODO: fall back to cursor simulation if client has not bound to touch | 422 | // TODO: fall back to cursor simulation if client has not bound to touch |
@@ -425,7 +426,7 @@ static void handle_touch_up(struct wl_listener *listener, void *data) { | |||
425 | static void handle_touch_motion(struct wl_listener *listener, void *data) { | 426 | static void handle_touch_motion(struct wl_listener *listener, void *data) { |
426 | struct sway_cursor *cursor = | 427 | struct sway_cursor *cursor = |
427 | wl_container_of(listener, cursor, touch_motion); | 428 | wl_container_of(listener, cursor, touch_motion); |
428 | seat_idle_notify_activity(cursor->seat, IDLE_SOURCE_TOUCH); | 429 | cursor_handle_activity(cursor, IDLE_SOURCE_TOUCH); |
429 | struct wlr_event_touch_motion *event = data; | 430 | struct wlr_event_touch_motion *event = data; |
430 | 431 | ||
431 | struct sway_seat *seat = cursor->seat; | 432 | struct sway_seat *seat = cursor->seat; |
@@ -494,6 +495,8 @@ static void handle_tablet_tool_position(struct sway_cursor *cursor, | |||
494 | bool change_x, bool change_y, | 495 | bool change_x, bool change_y, |
495 | double x, double y, double dx, double dy, | 496 | double x, double y, double dx, double dy, |
496 | int32_t time_msec) { | 497 | int32_t time_msec) { |
498 | cursor_handle_activity(cursor, IDLE_SOURCE_TABLET_TOOL); | ||
499 | |||
497 | if (!change_x && !change_y) { | 500 | if (!change_x && !change_y) { |
498 | return; | 501 | return; |
499 | } | 502 | } |
@@ -536,7 +539,7 @@ static void handle_tablet_tool_position(struct sway_cursor *cursor, | |||
536 | 539 | ||
537 | static void handle_tool_axis(struct wl_listener *listener, void *data) { | 540 | static void handle_tool_axis(struct wl_listener *listener, void *data) { |
538 | struct sway_cursor *cursor = wl_container_of(listener, cursor, tool_axis); | 541 | struct sway_cursor *cursor = wl_container_of(listener, cursor, tool_axis); |
539 | seat_idle_notify_activity(cursor->seat, IDLE_SOURCE_TABLET_TOOL); | 542 | cursor_handle_activity(cursor, IDLE_SOURCE_TABLET_TOOL); |
540 | struct wlr_event_tablet_tool_axis *event = data; | 543 | struct wlr_event_tablet_tool_axis *event = data; |
541 | struct sway_tablet_tool *sway_tool = event->tool->data; | 544 | struct sway_tablet_tool *sway_tool = event->tool->data; |
542 | 545 | ||
@@ -592,7 +595,7 @@ static void handle_tool_axis(struct wl_listener *listener, void *data) { | |||
592 | 595 | ||
593 | static void handle_tool_tip(struct wl_listener *listener, void *data) { | 596 | static void handle_tool_tip(struct wl_listener *listener, void *data) { |
594 | struct sway_cursor *cursor = wl_container_of(listener, cursor, tool_tip); | 597 | struct sway_cursor *cursor = wl_container_of(listener, cursor, tool_tip); |
595 | seat_idle_notify_activity(cursor->seat, IDLE_SOURCE_TABLET_TOOL); | 598 | cursor_handle_activity(cursor, IDLE_SOURCE_TABLET_TOOL); |
596 | struct wlr_event_tablet_tool_tip *event = data; | 599 | struct wlr_event_tablet_tool_tip *event = data; |
597 | struct sway_tablet_tool *sway_tool = event->tool->data; | 600 | struct sway_tablet_tool *sway_tool = event->tool->data; |
598 | struct wlr_tablet_v2_tablet *tablet_v2 = sway_tool->tablet->tablet_v2; | 601 | struct wlr_tablet_v2_tablet *tablet_v2 = sway_tool->tablet->tablet_v2; |
@@ -640,7 +643,7 @@ static struct sway_tablet *get_tablet_for_device(struct sway_cursor *cursor, | |||
640 | 643 | ||
641 | static void handle_tool_proximity(struct wl_listener *listener, void *data) { | 644 | static void handle_tool_proximity(struct wl_listener *listener, void *data) { |
642 | struct sway_cursor *cursor = wl_container_of(listener, cursor, tool_proximity); | 645 | struct sway_cursor *cursor = wl_container_of(listener, cursor, tool_proximity); |
643 | seat_idle_notify_activity(cursor->seat, IDLE_SOURCE_TABLET_TOOL); | 646 | cursor_handle_activity(cursor, IDLE_SOURCE_TABLET_TOOL); |
644 | struct wlr_event_tablet_tool_proximity *event = data; | 647 | struct wlr_event_tablet_tool_proximity *event = data; |
645 | 648 | ||
646 | struct wlr_tablet_tool *tool = event->tool; | 649 | struct wlr_tablet_tool *tool = event->tool; |
@@ -671,7 +674,7 @@ static void handle_tool_proximity(struct wl_listener *listener, void *data) { | |||
671 | static void handle_tool_button(struct wl_listener *listener, void *data) { | 674 | static void handle_tool_button(struct wl_listener *listener, void *data) { |
672 | struct sway_cursor *cursor = wl_container_of(listener, cursor, tool_button); | 675 | struct sway_cursor *cursor = wl_container_of(listener, cursor, tool_button); |
673 | struct sway_seat *seat = cursor->seat; | 676 | struct sway_seat *seat = cursor->seat; |
674 | seat_idle_notify_activity(cursor->seat, IDLE_SOURCE_TABLET_TOOL); | 677 | cursor_handle_activity(cursor, IDLE_SOURCE_TABLET_TOOL); |
675 | 678 | ||
676 | struct wlr_event_tablet_tool_button *event = data; | 679 | struct wlr_event_tablet_tool_button *event = data; |
677 | struct sway_tablet_tool *sway_tool = event->tool->data; | 680 | struct sway_tablet_tool *sway_tool = event->tool->data; |
diff --git a/sway/input/seat.c b/sway/input/seat.c index c3eae65c..b0e39612 100644 --- a/sway/input/seat.c +++ b/sway/input/seat.c | |||
@@ -1368,7 +1368,7 @@ void seat_apply_config(struct sway_seat *seat, | |||
1368 | seat_configure_device(seat, seat_device->input_device); | 1368 | seat_configure_device(seat, seat_device->input_device); |
1369 | } | 1369 | } |
1370 | 1370 | ||
1371 | cursor_handle_activity(seat->cursor); | 1371 | cursor_handle_activity(seat->cursor, IDLE_SOURCE_POINTER); |
1372 | } | 1372 | } |
1373 | 1373 | ||
1374 | struct seat_config *seat_get_config(struct sway_seat *seat) { | 1374 | struct seat_config *seat_get_config(struct sway_seat *seat) { |