diff options
author | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-12-07 15:06:26 +0200 |
---|---|---|
committer | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-12-07 15:06:26 +0200 |
commit | 71e149f463b18193a0a9e27822390708a2cca83c (patch) | |
tree | 89003cc0b4cb925a46b0b6175c269ef062c3342d | |
parent | 3820426634f2fb18a19baee00c7e445f3a2b7d30 (diff) |
DocumentWidget: Fixing glitches in swipe navigation
TODO: There should be a better method for copying the full state of the DocumentWidget to another one.
-rw-r--r-- | src/ui/documentwidget.c | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/src/ui/documentwidget.c b/src/ui/documentwidget.c index 94a58a35..1760be9e 100644 --- a/src/ui/documentwidget.c +++ b/src/ui/documentwidget.c | |||
@@ -2614,14 +2614,15 @@ static void swap_DocumentWidget_(iDocumentWidget *d, iGmDocument *doc, | |||
2614 | iDocumentWidget *swapBuffersWith) { | 2614 | iDocumentWidget *swapBuffersWith) { |
2615 | if (doc) { | 2615 | if (doc) { |
2616 | iAssert(isInstance_Object(doc, &Class_GmDocument)); | 2616 | iAssert(isInstance_Object(doc, &Class_GmDocument)); |
2617 | iGmDocument *copy = ref_Object(doc); | 2617 | replaceDocument_DocumentWidget_(d, doc); |
2618 | iRelease(d->doc); | ||
2619 | d->doc = copy; | ||
2620 | d->scrollY = swapBuffersWith->scrollY; | 2618 | d->scrollY = swapBuffersWith->scrollY; |
2621 | updateVisible_DocumentWidget_(d); | 2619 | iSwap(iBanner *, d->banner, swapBuffersWith->banner); |
2620 | setOwner_Banner(d->banner, d); | ||
2621 | setOwner_Banner(swapBuffersWith->banner, swapBuffersWith); | ||
2622 | iSwap(iVisBuf *, d->visBuf, swapBuffersWith->visBuf); | 2622 | iSwap(iVisBuf *, d->visBuf, swapBuffersWith->visBuf); |
2623 | iSwap(iVisBufMeta *, d->visBufMeta, swapBuffersWith->visBufMeta); | 2623 | iSwap(iVisBufMeta *, d->visBufMeta, swapBuffersWith->visBufMeta); |
2624 | iSwap(iDrawBufs *, d->drawBufs, swapBuffersWith->drawBufs); | 2624 | iSwap(iDrawBufs *, d->drawBufs, swapBuffersWith->drawBufs); |
2625 | updateVisible_DocumentWidget_(d); | ||
2625 | invalidate_DocumentWidget_(swapBuffersWith); | 2626 | invalidate_DocumentWidget_(swapBuffersWith); |
2626 | } | 2627 | } |
2627 | } | 2628 | } |
@@ -2645,12 +2646,9 @@ static iBool handleSwipe_DocumentWidget_(iDocumentWidget *d, const char *cmd) { | |||
2645 | return iTrue; | 2646 | return iTrue; |
2646 | } | 2647 | } |
2647 | iWidget *swipeParent = swipeParent_DocumentWidget_(d); | 2648 | iWidget *swipeParent = swipeParent_DocumentWidget_(d); |
2648 | /* The temporary "swipeIn" will display the previous page until the finger is lifted. */ | 2649 | /* The temporary "swipein" will display the previous page until the finger is lifted. */ |
2649 | iDocumentWidget *swipeIn = findChild_Widget(swipeParent, "swipein"); | 2650 | iDocumentWidget *swipeIn = findChild_Widget(swipeParent, "swipein"); |
2650 | if (!swipeIn) { | 2651 | if (!swipeIn) { |
2651 | const iBool sidebarSwipe = iFalse; /* && (isPortraitPhone_App() && | ||
2652 | d->flags & openedFromSidebar_DocumentWidgetFlag && | ||
2653 | !isVisible_Widget(findWidget_App("sidebar"))); */ | ||
2654 | swipeIn = new_DocumentWidget(); | 2652 | swipeIn = new_DocumentWidget(); |
2655 | setId_Widget(as_Widget(swipeIn), "swipein"); | 2653 | setId_Widget(as_Widget(swipeIn), "swipein"); |
2656 | setFlags_Widget(as_Widget(swipeIn), | 2654 | setFlags_Widget(as_Widget(swipeIn), |
@@ -2659,11 +2657,12 @@ static iBool handleSwipe_DocumentWidget_(iDocumentWidget *d, const char *cmd) { | |||
2659 | swipeIn->widget.rect.pos = windowToInner_Widget(swipeParent, localToWindow_Widget(w, w->rect.pos)); | 2657 | swipeIn->widget.rect.pos = windowToInner_Widget(swipeParent, localToWindow_Widget(w, w->rect.pos)); |
2660 | swipeIn->widget.rect.size = d->widget.rect.size; | 2658 | swipeIn->widget.rect.size = d->widget.rect.size; |
2661 | swipeIn->widget.offsetRef = parent_Widget(w); | 2659 | swipeIn->widget.offsetRef = parent_Widget(w); |
2662 | if (!sidebarSwipe) { | 2660 | /* Use a cached document for the layer underneath. */ { |
2663 | iRecentUrl *recent = new_RecentUrl(); | 2661 | iRecentUrl *recent = new_RecentUrl(); |
2664 | preceding_History(d->mod.history, recent); | 2662 | preceding_History(d->mod.history, recent); |
2665 | if (recent->cachedDoc) { | 2663 | if (recent->cachedDoc) { |
2666 | iChangeRef(swipeIn->doc, recent->cachedDoc); | 2664 | iChangeRef(swipeIn->doc, recent->cachedDoc); |
2665 | updateBanner_DocumentWidget_(swipeIn); | ||
2667 | updateScrollMax_DocumentWidget_(d); | 2666 | updateScrollMax_DocumentWidget_(d); |
2668 | setValue_Anim(&swipeIn->scrollY.pos, | 2667 | setValue_Anim(&swipeIn->scrollY.pos, |
2669 | pageHeight_DocumentWidget_(d) * recent->normScrollY, 0); | 2668 | pageHeight_DocumentWidget_(d) * recent->normScrollY, 0); |
@@ -2687,7 +2686,7 @@ static iBool handleSwipe_DocumentWidget_(iDocumentWidget *d, const char *cmd) { | |||
2687 | iWidget *swipeParent = swipeParent_DocumentWidget_(d); | 2686 | iWidget *swipeParent = swipeParent_DocumentWidget_(d); |
2688 | iDocumentWidget *target = new_DocumentWidget(); | 2687 | iDocumentWidget *target = new_DocumentWidget(); |
2689 | setId_Widget(as_Widget(target), "swipeout"); | 2688 | setId_Widget(as_Widget(target), "swipeout"); |
2690 | /* The target takes the old document and jumps on top. */ | 2689 | /* The target takes the old document and goes underneath. */ |
2691 | target->widget.rect.pos = windowToInner_Widget(swipeParent, localToWindow_Widget(w, w->rect.pos)); | 2690 | target->widget.rect.pos = windowToInner_Widget(swipeParent, localToWindow_Widget(w, w->rect.pos)); |
2692 | target->widget.rect.size = d->widget.rect.size; | 2691 | target->widget.rect.size = d->widget.rect.size; |
2693 | setFlags_Widget(as_Widget(target), fixedPosition_WidgetFlag | fixedSize_WidgetFlag, iTrue); | 2692 | setFlags_Widget(as_Widget(target), fixedPosition_WidgetFlag | fixedSize_WidgetFlag, iTrue); |