Codebase list i3-gaps / 3310253
Merge remote-tracking branch 'vanilla/next' into gaps-next Ingo Bürk 3 years ago
5 changed file(s) with 27 addition(s) and 10 deletion(s). Raw diff Collapse all Expand all
2727 • mention rofi in default config file
2828 • i3-input: add different exit codes for when i3-input fails
2929 • allow ppt values in move direction and move position commands
30 • i3bar: add coordinates relative to the current output in i3bar click events
3031
3132 ┌────────────────────────────┐
3233 │ Bugfixes │
259259 relative_x, relative_y::
260260 Coordinates where the click occurred, with respect to the top left corner
261261 of the block
262 output_x, output_y::
263 Coordinates relative to the current output where the click occurred
262264 width, height::
263265 Width and height (in px) of the block
264266 modifiers::
272274 "instance": "eth0",
273275 "button": 1,
274276 "modifiers": ["Shift", "Mod1"],
275 "x": 1320,
277 "x": 1925,
276278 "y": 1400,
277279 "relative_x": 12,
278280 "relative_y": 8,
281 "output_x": 5,
282 "output_y": 1400,
279283 "width": 50,
280284 "height": 22
281285 }
8484 * Generates a click event, if enabled.
8585 *
8686 */
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);
633633 * Generates a click event, if enabled.
634634 *
635635 */
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) {
637637 if (!child.click_events) {
638638 return;
639639 }
685685 ystr("relative_y");
686686 yajl_gen_integer(gen, y_rel);
687687
688 ystr("output_x");
689 yajl_gen_integer(gen, out_x);
690
691 ystr("output_y");
692 yajl_gen_integer(gen, out_y);
693
688694 ystr("width");
689695 yajl_gen_integer(gen, width);
690696
442442 return false;
443443 }
444444
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) {
446446 if (statusline_x > (uint32_t)output->statusline_width) {
447447 return;
448448 }
471471 /* x of the click event relative to the current block. */
472472 const uint32_t relative_x = statusline_x - last_block_x;
473473 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
474477 send_block_clicked(event->detail, block->name, block->instance,
475478 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,
477481 event->state);
478482 return;
479483 }
541545 /* Calculate the horizontal coordinate (x) of the start of the
542546 * statusline by subtracting its width and the width of the tray from
543547 * 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) {
547551 /* Click was after the start of the statusline, return to avoid
548552 * executing any other actions even if a click event is not
549553 * produced eventually. */
551555 if (!event_is_release) {
552556 /* x of the click event relative to the start of the
553557 * 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);
556562 }
557563
558564 return;