diff options
| author | Drew DeVault <sir@cmpwn.com> | 2018-10-14 16:34:22 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-10-14 16:34:22 +0200 |
| commit | 53d90dd6a82205a20c3e97a8a396048588e1b5ef (patch) | |
| tree | 10f5596fd0d90711af66281c38780c5a1d4d724f /swaylock/main.c | |
| parent | 135f0fc7e7d9435c5f6bd1725b5d3113b23ac991 (diff) | |
| parent | c6f153d8f9ad6c961c8dd8e620dc2e8fcb20e7bc (diff) | |
Merge pull request #2826 from RyanDwyer/common-eventloop
Implement common event loop for swaybar and swaylock
Diffstat (limited to 'swaylock/main.c')
| -rw-r--r-- | swaylock/main.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/swaylock/main.c b/swaylock/main.c index d1384c6f..27bcfe32 100644 --- a/swaylock/main.c +++ b/swaylock/main.c @@ -21,6 +21,7 @@ #include "pool-buffer.h" #include "cairo.h" #include "log.h" +#include "loop.h" #include "readline.h" #include "stringop.h" #include "util.h" @@ -844,6 +845,10 @@ static int load_config(char *path, struct swaylock_state *state, static struct swaylock_state state; +static void display_in(int fd, short mask, void *data) { + wl_display_dispatch(state.display); +} + int main(int argc, char **argv) { wlr_log_init(WLR_DEBUG, NULL); initialize_pw_backend(); @@ -946,9 +951,14 @@ int main(int argc, char **argv) { daemonize(); } + state.eventloop = loop_create(); + loop_add_fd(state.eventloop, wl_display_get_fd(state.display), POLL_IN, + display_in, NULL); + state.run_display = true; - while (wl_display_dispatch(state.display) != -1 && state.run_display) { - // This space intentionally left blank + while (state.run_display) { + wl_display_flush(state.display); + loop_poll(state.eventloop); } free(state.args.font); |
