aboutsummaryrefslogtreecommitdiffstats
path: root/sway/input/cursor.c
diff options
context:
space:
mode:
authorLibravatar Tudor Brindus <me@tbrindus.ca>2020-12-05 23:58:57 -0500
committerLibravatar Simon Ser <contact@emersion.fr>2020-12-06 09:38:49 +0100
commitcc2c0d5966f67189be4cfc350514134d3f4c0f3c (patch)
treed267d5af6174ac6708503ab006747a41cd137532 /sway/input/cursor.c
parentcriteria: fix crash when comparing NULL properties (diff)
downloadsway-cc2c0d5966f67189be4cfc350514134d3f4c0f3c.tar.gz
sway-cc2c0d5966f67189be4cfc350514134d3f4c0f3c.tar.zst
sway-cc2c0d5966f67189be4cfc350514134d3f4c0f3c.zip
input/cursor: unhide cursor on synthetic input
Fixes #5847.
Diffstat (limited to 'sway/input/cursor.c')
-rw-r--r--sway/input/cursor.c33
1 files changed, 19 insertions, 14 deletions
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
306void cursor_handle_activity(struct sway_cursor *cursor, 306void 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
317void 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
318void cursor_unhide(struct sway_cursor *cursor) { 323void 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,
437static void handle_pointer_axis(struct wl_listener *listener, void *data) { 442static 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) {
450static void handle_touch_down(struct wl_listener *listener, void *data) { 455static 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) {
497static void handle_touch_up(struct wl_listener *listener, void *data) { 502static 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,
641static void handle_tool_axis(struct wl_listener *listener, void *data) { 646static 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) {
697static void handle_tool_tip(struct wl_listener *listener, void *data) { 702static 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) {
780static void handle_tool_button(struct wl_listener *listener, void *data) { 785static 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) {