summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/ui/documentwidget.c10
-rw-r--r--src/ui/inputwidget.c6
-rw-r--r--src/ui/listwidget.c4
-rw-r--r--src/ui/mediaui.c4
-rw-r--r--src/ui/util.c4
-rw-r--r--src/ui/util.h2
-rw-r--r--src/ui/window.c21
-rw-r--r--src/ui/window.h3
8 files changed, 32 insertions, 22 deletions
diff --git a/src/ui/documentwidget.c b/src/ui/documentwidget.c
index 1e3eb08d..8b4ee932 100644
--- a/src/ui/documentwidget.c
+++ b/src/ui/documentwidget.c
@@ -882,7 +882,7 @@ static void updateVisible_DocumentWidget_(iDocumentWidget *d) {
882 if (memcmp(&oldHeading, &newHeading, sizeof(oldHeading))) { 882 if (memcmp(&oldHeading, &newHeading, sizeof(oldHeading))) {
883 d->drawBufs->flags |= updateSideBuf_DrawBufsFlag; 883 d->drawBufs->flags |= updateSideBuf_DrawBufsFlag;
884 } 884 }
885 updateHover_DocumentWidget_(d, mouseCoord_Window(get_Window())); 885 updateHover_DocumentWidget_(d, mouseCoord_Window(get_Window(), 0));
886 updateSideOpacity_DocumentWidget_(d, iTrue); 886 updateSideOpacity_DocumentWidget_(d, iTrue);
887 animateMedia_DocumentWidget_(d); 887 animateMedia_DocumentWidget_(d);
888 /* Remember scroll positions of recently visited pages. */ { 888 /* Remember scroll positions of recently visited pages. */ {
@@ -1806,7 +1806,7 @@ static void togglePreFold_DocumentWidget_(iDocumentWidget *d, uint16_t preId) {
1806 foldPre_GmDocument(d->doc, preId); 1806 foldPre_GmDocument(d->doc, preId);
1807 redoLayout_GmDocument(d->doc); 1807 redoLayout_GmDocument(d->doc);
1808 clampScroll_DocumentWidget_(d); 1808 clampScroll_DocumentWidget_(d);
1809 updateHover_DocumentWidget_(d, mouseCoord_Window(get_Window())); 1809 updateHover_DocumentWidget_(d, mouseCoord_Window(get_Window(), 0));
1810 invalidate_DocumentWidget_(d); 1810 invalidate_DocumentWidget_(d);
1811 refresh_Widget(as_Widget(d)); 1811 refresh_Widget(as_Widget(d));
1812} 1812}
@@ -3123,7 +3123,7 @@ static iBool handleCommand_DocumentWidget_(iDocumentWidget *d, const char *cmd)
3123 return iTrue; 3123 return iTrue;
3124 } 3124 }
3125 else if (equalWidget_Command(cmd, w, "menu.closed")) { 3125 else if (equalWidget_Command(cmd, w, "menu.closed")) {
3126 updateHover_DocumentWidget_(d, mouseCoord_Window(get_Window())); 3126 updateHover_DocumentWidget_(d, mouseCoord_Window(get_Window(), 0));
3127 } 3127 }
3128 else if (equal_Command(cmd, "document.autoreload")) { 3128 else if (equal_Command(cmd, "document.autoreload")) {
3129 if (d->mod.reloadInterval) { 3129 if (d->mod.reloadInterval) {
@@ -3435,7 +3435,7 @@ static iBool processEvent_DocumentWidget_(iDocumentWidget *d, const SDL_Event *e
3435 } 3435 }
3436 } 3436 }
3437 else if (ev->type == SDL_MOUSEWHEEL && isHover_Widget(w)) { 3437 else if (ev->type == SDL_MOUSEWHEEL && isHover_Widget(w)) {
3438 const iInt2 mouseCoord = mouseCoord_Window(get_Window()); 3438 const iInt2 mouseCoord = coord_MouseWheelEvent(&ev->wheel);
3439 if (isPerPixel_MouseWheelEvent(&ev->wheel)) { 3439 if (isPerPixel_MouseWheelEvent(&ev->wheel)) {
3440 const iInt2 wheel = init_I2(ev->wheel.x, ev->wheel.y); 3440 const iInt2 wheel = init_I2(ev->wheel.x, ev->wheel.y);
3441 stop_Anim(&d->scrollY.pos); 3441 stop_Anim(&d->scrollY.pos);
@@ -3694,7 +3694,7 @@ static iBool processEvent_DocumentWidget_(iDocumentWidget *d, const SDL_Event *e
3694 /* Enable hover state now that scrolling has surely finished. */ 3694 /* Enable hover state now that scrolling has surely finished. */
3695 if (d->flags & noHoverWhileScrolling_DocumentWidgetFlag) { 3695 if (d->flags & noHoverWhileScrolling_DocumentWidgetFlag) {
3696 d->flags &= ~noHoverWhileScrolling_DocumentWidgetFlag; 3696 d->flags &= ~noHoverWhileScrolling_DocumentWidgetFlag;
3697 updateHover_DocumentWidget_(d, mouseCoord_Window(get_Window())); 3697 updateHover_DocumentWidget_(d, mouseCoord_Window(get_Window(), ev->button.which));
3698 } 3698 }
3699 if (~flags_Widget(w) & touchDrag_WidgetFlag) { 3699 if (~flags_Widget(w) & touchDrag_WidgetFlag) {
3700 iChangeFlags(d->flags, selecting_DocumentWidgetFlag, iFalse); 3700 iChangeFlags(d->flags, selecting_DocumentWidgetFlag, iFalse);
diff --git a/src/ui/inputwidget.c b/src/ui/inputwidget.c
index 444f849d..525e2a33 100644
--- a/src/ui/inputwidget.c
+++ b/src/ui/inputwidget.c
@@ -1760,7 +1760,9 @@ static iBool processEvent_InputWidget_(iInputWidget *d, const SDL_Event *ev) {
1760 closeMenu_Widget(clipMenu); 1760 closeMenu_Widget(clipMenu);
1761 } 1761 }
1762 else { 1762 else {
1763 openMenuFlags_Widget(clipMenu, mouseCoord_Window(get_Window()), iFalse); 1763 openMenuFlags_Widget(clipMenu,
1764 mouseCoord_Window(get_Window(), ev->button.which),
1765 iFalse);
1764 } 1766 }
1765 return iTrue; 1767 return iTrue;
1766 } 1768 }
@@ -2058,7 +2060,7 @@ static void draw_InputWidget_(const iInputWidget *d) {
2058 iBool isHint = isHintVisible_InputWidget_(d); 2060 iBool isHint = isHintVisible_InputWidget_(d);
2059 const iBool isFocused = isFocused_Widget(w); 2061 const iBool isFocused = isFocused_Widget(w);
2060 const iBool isHover = isHover_Widget(w) && 2062 const iBool isHover = isHover_Widget(w) &&
2061 contains_InputWidget_(d, mouseCoord_Window(get_Window())); 2063 contains_InputWidget_(d, mouseCoord_Window(get_Window(), 0));
2062 if (d->inFlags & needUpdateBuffer_InputWidgetFlag) { 2064 if (d->inFlags & needUpdateBuffer_InputWidgetFlag) {
2063 updateBuffered_InputWidget_(iConstCast(iInputWidget *, d)); 2065 updateBuffered_InputWidget_(iConstCast(iInputWidget *, d));
2064 } 2066 }
diff --git a/src/ui/listwidget.c b/src/ui/listwidget.c
index 29aa9d1f..46d32e9a 100644
--- a/src/ui/listwidget.c
+++ b/src/ui/listwidget.c
@@ -283,7 +283,7 @@ static void setHoverItem_ListWidget_(iListWidget *d, size_t index) {
283} 283}
284 284
285void updateMouseHover_ListWidget(iListWidget *d) { 285void updateMouseHover_ListWidget(iListWidget *d) {
286 const iInt2 mouse = mouseCoord_Window(get_Window()); 286 const iInt2 mouse = mouseCoord_Window(get_Window(), 0);
287 setHoverItem_ListWidget_(d, itemIndex_ListWidget(d, mouse)); 287 setHoverItem_ListWidget_(d, itemIndex_ListWidget(d, mouse));
288} 288}
289 289
@@ -355,7 +355,7 @@ static iBool processEvent_ListWidget_(iListWidget *d, const SDL_Event *ev) {
355 switch (processEvent_Click(&d->click, ev)) { 355 switch (processEvent_Click(&d->click, ev)) {
356 case started_ClickResult: 356 case started_ClickResult:
357 d->noHoverWhileScrolling = iFalse; 357 d->noHoverWhileScrolling = iFalse;
358 updateHover_ListWidget_(d, mouseCoord_Window(get_Window())); 358 updateHover_ListWidget_(d, mouseCoord_Window(get_Window(), ev->button.which));
359 redrawHoverItem_ListWidget_(d); 359 redrawHoverItem_ListWidget_(d);
360 return iTrue; 360 return iTrue;
361 case aborted_ClickResult: 361 case aborted_ClickResult:
diff --git a/src/ui/mediaui.c b/src/ui/mediaui.c
index 22924876..b622a554 100644
--- a/src/ui/mediaui.c
+++ b/src/ui/mediaui.c
@@ -62,7 +62,7 @@ void init_PlayerUI(iPlayerUI *d, const iPlayer *player, iRect bounds) {
62} 62}
63 63
64static void drawPlayerButton_(iPaint *p, iRect rect, const char *label, int font) { 64static void drawPlayerButton_(iPaint *p, iRect rect, const char *label, int font) {
65 const iInt2 mouse = mouseCoord_Window(get_Window()); 65 const iInt2 mouse = mouseCoord_Window(get_Window(), 0);
66 const iBool isHover = contains_Rect(rect, mouse); 66 const iBool isHover = contains_Rect(rect, mouse);
67 const iBool isPressed = isHover && (SDL_GetMouseState(NULL, NULL) & SDL_BUTTON_LEFT) != 0; 67 const iBool isPressed = isHover && (SDL_GetMouseState(NULL, NULL) & SDL_BUTTON_LEFT) != 0;
68 const int frame = (isPressed ? uiTextCaution_ColorId : isHover ? uiHeading_ColorId : uiAnnotation_ColorId); 68 const int frame = (isPressed ? uiTextCaution_ColorId : isHover ? uiHeading_ColorId : uiAnnotation_ColorId);
@@ -159,7 +159,7 @@ void draw_PlayerUI(iPlayerUI *d, iPaint *p) {
159 dot); 159 dot);
160 /* Volume adjustment. */ 160 /* Volume adjustment. */
161 if (isAdjusting) { 161 if (isAdjusting) {
162 const iInt2 mouse = mouseCoord_Window(get_Window()); 162 const iInt2 mouse = mouseCoord_Window(get_Window(), 0);
163 const iBool isHover = contains_Rect(d->volumeRect, mouse) && 163 const iBool isHover = contains_Rect(d->volumeRect, mouse) &&
164 ~flags_Player(d->player) & volumeGrabbed_PlayerFlag; 164 ~flags_Player(d->player) & volumeGrabbed_PlayerFlag;
165 const iBool isPressed = (SDL_GetMouseState(NULL, NULL) & SDL_BUTTON_LEFT) != 0; 165 const iBool isPressed = (SDL_GetMouseState(NULL, NULL) & SDL_BUTTON_LEFT) != 0;
diff --git a/src/ui/util.c b/src/ui/util.c
index 13a9237e..b6ecc7d5 100644
--- a/src/ui/util.c
+++ b/src/ui/util.c
@@ -64,6 +64,10 @@ const char *command_UserEvent(const SDL_Event *d) {
64 return ""; 64 return "";
65} 65}
66 66
67iInt2 coord_MouseWheelEvent(const SDL_MouseWheelEvent *ev) {
68 return mouseCoord_Window(get_Window(), ev->which);
69}
70
67static void removePlus_(iString *str) { 71static void removePlus_(iString *str) {
68 if (endsWith_String(str, "+")) { 72 if (endsWith_String(str, "+")) {
69 removeEnd_String(str, 1); 73 removeEnd_String(str, 1);
diff --git a/src/ui/util.h b/src/ui/util.h
index 021f72d1..2423f834 100644
--- a/src/ui/util.h
+++ b/src/ui/util.h
@@ -58,6 +58,8 @@ iLocalDef iBool isPerPixel_MouseWheelEvent(const SDL_MouseWheelEvent *ev) {
58 return (ev->direction & perPixel_MouseWheelFlag) != 0; 58 return (ev->direction & perPixel_MouseWheelFlag) != 0;
59} 59}
60 60
61iInt2 coord_MouseWheelEvent (const SDL_MouseWheelEvent *);
62
61#if defined (iPlatformApple) 63#if defined (iPlatformApple)
62# define KMOD_PRIMARY KMOD_GUI 64# define KMOD_PRIMARY KMOD_GUI
63# define KMOD_SECONDARY KMOD_CTRL 65# define KMOD_SECONDARY KMOD_CTRL
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) {
diff --git a/src/ui/window.h b/src/ui/window.h
index 677001e5..bb98dbe9 100644
--- a/src/ui/window.h
+++ b/src/ui/window.h
@@ -126,7 +126,7 @@ iInt2 size_Window (const iWindow *);
126iInt2 maxTextureSize_Window (const iWindow *); 126iInt2 maxTextureSize_Window (const iWindow *);
127float uiScale_Window (const iWindow *); 127float uiScale_Window (const iWindow *);
128iInt2 coord_Window (const iWindow *, int x, int y); 128iInt2 coord_Window (const iWindow *, int x, int y);
129iInt2 mouseCoord_Window (const iWindow *); 129iInt2 mouseCoord_Window (const iWindow *, int whichDevice);
130iAnyObject *hitChild_Window (const iWindow *, iInt2 coord); 130iAnyObject *hitChild_Window (const iWindow *, iInt2 coord);
131uint32_t frameTime_Window (const iWindow *); 131uint32_t frameTime_Window (const iWindow *);
132SDL_Renderer *renderer_Window (const iWindow *); 132SDL_Renderer *renderer_Window (const iWindow *);
@@ -135,7 +135,6 @@ iBool isFullscreen_Window (const iWindow *);
135int numRoots_Window (const iWindow *); 135int numRoots_Window (const iWindow *);
136iRoot * findRoot_Window (const iWindow *, const iWidget *widget); 136iRoot * findRoot_Window (const iWindow *, const iWidget *widget);
137iRoot * otherRoot_Window (const iWindow *, iRoot *root); 137iRoot * otherRoot_Window (const iWindow *, iRoot *root);
138
139iWindow * get_Window (void); 138iWindow * get_Window (void);
140 139
141#if defined (LAGRANGE_ENABLE_CUSTOM_FRAME) 140#if defined (LAGRANGE_ENABLE_CUSTOM_FRAME)