From d8529b66a477fb65de13cd1a15610cb86e06341a Mon Sep 17 00:00:00 2001 From: Bakkeby Date: Mon, 24 Oct 2022 11:27:51 +0200 Subject: [PATCH] Adding fullscreen patch ref. #88 --- README.md | 5 +++++ config.def.h | 4 ++++ patch/fullscreen_x.c | 17 +++++++++++++++++ patch/fullscreen_x.h | 1 + patch/x_include.c | 3 +++ patch/x_include.h | 3 +++ patches.def.h | 7 +++++++ st.h | 3 +++ x.c | 5 +++++ 9 files changed, 48 insertions(+) create mode 100644 patch/fullscreen_x.c create mode 100644 patch/fullscreen_x.h diff --git a/README.md b/README.md index ac64429..42ae0cb 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,8 @@ Refer to [https://st.suckless.org/](https://st.suckless.org/) for details on the ### Changelog: +2022-10-24 - Added the fullscreen patch + 2022-08-28 - Added the use XftFontMatch patch 2022-08-24 - Added the no window decorations patch @@ -174,6 +176,9 @@ Refer to [https://st.suckless.org/](https://st.suckless.org/) for details on the - [~force-redraw-after-keypress~](https://lists.suckless.org/hackers/2004/17221.html) - ~this patch forces the terminal to check for new data on the tty on keypress with the aim of reducing input latency~ + - [fullscreen](https://st.suckless.org/patches/fullscreen/) + - allows the st window to go into fullscreen mode + - [gradient](https://st.suckless.org/patches/gradient/) - adds gradient transparency to st - depends on the alpha patch diff --git a/config.def.h b/config.def.h index ff6b5b3..2dcaef7 100644 --- a/config.def.h +++ b/config.def.h @@ -401,6 +401,10 @@ static Shortcut shortcuts[] = { //{ TERMMOD, XK_, changealphaunfocused, {.f = -0.05} }, #endif // ALPHA_FOCUS_HIGHLIGHT_PATCH #endif // ALPHA_PATCH + #if FULLSCREEN_PATCH + { XK_NO_MOD, XK_F11, fullscreen, {.i = 0} }, + { MODKEY, XK_Return, fullscreen, {.i = 0} }, + #endif // FULLSCREEN_PATCH #if SCROLLBACK_PATCH { ShiftMask, XK_Page_Up, kscrollup, {.i = -1}, S_PRI }, { ShiftMask, XK_Page_Down, kscrolldown, {.i = -1}, S_PRI }, diff --git a/patch/fullscreen_x.c b/patch/fullscreen_x.c new file mode 100644 index 0000000..3fa65f7 --- /dev/null +++ b/patch/fullscreen_x.c @@ -0,0 +1,17 @@ +void +fullscreen(const Arg *arg) +{ + XEvent ev; + + memset(&ev, 0, sizeof(ev)); + + ev.xclient.type = ClientMessage; + ev.xclient.message_type = xw.netwmstate; + ev.xclient.display = xw.dpy; + ev.xclient.window = xw.win; + ev.xclient.format = 32; + ev.xclient.data.l[0] = 2; /* _NET_WM_STATE_TOGGLE */ + ev.xclient.data.l[1] = xw.netwmfullscreen; + + XSendEvent(xw.dpy, DefaultRootWindow(xw.dpy), False, SubstructureNotifyMask|SubstructureRedirectMask, &ev); +} diff --git a/patch/fullscreen_x.h b/patch/fullscreen_x.h new file mode 100644 index 0000000..28a833b --- /dev/null +++ b/patch/fullscreen_x.h @@ -0,0 +1 @@ +static void fullscreen(const Arg *arg); diff --git a/patch/x_include.c b/patch/x_include.c index cd058a1..cbea418 100644 --- a/patch/x_include.c +++ b/patch/x_include.c @@ -17,6 +17,9 @@ #if FONT2_PATCH #include "font2.c" #endif +#if FULLSCREEN_PATCH +#include "fullscreen_x.c" +#endif #if INVERT_PATCH #include "invert.c" #endif diff --git a/patch/x_include.h b/patch/x_include.h index 3eb1d19..6505909 100644 --- a/patch/x_include.h +++ b/patch/x_include.h @@ -14,6 +14,9 @@ #if FONT2_PATCH #include "font2.h" #endif +#if FULLSCREEN_PATCH +#include "fullscreen_x.h" +#endif #if INVERT_PATCH #include "invert.h" #endif diff --git a/patches.def.h b/patches.def.h index 26ae7e6..013cc10 100644 --- a/patches.def.h +++ b/patches.def.h @@ -180,6 +180,13 @@ */ #define FONT2_PATCH 0 +/* This patch adds the ability to toggle st into fullscreen mode. + * Two key bindings are defined: F11 which is typical with other applications and Alt+Enter + * which matches the default xterm behavior. + * https://st.suckless.org/patches/fullscreen/ + */ +#define FULLSCREEN_PATCH 0 + /* Hide the X cursor whenever a key is pressed and show it back when the mouse is moved in * the terminal window. * https://st.suckless.org/patches/hidecursor/ diff --git a/st.h b/st.h index 6305667..41af307 100644 --- a/st.h +++ b/st.h @@ -211,6 +211,9 @@ typedef struct { Drawable buf; GlyphFontSpec *specbuf; /* font spec buffer used for rendering */ Atom xembed, wmdeletewin, netwmname, netwmiconname, netwmpid; + #if FULLSCREEN_PATCH + Atom netwmstate, netwmfullscreen; + #endif // FULLSCREEN_PATCH #if NETWMICON_PATCH Atom netwmicon; #endif // NETWMICON_PATCH diff --git a/x.c b/x.c index fbfe8d6..7f42e4b 100644 --- a/x.c +++ b/x.c @@ -1581,6 +1581,11 @@ xinit(int cols, int rows) XChangeProperty(xw.dpy, xw.win, xw.netwmpid, XA_CARDINAL, 32, PropModeReplace, (uchar *)&thispid, 1); + #if FULLSCREEN_PATCH + xw.netwmstate = XInternAtom(xw.dpy, "_NET_WM_STATE", False); + xw.netwmfullscreen = XInternAtom(xw.dpy, "_NET_WM_STATE_FULLSCREEN", False); + #endif // FULLSCREEN_PATCH + win.mode = MODE_NUMLOCK; resettitle(); xhints();