Re: [hackers] [sent] [PATCH] Add toggle fullscreen shortcut: f

From: Héctor Monacci <hector.monacci_AT_gmail.com>
Date: Sun, 18 Mar 2018 16:07:06 -0300

2018-03-18 11:50 GMT-03:00 Hiltjo Posthuma <hiltjo_AT_codemadness.org>:
> On Sun, Mar 18, 2018 at 09:08:54AM -0300, Héctor Monacci wrote:
>> Hi people, this is my first one, so please be patient if I
>> inadvertently break rules.
>>
>> After talking to Markus Teich, I added a fullscreen toggle function to
>> sent. It uses the f key for toggling.
>>
>> ---
>> 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
>> _AT_@ -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
>> _AT_@ -33,21 +33,21 @@ with `#` will be ignored. A `\` at the beginning
>> of the line escapes `_AT_` and
>> `#`. A presentation file could look like this:
>>
>> sent
>> -
>> +
>> _AT_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
>> -
>> +
>> \_AT_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
>> _AT_@ -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
>> _AT_@ -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 *);
>> _AT_@ -475,6 +476,16 @@ advance(const Arg *arg)
>> }
>> }
>>
>> +void
>> +fullscr_togg()
>
> Maybe rename this fullscreentoggle()

Why not? OK, I just made this change. Should I repost the diff?

>
>
>> +{
>> + static Bool toggle;
>> + toggle = !toggle;
>> + XDestroyWindow(xw.dpy, xw.win);
>> + XSync(xw.dpy, False);
>> + xinit(toggle);
>> +}
>> +
>> void
>> quit(const Arg *arg)
>> {
>> _AT_@ -560,7 +571,7 @@ xhints()
>> }
>>
>> void
>> -xinit()
>> +xinit(Bool fs)
>> {
>> XTextProperty prop;
>> unsigned int i;
>> _AT_@ -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);
>> +
>
> Theres an extra space before ) (" )") and the patch seems wrapped.

OK, thanks, I just deleted the extra space. Should I repost the diff now? ;)

>
>> 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);
>> _AT_@ -698,7 +713,7 @@ main(int argc, char *argv[])
>> load(fp);
>> fclose(fp);
>>
>> - xinit();
>> + xinit(False);
>> run();
>>
>> cleanup(0);
>> --
>> 2.16.2
>>
>
> For dwm you can already use the fullscreen layout, but this patch might be
> useful for other window managers indeed.

That's exactly my situation, since I don't use dwm. I think the patch
is a good trade-off between added complexity and added feature.

>
> --
> Kind regards,
> Hiltjo
>
Received on Sun Mar 18 2018 - 20:07:06 CET

This archive was generated by hypermail 2.3.0 : Sun Mar 18 2018 - 20:12:22 CET