From 7bb81a26b86e279577d29442e61cb8789b3a3f7b Mon Sep 17 00:00:00 2001 From: speedie Date: Mon, 3 Jul 2023 23:06:33 +0200 Subject: [PATCH] Add ClickImage click --- libs/conf/config.h | 3 +++ libs/wl/wayland.c | 4 ++++ libs/x11/mouse.c | 4 ++++ spmenu.c | 1 + 4 files changed, 12 insertions(+) diff --git a/libs/conf/config.h b/libs/conf/config.h index c70da38..ca22ff8 100644 --- a/libs/conf/config.h +++ b/libs/conf/config.h @@ -685,6 +685,9 @@ static ClickType ctp[] = { { "ClickNumber", ClickNumber }, { "ClickCaps", ClickCaps }, { "ClickMode", ClickMode }, +#if USEIMAGE + { "ClickImage", ClickImage }, +#endif }; static void conf_init(void); diff --git a/libs/wl/wayland.c b/libs/wl/wayland.c index c49a76d..c979d01 100644 --- a/libs/wl/wayland.c +++ b/libs/wl/wayland.c @@ -318,6 +318,10 @@ void buttonpress_wl(uint32_t button, double ex, double ey) { click = ClickItem; } } +#if USEIMAGE + } else if (ey >= y && ey <= (y + h) && ex >= x + (powerlineitems ? sp.plw : 0) - MAX((imagegaps * 2) + img.imagewidth, indentitems ? sp.promptw : 0) && ex <= (x - MAX((imagegaps * 2) + img.imagewidth, indentitems ? sp.promptw : 0) + w / columns) + (powerlineitems ? sp.plw : 0)) { + click = ClickImage; +#endif } } } else if (matches) { // a single line, meaning it could be arrows too, so we check that here diff --git a/libs/x11/mouse.c b/libs/x11/mouse.c index 5ae4741..0bf386d 100644 --- a/libs/x11/mouse.c +++ b/libs/x11/mouse.c @@ -102,6 +102,10 @@ void buttonpress_x11(XEvent *e) { click = ClickItem; } } +#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; +#endif } } } else if (matches) { // a single line, meaning it could be arrows too, so we check that here diff --git a/spmenu.c b/spmenu.c index 6a1ede7..83921b7 100644 --- a/spmenu.c +++ b/spmenu.c @@ -99,6 +99,7 @@ enum { ClickNumber, ClickCaps, ClickMode, + ClickImage, }; struct item {