Fix issue #14 by replacing bad code.

I don't know what I was thinking to be honest.
This commit is contained in:
speedie 2023-07-22 02:02:03 +02:00
parent 7f5caf7bf0
commit ea48ea69ed
4 changed files with 6 additions and 13 deletions

View file

@ -607,7 +607,7 @@ void switchmode(Arg *arg) {
}
void selecthover(Arg *arg) {
puts(items[sp.clickitemindex].text);
puts(mouseitem->text);
exit(0);
}

View file

@ -289,8 +289,6 @@ void buttonpress_wl(uint32_t button, double ex, double ey) {
ey += h;
}
i = 0;
for (item = currentitem; item != nextitem; item = item->right) {
if (item_num++ == lines) {
item_num = 1;
@ -301,15 +299,14 @@ void buttonpress_wl(uint32_t button, double ex, double ey) {
y += h;
if (ey >= y && ey <= (y + h) && ex >= x + (powerlineitems ? sp.plw : 0) && ex <= (x + w / columns) + (powerlineitems ? sp.plw : 0)) {
sp.clickitemindex = i;
click = ClickItem;
mouseitem = item;
#if USEIMAGE
} else if (ey >= y && ey <= (y + h) && ex >= x + (powerlineitems ? sp.plw : 0) - MAX((img.imagegaps * 2) + img.imagewidth, indentitems ? sp.promptw : 0) && ex <= (x - MAX((img.imagegaps * 2) + img.imagewidth, indentitems ? sp.promptw : 0) + w / columns) + (powerlineitems ? sp.plw : 0)) {
click = ClickImage;
mouseitem = item;
#endif
}
i++;
}
} else if (matches) { // a single line, meaning it could be arrows too, so we check that here
x += sp.inputw;

View file

@ -73,8 +73,6 @@ void buttonpress_x11(XEvent *e) {
ev->y += h;
}
i = 0;
for (item = currentitem; item != nextitem; item = item->right) {
if (item_num++ == lines) {
item_num = 1;
@ -87,14 +85,13 @@ void buttonpress_x11(XEvent *e) {
// ClickSelItem, called function doesn't matter
if (ev->y >= y && ev->y <= (y + h) && ev->x >= x + (powerlineitems ? sp.plw : 0) && ev->x <= (x + w / columns) + (powerlineitems ? sp.plw : 0)) {
click = ClickItem;
sp.clickitemindex = i;
mouseitem = item;
#if USEIMAGE
} else if (ev->y >= y && ev->y <= (y + h) && ev->x >= x + (powerlineitems ? sp.plw : 0) - MAX((img.imagegaps * 2) + img.imagewidth, indentitems ? sp.promptw : 0) && ev->x <= (x - MAX((img.imagegaps * 2) + img.imagewidth, indentitems ? sp.promptw : 0) + w / columns) + (powerlineitems ? sp.plw : 0)) {
click = ClickImage;
mouseitem = item;
#endif
}
i++;
}
} else if (matches) { // a single line, meaning it could be arrows too, so we check that here
x += sp.inputw;

View file

@ -140,8 +140,6 @@ struct sp {
int listcount;
int listchanged;
int clickitemindex;
size_t cursor; // cursor width
int ignoreconfkeys; // can be set globally if you don't want to override keybinds with config file keys
@ -206,6 +204,7 @@ static struct item *previousitem; // previous item
static struct item *currentitem; // current item
static struct item *nextitem; // next item
static struct item *selecteditem; // selected item
static struct item *mouseitem; // clicked item
// various headers
#include "libs/draw/draw.h"