summaryrefslogtreecommitdiff
path: root/src/ui/documentwidget.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui/documentwidget.c')
-rw-r--r--src/ui/documentwidget.c37
1 files changed, 24 insertions, 13 deletions
diff --git a/src/ui/documentwidget.c b/src/ui/documentwidget.c
index a4bf38dc..c71758be 100644
--- a/src/ui/documentwidget.c
+++ b/src/ui/documentwidget.c
@@ -1891,21 +1891,32 @@ static iBool processEvent_DocumentWidget_(iDocumentWidget *d, const SDL_Event *e
1891 } 1891 }
1892 } 1892 }
1893#if defined (iPlatformApple) 1893#if defined (iPlatformApple)
1894 /* Momentum scrolling. */ 1894 /* On macOS, we handle both trackpad and mouse events. We expect SDL to identify
1895 stop_Anim(&d->scrollY); 1895 which device is sending the event. */
1896 scroll_DocumentWidget_(d, -ev->wheel.y * get_Window()->pixelRatio * acceleration); 1896 if (ev->wheel.which == 0) { /* Trackpad with precise scrolling w/inertia. */
1897#else 1897 stop_Anim(&d->scrollY);
1898 if (keyMods_Sym(SDL_GetModState()) == KMOD_PRIMARY) { 1898 scroll_DocumentWidget_(d, -ev->wheel.y * get_Window()->pixelRatio * acceleration);
1899 postCommandf_App("zoom.delta arg:%d", ev->wheel.y > 0 ? 10 : -10);
1900 return iTrue;
1901 } 1899 }
1902 smoothScroll_DocumentWidget_( 1900 else
1903 d, 1901#endif
1904 -3 * ev->wheel.y * lineHeight_Text(paragraph_FontId) * acceleration, 1902 /* Traditional mouse wheel. */ {
1905 smoothDuration_DocumentWidget_ * 1903#if defined (iPlatformApple)
1906 (!isFinished_Anim(&d->scrollY) && pos_Anim(&d->scrollY) < 0.25f ? 0.5f : 1.0f)); 1904 /* Disregard wheel acceleration applied by the OS. */
1907 /* accelerated speed for repeated wheelings */ 1905 const int amount = iSign(ev->wheel.y);
1906#else
1907 const int amount = ev->wheel.y;
1908#endif 1908#endif
1909 if (keyMods_Sym(SDL_GetModState()) == KMOD_PRIMARY) {
1910 postCommandf_App("zoom.delta arg:%d", amount > 0 ? 10 : -10);
1911 return iTrue;
1912 }
1913 smoothScroll_DocumentWidget_(
1914 d,
1915 -3 * amount * lineHeight_Text(paragraph_FontId) * acceleration,
1916 smoothDuration_DocumentWidget_ *
1917 (!isFinished_Anim(&d->scrollY) && pos_Anim(&d->scrollY) < 0.25f ? 0.5f : 1.0f));
1918 /* accelerated speed for repeated wheelings */
1919 }
1909 iChangeFlags(d->flags, noHoverWhileScrolling_DocumentWidgetFlag, iTrue); 1920 iChangeFlags(d->flags, noHoverWhileScrolling_DocumentWidgetFlag, iTrue);
1910 return iTrue; 1921 return iTrue;
1911 } 1922 }