i3 - improved tiling WM


Really do not create con pixmap when not needed

Patch status: merged

Patch by Tony Crisci

Long description:

The pixmap of a borderless leaf container will not be used except
for the titlebar in a stack or tabs.

Make sure these containers do not (really) need a pixmap because it can
only get in the way.

fixes #1013

To apply this patch, use:
curl http://cr.i3wm.org/patch/401/raw.patch | git am

b/src/x.c

20
@@ -667,9 +667,24 @@ void x_push_node(Con *con) {
21
         /* As the pixmap only depends on the size and not on the position, it
22
          * is enough to check if width/height have changed. Also, we don’t
23
          * create a pixmap at all when the window is actually not visible
24
-         * (height == 0). */
25
-        if ((state->rect.width != rect.width ||
26
-            state->rect.height != rect.height)) {
27
+         * (height == 0) or when it is not needed. */
28
+        bool has_rect_changed = (state->rect.width != rect.width || state->rect.height != rect.height);
29
+
30
+        /* The pixmap of a borderless leaf container will not be used except
31
+         * for the titlebar in a stack or tabs (issue #1013). */
32
+        bool is_pixmap_needed = (con->border_style != BS_NONE ||
33
+                !con_is_leaf(con) ||
34
+                con->parent->layout == L_STACKED ||
35
+                con->parent->layout == L_TABBED);
36
+
37
+        /* Check if the container has an unneeded pixmap left over from
38
+         * previously having a border or titlebar. */
39
+        if (!is_pixmap_needed && con->pixmap != XCB_NONE) {
40
+            xcb_free_pixmap(conn, con->pixmap);
41
+            con->pixmap = XCB_NONE;
42
+        }
43
+
44
+        if (has_rect_changed && is_pixmap_needed) {
45
             if (con->pixmap == 0) {
46
                 con->pixmap = xcb_generate_id(conn);
47
                 con->pm_gc = xcb_generate_id(conn);