X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=src%2Frestore_layout.c;h=70eed523a6d5337689ccc79bc9f030d206af67ed;hb=1c4100ce5d8f9a7edc46f80f8a20ca50c6d97f8b;hp=d6d7927d27f821c3c69387bdcb8735ff913a5617;hpb=2d28273cac9643f6a6e71b3f434ac1318238d686;p=i3%2Fi3 diff --git a/src/restore_layout.c b/src/restore_layout.c index d6d7927d..70eed523 100644 --- a/src/restore_layout.c +++ b/src/restore_layout.c @@ -4,7 +4,7 @@ * vim:ts=4:sw=4:expandtab * * i3 - an improved dynamic tiling window manager - * © 2009-2013 Michael Stapelberg and contributors (see also: LICENSE) + * © 2009 Michael Stapelberg and contributors (see also: LICENSE) * * restore_layout.c: Everything for restored containers that is not pure state * parsing (which can be found in load_layout.c). @@ -109,9 +109,9 @@ void restore_connect(void) { if (restore_conn == NULL || xcb_connection_has_error(restore_conn)) errx(EXIT_FAILURE, "Cannot open display\n"); - xcb_watcher = scalloc(sizeof(struct ev_io)); - xcb_check = scalloc(sizeof(struct ev_check)); - xcb_prepare = scalloc(sizeof(struct ev_prepare)); + xcb_watcher = scalloc(1, sizeof(struct ev_io)); + xcb_check = scalloc(1, sizeof(struct ev_check)); + xcb_prepare = scalloc(1, sizeof(struct ev_prepare)); ev_io_init(xcb_watcher, restore_xcb_got_event, xcb_get_file_descriptor(restore_conn), EV_READ); ev_io_start(main_loop, xcb_watcher); @@ -125,9 +125,9 @@ 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}); xcb_poly_fill_rectangle(restore_conn, state->pixmap, state->gc, 1, - (xcb_rectangle_t[]) {{0, 0, state->rect.width, state->rect.height}}); + (xcb_rectangle_t[]){{0, 0, state->rect.width, state->rect.height}}); // TODO: make i3font functions per-connection, at least these two for now…? xcb_flush(restore_conn); @@ -161,7 +161,7 @@ static void update_placeholder_contents(placeholder_state *state) { DLOG("con %p (placeholder 0x%08x) line %d: %s\n", state->con, state->window, n, serialized); i3String *str = i3string_from_utf8(serialized); - draw_text(str, state->pixmap, state->gc, 2, (n * (config.font.height + 2)) + 2, state->rect.width - 2); + draw_text(str, state->pixmap, state->gc, NULL, 2, (n * (config.font.height + 2)) + 2, state->rect.width - 2); i3string_free(str); n++; free(serialized); @@ -172,7 +172,7 @@ static void update_placeholder_contents(placeholder_state *state) { int text_width = predict_text_width(line); int x = (state->rect.width / 2) - (text_width / 2); int y = (state->rect.height / 2) - (config.font.height / 2); - draw_text(line, state->pixmap, state->gc, x, y, text_width); + draw_text(line, state->pixmap, state->gc, NULL, x, y, text_width); i3string_free(line); xcb_flush(conn); xcb_aux_sync(conn); @@ -180,7 +180,9 @@ static void update_placeholder_contents(placeholder_state *state) { static void open_placeholder_window(Con *con) { if (con_is_leaf(con) && - (con->window == NULL || con->window->id == XCB_NONE)) { + (con->window == NULL || con->window->id == XCB_NONE) && + !TAILQ_EMPTY(&(con->swallow_head)) && + con->type == CT_CON) { xcb_window_t placeholder = create_window( restore_conn, con->rect, @@ -190,19 +192,25 @@ static void open_placeholder_window(Con *con) { XCURSOR_CURSOR_POINTER, true, XCB_CW_BACK_PIXEL | XCB_CW_EVENT_MASK, - (uint32_t[]) { + (uint32_t[]){ config.client.placeholder.background, XCB_EVENT_MASK_EXPOSURE | XCB_EVENT_MASK_STRUCTURE_NOTIFY, }); + /* Make i3 not focus this window. */ + xcb_icccm_wm_hints_t hints; + xcb_icccm_wm_hints_set_none(&hints); + xcb_icccm_wm_hints_set_input(&hints, 0); + xcb_icccm_set_wm_hints(restore_conn, placeholder, &hints); /* Set the same name as was stored in the layout file. While perhaps * slightly confusing in the first instant, this brings additional * clarity to which placeholder is waiting for which actual window. */ - xcb_change_property(restore_conn, XCB_PROP_MODE_REPLACE, placeholder, - A__NET_WM_NAME, A_UTF8_STRING, 8, strlen(con->name), con->name); + if (con->name != NULL) + xcb_change_property(restore_conn, XCB_PROP_MODE_REPLACE, placeholder, + A__NET_WM_NAME, A_UTF8_STRING, 8, strlen(con->name), con->name); DLOG("Created placeholder window 0x%08x for leaf container %p / %s\n", placeholder, con, con->name); - placeholder_state *state = scalloc(sizeof(placeholder_state)); + placeholder_state *state = scalloc(1, sizeof(placeholder_state)); state->window = placeholder; state->con = con; state->rect = con->rect; @@ -210,7 +218,7 @@ static void open_placeholder_window(Con *con) { xcb_create_pixmap(restore_conn, root_depth, state->pixmap, state->window, state->rect.width, state->rect.height); state->gc = xcb_generate_id(restore_conn); - xcb_create_gc(restore_conn, state->gc, state->pixmap, XCB_GC_GRAPHICS_EXPOSURES, (uint32_t[]) {0}); + xcb_create_gc(restore_conn, state->gc, state->pixmap, XCB_GC_GRAPHICS_EXPOSURES, (uint32_t[]){0}); update_placeholder_contents(state); TAILQ_INSERT_TAIL(&state_head, state, state); @@ -218,7 +226,7 @@ static void open_placeholder_window(Con *con) { Match *temp_id = smalloc(sizeof(Match)); match_init(temp_id); temp_id->id = placeholder; - TAILQ_INSERT_TAIL(&(con->swallow_head), temp_id, matches); + TAILQ_INSERT_HEAD(&(con->swallow_head), temp_id, matches); } Con *child; @@ -322,7 +330,7 @@ static void configure_notify(xcb_configure_notify_event_t *event) { xcb_create_pixmap(restore_conn, root_depth, state->pixmap, state->window, state->rect.width, state->rect.height); state->gc = xcb_generate_id(restore_conn); - xcb_create_gc(restore_conn, state->gc, state->pixmap, XCB_GC_GRAPHICS_EXPOSURES, (uint32_t[]) {0}); + xcb_create_gc(restore_conn, state->gc, state->pixmap, XCB_GC_GRAPHICS_EXPOSURES, (uint32_t[]){0}); update_placeholder_contents(state); xcb_copy_area(restore_conn, state->pixmap, state->window, state->gc,