i3 - improved tiling WM


Delegate click handling to dock clients

Patch status: merged

Patch by Tony Crisci

Long description:

Do not handle click events on dock clients because they are not managed
windows. Dock clients are responsible for sending the message to i3 to
focus a workspace if that is appropriate. i3bar now sends the message to
focus the correct workspace when that is appropriate.

Otherwise, it could interfere with the dock clients own click handling,
which could be an action to focus a different workspace than i3 had
assumed, such as would be the case with a workspace widget.

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

b/i3bar/src/xcb.c

22
@@ -393,8 +393,20 @@ void handle_button(xcb_button_press_event_t *event) {
23
                 }
24
                 x -= cur_ws->name_width + logical_px(11);
25
             }
26
+
27
+            /* Otherwise, focus our currently visible workspace if it is not
28
+             * already focused */
29
+            if (cur_ws == NULL) {
30
+                TAILQ_FOREACH(cur_ws, walk->workspaces, tailq) {
31
+                    if (cur_ws->visible && !cur_ws->focused)
32
+                        break;
33
+                }
34
+            }
35
+
36
+            /* if there is nothing to focus, we are done */
37
             if (cur_ws == NULL)
38
                 return;
39
+
40
             break;
41
         default:
42
             return;

b/src/click.c

47
@@ -171,6 +171,10 @@ static int route_click(Con *con, xcb_button_press_event_t *event, const bool mod
48
     DLOG("--> OUTCOME = %p\n", con);
49
     DLOG("type = %d, name = %s\n", con->type, con->name);
50
 
51
+    /* don’t handle dockarea cons, they must not be focused */
52
+    if (con->parent->type == CT_DOCKAREA)
53
+        goto done;
54
+
55
     /* Any click in a workspace should focus that workspace. If the
56
      * workspace is on another output we need to do a workspace_show in
57
      * order for i3bar (and others) to notice the change in workspace. */
58
@@ -187,10 +191,6 @@ static int route_click(Con *con, xcb_button_press_event_t *event, const bool mod
59
         workspace_show(ws);
60
     focused_id = XCB_NONE;
61
 
62
-    /* don’t handle dockarea cons, they must not be focused */
63
-    if (con->parent->type == CT_DOCKAREA)
64
-        goto done;
65
-
66
     /* get the floating con */
67
     Con *floatingcon = con_inside_floating(con);
68
     const bool proportional = (event->state & BIND_SHIFT);