Merge remote-tracking branch 'vanilla/next' into gaps-next
Ingo Bürk
3 years ago
27 | 27 | • mention rofi in default config file |
28 | 28 | • i3-input: add different exit codes for when i3-input fails |
29 | 29 | • allow ppt values in move direction and move position commands |
30 | • i3bar: add coordinates relative to the current output in i3bar click events | |
30 | 31 | |
31 | 32 | ┌────────────────────────────┐ |
32 | 33 | │ Bugfixes │ |
259 | 259 | relative_x, relative_y:: |
260 | 260 | Coordinates where the click occurred, with respect to the top left corner |
261 | 261 | of the block |
262 | output_x, output_y:: | |
263 | Coordinates relative to the current output where the click occurred | |
262 | 264 | width, height:: |
263 | 265 | Width and height (in px) of the block |
264 | 266 | modifiers:: |
272 | 274 | "instance": "eth0", |
273 | 275 | "button": 1, |
274 | 276 | "modifiers": ["Shift", "Mod1"], |
275 | "x": 1320, | |
277 | "x": 1925, | |
276 | 278 | "y": 1400, |
277 | 279 | "relative_x": 12, |
278 | 280 | "relative_y": 8, |
281 | "output_x": 5, | |
282 | "output_y": 1400, | |
279 | 283 | "width": 50, |
280 | 284 | "height": 22 |
281 | 285 | } |
84 | 84 | * Generates a click event, if enabled. |
85 | 85 | * |
86 | 86 | */ |
87 | void send_block_clicked(int button, const char *name, const char *instance, int x, int y, int x_rel, int y_rel, int width, int height, int mods); | |
87 | void send_block_clicked(int button, const char *name, const char *instance, int x, int y, int x_rel, int y_rel, int out_x, int out_y, int width, int height, int mods); |
633 | 633 | * Generates a click event, if enabled. |
634 | 634 | * |
635 | 635 | */ |
636 | void send_block_clicked(int button, const char *name, const char *instance, int x, int y, int x_rel, int y_rel, int width, int height, int mods) { | |
636 | void send_block_clicked(int button, const char *name, const char *instance, int x, int y, int x_rel, int y_rel, int out_x, int out_y, int width, int height, int mods) { | |
637 | 637 | if (!child.click_events) { |
638 | 638 | return; |
639 | 639 | } |
685 | 685 | ystr("relative_y"); |
686 | 686 | yajl_gen_integer(gen, y_rel); |
687 | 687 | |
688 | ystr("output_x"); | |
689 | yajl_gen_integer(gen, out_x); | |
690 | ||
691 | ystr("output_y"); | |
692 | yajl_gen_integer(gen, out_y); | |
693 | ||
688 | 694 | ystr("width"); |
689 | 695 | yajl_gen_integer(gen, width); |
690 | 696 |
442 | 442 | return false; |
443 | 443 | } |
444 | 444 | |
445 | static void child_handle_button(xcb_button_press_event_t *event, i3_output *output, uint32_t statusline_x) { | |
445 | static void child_handle_button(xcb_button_press_event_t *event, i3_output *output, uint32_t statusline_x, uint32_t statusline_y) { | |
446 | 446 | if (statusline_x > (uint32_t)output->statusline_width) { |
447 | 447 | return; |
448 | 448 | } |
471 | 471 | /* x of the click event relative to the current block. */ |
472 | 472 | const uint32_t relative_x = statusline_x - last_block_x; |
473 | 473 | if (relative_x <= full_render_width) { |
474 | const uint32_t output_x = event->event_x; | |
475 | const uint32_t output_y = statusline_y + event->event_y; | |
476 | ||
474 | 477 | send_block_clicked(event->detail, block->name, block->instance, |
475 | 478 | event->root_x, event->root_y, relative_x, |
476 | event->event_y, full_render_width, bar_height, | |
479 | event->event_y, output_x, output_y, | |
480 | full_render_width, bar_height, | |
477 | 481 | event->state); |
478 | 482 | return; |
479 | 483 | } |
541 | 545 | /* Calculate the horizontal coordinate (x) of the start of the |
542 | 546 | * statusline by subtracting its width and the width of the tray from |
543 | 547 | * the bar width. */ |
544 | const int offset = walk->rect.w - walk->statusline_width - | |
545 | tray_width - logical_px((tray_width > 0) * sb_hoff_px); | |
546 | if (x >= offset) { | |
548 | const int offset_x = walk->rect.w - walk->statusline_width - | |
549 | tray_width - logical_px((tray_width > 0) * sb_hoff_px); | |
550 | if (x >= offset_x) { | |
547 | 551 | /* Click was after the start of the statusline, return to avoid |
548 | 552 | * executing any other actions even if a click event is not |
549 | 553 | * produced eventually. */ |
551 | 555 | if (!event_is_release) { |
552 | 556 | /* x of the click event relative to the start of the |
553 | 557 | * statusline. */ |
554 | const uint32_t statusline_x = x - offset; | |
555 | child_handle_button(event, walk, statusline_x); | |
558 | const uint32_t statusline_x = x - offset_x; | |
559 | const uint32_t statusline_y = event->root_y - walk->rect.y - event->event_y; | |
560 | ||
561 | child_handle_button(event, walk, statusline_x, statusline_y); | |
556 | 562 | } |
557 | 563 | |
558 | 564 | return; |