- new->frame = xcb_generate_id(conn);
- new->child = child;
- new->rect.width = width;
- new->rect.height = height;
- /* Pre-initialize the values for floating */
- new->floating_rect.x = -1;
- new->floating_rect.width = width;
- new->floating_rect.height = height;
-
- mask = 0;
-
- /* Don’t generate events for our new window, it should *not* be managed */
- mask |= XCB_CW_OVERRIDE_REDIRECT;
- values[0] = 1;
-
- /* We want to know when… */
- mask |= XCB_CW_EVENT_MASK;
- values[1] = FRAME_EVENT_MASK;
-
- LOG("Reparenting 0x%08x under 0x%08x.\n", child, new->frame);
-
- i3Font *font = load_font(conn, config.font);
- width = min(width, c_ws->rect.x + c_ws->rect.width);
- height = min(height, c_ws->rect.y + c_ws->rect.height);
-
- Rect framerect = {x, y,
- width + 2 + 2, /* 2 px border at each side */
- height + 2 + 2 + font->height}; /* 2 px border plus font’s height */
-
- /* Yo dawg, I heard you like windows, so I create a window around your window… */
- new->frame = create_window(conn, framerect, XCB_WINDOW_CLASS_INPUT_OUTPUT, XCB_CURSOR_LEFT_PTR, false, mask, values);
-
- /* Set WM_STATE_NORMAL because GTK applications don’t want to drag & drop if we don’t.
- * Also, xprop(1) needs that to work. */
- long data[] = { XCB_WM_STATE_NORMAL, XCB_NONE };
- xcb_change_property(conn, XCB_PROP_MODE_REPLACE, new->child, atoms[WM_STATE], atoms[WM_STATE], 32, 2, data);
-
- /* Put the client inside the save set. Upon termination (whether killed or normal exit
- does not matter) of the window manager, these clients will be correctly reparented
- to their most closest living ancestor (= cleanup) */
- xcb_change_save_set(conn, XCB_SET_MODE_INSERT, child);
-
- /* Generate a graphics context for the titlebar */
- new->titlegc = xcb_generate_id(conn);
- xcb_create_gc(conn, new->titlegc, new->frame, 0, 0);
-
- /* Moves the original window into the new frame we've created for it */
- new->awaiting_useless_unmap = true;
- xcb_void_cookie_t cookie = xcb_reparent_window_checked(conn, child, new->frame, 0, font->height);
- if (xcb_request_check(conn, cookie) != NULL) {
- LOG("Could not reparent the window, aborting\n");
- xcb_destroy_window(conn, new->frame);
- free(new);
- return;
- }
-
- /* Put our data structure (Client) into the table */
- table_put(&by_parent, new->frame, new);
- table_put(&by_child, child, new);