swaylock: Use common event loop

This commit is contained in:
Ryan Dwyer 2018-10-13 16:14:35 +10:00
parent 4056c09e13
commit 9c833c661a
2 changed files with 13 additions and 2 deletions

View File

@ -54,6 +54,7 @@ struct swaylock_password {
}; };
struct swaylock_state { struct swaylock_state {
struct loop *eventloop;
struct wl_display *display; struct wl_display *display;
struct wl_compositor *compositor; struct wl_compositor *compositor;
struct zwlr_layer_shell_v1 *layer_shell; struct zwlr_layer_shell_v1 *layer_shell;

View File

@ -21,6 +21,7 @@
#include "pool-buffer.h" #include "pool-buffer.h"
#include "cairo.h" #include "cairo.h"
#include "log.h" #include "log.h"
#include "loop.h"
#include "readline.h" #include "readline.h"
#include "stringop.h" #include "stringop.h"
#include "util.h" #include "util.h"
@ -844,6 +845,10 @@ static int load_config(char *path, struct swaylock_state *state,
static 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) { int main(int argc, char **argv) {
wlr_log_init(WLR_DEBUG, NULL); wlr_log_init(WLR_DEBUG, NULL);
initialize_pw_backend(); initialize_pw_backend();
@ -946,9 +951,14 @@ int main(int argc, char **argv) {
daemonize(); 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; state.run_display = true;
while (wl_display_dispatch(state.display) != -1 && state.run_display) { while (state.run_display) {
// This space intentionally left blank wl_display_flush(state.display);
loop_poll(state.eventloop);
} }
free(state.args.font); free(state.args.font);