From e19a2207ead91d8be4ff089571498285e3f6dbd3 Mon Sep 17 00:00:00 2001 From: Jaakko Keränen Date: Mon, 27 Jul 2020 15:29:43 +0300 Subject: DocumentWidget: Fine-tuning Stop hovering on links when fetching content, and clamp scroll position when resizing the view. --- src/ui/documentwidget.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'src/ui/documentwidget.c') diff --git a/src/ui/documentwidget.c b/src/ui/documentwidget.c index 079f08f4..36ec99ff 100644 --- a/src/ui/documentwidget.c +++ b/src/ui/documentwidget.c @@ -399,6 +399,7 @@ static iBool processEvent_DocumentWidget_(iDocumentWidget *d, const SDL_Event *e iWidget *w = as_Widget(d); if (isResize_UserEvent(ev)) { setWidth_GmDocument(d->doc, documentWidth_DocumentWidget_(d)); + scroll_DocumentWidget_(d, 0); updateVisible_DocumentWidget_(d); refresh_Widget(w); } @@ -564,11 +565,13 @@ static iBool processEvent_DocumentWidget_(iDocumentWidget *d, const SDL_Event *e const iGmRun *oldHoverLink = d->hoverLink; d->hoverLink = NULL; const iInt2 hoverPos = addY_I2(sub_I2(mouse, topLeft_Rect(docBounds)), d->scrollY); - iConstForEach(PtrArray, i, &d->visibleLinks) { - const iGmRun *run = i.ptr; - if (contains_Rect(run->bounds, hoverPos)) { - d->hoverLink = run; - break; + if (d->state == ready_DocumentState) { + iConstForEach(PtrArray, i, &d->visibleLinks) { + const iGmRun *run = i.ptr; + if (contains_Rect(run->bounds, hoverPos)) { + d->hoverLink = run; + break; + } } } if (d->hoverLink != oldHoverLink) { -- cgit v1.2.3