i3lock-color

The world's most popular non-default computer lockscreen.
Index Commits Files Refs README LICENSE
commit de6bea260355ea55f71b7d39a306de1f0c73f9a8
parent 63a4c23ec6f0b3f62144122a4277d51caf023e4f
Author: Chris Guillott <chris@techfo.xyz>
Date:   Sat, 28 May 2016 10:48:35 -0400

Merge pull request #4 from i3/master

Merge upstream commits
Diffstat:
Mi3lock.c | 18++++++++++++++++++
Mxcb.c | 4++++
2 files changed, 22 insertions(+), 0 deletions(-)
diff --git a/i3lock.c b/i3lock.c
@@ -658,6 +658,22 @@ static void xcb_prepare_cb(EV_P_ ev_prepare *w, int revents) {
 }
 
 /*
+ * 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.
  *
@@ -691,6 +707,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… */
@@ -1131,6 +1148,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);
     }
diff --git a/xcb.c b/xcb.c
@@ -10,6 +10,7 @@
 #include <xcb/xcb.h>
 #include <xcb/xcb_image.h>
 #include <xcb/xcb_atom.h>
+#include <xcb/xcb_aux.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <stdbool.h>
@@ -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;
 }