2018-03-28 5:54 GMT-03:00 Markus Teich >> Thank you Markus! Sure I can wait! > > > Cool, please resend the fixed patch. >
Here it goes. I hope it is OK! >From 37637d82867278bad5593db9a2687bc95c1bdb13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor=20M=2E=20Monacci?= <[email protected]> Date: Sun, 18 Mar 2018 09:04:23 -0300 Subject: [PATCH] Add toggle fullscreen shortcut: f --- README.md | 12 ++++++------ config.def.h | 1 + sent.c | 21 ++++++++++++++++++--- 3 files changed, 25 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index c1e9385..4e93d26 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ To get a little demo, just type make && ./sent example -You can navigate with the arrow keys and quit with `q`. +You can navigate with the arrow keys, toggle fullscreen with `f`, and quit with `q`. Usage @@ -33,21 +33,21 @@ with `#` will be ignored. A `\` at the beginning of the line escapes `@` and `#`. A presentation file could look like this: sent - + @nyan.png - + depends on - Xlib - Xft - farbfeld - + sent FILENAME one slide per paragraph # This is a comment and will not be part of the presentation \# This and the next line start with backslashes - + \@FILE.png - + thanks / questions? diff --git a/config.def.h b/config.def.h index 60eb376..5dc7d2b 100644 --- a/config.def.h +++ b/config.def.h @@ -46,6 +46,7 @@ static Shortcut shortcuts[] = { { XK_Prior, advance, {.i = -1} }, { XK_n, advance, {.i = +1} }, { XK_p, advance, {.i = -1} }, + { XK_f, fullscr_togg, {0} }, { XK_r, reload, {0} }, }; diff --git a/sent.c b/sent.c index c50a572..5b0b6cc 100644 --- a/sent.c +++ b/sent.c @@ -97,13 +97,14 @@ static void cleanup(int slidesonly); static void reload(const Arg *arg); static void load(FILE *fp); static void advance(const Arg *arg); +static void fullscr_togg(); static void quit(const Arg *arg); static void resize(int width, int height); static void run(); static void usage(); static void xdraw(); static void xhints(); -static void xinit(); +static void xinit(Bool fs); static void xloadfonts(); static void bpress(XEvent *); @@ -475,6 +476,16 @@ advance(const Arg *arg) } } +void +fullscr_togg() +{ + static Bool toggle; + toggle = !toggle; + XDestroyWindow(xw.dpy, xw.win); + XSync(xw.dpy, False); + xinit(toggle); +} + void quit(const Arg *arg) { @@ -560,7 +571,7 @@ xhints() } void -xinit() +xinit(Bool fs) { XTextProperty prop; unsigned int i; @@ -580,6 +591,10 @@ xinit() InputOutput, xw.vis, CWBitGravity | CWEventMask, &xw.attrs); + Atom wm_state = XInternAtom(xw.dpy, "_NET_WM_STATE", True); + Atom wm_fullscreen = XInternAtom(xw.dpy, "_NET_WM_STATE_FULLSCREEN", True); + XChangeProperty(xw.dpy, xw.win, wm_state, XA_ATOM, 32, PropModeReplace, (unsigned char *)&wm_fullscreen, fs); + xw.wmdeletewin = XInternAtom(xw.dpy, "WM_DELETE_WINDOW", False); xw.netwmname = XInternAtom(xw.dpy, "_NET_WM_NAME", False); XSetWMProtocols(xw.dpy, xw.win, &xw.wmdeletewin, 1); @@ -698,7 +713,7 @@ main(int argc, char *argv[]) load(fp); fclose(fp); - xinit(); + xinit(False); run(); cleanup(0); -- 2.16.2
