summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apps/common/pdfapp.c26
-rw-r--r--apps/unix/x11pdf.c12
-rw-r--r--include/pdfapp.h2
3 files changed, 32 insertions, 8 deletions
diff --git a/apps/common/pdfapp.c b/apps/common/pdfapp.c
index ef342b43..70a83b29 100644
--- a/apps/common/pdfapp.c
+++ b/apps/common/pdfapp.c
@@ -512,7 +512,7 @@ void pdfapp_onkey(pdfapp_t *app, int c)
}
}
-void pdfapp_onmouse(pdfapp_t *app, int x, int y, int btn, int state)
+void pdfapp_onmouse(pdfapp_t *app, int x, int y, int btn, int modifiers, int state)
{
pdf_link *link;
fz_matrix ctm;
@@ -568,6 +568,30 @@ void pdfapp_onmouse(pdfapp_t *app, int x, int y, int btn, int state)
app->selr.y0 = y;
app->selr.y1 = y;
}
+ 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 */
+ app->zoom += 0.1 * dir;
+ if (app->zoom > 3.0)
+ app->zoom = 3.0;
+ if (app->zoom < 0.1)
+ app->zoom = 0.1;
+ pdfapp_showpage(app, 0, 1);
+ }
+ 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);
+ }
+ }
}
else if (state == -1)
diff --git a/apps/unix/x11pdf.c b/apps/unix/x11pdf.c
index 0df360db..f12d27f1 100644
--- a/apps/unix/x11pdf.c
+++ b/apps/unix/x11pdf.c
@@ -379,7 +379,7 @@ void onkey(int c)
pdfapp_onkey(&gapp, c);
}
-void onmouse(int x, int y, int btn, int state)
+void onmouse(int x, int y, int btn, int modifiers, int state)
{
if (state != 0 && justcopied)
{
@@ -387,7 +387,7 @@ void onmouse(int x, int y, int btn, int state)
winrepaint(&gapp);
}
- pdfapp_onmouse(&gapp, x, y, btn, state);
+ pdfapp_onmouse(&gapp, x, y, btn, modifiers, state);
}
void usage(void)
@@ -465,7 +465,7 @@ int main(int argc, char **argv)
len = XLookupString(&xevt.xkey, buf, sizeof buf, &keysym, 0);
if (len)
onkey(buf[0]);
- onmouse(oldx, oldy, 0, 0);
+ onmouse(oldx, oldy, 0, 0, 0);
if (dirty)
{
@@ -478,16 +478,16 @@ int main(int argc, char **argv)
case MotionNotify:
oldx = xevt.xbutton.x;
oldy = xevt.xbutton.y;
- onmouse(xevt.xbutton.x, xevt.xbutton.y, xevt.xbutton.button, 0);
+ onmouse(xevt.xbutton.x, xevt.xbutton.y, xevt.xbutton.button, xevt.xbutton.state, 0);
break;
case ButtonPress:
- onmouse(xevt.xbutton.x, xevt.xbutton.y, xevt.xbutton.button, 1);
+ onmouse(xevt.xbutton.x, xevt.xbutton.y, xevt.xbutton.button, xevt.xbutton.state, 1);
break;
case ButtonRelease:
copytime = xevt.xbutton.time;
- onmouse(xevt.xbutton.x, xevt.xbutton.y, xevt.xbutton.button, -1);
+ onmouse(xevt.xbutton.x, xevt.xbutton.y, xevt.xbutton.button, xevt.xbutton.state, -1);
break;
case SelectionRequest:
diff --git a/include/pdfapp.h b/include/pdfapp.h
index 407427e8..4792adda 100644
--- a/include/pdfapp.h
+++ b/include/pdfapp.h
@@ -69,7 +69,7 @@ void pdfapp_close(pdfapp_t *app);
char *pdfapp_usage(pdfapp_t *app);
void pdfapp_onkey(pdfapp_t *app, int c);
-void pdfapp_onmouse(pdfapp_t *app, int x, int y, int btn, int state);
+void pdfapp_onmouse(pdfapp_t *app, int x, int y, int btn, int modifiers, int state);
void pdfapp_oncopy(pdfapp_t *app, unsigned short *ucsbuf, int ucslen);
void pdfapp_onresize(pdfapp_t *app, int w, int h);