summaryrefslogtreecommitdiff
path: root/src/ui/documentwidget.c
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2020-08-06 17:52:04 +0300
committerJaakko Keränen <jaakko.keranen@iki.fi>2020-08-06 17:52:04 +0300
commit9f3378737bf957c1b31412dd28ffcfc7d504b2e3 (patch)
treeff9a945eb9df35cfba13b4884a8ce1c322383c5f /src/ui/documentwidget.c
parent3f0f06f1b35b6aafaa569fed3755a76aa6bed32a (diff)
DocumentWidget: Disable link hover while scrolling
Diffstat (limited to 'src/ui/documentwidget.c')
-rw-r--r--src/ui/documentwidget.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/ui/documentwidget.c b/src/ui/documentwidget.c
index b0c11ef0..3455db64 100644
--- a/src/ui/documentwidget.c
+++ b/src/ui/documentwidget.c
@@ -93,6 +93,7 @@ struct Impl_DocumentWidget {
93 int scrollY; 93 int scrollY;
94 iPtrArray visibleLinks; 94 iPtrArray visibleLinks;
95 const iGmRun *hoverLink; 95 const iGmRun *hoverLink;
96 iBool noHoverWhileScrolling;
96 iClick click; 97 iClick click;
97 int initialScrollY; 98 int initialScrollY;
98 iScrollWidget *scroll; 99 iScrollWidget *scroll;
@@ -124,6 +125,7 @@ void init_DocumentWidget(iDocumentWidget *d) {
124 d->pageMargin = 5; 125 d->pageMargin = 5;
125 d->scrollY = 0; 126 d->scrollY = 0;
126 d->hoverLink = NULL; 127 d->hoverLink = NULL;
128 d->noHoverWhileScrolling = iFalse;
127 d->arrowCursor = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_ARROW); 129 d->arrowCursor = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_ARROW);
128 d->beamCursor = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_IBEAM); 130 d->beamCursor = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_IBEAM);
129 d->handCursor = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_HAND); 131 d->handCursor = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_HAND);
@@ -218,7 +220,8 @@ static void updateHover_DocumentWidget_(iDocumentWidget *d, iInt2 mouse) {
218 const iGmRun *oldHoverLink = d->hoverLink; 220 const iGmRun *oldHoverLink = d->hoverLink;
219 d->hoverLink = NULL; 221 d->hoverLink = NULL;
220 const iInt2 hoverPos = addY_I2(sub_I2(mouse, topLeft_Rect(docBounds)), d->scrollY); 222 const iInt2 hoverPos = addY_I2(sub_I2(mouse, topLeft_Rect(docBounds)), d->scrollY);
221 if (d->state == ready_DocumentState || d->state == receivedPartialResponse_DocumentState) { 223 if (!d->noHoverWhileScrolling &&
224 (d->state == ready_DocumentState || d->state == receivedPartialResponse_DocumentState)) {
222 iConstForEach(PtrArray, i, &d->visibleLinks) { 225 iConstForEach(PtrArray, i, &d->visibleLinks) {
223 const iGmRun *run = i.ptr; 226 const iGmRun *run = i.ptr;
224 if (contains_Rect(run->bounds, hoverPos)) { 227 if (contains_Rect(run->bounds, hoverPos)) {
@@ -276,7 +279,9 @@ static void updateWindowTitle_DocumentWidget_(const iDocumentWidget *d) {
276 if (isEmpty_StringArray(title)) { 279 if (isEmpty_StringArray(title)) {
277 pushBackCStr_StringArray(title, "Lagrange"); 280 pushBackCStr_StringArray(title, "Lagrange");
278 } 281 }
279 setTitle_Window(get_Window(), collect_String(joinCStr_StringArray(title, " \u2014 "))); 282 const iString *text = collect_String(joinCStr_StringArray(title, " \u2014 "));
283 setTitle_Window(get_Window(), text);
284 setTabPageLabel_Widget(findWidget_App("doctabs"), d, text);
280} 285}
281 286
282static void setSource_DocumentWidget_(iDocumentWidget *d, const iString *source) { 287static void setSource_DocumentWidget_(iDocumentWidget *d, const iString *source) {
@@ -891,9 +896,11 @@ static iBool processEvent_DocumentWidget_(iDocumentWidget *d, const SDL_Event *e
891 } 896 }
892 scroll_DocumentWidget_(d, -3 * ev->wheel.y * lineHeight_Text(default_FontId)); 897 scroll_DocumentWidget_(d, -3 * ev->wheel.y * lineHeight_Text(default_FontId));
893#endif 898#endif
899 d->noHoverWhileScrolling = iTrue;
894 return iTrue; 900 return iTrue;
895 } 901 }
896 else if (ev->type == SDL_MOUSEMOTION) { 902 else if (ev->type == SDL_MOUSEMOTION) {
903 d->noHoverWhileScrolling = iFalse;
897 if (isVisible_Widget(d->menu)) { 904 if (isVisible_Widget(d->menu)) {
898 SDL_SetCursor(d->arrowCursor); 905 SDL_SetCursor(d->arrowCursor);
899 } 906 }
@@ -1101,7 +1108,7 @@ static void drawRun_DrawContext_(void *context, const iGmRun *run) {
1101 info.mime, info.size.x, info.size.y, info.numBytes / 1.0e6f); 1108 info.mime, info.size.x, info.size.y, info.numBytes / 1.0e6f);
1102 if (findMediaRequest_DocumentWidget_(d->widget, run->linkId)) { 1109 if (findMediaRequest_DocumentWidget_(d->widget, run->linkId)) {
1103 appendFormat_String( 1110 appendFormat_String(
1104 &text, " %s\U0001f7a8", isHover ? escape_Color(tmLinkText_ColorId) : ""); 1111 &text, " %s\u2a2f", isHover ? escape_Color(tmLinkText_ColorId) : "");
1105 } 1112 }
1106 drawAlign_Text(metaFont, 1113 drawAlign_Text(metaFont,
1107 add_I2(topRight_Rect(run->bounds), origin), 1114 add_I2(topRight_Rect(run->bounds), origin),