@@ -89,9 +89,17 @@ static void render_sharp_line(cairo_t *cairo, uint32_t color,
89
89
}
90
90
}
91
91
92
+ static void block_hotspot_callback (struct swaybar_output * output ,
93
+ int x , int y , uint32_t button , void * data ) {
94
+ struct i3bar_block * block = data ;
95
+ struct status_line * status = output -> bar -> status ;
96
+ i3bar_block_send_click (status , block , x , y , button );
97
+ }
98
+
92
99
static uint32_t render_status_block (cairo_t * cairo ,
93
- struct swaybar_config * config , struct i3bar_block * block ,
94
- double * x , uint32_t height , bool focused , bool edge ) {
100
+ struct swaybar_config * config , struct swaybar_output * output ,
101
+ struct i3bar_block * block , double * x ,
102
+ uint32_t height , bool focused , bool edge ) {
95
103
static const int margin = 3 ;
96
104
if (!block -> full_text || !* block -> full_text ) {
97
105
return 0 ;
@@ -139,7 +147,15 @@ static uint32_t render_status_block(cairo_t *cairo,
139
147
* x -= margin ;
140
148
}
141
149
142
- // TODO: Create hotspot here
150
+ struct swaybar_hotspot * hotspot = calloc (1 , sizeof (struct swaybar_hotspot ));
151
+ hotspot -> x = * x ;
152
+ hotspot -> y = 0 ;
153
+ hotspot -> width = width ;
154
+ hotspot -> height = height ;
155
+ hotspot -> callback = block_hotspot_callback ;
156
+ hotspot -> destroy = free ;
157
+ hotspot -> data = block ;
158
+ wl_list_insert (& output -> hotspots , & hotspot -> link );
143
159
144
160
double pos = * x ;
145
161
if (block -> background ) {
@@ -208,13 +224,14 @@ static uint32_t render_status_block(cairo_t *cairo,
208
224
}
209
225
210
226
static uint32_t render_status_line_i3bar (cairo_t * cairo ,
211
- struct swaybar_config * config , struct status_line * status ,
212
- bool focused , double * x , uint32_t width , uint32_t height ) {
227
+ struct swaybar_config * config , struct swaybar_output * output ,
228
+ struct status_line * status , bool focused ,
229
+ double * x , uint32_t width , uint32_t height ) {
213
230
struct i3bar_block * block ;
214
231
uint32_t max_height = 0 ;
215
232
bool edge = true;
216
233
wl_list_for_each_reverse (block , & status -> blocks , link ) {
217
- uint32_t h = render_status_block (cairo , config ,
234
+ uint32_t h = render_status_block (cairo , config , output ,
218
235
block , x , height , focused , edge );
219
236
max_height = h > max_height ? h : max_height ;
220
237
edge = false;
@@ -223,8 +240,9 @@ static uint32_t render_status_line_i3bar(cairo_t *cairo,
223
240
}
224
241
225
242
static uint32_t render_status_line (cairo_t * cairo ,
226
- struct swaybar_config * config , struct status_line * status ,
227
- bool focused , double * x , uint32_t width , uint32_t height ) {
243
+ struct swaybar_config * config , struct swaybar_output * output ,
244
+ struct status_line * status , bool focused ,
245
+ double * x , uint32_t width , uint32_t height ) {
228
246
switch (status -> protocol ) {
229
247
case PROTOCOL_ERROR :
230
248
return render_status_line_error (cairo ,
@@ -233,8 +251,8 @@ static uint32_t render_status_line(cairo_t *cairo,
233
251
return render_status_line_text (cairo ,
234
252
config , status -> text , focused , x , width , height );
235
253
case PROTOCOL_I3BAR :
236
- return render_status_line_i3bar (cairo ,
237
- config , status , focused , x , width , height );
254
+ return render_status_line_i3bar (cairo , config , output , status ,
255
+ focused , x , width , height );
238
256
case PROTOCOL_UNDEF :
239
257
return 0 ;
240
258
}
@@ -344,8 +362,8 @@ static uint32_t render_workspace_button(cairo_t *cairo,
344
362
struct swaybar_hotspot * hotspot = calloc (1 , sizeof (struct swaybar_hotspot ));
345
363
hotspot -> x = * x ;
346
364
hotspot -> y = 0 ;
347
- hotspot -> height = height ;
348
365
hotspot -> width = width ;
366
+ hotspot -> height = height ;
349
367
hotspot -> callback = workspace_hotspot_callback ;
350
368
hotspot -> destroy = free ;
351
369
hotspot -> data = strdup (name );
@@ -391,7 +409,7 @@ static uint32_t render_to_cairo(cairo_t *cairo,
391
409
}
392
410
x = output -> width ;
393
411
if (bar -> status ) {
394
- uint32_t h = render_status_line (cairo , config , bar -> status ,
412
+ uint32_t h = render_status_line (cairo , config , output , bar -> status ,
395
413
output -> focused , & x , output -> width , output -> height );
396
414
max_height = h > max_height ? h : max_height ;
397
415
}
0 commit comments