diff options
author | Tudor Brindus <me@tbrindus.ca> | 2020-12-05 23:58:57 -0500 |
---|---|---|
committer | Simon Ser <contact@emersion.fr> | 2020-12-06 09:38:49 +0100 |
commit | cc2c0d5966f67189be4cfc350514134d3f4c0f3c (patch) | |
tree | d267d5af6174ac6708503ab006747a41cd137532 | |
parent | criteria: fix crash when comparing NULL properties (diff) | |
download | sway-cc2c0d5966f67189be4cfc350514134d3f4c0f3c.tar.gz sway-cc2c0d5966f67189be4cfc350514134d3f4c0f3c.tar.zst sway-cc2c0d5966f67189be4cfc350514134d3f4c0f3c.zip |
input/cursor: unhide cursor on synthetic input
Fixes #5847.
-rw-r--r-- | include/sway/input/cursor.h | 4 | ||||
-rw-r--r-- | sway/commands/seat/cursor.c | 1 | ||||
-rw-r--r-- | sway/input/cursor.c | 33 | ||||
-rw-r--r-- | sway/input/seat.c | 2 |
4 files changed, 24 insertions, 16 deletions
diff --git a/include/sway/input/cursor.h b/include/sway/input/cursor.h index 55e2ce8e..6a38190b 100644 --- a/include/sway/input/cursor.h +++ b/include/sway/input/cursor.h | |||
@@ -95,7 +95,9 @@ void cursor_rebase(struct sway_cursor *cursor); | |||
95 | void cursor_rebase_all(void); | 95 | void cursor_rebase_all(void); |
96 | void cursor_update_image(struct sway_cursor *cursor, struct sway_node *node); | 96 | void cursor_update_image(struct sway_cursor *cursor, struct sway_node *node); |
97 | 97 | ||
98 | void cursor_handle_activity(struct sway_cursor *cursor, | 98 | void cursor_handle_activity_from_idle_source(struct sway_cursor *cursor, |
99 | enum sway_input_idle_source idle_source); | ||
100 | void cursor_handle_activity_from_device(struct sway_cursor *cursor, | ||
99 | struct wlr_input_device *device); | 101 | struct wlr_input_device *device); |
100 | void cursor_unhide(struct sway_cursor *cursor); | 102 | void cursor_unhide(struct sway_cursor *cursor); |
101 | int cursor_get_timeout(struct sway_cursor *cursor); | 103 | int cursor_get_timeout(struct sway_cursor *cursor); |
diff --git a/sway/commands/seat/cursor.c b/sway/commands/seat/cursor.c index ad7dc905..749235eb 100644 --- a/sway/commands/seat/cursor.c +++ b/sway/commands/seat/cursor.c | |||
@@ -45,6 +45,7 @@ static struct cmd_results *handle_command(struct sway_cursor *cursor, | |||
45 | } | 45 | } |
46 | } | 46 | } |
47 | 47 | ||
48 | cursor_handle_activity_from_idle_source(cursor, IDLE_SOURCE_POINTER); | ||
48 | return cmd_results_new(CMD_SUCCESS, NULL); | 49 | return cmd_results_new(CMD_SUCCESS, NULL); |
49 | } | 50 | } |
50 | 51 | ||
diff --git a/sway/input/cursor.c b/sway/input/cursor.c index 184f9a00..fa604426 100644 --- a/sway/input/cursor.c +++ b/sway/input/cursor.c | |||
@@ -303,18 +303,23 @@ static enum sway_input_idle_source idle_source_from_device( | |||
303 | abort(); | 303 | abort(); |
304 | } | 304 | } |
305 | 305 | ||
306 | void cursor_handle_activity(struct sway_cursor *cursor, | 306 | void cursor_handle_activity_from_idle_source(struct sway_cursor *cursor, |
307 | struct wlr_input_device *device) { | 307 | enum sway_input_idle_source idle_source) { |
308 | wl_event_source_timer_update( | 308 | wl_event_source_timer_update( |
309 | cursor->hide_source, cursor_get_timeout(cursor)); | 309 | cursor->hide_source, cursor_get_timeout(cursor)); |
310 | 310 | ||
311 | enum sway_input_idle_source idle_source = idle_source_from_device(device); | ||
312 | seat_idle_notify_activity(cursor->seat, idle_source); | 311 | seat_idle_notify_activity(cursor->seat, idle_source); |
313 | if (idle_source != IDLE_SOURCE_TOUCH) { | 312 | if (idle_source != IDLE_SOURCE_TOUCH) { |
314 | cursor_unhide(cursor); | 313 | cursor_unhide(cursor); |
315 | } | 314 | } |
316 | } | 315 | } |
317 | 316 | ||
317 | void cursor_handle_activity_from_device(struct sway_cursor *cursor, | ||
318 | struct wlr_input_device *device) { | ||
319 | enum sway_input_idle_source idle_source = idle_source_from_device(device); | ||
320 | cursor_handle_activity_from_idle_source(cursor, idle_source); | ||
321 | } | ||
322 | |||
318 | void cursor_unhide(struct sway_cursor *cursor) { | 323 | void cursor_unhide(struct sway_cursor *cursor) { |
319 | if (!cursor->hidden) { | 324 | if (!cursor->hidden) { |
320 | return; | 325 | return; |
@@ -374,7 +379,7 @@ static void handle_pointer_motion_relative( | |||
374 | struct wl_listener *listener, void *data) { | 379 | struct wl_listener *listener, void *data) { |
375 | struct sway_cursor *cursor = wl_container_of(listener, cursor, motion); | 380 | struct sway_cursor *cursor = wl_container_of(listener, cursor, motion); |
376 | struct wlr_event_pointer_motion *e = data; | 381 | struct wlr_event_pointer_motion *e = data; |
377 | cursor_handle_activity(cursor, e->device); | 382 | cursor_handle_activity_from_device(cursor, e->device); |
378 | 383 | ||
379 | pointer_motion(cursor, e->time_msec, e->device, e->delta_x, e->delta_y, | 384 | pointer_motion(cursor, e->time_msec, e->device, e->delta_x, e->delta_y, |
380 | e->unaccel_dx, e->unaccel_dy); | 385 | e->unaccel_dx, e->unaccel_dy); |
@@ -386,7 +391,7 @@ static void handle_pointer_motion_absolute( | |||
386 | struct sway_cursor *cursor = | 391 | struct sway_cursor *cursor = |
387 | wl_container_of(listener, cursor, motion_absolute); | 392 | wl_container_of(listener, cursor, motion_absolute); |
388 | struct wlr_event_pointer_motion_absolute *event = data; | 393 | struct wlr_event_pointer_motion_absolute *event = data; |
389 | cursor_handle_activity(cursor, event->device); | 394 | cursor_handle_activity_from_device(cursor, event->device); |
390 | 395 | ||
391 | double lx, ly; | 396 | double lx, ly; |
392 | wlr_cursor_absolute_to_layout_coords(cursor->cursor, event->device, | 397 | wlr_cursor_absolute_to_layout_coords(cursor->cursor, event->device, |
@@ -423,7 +428,7 @@ static void handle_pointer_button(struct wl_listener *listener, void *data) { | |||
423 | } | 428 | } |
424 | } | 429 | } |
425 | 430 | ||
426 | cursor_handle_activity(cursor, event->device); | 431 | cursor_handle_activity_from_device(cursor, event->device); |
427 | dispatch_cursor_button(cursor, event->device, | 432 | dispatch_cursor_button(cursor, event->device, |
428 | event->time_msec, event->button, event->state); | 433 | event->time_msec, event->button, event->state); |
429 | transaction_commit_dirty(); | 434 | transaction_commit_dirty(); |
@@ -437,7 +442,7 @@ void dispatch_cursor_axis(struct sway_cursor *cursor, | |||
437 | static void handle_pointer_axis(struct wl_listener *listener, void *data) { | 442 | static void handle_pointer_axis(struct wl_listener *listener, void *data) { |
438 | struct sway_cursor *cursor = wl_container_of(listener, cursor, axis); | 443 | struct sway_cursor *cursor = wl_container_of(listener, cursor, axis); |
439 | struct wlr_event_pointer_axis *event = data; | 444 | struct wlr_event_pointer_axis *event = data; |
440 | cursor_handle_activity(cursor, event->device); | 445 | cursor_handle_activity_from_device(cursor, event->device); |
441 | dispatch_cursor_axis(cursor, event); | 446 | dispatch_cursor_axis(cursor, event); |
442 | transaction_commit_dirty(); | 447 | transaction_commit_dirty(); |
443 | } | 448 | } |
@@ -450,7 +455,7 @@ static void handle_pointer_frame(struct wl_listener *listener, void *data) { | |||
450 | static void handle_touch_down(struct wl_listener *listener, void *data) { | 455 | static void handle_touch_down(struct wl_listener *listener, void *data) { |
451 | struct sway_cursor *cursor = wl_container_of(listener, cursor, touch_down); | 456 | struct sway_cursor *cursor = wl_container_of(listener, cursor, touch_down); |
452 | struct wlr_event_touch_down *event = data; | 457 | struct wlr_event_touch_down *event = data; |
453 | cursor_handle_activity(cursor, event->device); | 458 | cursor_handle_activity_from_device(cursor, event->device); |
454 | cursor_hide(cursor); | 459 | cursor_hide(cursor); |
455 | 460 | ||
456 | struct sway_seat *seat = cursor->seat; | 461 | struct sway_seat *seat = cursor->seat; |
@@ -497,7 +502,7 @@ static void handle_touch_down(struct wl_listener *listener, void *data) { | |||
497 | static void handle_touch_up(struct wl_listener *listener, void *data) { | 502 | static void handle_touch_up(struct wl_listener *listener, void *data) { |
498 | struct sway_cursor *cursor = wl_container_of(listener, cursor, touch_up); | 503 | struct sway_cursor *cursor = wl_container_of(listener, cursor, touch_up); |
499 | struct wlr_event_touch_up *event = data; | 504 | struct wlr_event_touch_up *event = data; |
500 | cursor_handle_activity(cursor, event->device); | 505 | cursor_handle_activity_from_device(cursor, event->device); |
501 | 506 | ||
502 | struct wlr_seat *wlr_seat = cursor->seat->wlr_seat; | 507 | struct wlr_seat *wlr_seat = cursor->seat->wlr_seat; |
503 | 508 | ||
@@ -518,7 +523,7 @@ static void handle_touch_motion(struct wl_listener *listener, void *data) { | |||
518 | struct sway_cursor *cursor = | 523 | struct sway_cursor *cursor = |
519 | wl_container_of(listener, cursor, touch_motion); | 524 | wl_container_of(listener, cursor, touch_motion); |
520 | struct wlr_event_touch_motion *event = data; | 525 | struct wlr_event_touch_motion *event = data; |
521 | cursor_handle_activity(cursor, event->device); | 526 | cursor_handle_activity_from_device(cursor, event->device); |
522 | 527 | ||
523 | struct sway_seat *seat = cursor->seat; | 528 | struct sway_seat *seat = cursor->seat; |
524 | struct wlr_seat *wlr_seat = seat->wlr_seat; | 529 | struct wlr_seat *wlr_seat = seat->wlr_seat; |
@@ -641,7 +646,7 @@ static void handle_tablet_tool_position(struct sway_cursor *cursor, | |||
641 | static void handle_tool_axis(struct wl_listener *listener, void *data) { | 646 | static void handle_tool_axis(struct wl_listener *listener, void *data) { |
642 | struct sway_cursor *cursor = wl_container_of(listener, cursor, tool_axis); | 647 | struct sway_cursor *cursor = wl_container_of(listener, cursor, tool_axis); |
643 | struct wlr_event_tablet_tool_axis *event = data; | 648 | struct wlr_event_tablet_tool_axis *event = data; |
644 | cursor_handle_activity(cursor, event->device); | 649 | cursor_handle_activity_from_device(cursor, event->device); |
645 | 650 | ||
646 | struct sway_tablet_tool *sway_tool = event->tool->data; | 651 | struct sway_tablet_tool *sway_tool = event->tool->data; |
647 | if (!sway_tool) { | 652 | if (!sway_tool) { |
@@ -697,7 +702,7 @@ static void handle_tool_axis(struct wl_listener *listener, void *data) { | |||
697 | static void handle_tool_tip(struct wl_listener *listener, void *data) { | 702 | static void handle_tool_tip(struct wl_listener *listener, void *data) { |
698 | struct sway_cursor *cursor = wl_container_of(listener, cursor, tool_tip); | 703 | struct sway_cursor *cursor = wl_container_of(listener, cursor, tool_tip); |
699 | struct wlr_event_tablet_tool_tip *event = data; | 704 | struct wlr_event_tablet_tool_tip *event = data; |
700 | cursor_handle_activity(cursor, event->device); | 705 | cursor_handle_activity_from_device(cursor, event->device); |
701 | 706 | ||
702 | struct sway_tablet_tool *sway_tool = event->tool->data; | 707 | struct sway_tablet_tool *sway_tool = event->tool->data; |
703 | struct wlr_tablet_v2_tablet *tablet_v2 = sway_tool->tablet->tablet_v2; | 708 | struct wlr_tablet_v2_tablet *tablet_v2 = sway_tool->tablet->tablet_v2; |
@@ -750,7 +755,7 @@ static void handle_tool_proximity(struct wl_listener *listener, void *data) { | |||
750 | struct sway_cursor *cursor = | 755 | struct sway_cursor *cursor = |
751 | wl_container_of(listener, cursor, tool_proximity); | 756 | wl_container_of(listener, cursor, tool_proximity); |
752 | struct wlr_event_tablet_tool_proximity *event = data; | 757 | struct wlr_event_tablet_tool_proximity *event = data; |
753 | cursor_handle_activity(cursor, event->device); | 758 | cursor_handle_activity_from_device(cursor, event->device); |
754 | 759 | ||
755 | struct wlr_tablet_tool *tool = event->tool; | 760 | struct wlr_tablet_tool *tool = event->tool; |
756 | if (!tool->data) { | 761 | if (!tool->data) { |
@@ -780,7 +785,7 @@ static void handle_tool_proximity(struct wl_listener *listener, void *data) { | |||
780 | static void handle_tool_button(struct wl_listener *listener, void *data) { | 785 | static void handle_tool_button(struct wl_listener *listener, void *data) { |
781 | struct sway_cursor *cursor = wl_container_of(listener, cursor, tool_button); | 786 | struct sway_cursor *cursor = wl_container_of(listener, cursor, tool_button); |
782 | struct wlr_event_tablet_tool_button *event = data; | 787 | struct wlr_event_tablet_tool_button *event = data; |
783 | cursor_handle_activity(cursor, event->device); | 788 | cursor_handle_activity_from_device(cursor, event->device); |
784 | 789 | ||
785 | struct sway_tablet_tool *sway_tool = event->tool->data; | 790 | struct sway_tablet_tool *sway_tool = event->tool->data; |
786 | if (!sway_tool) { | 791 | if (!sway_tool) { |
diff --git a/sway/input/seat.c b/sway/input/seat.c index 2b41d1cb..f899483d 100644 --- a/sway/input/seat.c +++ b/sway/input/seat.c | |||
@@ -1424,7 +1424,7 @@ void seat_apply_config(struct sway_seat *seat, | |||
1424 | 1424 | ||
1425 | wl_list_for_each(seat_device, &seat->devices, link) { | 1425 | wl_list_for_each(seat_device, &seat->devices, link) { |
1426 | seat_configure_device(seat, seat_device->input_device); | 1426 | seat_configure_device(seat, seat_device->input_device); |
1427 | cursor_handle_activity(seat->cursor, | 1427 | cursor_handle_activity_from_device(seat->cursor, |
1428 | seat_device->input_device->wlr_device); | 1428 | seat_device->input_device->wlr_device); |
1429 | } | 1429 | } |
1430 | } | 1430 | } |