i3 - improved tiling WM


i3bar: Realign tray clients on UnmapNotify

Patch status: superseded

Patch by Tony Crisci

Long description:

UnmapNotify events are interpreted by i3bar as an action taken by an
application to hide its tray window. We respond by adjusting the size of
the tray window and realigning any tray clients that remain. This will
close the gap left by the unmapping window.

Breaking change! The tray will not be properly readjusted if the
application remaps its tray window.

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

b/i3bar/src/xcb.c

20
@@ -433,8 +433,9 @@ void handle_button(xcb_button_press_event_t *event) {
21
 }
22
 
23
 /*
24
- * Configures the x coordinate of all trayclients. To be called after adding a
25
- * new tray client or removing an old one.
26
+ * Adjusts the size of the tray window and alignment of the tray clients by
27
+ * configuring their respective x coordinates. To be called when mapping or
28
+ * unmapping a tray client window.
29
  *
30
  */
31
 static void configure_trayclients(void) {
32
@@ -656,8 +657,8 @@ static void handle_destroy_notify(xcb_destroy_notify_event_t* event) {
33
 }
34
 
35
 /*
36
- * Handles UnmapNotify events. These events happen when a tray window unmaps
37
- * itself. We then update our data structure
38
+ * Handles UnmapNotify events. These events happen when a tray client hides its
39
+ * window. We respond by realigning the tray clients.
40
  *
41
  */
42
 static void handle_unmap_notify(xcb_unmap_notify_event_t* event) {
43
@@ -673,8 +674,8 @@ static void handle_unmap_notify(xcb_unmap_notify_event_t* event) {
44
             if (trayclient->win != event->window)
45
                 continue;
46
 
47
-            DLOG("Removing tray client with window ID %08x\n", event->window);
48
-            TAILQ_REMOVE(walk->trayclients, trayclient, tailq);
49
+            DLOG("Tray client unmapped (window ID %08x). Adjusting tray.\n", event->window);
50
+            trayclient->mapped = false;
51
 
52
             /* Trigger an update, we now have more space for the statusline */
53
             configure_trayclients();
54
@@ -836,7 +837,7 @@ void xcb_chk_cb(struct ev_loop *loop, ev_check *watcher, int revents) {
55
                 handle_destroy_notify((xcb_destroy_notify_event_t*) event);
56
                 break;
57
             case XCB_UNMAP_NOTIFY:
58
-                /* UnmapNotifies are received when a tray window unmaps itself */
59
+                /* UnmapNotify is received when a tray client hides its window. */
60
                 handle_unmap_notify((xcb_unmap_notify_event_t*) event);
61
                 break;
62
             case XCB_PROPERTY_NOTIFY: