summaryrefslogtreecommitdiff
path: root/platform
diff options
context:
space:
mode:
authorRobin Watts <robin.watts@artifex.com>2015-03-30 17:05:19 +0100
committerRobin Watts <robin.watts@artifex.com>2015-03-30 17:35:43 +0100
commit8d0ae07482401c8eab116c3dd6a78fde469e03ad (patch)
treec0300d5a2414f6a3bacf1535b3256b512ce26ca5 /platform
parentfd5a4f5128e76b1b9cf35f70b1341e67f640e9be (diff)
downloadmupdf-8d0ae07482401c8eab116c3dd6a78fde469e03ad.tar.xz
Bug 695804: Add support for 'Shift-Space' in the viewer.
Update pdfapp_onkey to take modifiers. If shift is held down when space is sent, then back up a page. This involves updating the windows app to actually send modifiers. Previously they were always sent as zero to the onmouse routine.
Diffstat (limited to 'platform')
-rw-r--r--platform/x11/pdfapp.c20
-rw-r--r--platform/x11/pdfapp.h2
-rw-r--r--platform/x11/win_main.c21
-rw-r--r--platform/x11/x11_main.c10
4 files changed, 34 insertions, 19 deletions
diff --git a/platform/x11/pdfapp.c b/platform/x11/pdfapp.c
index a54a357b..a4c3488d 100644
--- a/platform/x11/pdfapp.c
+++ b/platform/x11/pdfapp.c
@@ -1016,7 +1016,7 @@ void pdfapp_autozoom(pdfapp_t *app)
pdfapp_autozoom_vertical(app);
}
-void pdfapp_onkey(pdfapp_t *app, int c)
+void pdfapp_onkey(pdfapp_t *app, int c, int modifiers)
{
int oldpage = app->pageno;
enum panning panto = PAN_TO_TOP;
@@ -1048,7 +1048,7 @@ void pdfapp_onkey(pdfapp_t *app, int c)
pdfapp_showpage(app, 1, 1, 0, 0, 1);
}
- pdfapp_onkey(app, 'n');
+ pdfapp_onkey(app, 'n', 0);
}
else
winrepaint(app);
@@ -1293,10 +1293,20 @@ void pdfapp_onkey(pdfapp_t *app, int c)
case ' ':
panto = DONT_PAN;
- if (app->numberlen > 0)
- app->pageno += atoi(app->number);
+ if (modifiers & 1)
+ {
+ if (app->numberlen > 0)
+ app->pageno -= atoi(app->number);
+ else
+ app->pageno--;
+ }
else
- app->pageno++;
+ {
+ if (app->numberlen > 0)
+ app->pageno += atoi(app->number);
+ else
+ app->pageno++;
+ }
break;
case '<':
diff --git a/platform/x11/pdfapp.h b/platform/x11/pdfapp.h
index 81211181..3c298b67 100644
--- a/platform/x11/pdfapp.h
+++ b/platform/x11/pdfapp.h
@@ -145,7 +145,7 @@ int pdfapp_preclose(pdfapp_t *app);
char *pdfapp_version(pdfapp_t *app);
char *pdfapp_usage(pdfapp_t *app);
-void pdfapp_onkey(pdfapp_t *app, int c);
+void pdfapp_onkey(pdfapp_t *app, int c, int modifiers);
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);
diff --git a/platform/x11/win_main.c b/platform/x11/win_main.c
index 781e6892..532fa76c 100644
--- a/platform/x11/win_main.c
+++ b/platform/x11/win_main.c
@@ -910,7 +910,7 @@ static void killtimer(pdfapp_t *app)
timer_pending = 0;
}
-void handlekey(int c)
+void handlekey(int c, int modifier)
{
if (timer_pending)
killtimer(&gapp);
@@ -940,12 +940,15 @@ void handlekey(int c)
}
}
- pdfapp_onkey(&gapp, c);
+ pdfapp_onkey(&gapp, c, modifier);
winrepaint(&gapp);
}
void handlemouse(int x, int y, int btn, int state)
{
+ int modifier = (GetAsyncKeyState(VK_SHIFT) < 0);
+ modifier |= ((GetAsyncKeyState(VK_CONTROL) < 0)<<2);
+
if (state != 0 && timer_pending)
killtimer(&gapp);
@@ -960,7 +963,7 @@ void handlemouse(int x, int y, int btn, int state)
if (state == -1)
ReleaseCapture();
- pdfapp_onmouse(&gapp, x, y, btn, 0, state);
+ pdfapp_onmouse(&gapp, x, y, btn, modifier, state);
}
LRESULT CALLBACK
@@ -1097,9 +1100,9 @@ viewproc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
case WM_MOUSEWHEEL:
if ((signed short)HIWORD(wParam) > 0)
- handlekey(LOWORD(wParam) & MK_SHIFT ? '+' : 'k');
+ handlekey(LOWORD(wParam) & MK_SHIFT ? '+' : 'k', 0);
else
- handlekey(LOWORD(wParam) & MK_SHIFT ? '-' : 'j');
+ handlekey(LOWORD(wParam) & MK_SHIFT ? '-' : 'j', 0);
return 0;
/* Timer */
@@ -1107,7 +1110,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);
+ handlekey(VK_RIGHT + 256, 0);
handlemouse(oldx, oldy, 0, 0); /* update cursor */
return 0;
}
@@ -1127,7 +1130,7 @@ viewproc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
case VK_DOWN:
case VK_NEXT:
case VK_ESCAPE:
- handlekey(wParam + 256);
+ handlekey(wParam + 256, 0);
handlemouse(oldx, oldy, 0, 0); /* update cursor */
return 0;
}
@@ -1137,7 +1140,9 @@ viewproc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
case WM_CHAR:
if (wParam < 256)
{
- handlekey(wParam);
+ int modifier = (GetAsyncKeyState(VK_SHIFT) < 0);
+ modifier |= ((GetAsyncKeyState(VK_CONTROL) < 0)<<2);
+ handlekey(wParam, modifier);
handlemouse(oldx, oldy, 0, 0); /* update cursor */
}
return 0;
diff --git a/platform/x11/x11_main.c b/platform/x11/x11_main.c
index bef6a366..085c58d8 100644
--- a/platform/x11/x11_main.c
+++ b/platform/x11/x11_main.c
@@ -749,7 +749,7 @@ void winopenuri(pdfapp_t *app, char *buf)
waitpid(pid, NULL, 0);
}
-static void onkey(int c)
+static void onkey(int c, int modifiers)
{
advance_scheduled = 0;
@@ -772,7 +772,7 @@ static void onkey(int c)
return;
}
- pdfapp_onkey(&gapp, c);
+ pdfapp_onkey(&gapp, c, modifiers);
if (gapp.issearching)
{
@@ -958,7 +958,7 @@ int main(int argc, char **argv)
if (xevt.xkey.state & ControlMask && keysym == XK_c)
docopy(&gapp, XA_CLIPBOARD);
else if (len)
- onkey(buf[0]);
+ onkey(buf[0], xevt.xkey.state);
onmouse(oldx, oldy, 0, 0, 0);
@@ -1054,7 +1054,7 @@ int main(int argc, char **argv)
if (tmo_advance_delay.tv_sec <= 0)
{
/* Too late already */
- onkey(' ');
+ onkey(' ', 0);
onmouse(oldx, oldy, 0, 0, 0);
advance_scheduled = 0;
}
@@ -1086,7 +1086,7 @@ int main(int argc, char **argv)
{
if (timeout == &tmo_advance_delay)
{
- onkey(' ');
+ onkey(' ', 0);
onmouse(oldx, oldy, 0, 0, 0);
advance_scheduled = 0;
}