diff options
author | Ryan Dwyer <ryandwyer1@gmail.com> | 2018-10-14 12:28:38 +1000 |
---|---|---|
committer | Ryan Dwyer <ryandwyer1@gmail.com> | 2018-10-15 00:26:27 +1000 |
commit | 6921fdc6d6134fd7aaf38ffc1686623eca9bbd18 (patch) | |
tree | 0cbafde1d61ba4282e3ca73b4a312b9e82db25f9 /include | |
parent | swaylock: Don't wait too long for surface damage before verifying (diff) | |
download | sway-6921fdc6d6134fd7aaf38ffc1686623eca9bbd18.tar.gz sway-6921fdc6d6134fd7aaf38ffc1686623eca9bbd18.tar.zst sway-6921fdc6d6134fd7aaf38ffc1686623eca9bbd18.zip |
Remove timerfd from loop implementation
timerfd doesn't work on the BSDs, so this replaces it with a timespec
for the expiry and uses a poll timeout to check the timers when needed.
Diffstat (limited to 'include')
-rw-r--r-- | include/loop.h | 25 | ||||
-rw-r--r-- | include/swaybar/bar.h | 1 | ||||
-rw-r--r-- | include/swaylock/swaylock.h | 6 |
3 files changed, 19 insertions, 13 deletions
diff --git a/include/loop.h b/include/loop.h index 7c151785..2f608eda 100644 --- a/include/loop.h +++ b/include/loop.h | |||
@@ -5,12 +5,12 @@ | |||
5 | /** | 5 | /** |
6 | * This is an event loop system designed for sway clients, not sway itself. | 6 | * This is an event loop system designed for sway clients, not sway itself. |
7 | * | 7 | * |
8 | * It uses pollfds to block on multiple file descriptors at once, and provides | 8 | * The loop consists of file descriptors and timers. Typically the Wayland |
9 | * an easy way to set timers. Typically the Wayland display's fd will be one of | 9 | * display's file descriptor will be one of the fds in the loop. |
10 | * the fds in the loop. | ||
11 | */ | 10 | */ |
12 | 11 | ||
13 | struct loop; | 12 | struct loop; |
13 | struct loop_timer; | ||
14 | 14 | ||
15 | /** | 15 | /** |
16 | * Create an event loop. | 16 | * Create an event loop. |
@@ -28,20 +28,27 @@ void loop_destroy(struct loop *loop); | |||
28 | void loop_poll(struct loop *loop); | 28 | void loop_poll(struct loop *loop); |
29 | 29 | ||
30 | /** | 30 | /** |
31 | * Add an fd to the loop. | 31 | * Add a file descriptor to the loop. |
32 | */ | 32 | */ |
33 | struct loop_event *loop_add_fd(struct loop *loop, int fd, short mask, | 33 | void loop_add_fd(struct loop *loop, int fd, short mask, |
34 | void (*func)(int fd, short mask, void *data), void *data); | 34 | void (*func)(int fd, short mask, void *data), void *data); |
35 | 35 | ||
36 | /** | 36 | /** |
37 | * Add a timer to the loop. | 37 | * Add a timer to the loop. |
38 | * | ||
39 | * When the timer expires, the timer will be removed from the loop and freed. | ||
40 | */ | ||
41 | struct loop_timer *loop_add_timer(struct loop *loop, int ms, | ||
42 | void (*callback)(void *data), void *data); | ||
43 | |||
44 | /** | ||
45 | * Remove a file descriptor from the loop. | ||
38 | */ | 46 | */ |
39 | struct loop_event *loop_add_timer(struct loop *loop, int ms, | 47 | bool loop_remove_fd(struct loop *loop, int fd); |
40 | void (*callback)(int fd, short mask, void *data), void *data); | ||
41 | 48 | ||
42 | /** | 49 | /** |
43 | * Remove an event from the loop. | 50 | * Remove a timer from the loop. |
44 | */ | 51 | */ |
45 | bool loop_remove_event(struct loop *loop, struct loop_event *event); | 52 | bool loop_remove_timer(struct loop *loop, struct loop_timer *timer); |
46 | 53 | ||
47 | #endif | 54 | #endif |
diff --git a/include/swaybar/bar.h b/include/swaybar/bar.h index d61da5dc..db2d3d62 100644 --- a/include/swaybar/bar.h +++ b/include/swaybar/bar.h | |||
@@ -69,7 +69,6 @@ struct swaybar { | |||
69 | struct status_line *status; | 69 | struct status_line *status; |
70 | 70 | ||
71 | struct loop *eventloop; | 71 | struct loop *eventloop; |
72 | struct loop_event *status_event; | ||
73 | 72 | ||
74 | int ipc_event_socketfd; | 73 | int ipc_event_socketfd; |
75 | int ipc_socketfd; | 74 | int ipc_socketfd; |
diff --git a/include/swaylock/swaylock.h b/include/swaylock/swaylock.h index e7165b3b..25b41a71 100644 --- a/include/swaylock/swaylock.h +++ b/include/swaylock/swaylock.h | |||
@@ -55,9 +55,9 @@ struct swaylock_password { | |||
55 | 55 | ||
56 | struct swaylock_state { | 56 | struct swaylock_state { |
57 | struct loop *eventloop; | 57 | struct loop *eventloop; |
58 | struct loop_event *clear_indicator_timer; // clears the indicator | 58 | struct loop_timer *clear_indicator_timer; // clears the indicator |
59 | struct loop_event *clear_password_timer; // clears the password buffer | 59 | struct loop_timer *clear_password_timer; // clears the password buffer |
60 | struct loop_event *verify_password_timer; | 60 | struct loop_timer *verify_password_timer; |
61 | struct wl_display *display; | 61 | struct wl_display *display; |
62 | struct wl_compositor *compositor; | 62 | struct wl_compositor *compositor; |
63 | struct zwlr_layer_shell_v1 *layer_shell; | 63 | struct zwlr_layer_shell_v1 *layer_shell; |