]> git.sur5r.net Git - i3/i3/commitdiff
i3bar: Send mouse wheel events to child too
authorQuentin Glidic <sardemff7+git@sardemff7.net>
Thu, 13 Mar 2014 12:58:15 +0000 (13:58 +0100)
committerMichael Stapelberg <michael@stapelberg.de>
Fri, 21 Mar 2014 18:30:17 +0000 (19:30 +0100)
Signed-off-by: Quentin Glidic <sardemff7+git@sardemff7.net>
i3bar/include/child.h
i3bar/src/child.c
i3bar/src/xcb.c

index 493292692dfb56d9f4f493361f62458f8af60dea..72272b24c71440907d0e02da40dba4cb2934e6bf 100644 (file)
@@ -73,6 +73,12 @@ void stop_child(void);
  */
 void cont_child(void);
 
+/*
+ * Whether or not the child want click events
+ *
+ */
+bool child_want_click_events(void);
+
 /*
  * Generates a click event, if enabled.
  *
index cfdf911c11442866176ce158293dd2952befcefc..53aef2fa50e65257fc5ab9d2f67593904205d61b 100644 (file)
@@ -624,3 +624,11 @@ void cont_child(void) {
         killpg(child.pid, child.cont_signal);
     }
 }
+
+/*
+ * Whether or not the child want click events
+ *
+ */
+bool child_want_click_events(void) {
+    return child.click_events;
+}
index 928771d8d214d0488f3bbd8e4c968b07f311ba0b..5204d716370f0a04f8639c08314b695052c403b8 100644 (file)
@@ -330,6 +330,39 @@ void handle_button(xcb_button_press_event_t *event) {
 
     DLOG("Got Button %d\n", event->detail);
 
+    if (child_want_click_events()) {
+        /* If the child asked for click events,
+         * check if a status block has been clicked. */
+
+        /* First calculate width of tray area */
+        trayclient *trayclient;
+        int tray_width = 0;
+        TAILQ_FOREACH_REVERSE(trayclient, walk->trayclients, tc_head, tailq) {
+            if (!trayclient->mapped)
+                continue;
+            tray_width += (font.height + 2);
+        }
+
+        int block_x = 0, last_block_x;
+        int offset = (walk->rect.w - (statusline_width + tray_width)) - 10;
+
+        x = original_x - offset;
+        if (x >= 0) {
+            struct status_block *block;
+
+            TAILQ_FOREACH(block, &statusline_head, blocks) {
+                last_block_x = block_x;
+                block_x += block->width + block->x_offset + block->x_append;
+
+                if (x <= block_x && x >= last_block_x) {
+                    send_block_clicked(event->detail, block->name, block->instance, event->root_x, event->root_y);
+                    return;
+                }
+            }
+        }
+        x = original_x;
+    }
+
     switch (event->detail) {
         case 4:
             /* Mouse wheel up. We select the previous ws, if any.
@@ -351,7 +384,7 @@ void handle_button(xcb_button_press_event_t *event) {
 
             cur_ws = TAILQ_NEXT(cur_ws, tailq);
             break;
-        default:
+        case 1:
             /* Check if this event regards a workspace button */
             TAILQ_FOREACH(cur_ws, walk->workspaces, tailq) {
                 DLOG("x = %d\n", x);
@@ -360,43 +393,11 @@ void handle_button(xcb_button_press_event_t *event) {
                 }
                 x -= cur_ws->name_width + 11;
             }
-            if (cur_ws == NULL) {
-                /* No workspace button was pressed.
-                 * Check if a status block has been clicked.
-                 * This of course only has an effect,
-                 * if the child reported bidirectional protocol usage. */
-
-                /* First calculate width of tray area */
-                trayclient *trayclient;
-                int tray_width = 0;
-                TAILQ_FOREACH_REVERSE(trayclient, walk->trayclients, tc_head, tailq) {
-                    if (!trayclient->mapped)
-                        continue;
-                    tray_width += (font.height + 2);
-                }
-
-                int block_x = 0, last_block_x;
-                int offset = (walk->rect.w - (statusline_width + tray_width)) - 10;
-
-                x = original_x - offset;
-                if (x < 0)
-                    return;
-
-                struct status_block *block;
-
-                TAILQ_FOREACH(block, &statusline_head, blocks) {
-                    last_block_x = block_x;
-                    block_x += block->width + block->x_offset + block->x_append;
-
-                    if (x <= block_x && x >= last_block_x) {
-                        send_block_clicked(event->detail, block->name, block->instance, event->root_x, event->root_y);
-                        return;
-                    }
-                }
-                return;
-            }
-            if (event->detail != 1)
+            if (cur_ws == NULL)
                 return;
+            break;
+        default:
+            return;
     }
 
     /* To properly handle workspace names with double quotes in them, we need