diff options
author | 2018-10-14 16:34:22 +0200 | |
---|---|---|
committer | 2018-10-14 16:34:22 +0200 | |
commit | 53d90dd6a82205a20c3e97a8a396048588e1b5ef (patch) | |
tree | 10f5596fd0d90711af66281c38780c5a1d4d724f /swaylock/main.c | |
parent | Update README.MD (and README.*.md) (diff) | |
parent | Event loop: Fix memmove and remove extraneous declaration (diff) | |
download | sway-53d90dd6a82205a20c3e97a8a396048588e1b5ef.tar.gz sway-53d90dd6a82205a20c3e97a8a396048588e1b5ef.tar.zst sway-53d90dd6a82205a20c3e97a8a396048588e1b5ef.zip |
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 @@ | |||
21 | #include "pool-buffer.h" | 21 | #include "pool-buffer.h" |
22 | #include "cairo.h" | 22 | #include "cairo.h" |
23 | #include "log.h" | 23 | #include "log.h" |
24 | #include "loop.h" | ||
24 | #include "readline.h" | 25 | #include "readline.h" |
25 | #include "stringop.h" | 26 | #include "stringop.h" |
26 | #include "util.h" | 27 | #include "util.h" |
@@ -844,6 +845,10 @@ static int load_config(char *path, struct swaylock_state *state, | |||
844 | 845 | ||
845 | static struct swaylock_state state; | 846 | static struct swaylock_state state; |
846 | 847 | ||
848 | static void display_in(int fd, short mask, void *data) { | ||
849 | wl_display_dispatch(state.display); | ||
850 | } | ||
851 | |||
847 | int main(int argc, char **argv) { | 852 | int main(int argc, char **argv) { |
848 | wlr_log_init(WLR_DEBUG, NULL); | 853 | wlr_log_init(WLR_DEBUG, NULL); |
849 | initialize_pw_backend(); | 854 | initialize_pw_backend(); |
@@ -946,9 +951,14 @@ int main(int argc, char **argv) { | |||
946 | daemonize(); | 951 | daemonize(); |
947 | } | 952 | } |
948 | 953 | ||
954 | state.eventloop = loop_create(); | ||
955 | loop_add_fd(state.eventloop, wl_display_get_fd(state.display), POLL_IN, | ||
956 | display_in, NULL); | ||
957 | |||
949 | state.run_display = true; | 958 | state.run_display = true; |
950 | while (wl_display_dispatch(state.display) != -1 && state.run_display) { | 959 | while (state.run_display) { |
951 | // This space intentionally left blank | 960 | wl_display_flush(state.display); |
961 | loop_poll(state.eventloop); | ||
952 | } | 962 | } |
953 | 963 | ||
954 | free(state.args.font); | 964 | free(state.args.font); |