]> git.sur5r.net Git - i3/i3lock/blobdiff - xcb.c
Turn on the screen on successful authentication
[i3/i3lock] / xcb.c
diff --git a/xcb.c b/xcb.c
index d27b98cf89ecd0e6de7862e1da538f581b1422aa..fc27d0bde2d91826113fcf382721d743c81d5da2 100644 (file)
--- a/xcb.c
+++ b/xcb.c
@@ -8,12 +8,13 @@
  *
  */
 #include <xcb/xcb.h>
-#include <xcb/xcb_keysyms.h>
 #include <xcb/xcb_image.h>
+#include <xcb/xcb_atom.h>
 #include <xcb/dpms.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <stdbool.h>
+#include <string.h>
 #include <unistd.h>
 #include <assert.h>
 #include <err.h>
@@ -122,7 +123,7 @@ xcb_window_t open_fullscreen_window(xcb_connection_t *conn, xcb_screen_t *scr, c
                 XCB_EVENT_MASK_STRUCTURE_NOTIFY;
 
     xcb_create_window(conn,
-                      24,
+                      XCB_COPY_FROM_PARENT,
                       win, /* the window id */
                       scr->root, /* parent == root */
                       0, 0,
@@ -134,6 +135,16 @@ xcb_window_t open_fullscreen_window(xcb_connection_t *conn, xcb_screen_t *scr, c
                       mask,
                       values);
 
+    char *name = "i3lock";
+    xcb_change_property(conn,
+                        XCB_PROP_MODE_REPLACE,
+                        win,
+                        XCB_ATOM_WM_NAME,
+                        XCB_ATOM_STRING,
+                        8,
+                        strlen(name),
+                        name);
+
     /* Map the window (= make it visible) */
     xcb_map_window(conn, win);
 
@@ -145,39 +156,12 @@ xcb_window_t open_fullscreen_window(xcb_connection_t *conn, xcb_screen_t *scr, c
 }
 
 /*
- * Returns the mask for Mode_switch (to be used for looking up keysymbols by
- * keycode).
+ * Set the dpms level to 'mode'.
  *
  */
-uint32_t get_mod_mask(xcb_connection_t *conn, xcb_key_symbols_t *symbols, uint32_t keycode) {
-    xcb_get_modifier_mapping_reply_t *modmap_r;
-    xcb_keycode_t *modmap, kc;
-    xcb_keycode_t *modeswitchcodes = xcb_key_symbols_get_keycode(symbols, keycode);
-    if (modeswitchcodes == NULL)
-        return 0;
-
-    modmap_r = xcb_get_modifier_mapping_reply(conn, xcb_get_modifier_mapping(conn), NULL);
-    modmap = xcb_get_modifier_mapping_keycodes(modmap_r);
-
-    for (int i = 0; i < 8; i++)
-        for (int j = 0; j < modmap_r->keycodes_per_modifier; j++) {
-            kc = modmap[i * modmap_r->keycodes_per_modifier + j];
-            for (xcb_keycode_t *ktest = modeswitchcodes; *ktest; ktest++) {
-                if (*ktest != kc)
-                    continue;
-
-                free(modeswitchcodes);
-                free(modmap_r);
-                return (1 << i);
-            }
-        }
-
-    return 0;
-}
-
-void dpms_turn_off_screen(xcb_connection_t *conn) {
+void dpms_set_mode(xcb_connection_t *conn, xcb_dpms_dpms_mode_t mode) {
     xcb_dpms_enable(conn);
-    xcb_dpms_force_level(conn, XCB_DPMS_DPMS_MODE_OFF);
+    xcb_dpms_force_level(conn, mode);
     xcb_flush(conn);
 }