Adding fullscreen patch ref. #88

This commit is contained in:
Bakkeby 2022-10-24 11:27:51 +02:00
parent 4dfb6683cd
commit d8529b66a4
9 changed files with 48 additions and 0 deletions

View File

@ -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

View File

@ -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 },

17
patch/fullscreen_x.c Normal file
View File

@ -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);
}

1
patch/fullscreen_x.h Normal file
View File

@ -0,0 +1 @@
static void fullscreen(const Arg *arg);

View File

@ -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

View File

@ -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

View File

@ -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/

3
st.h
View File

@ -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

5
x.c
View File

@ -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();