summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorTor Andersson <tor.andersson@artifex.com>2012-01-18 13:30:28 +0100
committerTor Andersson <tor.andersson@artifex.com>2012-01-18 13:30:28 +0100
commitb2c87fcd70b3f069388755baf7baa6b3c2590123 (patch)
treece06e8c79926a4a7b2b9af7cd2b4761f24a42e24 /apps
parent4edaee4fafa76a5ac5daf873167ba0cda8af4bc4 (diff)
downloadmupdf-b2c87fcd70b3f069388755baf7baa6b3c2590123.tar.xz
Add fullscreen mode to mupdf viewer.
Toggle with 'f'. Fullscreen turns off shrinkwrap, and shrinkwrap turns off fullscreen.
Diffstat (limited to 'apps')
-rw-r--r--apps/pdfapp.c11
-rw-r--r--apps/pdfapp.h2
-rw-r--r--apps/win_main.c21
-rw-r--r--apps/x11_main.c23
4 files changed, 56 insertions, 1 deletions
diff --git a/apps/pdfapp.c b/apps/pdfapp.c
index f685d098..5b839eb1 100644
--- a/apps/pdfapp.c
+++ b/apps/pdfapp.c
@@ -789,7 +789,18 @@ void pdfapp_onkey(pdfapp_t *app, int c)
* Pan view, but don't need to repaint image
*/
+ case 'f':
+ app->shrinkwrap = 0;
+ winfullscreen(app, !app->fullscreen);
+ app->fullscreen = !app->fullscreen;
+ break;
+
case 'w':
+ if (app->fullscreen)
+ {
+ winfullscreen(app, 0);
+ app->fullscreen = 0;
+ }
app->shrinkwrap = 1;
app->panx = app->pany = 0;
pdfapp_showpage(app, 0, 0, 1);
diff --git a/apps/pdfapp.h b/apps/pdfapp.h
index b23f939a..7aad1238 100644
--- a/apps/pdfapp.h
+++ b/apps/pdfapp.h
@@ -25,6 +25,7 @@ extern void winreloadfile(pdfapp_t*);
extern void windrawstring(pdfapp_t*, int x, int y, char *s);
extern void winclose(pdfapp_t*);
extern void winhelp(pdfapp_t*);
+extern void winfullscreen(pdfapp_t*, int state);
struct pdfapp_s
{
@@ -58,6 +59,7 @@ struct pdfapp_s
int winw, winh;
int scrw, scrh;
int shrinkwrap;
+ int fullscreen;
/* event handling state */
char number[256];
diff --git a/apps/win_main.c b/apps/win_main.c
index 8ccdee65..4818c58b 100644
--- a/apps/win_main.c
+++ b/apps/win_main.c
@@ -553,6 +553,27 @@ void winrepaintsearch(pdfapp_t *app)
InvalidateRect(hwndview, NULL, 0);
}
+void winfullscreen(pdfapp_t *app, int state)
+{
+ static WINDOWPLACEMENT savedplace;
+ static int isfullscreen = 0;
+ if (state && !isfullscreen)
+ {
+ GetWindowPlacement(hwndframe, &savedplace);
+ SetWindowLong(hwndframe, GWL_STYLE, WS_POPUP | WS_VISIBLE);
+ SetWindowPos(hwndframe, NULL, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER | SWP_FRAMECHANGED);
+ ShowWindow(hwndframe, SW_SHOWMAXIMIZED);
+ isfullscreen = 1;
+ }
+ if (!state && isfullscreen)
+ {
+ SetWindowLong(hwndframe, GWL_STYLE, WS_OVERLAPPEDWINDOW);
+ SetWindowPos(hwndframe, NULL, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER | SWP_FRAMECHANGED);
+ SetWindowPlacement(hwndframe, &savedplace);
+ isfullscreen = 0;
+ }
+}
+
/*
* Event handling
*/
diff --git a/apps/x11_main.c b/apps/x11_main.c
index 8ab20674..907b843c 100644
--- a/apps/x11_main.c
+++ b/apps/x11_main.c
@@ -68,6 +68,8 @@ static Atom XA_TARGETS;
static Atom XA_TIMESTAMP;
static Atom XA_UTF8_STRING;
static Atom WM_DELETE_WINDOW;
+static Atom NET_WM_STATE;
+static Atom NET_WM_STATE_FULLSCREEN;
static int x11fd;
static int xscr;
static Window xwin;
@@ -133,6 +135,8 @@ static void winopen(void)
XA_TIMESTAMP = XInternAtom(xdpy, "TIMESTAMP", False);
XA_UTF8_STRING = XInternAtom(xdpy, "UTF8_STRING", False);
WM_DELETE_WINDOW = XInternAtom(xdpy, "WM_DELETE_WINDOW", False);
+ NET_WM_STATE = XInternAtom(xdpy, "_NET_WM_STATE", False);
+ NET_WM_STATE_FULLSCREEN = XInternAtom(xdpy, "_NET_WM_STATE_FULLSCREEN", False);
xscr = DefaultScreen(xdpy);
@@ -154,7 +158,7 @@ static void winopen(void)
XAllocColor(xdpy, DefaultColormap(xdpy, xscr), &xshcolor);
xwin = XCreateWindow(xdpy, DefaultRootWindow(xdpy),
- 10, 10, 200, 100, 1,
+ 10, 10, 200, 100, 0,
ximage_get_depth(),
InputOutput,
ximage_get_visual(),
@@ -282,6 +286,23 @@ void winresize(pdfapp_t *app, int w, int h)
}
}
+void winfullscreen(pdfapp_t *app, int state)
+{
+ XEvent xev;
+ xev.xclient.type = ClientMessage;
+ xev.xclient.serial = 0;
+ xev.xclient.send_event = True;
+ xev.xclient.window = xwin;
+ xev.xclient.message_type = NET_WM_STATE;
+ xev.xclient.format = 32;
+ xev.xclient.data.l[0] = state;
+ xev.xclient.data.l[1] = NET_WM_STATE_FULLSCREEN;
+ xev.xclient.data.l[2] = 0;
+ XSendEvent(xdpy, DefaultRootWindow(xdpy), False,
+ SubstructureRedirectMask | SubstructureNotifyMask,
+ &xev);
+}
+
static void fillrect(int x, int y, int w, int h)
{
if (w > 0 && h > 0)