i3 - improved tiling WM


Reply to _NET_REQUEST_FRAME_EXTENTS correctly

Patch status: merged

Patch by Tony Crisci

Long description:

Reply to _NET_REQUEST_FRAME_EXTENTS by settings _NET_FRAME_EXTENTS
property of the window to widths of the respective borders added by i3.

fixes #1093
fixes #1069

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

b/src/handlers.c

18
@@ -706,35 +706,26 @@ static void handle_client_message(xcb_client_message_event_t *event) {
19
         xcb_flush(conn);
20
         free(reply);
21
     } else if (event->type == A__NET_REQUEST_FRAME_EXTENTS) {
22
-        // A client can request an estimate for the frame size which the window
23
-        // manager will put around it before actually mapping its window. Java
24
-        // does this (as of openjdk-7).
25
-        //
26
-        // Note that the calculation below is not entirely accurate — once you
27
-        // set a different border type, it’s off. We _could_ request all the
28
-        // window properties (which have to be set up at this point according
29
-        // to EWMH), but that seems rather elaborate. The standard explicitly
30
-        // says the application must cope with an estimate that is not entirely
31
-        // accurate.
32
+        /*
33
+         * A client can request an estimate for the frame size which the window
34
+         * manager will put around it before actually mapping its window. Java
35
+         * does this (as of openjdk-7).
36
+         *
37
+         * Note that the calculation below is not entirely accurate — once you
38
+         * set a different border type, it’s off. We _could_ request all the
39
+         * window properties (which have to be set up at this point according
40
+         * to EWMH), but that seems rather elaborate. The standard explicitly
41
+         * says the application must cope with an estimate that is not entirely
42
+         * accurate.
43
+         */
44
         DLOG("_NET_REQUEST_FRAME_EXTENTS for window 0x%08x\n", event->window);
45
-        xcb_get_geometry_reply_t *geometry;
46
-        xcb_get_geometry_cookie_t cookie = xcb_get_geometry(conn, event->window);
47
-
48
-        if (!(geometry = xcb_get_geometry_reply(conn, cookie, NULL))) {
49
-            ELOG("Could not get geometry of X11 window 0x%08x while handling "
50
-                 "the _NET_REQUEST_FRAME_EXTENTS ClientMessage\n",
51
-                 event->window);
52
-            return;
53
-        }
54
-
55
-        DLOG("Current geometry = x=%d, y=%d, width=%d, height=%d\n",
56
-             geometry->x, geometry->y, geometry->width, geometry->height);
57
 
58
+        /* The reply data: approximate frame size */
59
         Rect r = {
60
-            0, // left
61
-            geometry->width + 4, // right
62
-            0, // top
63
-            geometry->height + config.font.height + 5, // bottom
64
+            config.default_border_width, /* left */
65
+            config.default_border_width, /* right */
66
+            config.font.height + 5, /* top */
67
+            config.default_border_width /* bottom */
68
         };
69
         xcb_change_property(
70
                 conn,