]> git.sur5r.net Git - i3/i3/blobdiff - src/restore_layout.c
Use the DPI setting within the i3bar (#2556)
[i3/i3] / src / restore_layout.c
index 70eed523a6d5337689ccc79bc9f030d206af67ed..d48e5c6ef6197496cd1b8be54bacc19b717622d6 100644 (file)
@@ -1,5 +1,3 @@
-#undef I3__FILE__
-#define I3__FILE__ "restore_layout.c"
 /*
  * vim:ts=4:sw=4:expandtab
  *
  */
 #include "all.h"
 
+#ifdef I3_ASAN_ENABLED
+#include <sanitizer/lsan_interface.h>
+#endif
+
 typedef struct placeholder_state {
     /** The X11 placeholder window. */
     xcb_window_t window;
@@ -27,7 +29,8 @@ typedef struct placeholder_state {
     /** The graphics context for “pixmap”. */
     xcb_gcontext_t gc;
 
-    TAILQ_ENTRY(placeholder_state) state;
+    TAILQ_ENTRY(placeholder_state)
+    state;
 } placeholder_state;
 
 static TAILQ_HEAD(state_head, placeholder_state) state_head =
@@ -98,7 +101,11 @@ void restore_connect(void) {
             free(state);
         }
 
-        free(restore_conn);
+        /* xcb_disconnect leaks memory in libxcb versions earlier than 1.11,
+         * but it’s the right function to call. See
+         * http://cgit.freedesktop.org/xcb/libxcb/commit/src/xcb_conn.c?id=4dcbfd77b
+         */
+        xcb_disconnect(restore_conn);
         free(xcb_watcher);
         free(xcb_check);
         free(xcb_prepare);
@@ -106,8 +113,15 @@ void restore_connect(void) {
 
     int screen;
     restore_conn = xcb_connect(NULL, &screen);
-    if (restore_conn == NULL || xcb_connection_has_error(restore_conn))
+    if (restore_conn == NULL || xcb_connection_has_error(restore_conn)) {
+        if (restore_conn != NULL) {
+            xcb_disconnect(restore_conn);
+        }
+#ifdef I3_ASAN_ENABLED
+        __lsan_do_leak_check();
+#endif
         errx(EXIT_FAILURE, "Cannot open display\n");
+    }
 
     xcb_watcher = scalloc(1, sizeof(struct ev_io));
     xcb_check = scalloc(1, sizeof(struct ev_check));
@@ -125,7 +139,7 @@ void restore_connect(void) {
 
 static void update_placeholder_contents(placeholder_state *state) {
     xcb_change_gc(restore_conn, state->gc, XCB_GC_FOREGROUND,
-                  (uint32_t[]){config.client.placeholder.background});
+                  (uint32_t[]){config.client.placeholder.background.colorpixel});
     xcb_poly_fill_rectangle(restore_conn, state->pixmap, state->gc, 1,
                             (xcb_rectangle_t[]){{0, 0, state->rect.width, state->rect.height}});
 
@@ -193,7 +207,7 @@ static void open_placeholder_window(Con *con) {
             true,
             XCB_CW_BACK_PIXEL | XCB_CW_EVENT_MASK,
             (uint32_t[]){
-                config.client.placeholder.background,
+                config.client.placeholder.background.colorpixel,
                 XCB_EVENT_MASK_EXPOSURE | XCB_EVENT_MASK_STRUCTURE_NOTIFY,
             });
         /* Make i3 not focus this window. */
@@ -225,6 +239,7 @@ static void open_placeholder_window(Con *con) {
         /* create temporary id swallow to match the placeholder */
         Match *temp_id = smalloc(sizeof(Match));
         match_init(temp_id);
+        temp_id->dock = M_DONTCHECK;
         temp_id->id = placeholder;
         TAILQ_INSERT_HEAD(&(con->swallow_head), temp_id, matches);
     }