From b0c39b6dc3bf5bcfb6e8a03a0fa1e39dc8317993 Mon Sep 17 00:00:00 2001 From: speedie Date: Sun, 18 Jun 2023 22:55:45 +0200 Subject: [PATCH] Remove single line clicks as they're not very useful, and fix clicks when item powerlines are enabled --- libs/wl/wayland.c | 31 ++++--------------------------- libs/x11/mouse.c | 30 ++---------------------------- 2 files changed, 6 insertions(+), 55 deletions(-) diff --git a/libs/wl/wayland.c b/libs/wl/wayland.c index 8ccdc6e..9a55c31 100644 --- a/libs/wl/wayland.c +++ b/libs/wl/wayland.c @@ -275,14 +275,14 @@ void buttonpress_wl(uint32_t button, double ex, double ey) { for (item = curr; item != next; item = item->right) { if (item_num++ == lines) { item_num = 1; - x += w / columns; + x += w / columns + (powerlineitems ? plw : 0); y = 0; } y += h; // ClickSelItem, called function doesn't matter - if (ey >= y && ey <= (y + h) && ex >= x && ex <= (x + w / columns)) { + if (ey >= y && ey <= (y + h) && ex + (powerlineitems ? plw : 0) >= x + (powerlineitems ? plw : 0) && ex + (powerlineitems ? plw : 0) <= (x + w / columns) + (powerlineitems ? plw : 0)) { for (i = 0; i < LENGTH(wl_buttons); i++) { if (ignoreglobalmouse) break; if (wl_buttons[i].click == ClickSelItem && wl_buttons[i].button == button) { @@ -306,40 +306,17 @@ void buttonpress_wl(uint32_t button, double ex, double ey) { } else if (matches) { x += inputw; w = larrowWidth; + if (prev && curr->left) { if (ex >= x && ex <= x + w) { click = ClickLArrow; } } - for (item = curr; item != next; item = item->right) { - x += w; - w = MIN(TEXTW(item->text), mw - x - rarrowWidth); - if (ex >= x && ex <= x + w) { - for (i = 0; i < LENGTH(wl_buttons); i++) { - if (ignoreglobalmouse) break; - if (wl_buttons[i].click == ClickSelItem && wl_buttons[i].button == button) { - puts(item->text); - exit(0); - } else if (wl_buttons[i].click == ClickItem) { - click = ClickItem; - } - } - for (i = 0; i < LENGTH(wl_cbuttons); i++) { - if (ignoreconfmouse) break; - if (wl_cbuttons[i].click == ClickSelItem && wl_cbuttons[i].button == button) { - puts(item->text); - exit(0); - } else if (wl_cbuttons[i].click == ClickItem) { - click = ClickItem; - } - } - - } - } // right arrow w = rarrowWidth; x = mw - w; + if (next && ex >= x && ex <= x + w) { click = ClickRArrow; } diff --git a/libs/x11/mouse.c b/libs/x11/mouse.c index 8d3bf9c..78aac39 100644 --- a/libs/x11/mouse.c +++ b/libs/x11/mouse.c @@ -67,7 +67,7 @@ void buttonpress_x11(XEvent *e) { y += h; // ClickSelItem, called function doesn't matter - if (ev->y >= y && ev->y <= (y + h) && ev->x >= x && ev->x <= (x + w / columns)) { + if (ev->y >= y && ev->y <= (y + h) && ev->x + (powerlineitems ? plw : 0) >= x + (powerlineitems ? plw : 0) && ev->x + (powerlineitems ? plw : 0) <= (x + w / columns) + (powerlineitems ? plw : 0)) { for (i = 0; i < LENGTH(buttons); i++) { if (ignoreglobalmouse) break; if (buttons[i].click == ClickSelItem && buttons[i].button == ev->button) { @@ -89,41 +89,15 @@ void buttonpress_x11(XEvent *e) { } } } else if (matches) { // a single line, meaning it could be arrows too, so we check that here - // left arrow x += inputw; w = larrowWidth; + if (prev && curr->left) { if (ev->x >= x && ev->x <= x + w) { click = ClickLArrow; } } - // item click - // horizontal list - for (item = curr; item != next; item = item->right) { - x += w; - w = MIN(TEXTW(item->text), mw - x - rarrowWidth); - if (ev->x >= x && ev->x <= x + w) { - for (i = 0; i < LENGTH(buttons); i++) { - if (ignoreglobalmouse) break; - if (buttons[i].click == ClickSelItem && buttons[i].button == ev->button) { - puts(item->text); - exit(0); - } else if (buttons[i].click == ClickItem) { - click = ClickItem; - } - } - for (i = 0; i < LENGTH(cbuttons); i++) { - if (ignoreconfmouse) break; - if (cbuttons[i].click == ClickSelItem && cbuttons[i].button == ev->button) { - puts(item->text); - exit(0); - } else if (cbuttons[i].click == ClickItem) { - click = ClickItem; - } - } - } - } // right arrow w = rarrowWidth; x = mw - w;