summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--platform/x11/pdfapp.c91
-rw-r--r--platform/x11/win_main.c19
2 files changed, 73 insertions, 37 deletions
diff --git a/platform/x11/pdfapp.c b/platform/x11/pdfapp.c
index a4c3488d..3eda4c6f 100644
--- a/platform/x11/pdfapp.c
+++ b/platform/x11/pdfapp.c
@@ -1400,6 +1400,66 @@ void pdfapp_onkey(pdfapp_t *app, int c, int modifiers)
}
}
+static void handlescroll(pdfapp_t *app, int modifiers, int dir)
+{
+ app->ispanning = app->iscopying = 0;
+ if (modifiers & (1<<2))
+ {
+ /* zoom in/out if ctrl is pressed */
+ if (dir < 0)
+ app->resolution = zoom_in(app->resolution);
+ else
+ app->resolution = zoom_out(app->resolution);
+ if (app->resolution > MAXRES)
+ app->resolution = MAXRES;
+ if (app->resolution < MINRES)
+ app->resolution = MINRES;
+ pdfapp_showpage(app, 0, 1, 1, 0, 0);
+ }
+ else
+ {
+ /* scroll up/down, or left/right if
+ shift is pressed */
+ int w = fz_pixmap_width(app->ctx, app->image);
+ int h = fz_pixmap_height(app->ctx, app->image);
+ int xstep = 0;
+ int ystep = 0;
+ int pagestep = 0;
+ if (modifiers & (1<<0))
+ {
+ if (dir > 0 && app->panx >= 0)
+ pagestep = -1;
+ else if (dir < 0 && app->panx <= app->winw - w)
+ pagestep = 1;
+ else
+ xstep = 20 * dir;
+ }
+ else
+ {
+ if (dir > 0 && app->pany >= 0)
+ pagestep = -1;
+ else if (dir < 0 && app->pany <= app->winh - h)
+ pagestep = 1;
+ else
+ ystep = 20 * dir;
+ }
+ if (pagestep == 0)
+ pdfapp_panview(app, app->panx + xstep, app->pany + ystep);
+ else if (pagestep > 0 && app->pageno < app->pagecount)
+ {
+ app->pageno++;
+ app->pany = 0;
+ pdfapp_showpage(app, 1, 1, 1, 0, 0);
+ }
+ else if (pagestep < 0 && app->pageno > 1)
+ {
+ app->pageno--;
+ app->pany = INT_MIN;
+ pdfapp_showpage(app, 1, 1, 1, 0, 0);
+ }
+ }
+}
+
void pdfapp_onmouse(pdfapp_t *app, int x, int y, int btn, int modifiers, int state)
{
fz_context *ctx = app->ctx;
@@ -1583,39 +1643,12 @@ void pdfapp_onmouse(pdfapp_t *app, int x, int y, int btn, int modifiers, int sta
}
if (btn == 4 || btn == 5) /* scroll wheel */
{
- int dir = btn == 4 ? 1 : -1;
- app->ispanning = app->iscopying = 0;
- if (modifiers & (1<<2))
- {
- /* zoom in/out if ctrl is pressed */
- if (dir > 0)
- app->resolution = zoom_in(app->resolution);
- else
- app->resolution = zoom_out(app->resolution);
- if (app->resolution > MAXRES)
- app->resolution = MAXRES;
- if (app->resolution < MINRES)
- app->resolution = MINRES;
- pdfapp_showpage(app, 0, 1, 1, 0, 0);
- }
- else
- {
- /* scroll up/down, or left/right if
- shift is pressed */
- int isx = (modifiers & (1<<0));
- int xstep = isx ? 20 * dir : 0;
- int ystep = !isx ? 20 * dir : 0;
- pdfapp_panview(app, app->panx + xstep, app->pany + ystep);
- }
+ handlescroll(app, modifiers, btn == 4 ? 1 : -1);
}
if (btn == 6 || btn == 7) /* scroll wheel (horizontal) */
{
/* scroll left/right or up/down if shift is pressed */
- int dir = btn == 6 ? 1 : -1;
- int isx = (modifiers & (1<<0));
- int xstep = !isx ? 20 * dir : 0;
- int ystep = isx ? 20 * dir : 0;
- pdfapp_panview(app, app->panx + xstep, app->pany + ystep);
+ handlescroll(app, modifiers ^ (1<<0), btn == 6 ? 1 : -1);
}
if (app->presentation_mode)
{
diff --git a/platform/x11/win_main.c b/platform/x11/win_main.c
index 532fa76c..32121f5f 100644
--- a/platform/x11/win_main.c
+++ b/platform/x11/win_main.c
@@ -910,8 +910,11 @@ static void killtimer(pdfapp_t *app)
timer_pending = 0;
}
-void handlekey(int c, int modifier)
+void handlekey(int c)
{
+ int modifier = (GetAsyncKeyState(VK_SHIFT) < 0);
+ modifier |= ((GetAsyncKeyState(VK_CONTROL) < 0)<<2);
+
if (timer_pending)
killtimer(&gapp);
@@ -1100,9 +1103,11 @@ viewproc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
case WM_MOUSEWHEEL:
if ((signed short)HIWORD(wParam) > 0)
- handlekey(LOWORD(wParam) & MK_SHIFT ? '+' : 'k', 0);
+ handlemouse(oldx, oldy, 4, 1);
+ //handlekey(LOWORD(wParam) & MK_SHIFT ? '+' : 'k');
else
- handlekey(LOWORD(wParam) & MK_SHIFT ? '-' : 'j', 0);
+ handlemouse(oldx, oldy, 5, 1);
+ //handlekey(LOWORD(wParam) & MK_SHIFT ? '-' : 'j');
return 0;
/* Timer */
@@ -1110,7 +1115,7 @@ viewproc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
if (wParam == OUR_TIMER_ID && timer_pending && gapp.presentation_mode)
{
timer_pending = 0;
- handlekey(VK_RIGHT + 256, 0);
+ handlekey(VK_RIGHT + 256);
handlemouse(oldx, oldy, 0, 0); /* update cursor */
return 0;
}
@@ -1130,7 +1135,7 @@ viewproc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
case VK_DOWN:
case VK_NEXT:
case VK_ESCAPE:
- handlekey(wParam + 256, 0);
+ handlekey(wParam + 256);
handlemouse(oldx, oldy, 0, 0); /* update cursor */
return 0;
}
@@ -1140,9 +1145,7 @@ viewproc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
case WM_CHAR:
if (wParam < 256)
{
- int modifier = (GetAsyncKeyState(VK_SHIFT) < 0);
- modifier |= ((GetAsyncKeyState(VK_CONTROL) < 0)<<2);
- handlekey(wParam, modifier);
+ handlekey(wParam);
handlemouse(oldx, oldy, 0, 0); /* update cursor */
}
return 0;