aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorRyan Dwyer <ryandwyer1@gmail.com>2018-10-14 12:28:38 +1000
committerRyan Dwyer <ryandwyer1@gmail.com>2018-10-15 00:26:27 +1000
commit6921fdc6d6134fd7aaf38ffc1686623eca9bbd18 (patch)
tree0cbafde1d61ba4282e3ca73b4a312b9e82db25f9 /include
parentf98f351a5275967c46482e1c9c754fee927d72ee (diff)
downloadsway-6921fdc6d6134fd7aaf38ffc1686623eca9bbd18.tar.xz
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.h25
-rw-r--r--include/swaybar/bar.h1
-rw-r--r--include/swaylock/swaylock.h6
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 @@
/**
* This is an event loop system designed for sway clients, not sway itself.
*
- * It uses pollfds to block on multiple file descriptors at once, and provides
- * an easy way to set timers. Typically the Wayland display's fd will be one of
- * the fds in the loop.
+ * The loop consists of file descriptors and timers. Typically the Wayland
+ * display's file descriptor will be one of the fds in the loop.
*/
struct loop;
+struct loop_timer;
/**
* Create an event loop.
@@ -28,20 +28,27 @@ void loop_destroy(struct loop *loop);
void loop_poll(struct loop *loop);
/**
- * Add an fd to the loop.
+ * Add a file descriptor to the loop.
*/
-struct loop_event *loop_add_fd(struct loop *loop, int fd, short mask,
+void loop_add_fd(struct loop *loop, int fd, short mask,
void (*func)(int fd, short mask, void *data), void *data);
/**
* Add a timer to the loop.
+ *
+ * When the timer expires, the timer will be removed from the loop and freed.
+ */
+struct loop_timer *loop_add_timer(struct loop *loop, int ms,
+ void (*callback)(void *data), void *data);
+
+/**
+ * Remove a file descriptor from the loop.
*/
-struct loop_event *loop_add_timer(struct loop *loop, int ms,
- void (*callback)(int fd, short mask, void *data), void *data);
+bool loop_remove_fd(struct loop *loop, int fd);
/**
- * Remove an event from the loop.
+ * Remove a timer from the loop.
*/
-bool loop_remove_event(struct loop *loop, struct loop_event *event);
+bool loop_remove_timer(struct loop *loop, struct loop_timer *timer);
#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 {
struct status_line *status;
struct loop *eventloop;
- struct loop_event *status_event;
int ipc_event_socketfd;
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 {
struct swaylock_state {
struct loop *eventloop;
- struct loop_event *clear_indicator_timer; // clears the indicator
- struct loop_event *clear_password_timer; // clears the password buffer
- struct loop_event *verify_password_timer;
+ struct loop_timer *clear_indicator_timer; // clears the indicator
+ struct loop_timer *clear_password_timer; // clears the password buffer
+ struct loop_timer *verify_password_timer;
struct wl_display *display;
struct wl_compositor *compositor;
struct zwlr_layer_shell_v1 *layer_shell;