summaryrefslogtreecommitdiff
path: root/src/ui/window.c
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2021-07-23 14:58:42 +0300
committerJaakko Keränen <jaakko.keranen@iki.fi>2021-07-23 14:58:42 +0300
commit99d980b5867b277d15d39731eb235bfa9695268e (patch)
treea5b332341bd119b7717af333b4f4381641c0c258 /src/ui/window.c
parentbb401db8b648e6bc3d3f93281031b3164159bf1a (diff)
Window: Mouse wheel events vs. split mode
Only process mouse wheel events on the root over which the mouse is currently.
Diffstat (limited to 'src/ui/window.c')
-rw-r--r--src/ui/window.c21
1 files changed, 12 insertions, 9 deletions
diff --git a/src/ui/window.c b/src/ui/window.c
index f71d8102..4bf42a30 100644
--- a/src/ui/window.c
+++ b/src/ui/window.c
@@ -957,10 +957,14 @@ iBool dispatchEvent_Window(iWindow *d, const SDL_Event *ev) {
957 if (isCommand_SDLEvent(ev) && ev->user.data2 && ev->user.data2 != root) { 957 if (isCommand_SDLEvent(ev) && ev->user.data2 && ev->user.data2 != root) {
958 continue; /* Not meant for this root. */ 958 continue; /* Not meant for this root. */
959 } 959 }
960 else if ((ev->type == SDL_KEYDOWN || ev->type == SDL_KEYUP || ev->type == SDL_TEXTINPUT) 960 if ((ev->type == SDL_KEYDOWN || ev->type == SDL_KEYUP || ev->type == SDL_TEXTINPUT)
961 && d->keyRoot != root) { 961 && d->keyRoot != root) {
962 continue; /* Key events go only to the root with keyboard focus. */ 962 continue; /* Key events go only to the root with keyboard focus. */
963 } 963 }
964 if (ev->type == SDL_MOUSEWHEEL && !contains_Rect(rect_Root(root),
965 coord_MouseWheelEvent(&ev->wheel))) {
966 continue; /* Only process the event in the relevant split. */
967 }
964 setCurrent_Root(root); 968 setCurrent_Root(root);
965 const iBool wasUsed = dispatchEvent_Widget(root->widget, ev); 969 const iBool wasUsed = dispatchEvent_Widget(root->widget, ev);
966 if (wasUsed) { 970 if (wasUsed) {
@@ -1154,20 +1158,19 @@ iInt2 coord_Window(const iWindow *d, int x, int y) {
1154 return mulf_I2(init_I2(x, y), d->pixelRatio); 1158 return mulf_I2(init_I2(x, y), d->pixelRatio);
1155} 1159}
1156 1160
1157iInt2 mouseCoord_Window(const iWindow *d) { 1161iInt2 mouseCoord_Window(const iWindow *d, int whichDevice) {
1158#if defined (iPlatformMobile) 1162 if (whichDevice == SDL_TOUCH_MOUSEID) {
1159 /* At least on iOS the coordinates returned by SDL_GetMouseState() do no match up with 1163 /* At least on iOS the coordinates returned by SDL_GetMouseState() do no match up with
1160 our touch coordinates on the Y axis (?). Maybe a pixel ratio thing? */ 1164 our touch coordinates on the Y axis (?). Maybe a pixel ratio thing? */
1161 iUnused(d); 1165 iUnused(d);
1162 return latestPosition_Touch(); 1166 return latestPosition_Touch();
1163#else 1167 }
1164 if (!d->isMouseInside) { 1168 if (!d->isMouseInside) {
1165 return init_I2(-1000000, -1000000); 1169 return init_I2(-1000000, -1000000);
1166 } 1170 }
1167 int x, y; 1171 int x, y;
1168 SDL_GetMouseState(&x, &y); 1172 SDL_GetMouseState(&x, &y);
1169 return coord_Window(d, x, y); 1173 return coord_Window(d, x, y);
1170#endif
1171} 1174}
1172 1175
1173float uiScale_Window(const iWindow *d) { 1176float uiScale_Window(const iWindow *d) {