From 402254b5752fcf6a8197b92f558cb0c35289fa74 Mon Sep 17 00:00:00 2001 From: martin Date: Wed, 25 May 2016 22:19:17 +0200 Subject: [PATCH 1/2] Flush xcb connection after opening fullscreen window (#74) We need to ensure that the window handle is valid, i. e. the window is actually created and accessible, before returning. This is necessary because we immediately fork after returning, and the child process opens its own X11 connection and expects the window handle to be valid. Fixes #46 --- xcb.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/xcb.c b/xcb.c index f1a9a76..3e8cd07 100644 --- a/xcb.c +++ b/xcb.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -150,6 +151,9 @@ xcb_window_t open_fullscreen_window(xcb_connection_t *conn, xcb_screen_t *scr, c values[0] = XCB_STACK_MODE_ABOVE; xcb_configure_window(conn, win, XCB_CONFIG_WINDOW_STACK_MODE, values); + /* Ensure that the window is created and set up before returning */ + xcb_aux_sync(conn); + return win; } From 463d38fed634ef569dfd524a7ab7bc19ae659b00 Mon Sep 17 00:00:00 2001 From: Christoph Ruegge Date: Wed, 25 May 2016 22:21:12 +0200 Subject: [PATCH 2/2] Add support for `xss-lock --transfer-sleep-lock' (#75) Add support for `xss-lock --transfer-sleep-lock' --- i3lock.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/i3lock.c b/i3lock.c index 928953b..524463f 100644 --- a/i3lock.c +++ b/i3lock.c @@ -627,6 +627,22 @@ static void xcb_prepare_cb(EV_P_ ev_prepare *w, int revents) { xcb_flush(conn); } +/* + * Try closing logind sleep lock fd passed over from xss-lock, in case we're + * being run from there. + * + */ +static void maybe_close_sleep_lock_fd(void) { + const char *sleep_lock_fd = getenv("XSS_SLEEP_LOCK_FD"); + char *endptr; + if (sleep_lock_fd && *sleep_lock_fd != 0) { + long int fd = strtol(sleep_lock_fd, &endptr, 10); + if (*endptr == 0) { + close(fd); + } + } +} + /* * Instead of polling the X connection socket we leave this to * xcb_poll_for_event() which knows better than we can ever know. @@ -661,6 +677,7 @@ static void xcb_check_cb(EV_P_ ev_check *w, int revents) { break; case XCB_MAP_NOTIFY: + maybe_close_sleep_lock_fd(); if (!dont_fork) { /* After the first MapNotify, we never fork again. We don’t * expect to get another MapNotify, but better be sure… */ @@ -956,6 +973,7 @@ int main(int argc, char *argv[]) { if (pid == 0) { /* Child */ close(xcb_get_file_descriptor(conn)); + maybe_close_sleep_lock_fd(); raise_loop(win); exit(EXIT_SUCCESS); }