i3bar: Send mouse wheel events to child too
Patch status: superseded
Patch by Quentin Glidic
Long description:
Signed-off-by: Quentin Glidic <sardemff7+git@sardemff7.net>
To apply this patch, use:
curl http://cr.i3wm.org/patch/477/raw.patch | git am
b/i3bar/include/child.h
16 |
@@ -74,6 +74,12 @@ void stop_child(void); |
17 |
void cont_child(void); |
18 |
|
19 |
/* |
20 |
+ * Whether or not the child want click events |
21 |
+ * |
22 |
+ */ |
23 |
+bool child_want_click_events(void); |
24 |
+ |
25 |
+/* |
26 |
* Generates a click event, if enabled. |
27 |
* |
28 |
*/ |
b/i3bar/src/child.c
33 |
@@ -624,3 +624,11 @@ void cont_child(void) { |
34 |
killpg(child.pid, child.cont_signal); |
35 |
} |
36 |
} |
37 |
+ |
38 |
+/* |
39 |
+ * Whether or not the child want click events |
40 |
+ * |
41 |
+ */ |
42 |
+bool child_want_click_events(void) { |
43 |
+ return child.click_events; |
44 |
+} |
b/i3bar/src/xcb.c
49 |
@@ -330,6 +330,38 @@ void handle_button(xcb_button_press_event_t *event) { |
50 |
|
51 |
DLOG("Got Button %d\n", event->detail); |
52 |
|
53 |
+ if (child_want_click_events()) { |
54 |
+ /* If the child asked for click events, |
55 |
+ * check if a status block has been clicked. */ |
56 |
+ |
57 |
+ /* First calculate width of tray area */ |
58 |
+ trayclient *trayclient; |
59 |
+ int tray_width = 0; |
60 |
+ TAILQ_FOREACH_REVERSE(trayclient, walk->trayclients, tc_head, tailq) { |
61 |
+ if (!trayclient->mapped) |
62 |
+ continue; |
63 |
+ tray_width += (font.height + 2); |
64 |
+ } |
65 |
+ |
66 |
+ int block_x = 0, last_block_x; |
67 |
+ int offset = (walk->rect.w - (statusline_width + tray_width)) - 10; |
68 |
+ |
69 |
+ x = original_x - offset; |
70 |
+ if (x >= 0) { |
71 |
+ struct status_block *block; |
72 |
+ |
73 |
+ TAILQ_FOREACH(block, &statusline_head, blocks) { |
74 |
+ last_block_x = block_x; |
75 |
+ block_x += block->width + block->x_offset + block->x_append; |
76 |
+ |
77 |
+ if (x <= block_x && x >= last_block_x) { |
78 |
+ send_block_clicked(event->detail, block->name, block->instance, event->root_x, event->root_y); |
79 |
+ return; |
80 |
+ } |
81 |
+ } |
82 |
+ } |
83 |
+ } |
84 |
+ |
85 |
switch (event->detail) { |
86 |
case 4: |
87 |
/* Mouse wheel up. We select the previous ws, if any. |
88 |
@@ -351,7 +383,7 @@ void handle_button(xcb_button_press_event_t *event) { |
89 |
|
90 |
cur_ws = TAILQ_NEXT(cur_ws, tailq); |
91 |
break; |
92 |
- default: |
93 |
+ case 1: |
94 |
/* Check if this event regards a workspace button */ |
95 |
TAILQ_FOREACH(cur_ws, walk->workspaces, tailq) { |
96 |
DLOG("x = %d\n", x); |
97 |
@@ -360,42 +392,10 @@ void handle_button(xcb_button_press_event_t *event) { |
98 |
} |
99 |
x -= cur_ws->name_width + 11; |
100 |
} |
101 |
- if (cur_ws == NULL) { |
102 |
- /* No workspace button was pressed. |
103 |
- * Check if a status block has been clicked. |
104 |
- * This of course only has an effect, |
105 |
- * if the child reported bidirectional protocol usage. */ |
106 |
- |
107 |
- /* First calculate width of tray area */ |
108 |
- trayclient *trayclient; |
109 |
- int tray_width = 0; |
110 |
- TAILQ_FOREACH_REVERSE(trayclient, walk->trayclients, tc_head, tailq) { |
111 |
- if (!trayclient->mapped) |
112 |
- continue; |
113 |
- tray_width += (font.height + 2); |
114 |
- } |
115 |
- |
116 |
- int block_x = 0, last_block_x; |
117 |
- int offset = (walk->rect.w - (statusline_width + tray_width)) - 10; |
118 |
- |
119 |
- x = original_x - offset; |
120 |
- if (x < 0) |
121 |
- return; |
122 |
- |
123 |
- struct status_block *block; |
124 |
- |
125 |
- TAILQ_FOREACH(block, &statusline_head, blocks) { |
126 |
- last_block_x = block_x; |
127 |
- block_x += block->width + block->x_offset + block->x_append; |
128 |
- |
129 |
- if (x <= block_x && x >= last_block_x) { |
130 |
- send_block_clicked(event->detail, block->name, block->instance, event->root_x, event->root_y); |
131 |
- return; |
132 |
- } |
133 |
- } |
134 |
+ if (cur_ws == NULL) |
135 |
return; |
136 |
- } |
137 |
- if (event->detail != 1) |
138 |
+ break; |
139 |
+ default: |
140 |
return; |
141 |
} |
142 |
|