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.c55
1 files changed, 23 insertions, 32 deletions
diff --git a/src/ui/documentwidget.c b/src/ui/documentwidget.c
index 9b412783..f3083207 100644
--- a/src/ui/documentwidget.c
+++ b/src/ui/documentwidget.c
@@ -2324,37 +2324,33 @@ static iBool processEvent_DocumentWidget_(iDocumentWidget *d, const SDL_Event *e
2324 /* TODO: Maybe clean this up a bit? Wheel events are used for scrolling 2324 /* TODO: Maybe clean this up a bit? Wheel events are used for scrolling
2325 but they are calculated differently based on device/mouse/trackpad. */ 2325 but they are calculated differently based on device/mouse/trackpad. */
2326 const iInt2 mouseCoord = mouseCoord_Window(get_Window()); 2326 const iInt2 mouseCoord = mouseCoord_Window(get_Window());
2327#if defined (iPlatformApple) 2327 if (isPerPixel_MouseWheelEvent(&ev->wheel)) {
2328 /* On macOS, we handle both trackpad and mouse events. We expect SDL to identify
2329 which device is sending the event. */
2330 if (ev->wheel.which == 0) { /* Trackpad with precise scrolling w/inertia. */
2331 stop_Anim(&d->scrollY); 2328 stop_Anim(&d->scrollY);
2332 iInt2 wheel = init_I2(ev->wheel.x, ev->wheel.y); 2329 iInt2 wheel = init_I2(ev->wheel.x, ev->wheel.y);
2333# if defined (iPlatformAppleMobile) 2330//# if defined (iPlatformAppleMobile)
2334 wheel.x = -wheel.x; 2331// wheel.x = -wheel.x;
2335# else 2332//# else
2336 /* Wheel mounts are in points. */ 2333// /* Wheel mounts are in points. */
2337 mulfv_I2(&wheel, get_Window()->pixelRatio); 2334// mulfv_I2(&wheel, get_Window()->pixelRatio);
2338 /* Only scroll on one axis at a time. */ 2335// /* Only scroll on one axis at a time. */
2339 if (iAbs(wheel.x) > iAbs(wheel.y)) { 2336// if (iAbs(wheel.x) > iAbs(wheel.y)) {
2340 wheel.y = 0; 2337// wheel.y = 0;
2341 } 2338// }
2342 else { 2339// else {
2343 wheel.x = 0; 2340// wheel.x = 0;
2344 } 2341// }
2345# endif 2342//# endif
2346 scroll_DocumentWidget_(d, -wheel.y); 2343 scroll_DocumentWidget_(d, -wheel.y);
2347 scrollWideBlock_DocumentWidget_(d, mouseCoord, wheel.x, 0); 2344 scrollWideBlock_DocumentWidget_(d, mouseCoord, -wheel.x, 0);
2348 } 2345 }
2349 else 2346 else {
2350#endif 2347 /* Traditional mouse wheel. */
2351 /* Traditional mouse wheel. */ { 2348//#if defined (iPlatformApple)
2352#if defined (iPlatformApple) 2349// /* Disregard wheel acceleration applied by the OS. */
2353 /* Disregard wheel acceleration applied by the OS. */ 2350// const int amount = iSign(ev->wheel.y);
2354 const int amount = iSign(ev->wheel.y); 2351//#else
2355#else
2356 const int amount = ev->wheel.y; 2352 const int amount = ev->wheel.y;
2357#endif 2353//#endif
2358 if (keyMods_Sym(modState_Keys()) == KMOD_PRIMARY) { 2354 if (keyMods_Sym(modState_Keys()) == KMOD_PRIMARY) {
2359 postCommandf_App("zoom.delta arg:%d", amount > 0 ? 10 : -10); 2355 postCommandf_App("zoom.delta arg:%d", amount > 0 ? 10 : -10);
2360 return iTrue; 2356 return iTrue;
@@ -2365,13 +2361,8 @@ static iBool processEvent_DocumentWidget_(iDocumentWidget *d, const SDL_Event *e
2365 smoothDuration_DocumentWidget_ * 2361 smoothDuration_DocumentWidget_ *
2366 /* accelerated speed for repeated wheelings */ 2362 /* accelerated speed for repeated wheelings */
2367 (!isFinished_Anim(&d->scrollY) && pos_Anim(&d->scrollY) < 0.25f ? 0.5f : 1.0f)); 2363 (!isFinished_Anim(&d->scrollY) && pos_Anim(&d->scrollY) < 0.25f ? 0.5f : 1.0f));
2368#if defined (iPlatformMsys)
2369 const int horizStep = ev->wheel.x * 3;
2370#else
2371 const int horizStep = ev->wheel.x * -3;
2372#endif
2373 scrollWideBlock_DocumentWidget_( 2364 scrollWideBlock_DocumentWidget_(
2374 d, mouseCoord, horizStep * lineHeight_Text(paragraph_FontId), 167); 2365 d, mouseCoord, -3 * ev->wheel.x * lineHeight_Text(paragraph_FontId), 167);
2375 } 2366 }
2376 iChangeFlags(d->flags, noHoverWhileScrolling_DocumentWidgetFlag, iTrue); 2367 iChangeFlags(d->flags, noHoverWhileScrolling_DocumentWidgetFlag, iTrue);
2377 return iTrue; 2368 return iTrue;