-#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;
/** 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 =
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);
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));
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}});
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. */
/* 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);
}