Remove single line clicks as they're not very useful, and fix clicks

when item powerlines are enabled
This commit is contained in:
speedie 2023-06-18 22:55:45 +02:00
parent 618dc15530
commit b0c39b6dc3
2 changed files with 6 additions and 55 deletions

View file

@ -275,14 +275,14 @@ void buttonpress_wl(uint32_t button, double ex, double ey) {
for (item = curr; item != next; item = item->right) { for (item = curr; item != next; item = item->right) {
if (item_num++ == lines) { if (item_num++ == lines) {
item_num = 1; item_num = 1;
x += w / columns; x += w / columns + (powerlineitems ? plw : 0);
y = 0; y = 0;
} }
y += h; y += h;
// ClickSelItem, called function doesn't matter // 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++) { for (i = 0; i < LENGTH(wl_buttons); i++) {
if (ignoreglobalmouse) break; if (ignoreglobalmouse) break;
if (wl_buttons[i].click == ClickSelItem && wl_buttons[i].button == button) { 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) { } else if (matches) {
x += inputw; x += inputw;
w = larrowWidth; w = larrowWidth;
if (prev && curr->left) { if (prev && curr->left) {
if (ex >= x && ex <= x + w) { if (ex >= x && ex <= x + w) {
click = ClickLArrow; 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 // right arrow
w = rarrowWidth; w = rarrowWidth;
x = mw - w; x = mw - w;
if (next && ex >= x && ex <= x + w) { if (next && ex >= x && ex <= x + w) {
click = ClickRArrow; click = ClickRArrow;
} }

View file

@ -67,7 +67,7 @@ void buttonpress_x11(XEvent *e) {
y += h; y += h;
// ClickSelItem, called function doesn't matter // 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++) { for (i = 0; i < LENGTH(buttons); i++) {
if (ignoreglobalmouse) break; if (ignoreglobalmouse) break;
if (buttons[i].click == ClickSelItem && buttons[i].button == ev->button) { 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 } else if (matches) { // a single line, meaning it could be arrows too, so we check that here
// left arrow
x += inputw; x += inputw;
w = larrowWidth; w = larrowWidth;
if (prev && curr->left) { if (prev && curr->left) {
if (ev->x >= x && ev->x <= x + w) { if (ev->x >= x && ev->x <= x + w) {
click = ClickLArrow; 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 // right arrow
w = rarrowWidth; w = rarrowWidth;
x = mw - w; x = mw - w;