diff options
author | Rouven Czerwinski <rouven@czerwinskis.de> | 2019-01-07 13:19:47 +0100 |
---|---|---|
committer | Brian Ashworth <bosrsf04@gmail.com> | 2019-01-07 10:30:19 -0500 |
commit | fde900861af742f4078ace5720ddd5b02eeb0bac (patch) | |
tree | ac7ed6d556751f6871e328ef9ad7dedf7666063b | |
parent | Merge pull request #3381 from oscarwcl/swayidle-inhibit-sleep (diff) | |
download | sway-fde900861af742f4078ace5720ddd5b02eeb0bac.tar.gz sway-fde900861af742f4078ace5720ddd5b02eeb0bac.tar.zst sway-fde900861af742f4078ace5720ddd5b02eeb0bac.zip |
cursor: move unhide and timeout retrieval into separate functions
The unhide and timeout retrieval functions are needed in a later commit. No
functional changes.
-rw-r--r-- | include/sway/input/cursor.h | 2 | ||||
-rw-r--r-- | sway/input/cursor.c | 35 |
2 files changed, 25 insertions, 12 deletions
diff --git a/include/sway/input/cursor.h b/include/sway/input/cursor.h index 78489e21..22e278b0 100644 --- a/include/sway/input/cursor.h +++ b/include/sway/input/cursor.h | |||
@@ -61,6 +61,8 @@ struct sway_cursor *sway_cursor_create(struct sway_seat *seat); | |||
61 | void cursor_rebase(struct sway_cursor *cursor); | 61 | void cursor_rebase(struct sway_cursor *cursor); |
62 | 62 | ||
63 | void cursor_handle_activity(struct sway_cursor *cursor); | 63 | void cursor_handle_activity(struct sway_cursor *cursor); |
64 | void cursor_unhide(struct sway_cursor *cursor); | ||
65 | int cursor_get_timeout(struct sway_cursor *cursor); | ||
64 | 66 | ||
65 | /** | 67 | /** |
66 | * Like cursor_rebase, but also allows focus to change when the cursor enters a | 68 | * Like cursor_rebase, but also allows focus to change when the cursor enters a |
diff --git a/sway/input/cursor.c b/sway/input/cursor.c index 66a9e435..510030ae 100644 --- a/sway/input/cursor.c +++ b/sway/input/cursor.c | |||
@@ -621,7 +621,7 @@ static int hide_notify(void *data) { | |||
621 | return 1; | 621 | return 1; |
622 | } | 622 | } |
623 | 623 | ||
624 | void cursor_handle_activity(struct sway_cursor *cursor) { | 624 | int cursor_get_timeout(struct sway_cursor *cursor){ |
625 | struct seat_config *sc = seat_get_config(cursor->seat); | 625 | struct seat_config *sc = seat_get_config(cursor->seat); |
626 | if (!sc) { | 626 | if (!sc) { |
627 | sc = seat_get_config_by_name("*"); | 627 | sc = seat_get_config_by_name("*"); |
@@ -630,20 +630,31 @@ void cursor_handle_activity(struct sway_cursor *cursor) { | |||
630 | if (timeout < 0) { | 630 | if (timeout < 0) { |
631 | timeout = 0; | 631 | timeout = 0; |
632 | } | 632 | } |
633 | wl_event_source_timer_update(cursor->hide_source, timeout); | 633 | return timeout; |
634 | } | ||
635 | |||
636 | void cursor_handle_activity(struct sway_cursor *cursor) { | ||
637 | wl_event_source_timer_update( | ||
638 | cursor->hide_source, cursor_get_timeout(cursor)); | ||
634 | 639 | ||
635 | wlr_idle_notify_activity(server.idle, cursor->seat->wlr_seat); | 640 | wlr_idle_notify_activity(server.idle, cursor->seat->wlr_seat); |
636 | if (cursor->hidden) { | 641 | if (cursor->hidden) { |
637 | cursor->hidden = false; | 642 | cursor_unhide(cursor); |
638 | if (cursor->image_surface) { | 643 | } |
639 | cursor_set_image_surface(cursor, cursor->image_surface, | 644 | } |
640 | cursor->hotspot_x, cursor->hotspot_y, | 645 | |
641 | cursor->image_client); | 646 | void cursor_unhide(struct sway_cursor *cursor) { |
642 | } else { | 647 | cursor->hidden = false; |
643 | const char *image = cursor->image; | 648 | if (cursor->image_surface) { |
644 | cursor->image = NULL; | 649 | cursor_set_image_surface(cursor, |
645 | cursor_set_image(cursor, image, cursor->image_client); | 650 | cursor->image_surface, |
646 | } | 651 | cursor->hotspot_x, |
652 | cursor->hotspot_y, | ||
653 | cursor->image_client); | ||
654 | } else { | ||
655 | const char *image = cursor->image; | ||
656 | cursor->image = NULL; | ||
657 | cursor_set_image(cursor, image, cursor->image_client); | ||
647 | } | 658 | } |
648 | } | 659 | } |
649 | 660 | ||