forked from speedie/spmenu
rewrite the way clicking on items work
This commit is contained in:
parent
39b166bf17
commit
628ed1dc40
28
libs/mouse.c
28
libs/mouse.c
|
@ -114,13 +114,14 @@ buttonpress(XEvent *e)
|
|||
y += h;
|
||||
|
||||
if (ev->y >= y && ev->y <= (y + h) && ev->x >= x && ev->x <= (x + w / columns)) {
|
||||
|
||||
// TODO: make clickitem a thing
|
||||
if (ev->button != Button1)
|
||||
return;
|
||||
|
||||
puts(item->text);
|
||||
exit(0);
|
||||
for (i = 0; i < LENGTH(buttons); i++) {
|
||||
if (buttons[i].click == clickselitem && buttons[i].button == ev->button && CLEANMASK(buttons[i].mask) == CLEANMASK(ev->state)) {
|
||||
puts(item->text);
|
||||
exit(0);
|
||||
} else if (buttons[i].click == clickitem) {
|
||||
click = clickitem;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (matches) {
|
||||
|
@ -138,12 +139,15 @@ buttonpress(XEvent *e)
|
|||
x += w;
|
||||
w = MIN(TEXTW(item->text), mw - x - rarrowWidth);
|
||||
if (ev->x >= x && ev->x <= x + w) {
|
||||
// TODO: make clickitem a thing
|
||||
if (ev->button != Button1)
|
||||
return;
|
||||
for (i = 0; i < LENGTH(buttons); i++) {
|
||||
if (buttons[i].click == clickselitem && buttons[i].button == ev->button && CLEANMASK(buttons[i].mask) == CLEANMASK(ev->state)) {
|
||||
puts(item->text);
|
||||
exit(0);
|
||||
} else if (buttons[i].click == clickitem) {
|
||||
click = clickitem;
|
||||
}
|
||||
}
|
||||
|
||||
puts(item->text);
|
||||
exit(0);
|
||||
}
|
||||
}
|
||||
// left-click on right arrow
|
||||
|
|
|
@ -12,6 +12,8 @@ enum {
|
|||
clickprompt,
|
||||
clickinput,
|
||||
clicklarrow,
|
||||
clickitem,
|
||||
clickselitem,
|
||||
clickrarrow,
|
||||
clicknumber,
|
||||
clickmode,
|
||||
|
|
27
mouse.h
27
mouse.h
|
@ -3,19 +3,21 @@
|
|||
* This header contains mouse binds.
|
||||
* Change them or remove them if you prefer. You can also add more if you want.
|
||||
*
|
||||
* clickwindow: - spmenu window/client
|
||||
* clickinput: - Input box
|
||||
* clickprompt: - Prompt
|
||||
* clicklarrow: - Left arrow
|
||||
* clickrarrow: - Right arrow
|
||||
* clicknumber: - Match count
|
||||
* clickmode: - Mode indicator
|
||||
* clickwindow: - spmenu window/client
|
||||
* clickinput: - Input box
|
||||
* clickprompt: - Prompt
|
||||
* clicklarrow: - Left arrow
|
||||
* clickitem: - Item
|
||||
* clickselitem: - Item hovered over (function doesn't matter, this will always select the item)
|
||||
* clickrarrow: - Right arrow
|
||||
* clicknumber: - Match count
|
||||
* clickmode: - Mode indicator
|
||||
*
|
||||
* Button1 - Left click
|
||||
* Button2 - Middle click
|
||||
* Button3 - Right click
|
||||
* Button4 - Scroll up
|
||||
* Button5 - Scroll down
|
||||
* Button1 - Left click
|
||||
* Button2 - Middle click
|
||||
* Button3 - Right click
|
||||
* Button4 - Scroll up
|
||||
* Button5 - Scroll down
|
||||
*
|
||||
* Note that clicking on an item will select it, as of now it's hardcoded.
|
||||
*/
|
||||
|
@ -25,4 +27,5 @@ static Mouse buttons[] = {
|
|||
{ clickprompt, 0, Button1, clear, {0} },
|
||||
{ clickmode, 0, Button1, switchmode, {0} },
|
||||
{ clicknumber, 0, Button1, viewhist, {0} },
|
||||
{ clickselitem, 0, Button1, NULL, {0} },
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue