From 984b005bd01a57e53212bc1176b57b617414e75d Mon Sep 17 00:00:00 2001 From: Jaakko Keränen Date: Fri, 19 Nov 2021 14:32:55 +0200 Subject: Fixed clicking on tabs when banner is underneath Banner was too eager to eat all mouse events. --- src/ui/banner.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'src') diff --git a/src/ui/banner.c b/src/ui/banner.c index 0ffb1d9f..7168f4b2 100644 --- a/src/ui/banner.c +++ b/src/ui/banner.c @@ -257,8 +257,26 @@ static size_t itemAtCoord_Banner_(const iBanner *d, iInt2 coord) { return iInvalidPos; } +static iBool isInside_Banner(const iBanner *d, const SDL_Event *ev) { + if (ev->type == SDL_MOUSEMOTION || ev->type == SDL_MOUSEBUTTONDOWN || + ev->type == SDL_MOUSEBUTTONDOWN) { + iInt2 coord; + if (ev->type == SDL_MOUSEMOTION) { + coord = init_I2(ev->motion.x, ev->motion.y); + } + else { + coord = init_I2(ev->button.x, ev->button.y); + } + return contains_Rect(bounds_Widget(constAs_Widget(d->doc)), coord); + } + return iTrue; +} + iBool processEvent_Banner(iBanner *d, const SDL_Event *ev) { iWidget *w = as_Widget(d->doc); + if (!isInside_Banner(d, ev)) { + return iFalse; + } switch (ev->type) { case SDL_MOUSEMOTION: { const iInt2 coord = init_I2(ev->motion.x, ev->motion.y); -- cgit v1.2.3