X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=src%2Fx.c;h=f73fc8463684f3d47fd1a48a3fe80e08b63dd6e7;hb=6a1c34d2c584271d26f4dcc214798421c097a1ac;hp=2ed8fd11fb6b928d012339a21872294e3bf468cc;hpb=c145f7e5297ef06aaf84689762a736d5bc8cbb83;p=i3%2Fi3 diff --git a/src/x.c b/src/x.c index 2ed8fd11..f73fc846 100644 --- a/src/x.c +++ b/src/x.c @@ -86,6 +86,25 @@ void x_con_init(Con *con) { LOG("adding new state for window id 0x%08x\n", state->id); } +/* + * Re-initializes the associated X window state for this container. You have + * to call this when you assign a client to an empty container to ensure that + * its state gets updated correctly. + * + */ +void x_reinit(Con *con) { + struct con_state *state; + + if ((state = state_for_frame(con->frame)) == NULL) { + ELOG("window state not found\n"); + return; + } + + LOG("resetting state %p to initial\n", state); + state->initial = true; + memset(&(state->window_rect), 0, sizeof(Rect)); +} + void x_con_kill(Con *con) { con_state *state; @@ -153,28 +172,40 @@ void x_draw_decoration(Con *con) { xcb_rectangle_t drect = { con->deco_rect.x, con->deco_rect.y, con->deco_rect.width, con->deco_rect.height }; xcb_poly_fill_rectangle(conn, parent->frame, parent->gc, 1, &drect); - if (con->window == NULL) { + if (con->window == NULL) return; - } - if (con->window->class == NULL) { + i3Window *win = con->window; + + if (win->name_x == NULL) { LOG("not rendering decoration, not yet known\n"); return; } - LOG("should render text %s onto %p / %s\n", con->window->class, parent, parent->name); + LOG("should render text %s onto %p / %s\n", win->name_json, parent, parent->name); xcb_change_gc_single(conn, parent->gc, XCB_GC_FOREGROUND, get_colorpixel("#FFFFFF")); - xcb_image_text_8( - conn, - strlen(con->window->class), - parent->frame, - parent->gc, - con->deco_rect.x, - con->deco_rect.y + 14, - con->window->class - ); + if (win->uses_net_wm_name) + xcb_image_text_16( + conn, + win->name_len, + parent->frame, + parent->gc, + con->deco_rect.x, + con->deco_rect.y + 14, /* TODO: hardcoded */ + (xcb_char2b_t*)win->name_x + ); + else + xcb_image_text_8( + conn, + win->name_len, + parent->frame, + parent->gc, + con->deco_rect.x, + con->deco_rect.y + 14, /* TODO: hardcoded */ + win->name_x + ); } /* @@ -190,8 +221,10 @@ static void x_push_node(Con *con) { LOG("Pushing changes for node %p / %s\n", con, con->name); state = state_for_frame(con->frame); - /* map/unmap if map state changed */ - if (state->mapped != con->mapped) { + /* map/unmap if map state changed, also ensure that the child window + * is changed if we are mapped *and* in initial state (meaning the + * container was empty before, but now got a child) */ + if (state->mapped != con->mapped || (con->mapped && state->initial)) { if (!con->mapped) { LOG("unmapping container\n"); xcb_unmap_window(conn, con->frame); @@ -243,7 +276,7 @@ void x_push_changes(Con *con) { LOG("\n\n PUSHING CHANGES\n\n"); x_push_node(con); - LOG("-- PUSHING FOCUS STACK --\n"); + LOG("-- PUSHING WINDOW STACK --\n"); /* X11 correctly represents the stack if we push it from bottom to top */ CIRCLEQ_FOREACH_REVERSE(state, &state_head, state) { LOG("stack: 0x%08x\n", state->id); @@ -266,7 +299,7 @@ void x_push_changes(Con *con) { to_focus = focused->window->id; if (focused_id != to_focus) { - LOG("Updating focus\n"); + LOG("Updating focus (focused: %p / %s)\n", focused, focused->name); xcb_set_input_focus(conn, XCB_INPUT_FOCUS_POINTER_ROOT, to_focus, XCB_CURRENT_TIME); }