remove games/actualfullscreenpatch use fullscreen compilation and add ewmhtags

This commit is contained in:
2026-07-02 22:42:48 +02:00
parent 5accaed254
commit 3f2aa9d37f
13 changed files with 760 additions and 824 deletions

View File

@@ -140,10 +140,12 @@ static const Key keys[] = {
{ MODKEY, XK_Tab, view, {0} }, { MODKEY, XK_Tab, view, {0} },
{ MODKEY|ShiftMask, XK_c, killclient, {0} }, { MODKEY|ShiftMask, XK_c, killclient, {0} },
{ MODKEY, XK_t, setlayout, {.v = &layouts[0]} }, { MODKEY, XK_t, setlayout, {.v = &layouts[0]} },
{ MODKEY, XK_f, setlayout, {.v = &layouts[1]} }, { MODKEY, XK_e, setlayout, {.v = &layouts[1]} },
{ MODKEY, XK_m, setlayout, {.v = &layouts[2]} }, { MODKEY, XK_m, setlayout, {.v = &layouts[2]} },
{ MODKEY, XK_space, setlayout, {0} }, { MODKEY, XK_space, setlayout, {0} },
{ MODKEY|ShiftMask, XK_space, togglefloating, {0} }, { MODKEY|ShiftMask, XK_space, togglefloating, {0} },
{ MODKEY, XK_f, togglefullscreen, {0} },
{ MODKEY|ShiftMask, XK_f, togglefakefullscreen, {0} },
{ MODKEY, XK_0, view, {.ui = ~0 } }, { MODKEY, XK_0, view, {.ui = ~0 } },
{ MODKEY|ShiftMask, XK_0, tag, {.ui = ~0 } }, { MODKEY|ShiftMask, XK_0, tag, {.ui = ~0 } },
{ MODKEY, XK_comma, focusmon, {.i = -1 } }, { MODKEY, XK_comma, focusmon, {.i = -1 } },

View File

@@ -1,19 +1,10 @@
--- config.def.h --- config.def.h
+++ config.def.h +++ config.def.h
@@ -42,6 +42,7 @@ static const Layout layouts[] = { @@ -35,7 +35,6 @@ static const Rule rules[] = {
{ "[]=", tile }, /* first entry is default */ static const float mfact = 0.55; /* factor of master area size [0.05..0.95] */
{ "><>", NULL }, /* no layout function means floating behavior */ static const int nmaster = 1; /* number of clients in master area */
{ "[M]", monocle }, static const int resizehints = 1; /* 1 means respect size hints in tiled resizals */
+ { NULL, NULL }, -static const int lockfullscreen = 1; /* 1 will force focus on the fullscreen window */
};
/* key definitions */ static const Layout layouts[] = {
@@ -85,6 +86,8 @@ static Key keys[] = { /* symbol arrange function */
{ MODKEY, XK_period, focusmon, {.i = +1 } },
{ MODKEY|ShiftMask, XK_comma, tagmon, {.i = -1 } },
{ MODKEY|ShiftMask, XK_period, tagmon, {.i = +1 } },
+ { MODKEY|ControlMask, XK_comma, cyclelayout, {.i = -1 } },
+ { MODKEY|ControlMask, XK_period, cyclelayout, {.i = +1 } },
TAGKEYS( XK_1, 0)
TAGKEYS( XK_2, 1)
TAGKEYS( XK_3, 2)

View File

@@ -14,7 +14,6 @@ static const unsigned int gappiv = 10; /* vert inner gap between window
static const unsigned int gappoh = 10; /* horiz outer gap between windows and screen edge */ static const unsigned int gappoh = 10; /* horiz outer gap between windows and screen edge */
static const unsigned int gappov = 30; /* vert outer gap between windows and screen edge */ static const unsigned int gappov = 30; /* vert outer gap between windows and screen edge */
static int smartgaps = 0; /* 1 means no outer gap when there is only one window */ static int smartgaps = 0; /* 1 means no outer gap when there is only one window */
static const int swallowfloating = 0; /* 1 means swallow floating windows by default */
static const int showbar = 1; /* 0 means no bar */ static const int showbar = 1; /* 0 means no bar */
static const int topbar = 1; /* 0 means bottom bar */ static const int topbar = 1; /* 0 means bottom bar */
static const char *fonts[] = { "JetBrainsMono Nerd Font Mono:style=Bold:size=16",}; static const char *fonts[] = { "JetBrainsMono Nerd Font Mono:style=Bold:size=16",};
@@ -35,7 +34,7 @@ typedef struct {
const void *cmd; const void *cmd;
} Sp; } Sp;
const char *spcmd1[] = {"alacritty", "--class", "spterm", NULL }; const char *spcmd1[] = {"alacritty", "--class", "spterm", NULL };
const char *spcmd2[] = {"alacritty", "--class", "spfm", NULL }; const char *spcmd2[] = {"alacritty", "--class", "spfm", "-e", "ranger", NULL };
const char *spcmd3[] = {"keepassxc", NULL }; const char *spcmd3[] = {"keepassxc", NULL };
static Sp scratchpads[] = { static Sp scratchpads[] = {
/* name cmd */ /* name cmd */
@@ -52,28 +51,24 @@ static const Rule rules[] = {
* WM_CLASS(STRING) = instance, class * WM_CLASS(STRING) = instance, class
* WM_NAME(STRING) = title * WM_NAME(STRING) = title
*/ */
/* class instance title tags mask isfloating isterminal isswallow monitor isgame */ /* class instance title tags mask isfloating isterminal monitor */
{ "Playground", NULL, NULL, 0, 1, 0, -1 -1 }, { "Playground", NULL, NULL, 0, 1, -1 },
{ "steam", NULL, NULL, 1 << 1, 0, 0, -1 -1 }, { "steam", NULL, NULL, 1 << 1, 0, -1 },
{ "Firefox", NULL, NULL, 1 << 2, 0, 0, -1 -1 }, { "Firefox", NULL, NULL, 1 << 2, 0, -1 },
{ "brave-browser", NULL, NULL, 1 << 3, 0, 0, -1 -1 }, { "brave-browser", NULL, NULL, 1 << 3, 0, -1 },
{ "discord", NULL, NULL, 1 << 4, 0, 0, -1 -1 }, { "discord", NULL, NULL, 1 << 4, 0, -1 },
{ "feishin", NULL, NULL, 1 << 5, 0, 0, -1 -1 }, { "feishin", NULL, NULL, 1 << 5, 0, -1 },
{ NULL, "spterm", NULL, SPTAG(0), 1, 0, 0, -1 }, { NULL, "spterm", NULL, SPTAG(0), 1, 0 },
{ NULL, "spfm", NULL, SPTAG(1), 1, 0, 0, -1 }, { NULL, "spfm", NULL, SPTAG(1), 1, 0 },
{ NULL, "keepassxc", NULL, SPTAG(2), 0, 0, 0, -1 }, { NULL, "keepassxc", NULL, SPTAG(2), 0, 0 },
{ "Steam", NULL, NULL, 0, 0, 0, -1 -1, 1 },
{ "steam_app", NULL, NULL, 0, 0, 0, -1 -1, 1 },
}; };
/* layout(s) */ /* layout(s) */
static const float mfact = 0.55; /* factor of master area size [0.05..0.95] */ static const float mfact = 0.55; /* factor of master area size [0.05..0.95] */
static const int nmaster = 1; /* number of clients in master area */ static const int nmaster = 1; /* number of clients in master area */
static const int resizehints = 1; /* 1 means respect size hints in tiled resizals */ static const int resizehints = 1; /* 1 means respect size hints in tiled resizals */
static const int lockfullscreen = 1; /* 1 will force focus on the fullscreen window */ static const int refreshrate = 144; /* refresh rate (per second) for client move/resize */
static const int refreshrate = 120; /* refresh rate (per second) for client move/resize */
#define FORCE_VSPLIT 1 /* nrowgrid layout: force two clients to always split vertically */ #define FORCE_VSPLIT 1 /* nrowgrid layout: force two clients to always split vertically */
#include "vanitygaps.c" #include "vanitygaps.c"
@@ -125,14 +120,18 @@ static const char *mediaprevcmd[] = { "playerctl", "previous", NULL };
static const char *brightupcmd[] = { "ddcutil", "-b", "2", "setvcp", "10", "+", "10", NULL }; static const char *brightupcmd[] = { "ddcutil", "-b", "2", "setvcp", "10", "+", "10", NULL };
static const char *brightdowncmd[] = { "ddcutil", "-b", "2", "setvcp", "10", "-", "10", NULL }; static const char *brightdowncmd[] = { "ddcutil", "-b", "2", "setvcp", "10", "-", "10", NULL };
static const char *screenshotcmd[] = { "/bin/sh", "-c", "maim -s | xclip -selection clipboard -t image/png", NULL };
static const Key keys[] = { static const Key keys[] = {
/* modifier key function argument */ /* modifier key function argument */
{ MODKEY, XK_d, spawn, {.v = roficmd } }, { MODKEY, XK_d, spawn, {.v = roficmd } },
{ MODKEY, XK_Return, spawn, {.v = termcmd } }, { MODKEY, XK_Return, spawn, {.v = termcmd } },
{ MODKEY, XK_b, spawn, {.v = ffcmd } }, { MODKEY, XK_b, spawn, {.v = ffcmd } },
{ MODKEY|ShiftMask, XK_n, spawn, {.v = nmroficmd } }, { MODKEY|ShiftMask, XK_n, spawn, {.v = nmroficmd } },
{ ControlMask, XK_Print, spawn, {.v = screenshotcmd } },
{ MODKEY|ShiftMask, XK_Return, togglescratch, {.ui = 0 } }, { MODKEY|ShiftMask, XK_Return, togglescratch, {.ui = 0 } },
{ MODKEY, XK_e, togglescratch, {.ui = 1 } },
{ MODKEY, XK_i, incnmaster, {.i = +1 } }, { MODKEY, XK_i, incnmaster, {.i = +1 } },
{ MODKEY, XK_p, incnmaster, {.i = -1 } }, { MODKEY, XK_p, incnmaster, {.i = -1 } },
@@ -193,6 +192,8 @@ static const Key keys[] = {
{ MODKEY, XK_space, setlayout, {0} }, { MODKEY, XK_space, setlayout, {0} },
{ MODKEY|ShiftMask, XK_space, togglefloating, {0} }, { MODKEY|ShiftMask, XK_space, togglefloating, {0} },
{ MODKEY, XK_f, togglefullscreen, {0} },
{ MODKEY|ShiftMask, XK_f, togglefakefullscreen, {0} },
{ MODKEY, XK_0, view, {.ui = ~0 } }, { MODKEY, XK_0, view, {.ui = ~0 } },
{ MODKEY|ShiftMask, XK_0, tag, {.ui = ~0 } }, { MODKEY|ShiftMask, XK_0, tag, {.ui = ~0 } },
{ MODKEY, XK_comma, focusmon, {.i = -1 } }, { MODKEY, XK_comma, focusmon, {.i = -1 } },

View File

@@ -20,11 +20,10 @@ FREETYPEINC = /usr/include/freetype2
# OpenBSD (uncomment) # OpenBSD (uncomment)
#FREETYPEINC = ${X11INC}/freetype2 #FREETYPEINC = ${X11INC}/freetype2
#MANPREFIX = ${PREFIX}/man #MANPREFIX = ${PREFIX}/man
#KVMLIB = -lkvm
# includes and libs # includes and libs
INCS = -I${X11INC} -I${FREETYPEINC} INCS = -I${X11INC} -I${FREETYPEINC}
LIBS = -L${X11LIB} -lX11 ${XINERAMALIBS} ${FREETYPELIBS} -lX11-xcb -lxcb -lxcb-res ${KVMLIB} LIBS = -L${X11LIB} -lX11 ${XINERAMALIBS} ${FREETYPELIBS}
# flags # flags
CPPFLAGS = -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_XOPEN_SOURCE=700L -DVERSION=\"${VERSION}\" ${XINERAMAFLAGS} CPPFLAGS = -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_XOPEN_SOURCE=700L -DVERSION=\"${VERSION}\" ${XINERAMAFLAGS}

View File

@@ -20,10 +20,11 @@ FREETYPEINC = /usr/include/freetype2
# OpenBSD (uncomment) # OpenBSD (uncomment)
#FREETYPEINC = ${X11INC}/freetype2 #FREETYPEINC = ${X11INC}/freetype2
#MANPREFIX = ${PREFIX}/man #MANPREFIX = ${PREFIX}/man
#KVMLIB = -lkvm
# includes and libs # includes and libs
INCS = -I${X11INC} -I${FREETYPEINC} INCS = -I${X11INC} -I${FREETYPEINC}
LIBS = -L${X11LIB} -lX11 ${XINERAMALIBS} ${FREETYPELIBS} LIBS = -L${X11LIB} -lX11 ${XINERAMALIBS} ${FREETYPELIBS} -lX11-xcb -lxcb -lxcb-res ${KVMLIB}
# flags # flags
CPPFLAGS = -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_XOPEN_SOURCE=700L -DVERSION=\"${VERSION}\" ${XINERAMAFLAGS} CPPFLAGS = -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_XOPEN_SOURCE=700L -DVERSION=\"${VERSION}\" ${XINERAMAFLAGS}

BIN
dwm

Binary file not shown.

469
dwm.c
View File

@@ -40,12 +40,6 @@
#include <X11/extensions/Xinerama.h> #include <X11/extensions/Xinerama.h>
#endif /* XINERAMA */ #endif /* XINERAMA */
#include <X11/Xft/Xft.h> #include <X11/Xft/Xft.h>
#include <X11/Xlib-xcb.h>
#include <xcb/res.h>
#ifdef __OpenBSD__
#include <sys/sysctl.h>
#include <kvm.h>
#endif /* __OpenBSD */
#include "drw.h" #include "drw.h"
#include "util.h" #include "util.h"
@@ -57,7 +51,6 @@
* MAX(0, MIN((y)+(h),(m)->wy+(m)->wh) - MAX((y),(m)->wy))) * MAX(0, MIN((y)+(h),(m)->wy+(m)->wh) - MAX((y),(m)->wy)))
#define ISVISIBLEONTAG(C, T) ((C->tags & T)) #define ISVISIBLEONTAG(C, T) ((C->tags & T))
#define ISVISIBLE(C) ISVISIBLEONTAG(C, C->mon->tagset[C->mon->seltags]) #define ISVISIBLE(C) ISVISIBLEONTAG(C, C->mon->tagset[C->mon->seltags])
#define MINIMIZED(C) ((getstate(C->win) == IconicState))
#define MOUSEMASK (BUTTONMASK|PointerMotionMask) #define MOUSEMASK (BUTTONMASK|PointerMotionMask)
#define WIDTH(X) ((X)->w + 2 * (X)->bw) #define WIDTH(X) ((X)->w + 2 * (X)->bw)
#define HEIGHT(X) ((X)->h + 2 * (X)->bw) #define HEIGHT(X) ((X)->h + 2 * (X)->bw)
@@ -118,12 +111,10 @@ struct Client {
int basew, baseh, incw, inch, maxw, maxh, minw, minh, hintsvalid; int basew, baseh, incw, inch, maxw, maxh, minw, minh, hintsvalid;
int bw, oldbw; int bw, oldbw;
unsigned int tags; unsigned int tags;
int isfixed, isfloating, isurgent, neverfocus, oldstate, isfullscreen, isterminal, noswallow; int isfixed, isfloating, isurgent, neverfocus, oldstate, isfullscreen;
int isgame; int fakefullscreen;
pid_t pid;
Client *next; Client *next;
Client *snext; Client *snext;
Client *swallowing;
Monitor *mon; Monitor *mon;
Window win; Window win;
}; };
@@ -171,10 +162,7 @@ typedef struct {
const char *title; const char *title;
unsigned int tags; unsigned int tags;
int isfloating; int isfloating;
int isterminal;
int noswallow;
int monitor; int monitor;
int isgame;
} Rule; } Rule;
typedef struct Systray Systray; typedef struct Systray Systray;
@@ -224,10 +212,10 @@ static void grabkeys(void);
static void incnmaster(const Arg *arg); static void incnmaster(const Arg *arg);
static void keypress(XEvent *e); static void keypress(XEvent *e);
static void killclient(const Arg *arg); static void killclient(const Arg *arg);
static void losefullscreen(Client *next);
static void manage(Window w, XWindowAttributes *wa); static void manage(Window w, XWindowAttributes *wa);
static void mappingnotify(XEvent *e); static void mappingnotify(XEvent *e);
static void maprequest(XEvent *e); static void maprequest(XEvent *e);
static void minimize(Client *c);
static void monocle(Monitor *m); static void monocle(Monitor *m);
static void motionnotify(XEvent *e); static void motionnotify(XEvent *e);
static void movemouse(const Arg *arg); static void movemouse(const Arg *arg);
@@ -246,6 +234,7 @@ static void resizemouse(const Arg *arg);
static void resizerequest(XEvent *e); static void resizerequest(XEvent *e);
static void restack(Monitor *m); static void restack(Monitor *m);
static void run(void); static void run(void);
static void runAutostart(void);
static void scan(void); static void scan(void);
static int sendevent(Window w, Atom proto, int m, long d0, long d1, long d2, long d3, long d4); static int sendevent(Window w, Atom proto, int m, long d0, long d1, long d2, long d3, long d4);
static void sendmon(Client *c, Monitor *m); static void sendmon(Client *c, Monitor *m);
@@ -266,14 +255,15 @@ static Monitor *systraytomon(Monitor *m);
static void tag(const Arg *arg); static void tag(const Arg *arg);
static void tagmon(const Arg *arg); static void tagmon(const Arg *arg);
static void togglebar(const Arg *arg); static void togglebar(const Arg *arg);
static void togglefakefullscreen(const Arg *arg);
static void togglefloating(const Arg *arg); static void togglefloating(const Arg *arg);
static void togglefullscreen(const Arg *arg);
static void togglescratch(const Arg *arg); static void togglescratch(const Arg *arg);
static void toggletag(const Arg *arg); static void toggletag(const Arg *arg);
static void toggleview(const Arg *arg); static void toggleview(const Arg *arg);
static void unfocus(Client *c, int setfocus); static void unfocus(Client *c, int setfocus);
static void unmanage(Client *c, int destroyed); static void unmanage(Client *c, int destroyed);
static void unmapnotify(XEvent *e); static void unmapnotify(XEvent *e);
static void unminimize(Client *c);
static void updatebarpos(Monitor *m); static void updatebarpos(Monitor *m);
static void updatebars(void); static void updatebars(void);
static void updateclientlist(void); static void updateclientlist(void);
@@ -301,12 +291,6 @@ static void combotag(const Arg *arg);
static void comboview(const Arg *arg); static void comboview(const Arg *arg);
static pid_t getparentprocess(pid_t p);
static int isdescprocess(pid_t p, pid_t c);
static Client *swallowingclient(Window w);
static Client *termforwin(const Client *c);
static pid_t winpid(Window w);
/* variables */ /* variables */
static Systray *systray = NULL; static Systray *systray = NULL;
static const char broken[] = "broken"; static const char broken[] = "broken";
@@ -346,8 +330,6 @@ static Drw *drw;
static Monitor *mons, *selmon; static Monitor *mons, *selmon;
static Window root, wmcheckwin; static Window root, wmcheckwin;
static xcb_connection_t *xcon;
/* configuration, allows nested code to access above variables */ /* configuration, allows nested code to access above variables */
#include "config.h" #include "config.h"
@@ -413,11 +395,8 @@ applyrules(Client *c)
&& (!r->class || strstr(class, r->class)) && (!r->class || strstr(class, r->class))
&& (!r->instance || strstr(instance, r->instance))) && (!r->instance || strstr(instance, r->instance)))
{ {
c->isterminal = r->isterminal;
c->noswallow = r->noswallow;
c->isfloating = r->isfloating; c->isfloating = r->isfloating;
c->tags |= r->tags; c->tags |= r->tags;
c->isgame = r->isgame;
if ((r->tags & SPTAGMASK) && r->isfloating) { if ((r->tags & SPTAGMASK) && r->isfloating) {
c->x = c->mon->wx + (c->mon->ww / 2 - WIDTH(c) / 2); c->x = c->mon->wx + (c->mon->ww / 2 - WIDTH(c) / 2);
c->y = c->mon->wy + (c->mon->wh / 2 - HEIGHT(c) / 2); c->y = c->mon->wy + (c->mon->wh / 2 - HEIGHT(c) / 2);
@@ -550,53 +529,6 @@ attachstack(Client *c)
c->mon->stack = c; c->mon->stack = c;
} }
void
swallow(Client *p, Client *c)
{
if (c->noswallow || c->isterminal)
return;
if (c->noswallow && !swallowfloating && c->isfloating)
return;
detach(c);
detachstack(c);
setclientstate(c, WithdrawnState);
XUnmapWindow(dpy, p->win);
p->swallowing = c;
c->mon = p->mon;
Window w = p->win;
p->win = c->win;
c->win = w;
updatetitle(p);
XMoveResizeWindow(dpy, p->win, p->x, p->y, p->w, p->h);
arrange(p->mon);
configure(p);
updateclientlist();
}
void
unswallow(Client *c)
{
c->win = c->swallowing->win;
free(c->swallowing);
c->swallowing = NULL;
/* unfullscreen the client */
setfullscreen(c, 0);
updatetitle(c);
arrange(c->mon);
XMapWindow(dpy, c->win);
XMoveResizeWindow(dpy, c->win, c->x, c->y, c->w, c->h);
setclientstate(c, NormalState);
focus(NULL);
arrange(c->mon);
}
void void
buttonpress(XEvent *e) buttonpress(XEvent *e)
{ {
@@ -760,9 +692,12 @@ clientmessage(XEvent *e)
return; return;
if (cme->message_type == netatom[NetWMState]) { if (cme->message_type == netatom[NetWMState]) {
if (cme->data.l[1] == netatom[NetWMFullscreen] if (cme->data.l[1] == netatom[NetWMFullscreen]
|| cme->data.l[2] == netatom[NetWMFullscreen]) || cme->data.l[2] == netatom[NetWMFullscreen]) {
if (c->fakefullscreen == 2 && c->isfullscreen)
c->fakefullscreen = 3;
setfullscreen(c, (cme->data.l[0] == 1 /* _NET_WM_STATE_ADD */ setfullscreen(c, (cme->data.l[0] == 1 /* _NET_WM_STATE_ADD */
|| (cme->data.l[0] == 2 /* _NET_WM_STATE_TOGGLE */ && !c->isfullscreen))); || (cme->data.l[0] == 2 /* _NET_WM_STATE_TOGGLE */ && !c->isfullscreen)));
}
} else if (cme->message_type == netatom[NetActiveWindow]) { } else if (cme->message_type == netatom[NetActiveWindow]) {
if (c != selmon->sel && !c->isurgent) if (c != selmon->sel && !c->isurgent)
seturgent(c, 1); seturgent(c, 1);
@@ -806,7 +741,7 @@ configurenotify(XEvent *e)
updatebars(); updatebars();
for (m = mons; m; m = m->next) { for (m = mons; m; m = m->next) {
for (c = m->clients; c; c = c->next) for (c = m->clients; c; c = c->next)
if (c->isfullscreen) if (c->isfullscreen && c->fakefullscreen != 1)
resizeclient(c, m->mx, m->my, m->mw, m->mh); resizeclient(c, m->mx, m->my, m->mw, m->mh);
resizebarwin(m); resizebarwin(m);
} }
@@ -914,8 +849,6 @@ destroynotify(XEvent *e)
if ((c = wintoclient(ev->window))) if ((c = wintoclient(ev->window)))
unmanage(c, 1); unmanage(c, 1);
else if ((c = swallowingclient(ev->window)))
unmanage(c->swallowing, 1);
else if ((c = wintosystrayicon(ev->window))) { else if ((c = wintosystrayicon(ev->window))) {
removesystrayicon(c); removesystrayicon(c);
resizebarwin(selmon); resizebarwin(selmon);
@@ -1057,8 +990,10 @@ focus(Client *c)
{ {
if (!c || !ISVISIBLE(c)) if (!c || !ISVISIBLE(c))
for (c = selmon->stack; c && !ISVISIBLE(c); c = c->snext); for (c = selmon->stack; c && !ISVISIBLE(c); c = c->snext);
if (selmon->sel && selmon->sel != c) if (selmon->sel && selmon->sel != c) {
losefullscreen(c);
unfocus(selmon->sel, 0); unfocus(selmon->sel, 0);
}
if (c) { if (c) {
if (c->mon != selmon) if (c->mon != selmon)
selmon = c->mon; selmon = c->mon;
@@ -1172,7 +1107,7 @@ focusstack(const Arg *arg)
{ {
Client *c = NULL, *i; Client *c = NULL, *i;
if (!selmon->sel || (selmon->sel->isfullscreen && lockfullscreen)) if (!selmon->sel || (selmon->sel->isfullscreen && selmon->sel->fakefullscreen != 1))
return; return;
if (arg->i > 0) { if (arg->i > 0) {
for (c = selmon->sel->next; c && !ISVISIBLE(c); c = c->next); for (c = selmon->sel->next; c && !ISVISIBLE(c); c = c->next);
@@ -1379,16 +1314,25 @@ killclient(const Arg *arg)
} }
} }
void
losefullscreen(Client *next)
{
Client *sel = selmon->sel;
if (!sel || !next)
return;
if (sel->isfullscreen && sel->fakefullscreen != 1 && ISVISIBLE(sel) && sel->mon == next->mon && !next->isfloating)
setfullscreen(sel, 0);
}
void void
manage(Window w, XWindowAttributes *wa) manage(Window w, XWindowAttributes *wa)
{ {
Client *c, *t = NULL, *term = NULL; Client *c, *t = NULL;
Window trans = None; Window trans = None;
XWindowChanges wc; XWindowChanges wc;
c = ecalloc(1, sizeof(Client)); c = ecalloc(1, sizeof(Client));
c->win = w; c->win = w;
c->pid = winpid(w);
/* geometry */ /* geometry */
c->x = c->oldx = wa->x; c->x = c->oldx = wa->x;
c->y = c->oldy = wa->y; c->y = c->oldy = wa->y;
@@ -1404,7 +1348,6 @@ manage(Window w, XWindowAttributes *wa)
} else { } else {
c->mon = selmon; c->mon = selmon;
applyrules(c); applyrules(c);
term = termforwin(c);
} }
if (c->x + WIDTH(c) > c->mon->wx + c->mon->ww) if (c->x + WIDTH(c) > c->mon->wx + c->mon->ww)
@@ -1454,13 +1397,13 @@ manage(Window w, XWindowAttributes *wa)
(unsigned char *) &(c->win), 1); (unsigned char *) &(c->win), 1);
XMoveResizeWindow(dpy, c->win, c->x + 2 * sw, c->y, c->w, c->h); /* some windows require this */ XMoveResizeWindow(dpy, c->win, c->x + 2 * sw, c->y, c->w, c->h); /* some windows require this */
setclientstate(c, NormalState); setclientstate(c, NormalState);
if (c->mon == selmon) if (c->mon == selmon) {
losefullscreen(c);
unfocus(selmon->sel, 0); unfocus(selmon->sel, 0);
}
c->mon->sel = c; c->mon->sel = c;
arrange(c->mon); arrange(c->mon);
XMapWindow(dpy, c->win); XMapWindow(dpy, c->win);
if (term)
swallow(term, c);
focus(NULL); focus(NULL);
} }
@@ -1493,29 +1436,6 @@ maprequest(XEvent *e)
manage(ev->window, &wa); manage(ev->window, &wa);
} }
void
minimize(Client *c)
{
if (!c || MINIMIZED(c))
return;
Window w = c->win;
static XWindowAttributes ra, ca;
// more or less taken directly from blackbox's hide() function
XGrabServer(dpy);
XGetWindowAttributes(dpy, root, &ra);
XGetWindowAttributes(dpy, w, &ca);
// prevent UnmapNotify events
XSelectInput(dpy, root, ra.your_event_mask & ~SubstructureNotifyMask);
XSelectInput(dpy, w, ca.your_event_mask & ~StructureNotifyMask);
XUnmapWindow(dpy, w);
setclientstate(c, IconicState);
XSelectInput(dpy, root, ra.your_event_mask);
XSelectInput(dpy, w, ca.your_event_mask);
XUngrabServer(dpy);
}
void void
monocle(Monitor *m) monocle(Monitor *m)
{ {
@@ -1559,7 +1479,7 @@ movemouse(const Arg *arg)
if (!(c = selmon->sel)) if (!(c = selmon->sel))
return; return;
if (c->isfullscreen) /* no support moving fullscreen windows by mouse */ if (c->isfullscreen && c->fakefullscreen != 1) /* no support moving fullscreen windows by mouse */
return; return;
restack(selmon); restack(selmon);
ocx = c->x; ocx = c->x;
@@ -1864,7 +1784,7 @@ resizemouse(const Arg *arg)
if (!(c = selmon->sel)) if (!(c = selmon->sel))
return; return;
if (c->isfullscreen) /* no support resizing fullscreen windows by mouse */ if (c->isfullscreen && c->fakefullscreen != 1) /* no support resizing fullscreen windows by mouse */
return; return;
restack(selmon); restack(selmon);
ocx = c->x; ocx = c->x;
@@ -1946,6 +1866,17 @@ run(void)
handler[ev.type](&ev); /* call handler */ handler[ev.type](&ev); /* call handler */
} }
void
runAutostart(void) {
int ret;
ret = system("cd ~/.config/dwm; ./autostart_blocking.sh");
ret = system("cd ~/.config/dwm; ./autostart.sh &");
if (ret); // ignore, hide compilation warnings
}
void void
scan(void) scan(void)
{ {
@@ -2045,38 +1976,85 @@ setfocus(Client *c)
(unsigned char *) &(c->win), 1); (unsigned char *) &(c->win), 1);
} }
if (c->isgame && c->isfullscreen)
unminimize(c);
sendevent(c->win, wmatom[WMTakeFocus], NoEventMask, wmatom[WMTakeFocus], CurrentTime, 0, 0, 0); sendevent(c->win, wmatom[WMTakeFocus], NoEventMask, wmatom[WMTakeFocus], CurrentTime, 0, 0, 0);
} }
void void
setfullscreen(Client *c, int fullscreen) setfullscreen(Client *c, int fullscreen)
{ {
if (fullscreen && !c->isfullscreen) { XEvent ev;
XChangeProperty(dpy, c->win, netatom[NetWMState], XA_ATOM, 32, int savestate = 0, restorestate = 0, restorefakefullscreen = 0;
PropModeReplace, (unsigned char*)&netatom[NetWMFullscreen], 1);
if ((c->fakefullscreen == 0 && fullscreen && !c->isfullscreen) // normal fullscreen
|| (c->fakefullscreen == 2 && fullscreen)) // fake fullscreen --> actual fullscreen
savestate = 1; // go actual fullscreen
else if ((c->fakefullscreen == 0 && !fullscreen && c->isfullscreen) // normal fullscreen exit
|| (c->fakefullscreen >= 2 && !fullscreen)) // fullscreen exit --> fake fullscreen
restorestate = 1; // go back into tiled
/* If leaving fullscreen and the window was previously fake fullscreen (2), then restore
* that while staying in fullscreen. The exception to this is if we are in said state, but
* the client itself disables fullscreen (3) then we let the client go out of fullscreen
* while keeping fake fullscreen enabled (as otherwise there will be a mismatch between the
* client and the window manager's perception of the client's fullscreen state). */
if (c->fakefullscreen == 2 && !fullscreen && c->isfullscreen) {
restorefakefullscreen = 1;
c->isfullscreen = 1; c->isfullscreen = 1;
c->oldstate = c->isfloating; fullscreen = 1;
}
if (fullscreen != c->isfullscreen) { // only send property change if necessary
if (fullscreen)
XChangeProperty(dpy, c->win, netatom[NetWMState], XA_ATOM, 32,
PropModeReplace, (unsigned char*)&netatom[NetWMFullscreen], 1);
else
XChangeProperty(dpy, c->win, netatom[NetWMState], XA_ATOM, 32,
PropModeReplace, (unsigned char*)0, 0);
}
c->isfullscreen = fullscreen;
/* Some clients, e.g. firefox, will send a client message informing the window manager
* that it is going into fullscreen after receiving the above signal. This has the side
* effect of this function (setfullscreen) sometimes being called twice when toggling
* fullscreen on and off via the window manager as opposed to the application itself.
* To protect against obscure issues where the client settings are stored or restored
* when they are not supposed to we add an additional bit-lock on the old state so that
* settings can only be stored and restored in that precise order. */
if (savestate && !(c->oldstate & (1 << 1))) {
c->oldbw = c->bw; c->oldbw = c->bw;
c->oldstate = c->isfloating | (1 << 1);
c->bw = 0; c->bw = 0;
c->isfloating = 1; c->isfloating = 1;
resizeclient(c, c->mon->mx, c->mon->my, c->mon->mw, c->mon->mh); resizeclient(c, c->mon->mx, c->mon->my, c->mon->mw, c->mon->mh);
XRaiseWindow(dpy, c->win); XRaiseWindow(dpy, c->win);
} else if (!fullscreen && c->isfullscreen){ } else if (restorestate && (c->oldstate & (1 << 1))) {
XChangeProperty(dpy, c->win, netatom[NetWMState], XA_ATOM, 32,
PropModeReplace, (unsigned char*)0, 0);
c->isfullscreen = 0;
c->isfloating = c->oldstate;
c->bw = c->oldbw; c->bw = c->oldbw;
c->x = c->oldx; c->isfloating = c->oldstate = c->oldstate & 1;
c->y = c->oldy; if (restorefakefullscreen || c->fakefullscreen == 3)
c->w = c->oldw; c->fakefullscreen = 1;
c->h = c->oldh; /* The client may have been moved to another monitor whilst in fullscreen which if tiled
* we address by doing a full arrange of tiled clients. If the client is floating then the
* height and width may be larger than the monitor's window area, so we cap that by
* ensuring max / min values. */
if (c->isfloating) {
c->x = MAX(c->mon->wx, c->oldx);
c->y = MAX(c->mon->wy, c->oldy);
c->w = MIN(c->mon->ww - c->x - 2*c->bw, c->oldw);
c->h = MIN(c->mon->wh - c->y - 2*c->bw, c->oldh);
resizeclient(c, c->x, c->y, c->w, c->h);
restack(c->mon);
} else
arrange(c->mon);
} else
resizeclient(c, c->x, c->y, c->w, c->h); resizeclient(c, c->x, c->y, c->w, c->h);
arrange(c->mon);
} /* Exception: if the client was in actual fullscreen and we exit out to fake fullscreen
* mode, then the focus would sometimes drift to whichever window is under the mouse cursor
* at the time. To avoid this we ask X for all EnterNotify events and just ignore them.
*/
if (!c->isfullscreen)
while (XCheckMaskEvent(dpy, EnterWindowMask, &ev));
} }
void void
@@ -2312,9 +2290,19 @@ tag(const Arg *arg)
void void
tagmon(const Arg *arg) tagmon(const Arg *arg)
{ {
if (!selmon->sel || !mons->next) Client *c = selmon->sel;
if (!c || !mons->next)
return; return;
sendmon(selmon->sel, dirtomon(arg->i)); if (c->isfullscreen) {
c->isfullscreen = 0;
sendmon(c, dirtomon(arg->i));
c->isfullscreen = 1;
if (c->fakefullscreen != 1) {
resizeclient(c, c->mon->mx, c->mon->my, c->mon->mw, c->mon->mh);
XRaiseWindow(dpy, c->win);
}
} else
sendmon(c, dirtomon(arg->i));
} }
void void
@@ -2337,18 +2325,51 @@ togglebar(const Arg *arg)
arrange(selmon); arrange(selmon);
} }
void
togglefakefullscreen(const Arg *arg)
{
Client *c = selmon->sel;
if (!c)
return;
if (c->fakefullscreen != 1 && c->isfullscreen) { // exit fullscreen --> fake fullscreen
c->fakefullscreen = 2;
setfullscreen(c, 0);
} else if (c->fakefullscreen == 1) {
setfullscreen(c, 0);
c->fakefullscreen = 0;
} else {
c->fakefullscreen = 1;
setfullscreen(c, 1);
}
}
void void
togglefloating(const Arg *arg) togglefloating(const Arg *arg)
{ {
if (!selmon->sel) Client *c = selmon->sel;
if (!c)
return; return;
if (selmon->sel->isfullscreen) /* no support for fullscreen windows */ if (c->isfullscreen && c->fakefullscreen != 1) /* no support for fullscreen windows */
return; return;
selmon->sel->isfloating = !selmon->sel->isfloating || selmon->sel->isfixed; c->isfloating = !c->isfloating || c->isfixed;
if (selmon->sel->isfloating) if (c->isfloating)
resize(selmon->sel, selmon->sel->x, selmon->sel->y, resize(c, c->x, c->y, c->w, c->h, 0);
selmon->sel->w, selmon->sel->h, 0); arrange(c->mon);
arrange(selmon); }
void
togglefullscreen(const Arg *arg)
{
Client *c = selmon->sel;
if (!c)
return;
if (c->fakefullscreen == 1) { // fake fullscreen --> fullscreen
c->fakefullscreen = 2;
setfullscreen(c, 1);
} else
setfullscreen(c, !c->isfullscreen);
} }
void void
@@ -2410,10 +2431,6 @@ unfocus(Client *c, int setfocus)
{ {
if (!c) if (!c)
return; return;
if (c->isgame && c->isfullscreen)
minimize(c);
grabbuttons(c, 0); grabbuttons(c, 0);
XSetWindowBorder(dpy, c->win, scheme[SchemeNorm][ColBorder].pixel); XSetWindowBorder(dpy, c->win, scheme[SchemeNorm][ColBorder].pixel);
if (setfocus) { if (setfocus) {
@@ -2428,20 +2445,6 @@ unmanage(Client *c, int destroyed)
Monitor *m = c->mon; Monitor *m = c->mon;
XWindowChanges wc; XWindowChanges wc;
if (c->swallowing) {
unswallow(c);
return;
}
Client *s = swallowingclient(c->win);
if (s) {
free(s->swallowing);
s->swallowing = NULL;
arrange(m);
focus(NULL);
return;
}
detach(c); detach(c);
detachstack(c); detachstack(c);
if (!destroyed) { if (!destroyed) {
@@ -2457,12 +2460,9 @@ unmanage(Client *c, int destroyed)
XUngrabServer(dpy); XUngrabServer(dpy);
} }
free(c); free(c);
focus(NULL);
if (!s) { updateclientlist();
arrange(m); arrange(m);
focus(NULL);
updateclientlist();
}
} }
void void
@@ -2485,16 +2485,6 @@ unmapnotify(XEvent *e)
} }
} }
void
unminimize(Client *c)
{
if (!c || !MINIMIZED(c))
return;
XMapWindow(dpy, c->win);
setclientstate(c, NormalState);
}
void void
updatebars(void) updatebars(void)
{ {
@@ -2867,136 +2857,6 @@ view(const Arg *arg)
arrange(selmon); arrange(selmon);
} }
pid_t
winpid(Window w)
{
pid_t result = 0;
#ifdef __linux__
xcb_res_client_id_spec_t spec = {0};
spec.client = w;
spec.mask = XCB_RES_CLIENT_ID_MASK_LOCAL_CLIENT_PID;
xcb_generic_error_t *e = NULL;
xcb_res_query_client_ids_cookie_t c = xcb_res_query_client_ids(xcon, 1, &spec);
xcb_res_query_client_ids_reply_t *r = xcb_res_query_client_ids_reply(xcon, c, &e);
if (!r)
return (pid_t)0;
xcb_res_client_id_value_iterator_t i = xcb_res_query_client_ids_ids_iterator(r);
for (; i.rem; xcb_res_client_id_value_next(&i)) {
spec = i.data->spec;
if (spec.mask & XCB_RES_CLIENT_ID_MASK_LOCAL_CLIENT_PID) {
uint32_t *t = xcb_res_client_id_value_value(i.data);
result = *t;
break;
}
}
free(r);
if (result == (pid_t)-1)
result = 0;
#endif /* __linux__ */
#ifdef __OpenBSD__
Atom type;
int format;
unsigned long len, bytes;
unsigned char *prop;
pid_t ret;
if (XGetWindowProperty(dpy, w, XInternAtom(dpy, "_NET_WM_PID", 0), 0, 1, False, AnyPropertyType, &type, &format, &len, &bytes, &prop) != Success || !prop)
return 0;
ret = *(pid_t*)prop;
XFree(prop);
result = ret;
#endif /* __OpenBSD__ */
return result;
}
pid_t
getparentprocess(pid_t p)
{
unsigned int v = 0;
#ifdef __linux__
FILE *f;
char buf[256];
snprintf(buf, sizeof(buf) - 1, "/proc/%u/stat", (unsigned)p);
if (!(f = fopen(buf, "r")))
return 0;
fscanf(f, "%*u %*s %*c %u", &v);
fclose(f);
#endif /* __linux__*/
#ifdef __OpenBSD__
int n;
kvm_t *kd;
struct kinfo_proc *kp;
kd = kvm_openfiles(NULL, NULL, NULL, KVM_NO_FILES, NULL);
if (!kd)
return 0;
kp = kvm_getprocs(kd, KERN_PROC_PID, p, sizeof(*kp), &n);
v = kp->p_ppid;
#endif /* __OpenBSD__ */
return (pid_t)v;
}
int
isdescprocess(pid_t p, pid_t c)
{
while (p != c && c != 0)
c = getparentprocess(c);
return (int)c;
}
Client *
termforwin(const Client *w)
{
Client *c;
Monitor *m;
if (!w->pid || w->isterminal)
return NULL;
for (m = mons; m; m = m->next) {
for (c = m->clients; c; c = c->next) {
if (c->isterminal && !c->swallowing && c->pid && isdescprocess(c->pid, w->pid))
return c;
}
}
return NULL;
}
Client *
swallowingclient(Window w)
{
Client *c;
Monitor *m;
for (m = mons; m; m = m->next) {
for (c = m->clients; c; c = c->next) {
if (c->swallowing && c->swallowing->win == w)
return c;
}
}
return NULL;
}
Client * Client *
wintoclient(Window w) wintoclient(Window w)
{ {
@@ -3112,15 +2972,14 @@ main(int argc, char *argv[])
fputs("warning: no locale support\n", stderr); fputs("warning: no locale support\n", stderr);
if (!(dpy = XOpenDisplay(NULL))) if (!(dpy = XOpenDisplay(NULL)))
die("dwm: cannot open display"); die("dwm: cannot open display");
if (!(xcon = XGetXCBConnection(dpy)))
die("dwm: cannot get xcb connection\n");
checkotherwm(); checkotherwm();
setup(); setup();
#ifdef __OpenBSD__ #ifdef __OpenBSD__
if (pledge("stdio rpath proc exec ps", NULL) == -1) if (pledge("stdio rpath proc exec", NULL) == -1)
die("pledge"); die("pledge");
#endif /* __OpenBSD__ */ #endif /* __OpenBSD__ */
scan(); scan();
runAutostart();
run(); run();
if(restart) execvp(argv[0], argv); if(restart) execvp(argv[0], argv);
cleanup(); cleanup();

View File

@@ -40,12 +40,6 @@
#include <X11/extensions/Xinerama.h> #include <X11/extensions/Xinerama.h>
#endif /* XINERAMA */ #endif /* XINERAMA */
#include <X11/Xft/Xft.h> #include <X11/Xft/Xft.h>
#include <X11/Xlib-xcb.h>
#include <xcb/res.h>
#ifdef __OpenBSD__
#include <sys/sysctl.h>
#include <kvm.h>
#endif /* __OpenBSD */
#include "drw.h" #include "drw.h"
#include "util.h" #include "util.h"
@@ -57,7 +51,6 @@
* MAX(0, MIN((y)+(h),(m)->wy+(m)->wh) - MAX((y),(m)->wy))) * MAX(0, MIN((y)+(h),(m)->wy+(m)->wh) - MAX((y),(m)->wy)))
#define ISVISIBLEONTAG(C, T) ((C->tags & T)) #define ISVISIBLEONTAG(C, T) ((C->tags & T))
#define ISVISIBLE(C) ISVISIBLEONTAG(C, C->mon->tagset[C->mon->seltags]) #define ISVISIBLE(C) ISVISIBLEONTAG(C, C->mon->tagset[C->mon->seltags])
#define MINIMIZED(C) ((getstate(C->win) == IconicState))
#define MOUSEMASK (BUTTONMASK|PointerMotionMask) #define MOUSEMASK (BUTTONMASK|PointerMotionMask)
#define WIDTH(X) ((X)->w + 2 * (X)->bw) #define WIDTH(X) ((X)->w + 2 * (X)->bw)
#define HEIGHT(X) ((X)->h + 2 * (X)->bw) #define HEIGHT(X) ((X)->h + 2 * (X)->bw)
@@ -118,12 +111,9 @@ struct Client {
int basew, baseh, incw, inch, maxw, maxh, minw, minh, hintsvalid; int basew, baseh, incw, inch, maxw, maxh, minw, minh, hintsvalid;
int bw, oldbw; int bw, oldbw;
unsigned int tags; unsigned int tags;
int isfixed, isfloating, isurgent, neverfocus, oldstate, isfullscreen, isterminal, noswallow; int isfixed, isfloating, isurgent, neverfocus, oldstate, isfullscreen;
int isgame;
pid_t pid;
Client *next; Client *next;
Client *snext; Client *snext;
Client *swallowing;
Monitor *mon; Monitor *mon;
Window win; Window win;
}; };
@@ -171,10 +161,7 @@ typedef struct {
const char *title; const char *title;
unsigned int tags; unsigned int tags;
int isfloating; int isfloating;
int isterminal;
int noswallow;
int monitor; int monitor;
int isgame;
} Rule; } Rule;
typedef struct Systray Systray; typedef struct Systray Systray;
@@ -200,6 +187,7 @@ static void configure(Client *c);
static void configurenotify(XEvent *e); static void configurenotify(XEvent *e);
static void configurerequest(XEvent *e); static void configurerequest(XEvent *e);
static Monitor *createmon(void); static Monitor *createmon(void);
static void cyclelayout(const Arg *arg);
static void destroynotify(XEvent *e); static void destroynotify(XEvent *e);
static void detach(Client *c); static void detach(Client *c);
static void detachstack(Client *c); static void detachstack(Client *c);
@@ -226,7 +214,6 @@ static void killclient(const Arg *arg);
static void manage(Window w, XWindowAttributes *wa); static void manage(Window w, XWindowAttributes *wa);
static void mappingnotify(XEvent *e); static void mappingnotify(XEvent *e);
static void maprequest(XEvent *e); static void maprequest(XEvent *e);
static void minimize(Client *c);
static void monocle(Monitor *m); static void monocle(Monitor *m);
static void motionnotify(XEvent *e); static void motionnotify(XEvent *e);
static void movemouse(const Arg *arg); static void movemouse(const Arg *arg);
@@ -245,6 +232,7 @@ static void resizemouse(const Arg *arg);
static void resizerequest(XEvent *e); static void resizerequest(XEvent *e);
static void restack(Monitor *m); static void restack(Monitor *m);
static void run(void); static void run(void);
static void runAutostart(void);
static void scan(void); static void scan(void);
static int sendevent(Window w, Atom proto, int m, long d0, long d1, long d2, long d3, long d4); static int sendevent(Window w, Atom proto, int m, long d0, long d1, long d2, long d3, long d4);
static void sendmon(Client *c, Monitor *m); static void sendmon(Client *c, Monitor *m);
@@ -272,7 +260,6 @@ static void toggleview(const Arg *arg);
static void unfocus(Client *c, int setfocus); static void unfocus(Client *c, int setfocus);
static void unmanage(Client *c, int destroyed); static void unmanage(Client *c, int destroyed);
static void unmapnotify(XEvent *e); static void unmapnotify(XEvent *e);
static void unminimize(Client *c);
static void updatebarpos(Monitor *m); static void updatebarpos(Monitor *m);
static void updatebars(void); static void updatebars(void);
static void updateclientlist(void); static void updateclientlist(void);
@@ -300,12 +287,6 @@ static void combotag(const Arg *arg);
static void comboview(const Arg *arg); static void comboview(const Arg *arg);
static pid_t getparentprocess(pid_t p);
static int isdescprocess(pid_t p, pid_t c);
static Client *swallowingclient(Window w);
static Client *termforwin(const Client *c);
static pid_t winpid(Window w);
/* variables */ /* variables */
static Systray *systray = NULL; static Systray *systray = NULL;
static const char broken[] = "broken"; static const char broken[] = "broken";
@@ -345,8 +326,6 @@ static Drw *drw;
static Monitor *mons, *selmon; static Monitor *mons, *selmon;
static Window root, wmcheckwin; static Window root, wmcheckwin;
static xcb_connection_t *xcon;
/* configuration, allows nested code to access above variables */ /* configuration, allows nested code to access above variables */
#include "config.h" #include "config.h"
@@ -412,11 +391,8 @@ applyrules(Client *c)
&& (!r->class || strstr(class, r->class)) && (!r->class || strstr(class, r->class))
&& (!r->instance || strstr(instance, r->instance))) && (!r->instance || strstr(instance, r->instance)))
{ {
c->isterminal = r->isterminal;
c->noswallow = r->noswallow;
c->isfloating = r->isfloating; c->isfloating = r->isfloating;
c->tags |= r->tags; c->tags |= r->tags;
c->isgame = r->isgame;
if ((r->tags & SPTAGMASK) && r->isfloating) { if ((r->tags & SPTAGMASK) && r->isfloating) {
c->x = c->mon->wx + (c->mon->ww / 2 - WIDTH(c) / 2); c->x = c->mon->wx + (c->mon->ww / 2 - WIDTH(c) / 2);
c->y = c->mon->wy + (c->mon->wh / 2 - HEIGHT(c) / 2); c->y = c->mon->wy + (c->mon->wh / 2 - HEIGHT(c) / 2);
@@ -549,53 +525,6 @@ attachstack(Client *c)
c->mon->stack = c; c->mon->stack = c;
} }
void
swallow(Client *p, Client *c)
{
if (c->noswallow || c->isterminal)
return;
if (c->noswallow && !swallowfloating && c->isfloating)
return;
detach(c);
detachstack(c);
setclientstate(c, WithdrawnState);
XUnmapWindow(dpy, p->win);
p->swallowing = c;
c->mon = p->mon;
Window w = p->win;
p->win = c->win;
c->win = w;
updatetitle(p);
XMoveResizeWindow(dpy, p->win, p->x, p->y, p->w, p->h);
arrange(p->mon);
configure(p);
updateclientlist();
}
void
unswallow(Client *c)
{
c->win = c->swallowing->win;
free(c->swallowing);
c->swallowing = NULL;
/* unfullscreen the client */
setfullscreen(c, 0);
updatetitle(c);
arrange(c->mon);
XMapWindow(dpy, c->win);
XMoveResizeWindow(dpy, c->win, c->x, c->y, c->w, c->h);
setclientstate(c, NormalState);
focus(NULL);
arrange(c->mon);
}
void void
buttonpress(XEvent *e) buttonpress(XEvent *e)
{ {
@@ -888,6 +817,23 @@ createmon(void)
return m; return m;
} }
void
cyclelayout(const Arg *arg) {
Layout *l;
for(l = (Layout *)layouts; l != selmon->lt[selmon->sellt]; l++);
if(arg->i > 0) {
if(l->symbol && (l + 1)->symbol)
setlayout(&((Arg) { .v = (l + 1) }));
else
setlayout(&((Arg) { .v = layouts }));
} else {
if(l != layouts && (l - 1)->symbol)
setlayout(&((Arg) { .v = (l - 1) }));
else
setlayout(&((Arg) { .v = &layouts[LENGTH(layouts) - 2] }));
}
}
void void
destroynotify(XEvent *e) destroynotify(XEvent *e)
{ {
@@ -896,8 +842,6 @@ destroynotify(XEvent *e)
if ((c = wintoclient(ev->window))) if ((c = wintoclient(ev->window)))
unmanage(c, 1); unmanage(c, 1);
else if ((c = swallowingclient(ev->window)))
unmanage(c->swallowing, 1);
else if ((c = wintosystrayicon(ev->window))) { else if ((c = wintosystrayicon(ev->window))) {
removesystrayicon(c); removesystrayicon(c);
resizebarwin(selmon); resizebarwin(selmon);
@@ -1364,13 +1308,12 @@ killclient(const Arg *arg)
void void
manage(Window w, XWindowAttributes *wa) manage(Window w, XWindowAttributes *wa)
{ {
Client *c, *t = NULL, *term = NULL; Client *c, *t = NULL;
Window trans = None; Window trans = None;
XWindowChanges wc; XWindowChanges wc;
c = ecalloc(1, sizeof(Client)); c = ecalloc(1, sizeof(Client));
c->win = w; c->win = w;
c->pid = winpid(w);
/* geometry */ /* geometry */
c->x = c->oldx = wa->x; c->x = c->oldx = wa->x;
c->y = c->oldy = wa->y; c->y = c->oldy = wa->y;
@@ -1386,7 +1329,6 @@ manage(Window w, XWindowAttributes *wa)
} else { } else {
c->mon = selmon; c->mon = selmon;
applyrules(c); applyrules(c);
term = termforwin(c);
} }
if (c->x + WIDTH(c) > c->mon->wx + c->mon->ww) if (c->x + WIDTH(c) > c->mon->wx + c->mon->ww)
@@ -1441,8 +1383,6 @@ manage(Window w, XWindowAttributes *wa)
c->mon->sel = c; c->mon->sel = c;
arrange(c->mon); arrange(c->mon);
XMapWindow(dpy, c->win); XMapWindow(dpy, c->win);
if (term)
swallow(term, c);
focus(NULL); focus(NULL);
} }
@@ -1475,29 +1415,6 @@ maprequest(XEvent *e)
manage(ev->window, &wa); manage(ev->window, &wa);
} }
void
minimize(Client *c)
{
if (!c || MINIMIZED(c))
return;
Window w = c->win;
static XWindowAttributes ra, ca;
// more or less taken directly from blackbox's hide() function
XGrabServer(dpy);
XGetWindowAttributes(dpy, root, &ra);
XGetWindowAttributes(dpy, w, &ca);
// prevent UnmapNotify events
XSelectInput(dpy, root, ra.your_event_mask & ~SubstructureNotifyMask);
XSelectInput(dpy, w, ca.your_event_mask & ~StructureNotifyMask);
XUnmapWindow(dpy, w);
setclientstate(c, IconicState);
XSelectInput(dpy, root, ra.your_event_mask);
XSelectInput(dpy, w, ca.your_event_mask);
XUngrabServer(dpy);
}
void void
monocle(Monitor *m) monocle(Monitor *m)
{ {
@@ -1928,6 +1845,17 @@ run(void)
handler[ev.type](&ev); /* call handler */ handler[ev.type](&ev); /* call handler */
} }
void
runAutostart(void) {
int ret;
ret = system("cd ~/.config/dwm; ./autostart_blocking.sh");
ret = system("cd ~/.config/dwm; ./autostart.sh &");
if (ret); // ignore, hide compilation warnings
}
void void
scan(void) scan(void)
{ {
@@ -2027,9 +1955,6 @@ setfocus(Client *c)
(unsigned char *) &(c->win), 1); (unsigned char *) &(c->win), 1);
} }
if (c->isgame && c->isfullscreen)
unminimize(c);
sendevent(c->win, wmatom[WMTakeFocus], NoEventMask, wmatom[WMTakeFocus], CurrentTime, 0, 0, 0); sendevent(c->win, wmatom[WMTakeFocus], NoEventMask, wmatom[WMTakeFocus], CurrentTime, 0, 0, 0);
} }
@@ -2392,10 +2317,6 @@ unfocus(Client *c, int setfocus)
{ {
if (!c) if (!c)
return; return;
if (c->isgame && c->isfullscreen)
minimize(c);
grabbuttons(c, 0); grabbuttons(c, 0);
XSetWindowBorder(dpy, c->win, scheme[SchemeNorm][ColBorder].pixel); XSetWindowBorder(dpy, c->win, scheme[SchemeNorm][ColBorder].pixel);
if (setfocus) { if (setfocus) {
@@ -2410,20 +2331,6 @@ unmanage(Client *c, int destroyed)
Monitor *m = c->mon; Monitor *m = c->mon;
XWindowChanges wc; XWindowChanges wc;
if (c->swallowing) {
unswallow(c);
return;
}
Client *s = swallowingclient(c->win);
if (s) {
free(s->swallowing);
s->swallowing = NULL;
arrange(m);
focus(NULL);
return;
}
detach(c); detach(c);
detachstack(c); detachstack(c);
if (!destroyed) { if (!destroyed) {
@@ -2439,12 +2346,9 @@ unmanage(Client *c, int destroyed)
XUngrabServer(dpy); XUngrabServer(dpy);
} }
free(c); free(c);
focus(NULL);
if (!s) { updateclientlist();
arrange(m); arrange(m);
focus(NULL);
updateclientlist();
}
} }
void void
@@ -2467,16 +2371,6 @@ unmapnotify(XEvent *e)
} }
} }
void
unminimize(Client *c)
{
if (!c || !MINIMIZED(c))
return;
XMapWindow(dpy, c->win);
setclientstate(c, NormalState);
}
void void
updatebars(void) updatebars(void)
{ {
@@ -2849,136 +2743,6 @@ view(const Arg *arg)
arrange(selmon); arrange(selmon);
} }
pid_t
winpid(Window w)
{
pid_t result = 0;
#ifdef __linux__
xcb_res_client_id_spec_t spec = {0};
spec.client = w;
spec.mask = XCB_RES_CLIENT_ID_MASK_LOCAL_CLIENT_PID;
xcb_generic_error_t *e = NULL;
xcb_res_query_client_ids_cookie_t c = xcb_res_query_client_ids(xcon, 1, &spec);
xcb_res_query_client_ids_reply_t *r = xcb_res_query_client_ids_reply(xcon, c, &e);
if (!r)
return (pid_t)0;
xcb_res_client_id_value_iterator_t i = xcb_res_query_client_ids_ids_iterator(r);
for (; i.rem; xcb_res_client_id_value_next(&i)) {
spec = i.data->spec;
if (spec.mask & XCB_RES_CLIENT_ID_MASK_LOCAL_CLIENT_PID) {
uint32_t *t = xcb_res_client_id_value_value(i.data);
result = *t;
break;
}
}
free(r);
if (result == (pid_t)-1)
result = 0;
#endif /* __linux__ */
#ifdef __OpenBSD__
Atom type;
int format;
unsigned long len, bytes;
unsigned char *prop;
pid_t ret;
if (XGetWindowProperty(dpy, w, XInternAtom(dpy, "_NET_WM_PID", 0), 0, 1, False, AnyPropertyType, &type, &format, &len, &bytes, &prop) != Success || !prop)
return 0;
ret = *(pid_t*)prop;
XFree(prop);
result = ret;
#endif /* __OpenBSD__ */
return result;
}
pid_t
getparentprocess(pid_t p)
{
unsigned int v = 0;
#ifdef __linux__
FILE *f;
char buf[256];
snprintf(buf, sizeof(buf) - 1, "/proc/%u/stat", (unsigned)p);
if (!(f = fopen(buf, "r")))
return 0;
fscanf(f, "%*u %*s %*c %u", &v);
fclose(f);
#endif /* __linux__*/
#ifdef __OpenBSD__
int n;
kvm_t *kd;
struct kinfo_proc *kp;
kd = kvm_openfiles(NULL, NULL, NULL, KVM_NO_FILES, NULL);
if (!kd)
return 0;
kp = kvm_getprocs(kd, KERN_PROC_PID, p, sizeof(*kp), &n);
v = kp->p_ppid;
#endif /* __OpenBSD__ */
return (pid_t)v;
}
int
isdescprocess(pid_t p, pid_t c)
{
while (p != c && c != 0)
c = getparentprocess(c);
return (int)c;
}
Client *
termforwin(const Client *w)
{
Client *c;
Monitor *m;
if (!w->pid || w->isterminal)
return NULL;
for (m = mons; m; m = m->next) {
for (c = m->clients; c; c = c->next) {
if (c->isterminal && !c->swallowing && c->pid && isdescprocess(c->pid, w->pid))
return c;
}
}
return NULL;
}
Client *
swallowingclient(Window w)
{
Client *c;
Monitor *m;
for (m = mons; m; m = m->next) {
for (c = m->clients; c; c = c->next) {
if (c->swallowing && c->swallowing->win == w)
return c;
}
}
return NULL;
}
Client * Client *
wintoclient(Window w) wintoclient(Window w)
{ {
@@ -3094,15 +2858,14 @@ main(int argc, char *argv[])
fputs("warning: no locale support\n", stderr); fputs("warning: no locale support\n", stderr);
if (!(dpy = XOpenDisplay(NULL))) if (!(dpy = XOpenDisplay(NULL)))
die("dwm: cannot open display"); die("dwm: cannot open display");
if (!(xcon = XGetXCBConnection(dpy)))
die("dwm: cannot get xcb connection\n");
checkotherwm(); checkotherwm();
setup(); setup();
#ifdef __OpenBSD__ #ifdef __OpenBSD__
if (pledge("stdio rpath proc exec ps", NULL) == -1) if (pledge("stdio rpath proc exec", NULL) == -1)
die("pledge"); die("pledge");
#endif /* __OpenBSD__ */ #endif /* __OpenBSD__ */
scan(); scan();
runAutostart();
run(); run();
if(restart) execvp(argv[0], argv); if(restart) execvp(argv[0], argv);
cleanup(); cleanup();

View File

@@ -1,37 +1,12 @@
--- dwm.c --- dwm.c
+++ dwm.c +++ dwm.c
@@ -50,6 +50,7 @@ @@ -213,7 +215,9 @@ static void tag(const Arg *arg);
#define INTERSECT(x,y,w,h,m) (MAX(0, MIN((x)+(w),(m)->wx+(m)->ww) - MAX((x),(m)->wx)) \ static void tagmon(const Arg *arg);
* MAX(0, MIN((y)+(h),(m)->wy+(m)->wh) - MAX((y),(m)->wy))) static void tile(Monitor *);
#define ISVISIBLE(C) ((C->tags & C->mon->tagset[C->mon->seltags])) static void togglebar(const Arg *arg);
+#define MINIMIZED(C) ((getstate(C->win) == IconicState)) +static void togglefakefullscreen(const Arg *arg);
#define MOUSEMASK (BUTTONMASK|PointerMotionMask) static void togglefloating(const Arg *arg);
#define WIDTH(X) ((X)->w + 2 * (X)->bw) +static void togglefullscreen(const Arg *arg);
#define HEIGHT(X) ((X)->h + 2 * (X)->bw) static void toggletag(const Arg *arg);
@@ -92,6 +93,7 @@ struct Client { static void toggleview(const Arg *arg);
int bw, oldbw; static void unfocus(Client *c, int setfocus);
unsigned int tags;
int isfixed, isfloating, isurgent, neverfocus, oldstate, isfullscreen;
+ int isgame;
Client *next;
Client *snext;
Monitor *mon;
@@ -301,6 +306,7 @@ applyrules(Client *c)
{
c->isfloating = r->isfloating;
c->tags |= r->tags;
+ c->isgame = r->isgame;
for (m = mons; m && m->num != r->monitor; m = m->next);
if (m)
c->mon = m;
@@ -1501,6 +1530,10 @@ setfocus(Client *c)
XA_WINDOW, 32, PropModeReplace,
(unsigned char *) &(c->win), 1);
}
+
+ if (c->isgame && c->isfullscreen)
+ unminimize(c);
+
sendevent(c, wmatom[WMTakeFocus]);
}

BIN
dwm.o

Binary file not shown.

View File

@@ -0,0 +1,161 @@
From e5f0eefa921e6bad1e6f75faced0c3ae519995b3 Mon Sep 17 00:00:00 2001
From: Ryan Kes <alrayyes@gmail.com>
Date: Thu, 28 Mar 2019 14:49:28 +0100
Subject: [PATCH] dwm-ewhmtags-6.2
---
dwm.c | 49 ++++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 48 insertions(+), 1 deletion(-)
diff --git a/dwm.c b/dwm.c
index 4465af1..92022a1 100644
--- a/dwm.c
+++ b/dwm.c
@@ -55,6 +55,7 @@
#define WIDTH(X) ((X)->w + 2 * (X)->bw)
#define HEIGHT(X) ((X)->h + 2 * (X)->bw)
#define TAGMASK ((1 << LENGTH(tags)) - 1)
+#define TAGSLENGTH (LENGTH(tags))
#define TEXTW(X) (drw_fontset_getwidth(drw, (X)) + lrpad)
/* enums */
@@ -62,7 +63,7 @@ enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */
enum { SchemeNorm, SchemeSel }; /* color schemes */
enum { NetSupported, NetWMName, NetWMState, NetWMCheck,
NetWMFullscreen, NetActiveWindow, NetWMWindowType,
- NetWMWindowTypeDialog, NetClientList, NetLast }; /* EWMH atoms */
+ NetWMWindowTypeDialog, NetClientList, NetDesktopNames, NetDesktopViewport, NetNumberOfDesktops, NetCurrentDesktop, NetLast }; /* EWMH atoms */
enum { WMProtocols, WMDelete, WMState, WMTakeFocus, WMLast }; /* default atoms */
enum { ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle,
ClkClientWin, ClkRootWin, ClkLast }; /* clicks */
@@ -197,11 +198,15 @@ static void scan(void);
static int sendevent(Client *c, Atom proto);
static void sendmon(Client *c, Monitor *m);
static void setclientstate(Client *c, long state);
+static void setcurrentdesktop(void);
+static void setdesktopnames(void);
static void setfocus(Client *c);
static void setfullscreen(Client *c, int fullscreen);
static void setlayout(const Arg *arg);
static void setmfact(const Arg *arg);
+static void setnumdesktops(void);
static void setup(void);
+static void setviewport(void);
static void seturgent(Client *c, int urg);
static void showhide(Client *c);
static void sigchld(int unused);
@@ -216,6 +221,7 @@ static void toggleview(const Arg *arg);
static void unfocus(Client *c, int setfocus);
static void unmanage(Client *c, int destroyed);
static void unmapnotify(XEvent *e);
+static void updatecurrentdesktop(void);
static void updatebarpos(Monitor *m);
static void updatebars(void);
static void updateclientlist(void);
@@ -1431,6 +1437,16 @@ setclientstate(Client *c, long state)
XChangeProperty(dpy, c->win, wmatom[WMState], wmatom[WMState], 32,
PropModeReplace, (unsigned char *)data, 2);
}
+void
+setcurrentdesktop(void){
+ long data[] = { 0 };
+ XChangeProperty(dpy, root, netatom[NetCurrentDesktop], XA_CARDINAL, 32, PropModeReplace, (unsigned char *)data, 1);
+}
+void setdesktopnames(void){
+ XTextProperty text;
+ Xutf8TextListToTextProperty(dpy, tags, TAGSLENGTH, XUTF8StringStyle, &text);
+ XSetTextProperty(dpy, root, &text, netatom[NetDesktopNames]);
+}
int
sendevent(Client *c, Atom proto)
@@ -1457,6 +1473,12 @@ sendevent(Client *c, Atom proto)
return exists;
}
+void
+setnumdesktops(void){
+ long data[] = { TAGSLENGTH };
+ XChangeProperty(dpy, root, netatom[NetNumberOfDesktops], XA_CARDINAL, 32, PropModeReplace, (unsigned char *)data, 1);
+}
+
void
setfocus(Client *c)
{
@@ -1562,6 +1584,10 @@ setup(void)
netatom[NetWMWindowType] = XInternAtom(dpy, "_NET_WM_WINDOW_TYPE", False);
netatom[NetWMWindowTypeDialog] = XInternAtom(dpy, "_NET_WM_WINDOW_TYPE_DIALOG", False);
netatom[NetClientList] = XInternAtom(dpy, "_NET_CLIENT_LIST", False);
+ netatom[NetDesktopViewport] = XInternAtom(dpy, "_NET_DESKTOP_VIEWPORT", False);
+ netatom[NetNumberOfDesktops] = XInternAtom(dpy, "_NET_NUMBER_OF_DESKTOPS", False);
+ netatom[NetCurrentDesktop] = XInternAtom(dpy, "_NET_CURRENT_DESKTOP", False);
+ netatom[NetDesktopNames] = XInternAtom(dpy, "_NET_DESKTOP_NAMES", False);
/* init cursors */
cursor[CurNormal] = drw_cur_create(drw, XC_left_ptr);
cursor[CurResize] = drw_cur_create(drw, XC_sizing);
@@ -1584,6 +1610,10 @@ setup(void)
/* EWMH support per view */
XChangeProperty(dpy, root, netatom[NetSupported], XA_ATOM, 32,
PropModeReplace, (unsigned char *) netatom, NetLast);
+ setnumdesktops();
+ setcurrentdesktop();
+ setdesktopnames();
+ setviewport();
XDeleteProperty(dpy, root, netatom[NetClientList]);
/* select events */
wa.cursor = cursor[CurNormal]->cursor;
@@ -1595,6 +1625,11 @@ setup(void)
grabkeys();
focus(NULL);
}
+void
+setviewport(void){
+ long data[] = { 0, 0 };
+ XChangeProperty(dpy, root, netatom[NetDesktopViewport], XA_CARDINAL, 32, PropModeReplace, (unsigned char *)data, 2);
+}
void
@@ -1732,6 +1767,7 @@ toggletag(const Arg *arg)
focus(NULL);
arrange(selmon);
}
+ updatecurrentdesktop();
}
void
@@ -1744,6 +1780,7 @@ toggleview(const Arg *arg)
focus(NULL);
arrange(selmon);
}
+ updatecurrentdesktop();
}
void
@@ -1846,6 +1883,15 @@ updateclientlist()
XA_WINDOW, 32, PropModeAppend,
(unsigned char *) &(c->win), 1);
}
+void updatecurrentdesktop(void){
+ long rawdata[] = { selmon->tagset[selmon->seltags] };
+ int i=0;
+ while(*rawdata >> i+1){
+ i++;
+ }
+ long data[] = { i };
+ XChangeProperty(dpy, root, netatom[NetCurrentDesktop], XA_CARDINAL, 32, PropModeReplace, (unsigned char *)data, 1);
+}
int
updategeom(void)
@@ -2042,6 +2088,7 @@ view(const Arg *arg)
selmon->tagset[selmon->seltags] = arg->ui & TAGMASK;
focus(NULL);
arrange(selmon);
+ updatecurrentdesktop();
}
Client *
--
2.21.0

View File

@@ -0,0 +1,357 @@
From 4d2fb76ca3024447fd06407bdc87c09e726f6c27 Mon Sep 17 00:00:00 2001
From: Bakkeby <bakkeby@gmail.com>
Date: Mon, 1 Jul 2024 22:14:32 +0200
Subject: [PATCH] Compilation of fullscreen patches for dwm.
This aims to provide a comprehensive fullscreen solution with the following features:
- toggle fullscreen for any window using a single keybinding rather than having
to rely on per-application keybindings
- the ability to have windows go fullscreen within the size and position the
window is currently in (fake fullscreen)
- allow a fullscreen window to be moved to an adjacent monitor while remaining
fullscreen
- make fullscreen windows lose fullscreen if another (e.g. new) window on the
same monitor receives focus, while still allowing dialog boxes to show while
in fullscreen
- allow seamless transition between the two fullscreen modes
The default keybindings are:
- MOD+f to make a window fullscreen
- MOD+Shift+f to make a window fake fullscreen
This incorporates, and expands on, the following patches:
- fakefullscreenclient
- togglefullscreen (a.k.a. actualfullscreen)
- tagmonfixfs
- losefullscreen
---
config.def.h | 5 +-
dwm.c | 176 ++++++++++++++++++++++++++++++++++++++++++---------
2 files changed, 148 insertions(+), 33 deletions(-)
diff --git a/config.def.h b/config.def.h
index a2ac963..5f28f2c 100644
--- a/config.def.h
+++ b/config.def.h
@@ -35,7 +35,6 @@ static const Rule rules[] = {
static const float mfact = 0.55; /* factor of master area size [0.05..0.95] */
static const int nmaster = 1; /* number of clients in master area */
static const int resizehints = 1; /* 1 means respect size hints in tiled resizals */
-static const int lockfullscreen = 1; /* 1 will force focus on the fullscreen window */
static const Layout layouts[] = {
/* symbol arrange function */
@@ -75,10 +74,12 @@ static Key keys[] = {
{ MODKEY, XK_Tab, view, {0} },
{ MODKEY|ShiftMask, XK_c, killclient, {0} },
{ MODKEY, XK_t, setlayout, {.v = &layouts[0]} },
- { MODKEY, XK_f, setlayout, {.v = &layouts[1]} },
+ { MODKEY, XK_e, setlayout, {.v = &layouts[1]} },
{ MODKEY, XK_m, setlayout, {.v = &layouts[2]} },
{ MODKEY, XK_space, setlayout, {0} },
{ MODKEY|ShiftMask, XK_space, togglefloating, {0} },
+ { MODKEY, XK_f, togglefullscreen, {0} },
+ { MODKEY|ShiftMask, XK_f, togglefakefullscreen, {0} },
{ MODKEY, XK_0, view, {.ui = ~0 } },
{ MODKEY|ShiftMask, XK_0, tag, {.ui = ~0 } },
{ MODKEY, XK_comma, focusmon, {.i = -1 } },
diff --git a/dwm.c b/dwm.c
index a96f33c..53f0bd4 100644
--- a/dwm.c
+++ b/dwm.c
@@ -93,6 +93,7 @@ struct Client {
int bw, oldbw;
unsigned int tags;
int isfixed, isfloating, isurgent, neverfocus, oldstate, isfullscreen;
+ int fakefullscreen;
Client *next;
Client *snext;
Monitor *mon;
@@ -178,6 +179,7 @@ static void grabkeys(void);
static void incnmaster(const Arg *arg);
static void keypress(XEvent *e);
static void killclient(const Arg *arg);
+static void losefullscreen(Client *next);
static void manage(Window w, XWindowAttributes *wa);
static void mappingnotify(XEvent *e);
static void maprequest(XEvent *e);
@@ -211,7 +213,9 @@ static void tag(const Arg *arg);
static void tagmon(const Arg *arg);
static void tile(Monitor *);
static void togglebar(const Arg *arg);
+static void togglefakefullscreen(const Arg *arg);
static void togglefloating(const Arg *arg);
+static void togglefullscreen(const Arg *arg);
static void toggletag(const Arg *arg);
static void toggleview(const Arg *arg);
static void unfocus(Client *c, int setfocus);
@@ -520,9 +524,12 @@ clientmessage(XEvent *e)
return;
if (cme->message_type == netatom[NetWMState]) {
if (cme->data.l[1] == netatom[NetWMFullscreen]
- || cme->data.l[2] == netatom[NetWMFullscreen])
+ || cme->data.l[2] == netatom[NetWMFullscreen]) {
+ if (c->fakefullscreen == 2 && c->isfullscreen)
+ c->fakefullscreen = 3;
setfullscreen(c, (cme->data.l[0] == 1 /* _NET_WM_STATE_ADD */
|| (cme->data.l[0] == 2 /* _NET_WM_STATE_TOGGLE */ && !c->isfullscreen)));
+ }
} else if (cme->message_type == netatom[NetActiveWindow]) {
if (c != selmon->sel && !c->isurgent)
seturgent(c, 1);
@@ -566,7 +573,7 @@ configurenotify(XEvent *e)
updatebars();
for (m = mons; m; m = m->next) {
for (c = m->clients; c; c = c->next)
- if (c->isfullscreen)
+ if (c->isfullscreen && c->fakefullscreen != 1)
resizeclient(c, m->mx, m->my, m->mw, m->mh);
XMoveResizeWindow(dpy, m->barwin, m->wx, m->by, m->ww, bh);
}
@@ -789,8 +796,10 @@ focus(Client *c)
{
if (!c || !ISVISIBLE(c))
for (c = selmon->stack; c && !ISVISIBLE(c); c = c->snext);
- if (selmon->sel && selmon->sel != c)
+ if (selmon->sel && selmon->sel != c) {
+ losefullscreen(c);
unfocus(selmon->sel, 0);
+ }
if (c) {
if (c->mon != selmon)
selmon = c->mon;
@@ -838,7 +847,7 @@ focusstack(const Arg *arg)
{
Client *c = NULL, *i;
- if (!selmon->sel || (selmon->sel->isfullscreen && lockfullscreen))
+ if (!selmon->sel || (selmon->sel->isfullscreen && selmon->sel->fakefullscreen != 1))
return;
if (arg->i > 0) {
for (c = selmon->sel->next; c && !ISVISIBLE(c); c = c->next);
@@ -1018,6 +1027,16 @@ killclient(const Arg *arg)
}
}
+void
+losefullscreen(Client *next)
+{
+ Client *sel = selmon->sel;
+ if (!sel || !next)
+ return;
+ if (sel->isfullscreen && sel->fakefullscreen != 1 && ISVISIBLE(sel) && sel->mon == next->mon && !next->isfloating)
+ setfullscreen(sel, 0);
+}
+
void
manage(Window w, XWindowAttributes *wa)
{
@@ -1072,8 +1091,10 @@ manage(Window w, XWindowAttributes *wa)
(unsigned char *) &(c->win), 1);
XMoveResizeWindow(dpy, c->win, c->x + 2 * sw, c->y, c->w, c->h); /* some windows require this */
setclientstate(c, NormalState);
- if (c->mon == selmon)
+ if (c->mon == selmon) {
+ losefullscreen(c);
unfocus(selmon->sel, 0);
+ }
c->mon->sel = c;
arrange(c->mon);
XMapWindow(dpy, c->win);
@@ -1147,7 +1168,7 @@ movemouse(const Arg *arg)
if (!(c = selmon->sel))
return;
- if (c->isfullscreen) /* no support moving fullscreen windows by mouse */
+ if (c->isfullscreen && c->fakefullscreen != 1) /* no support moving fullscreen windows by mouse */
return;
restack(selmon);
ocx = c->x;
@@ -1302,7 +1323,7 @@ resizemouse(const Arg *arg)
if (!(c = selmon->sel))
return;
- if (c->isfullscreen) /* no support resizing fullscreen windows by mouse */
+ if (c->isfullscreen && c->fakefullscreen != 1) /* no support resizing fullscreen windows by mouse */
return;
restack(selmon);
ocx = c->x;
@@ -1476,29 +1497,79 @@ setfocus(Client *c)
void
setfullscreen(Client *c, int fullscreen)
{
- if (fullscreen && !c->isfullscreen) {
- XChangeProperty(dpy, c->win, netatom[NetWMState], XA_ATOM, 32,
- PropModeReplace, (unsigned char*)&netatom[NetWMFullscreen], 1);
+ XEvent ev;
+ int savestate = 0, restorestate = 0, restorefakefullscreen = 0;
+
+ if ((c->fakefullscreen == 0 && fullscreen && !c->isfullscreen) // normal fullscreen
+ || (c->fakefullscreen == 2 && fullscreen)) // fake fullscreen --> actual fullscreen
+ savestate = 1; // go actual fullscreen
+ else if ((c->fakefullscreen == 0 && !fullscreen && c->isfullscreen) // normal fullscreen exit
+ || (c->fakefullscreen >= 2 && !fullscreen)) // fullscreen exit --> fake fullscreen
+ restorestate = 1; // go back into tiled
+
+ /* If leaving fullscreen and the window was previously fake fullscreen (2), then restore
+ * that while staying in fullscreen. The exception to this is if we are in said state, but
+ * the client itself disables fullscreen (3) then we let the client go out of fullscreen
+ * while keeping fake fullscreen enabled (as otherwise there will be a mismatch between the
+ * client and the window manager's perception of the client's fullscreen state). */
+ if (c->fakefullscreen == 2 && !fullscreen && c->isfullscreen) {
+ restorefakefullscreen = 1;
c->isfullscreen = 1;
- c->oldstate = c->isfloating;
+ fullscreen = 1;
+ }
+
+ if (fullscreen != c->isfullscreen) { // only send property change if necessary
+ if (fullscreen)
+ XChangeProperty(dpy, c->win, netatom[NetWMState], XA_ATOM, 32,
+ PropModeReplace, (unsigned char*)&netatom[NetWMFullscreen], 1);
+ else
+ XChangeProperty(dpy, c->win, netatom[NetWMState], XA_ATOM, 32,
+ PropModeReplace, (unsigned char*)0, 0);
+ }
+
+ c->isfullscreen = fullscreen;
+
+ /* Some clients, e.g. firefox, will send a client message informing the window manager
+ * that it is going into fullscreen after receiving the above signal. This has the side
+ * effect of this function (setfullscreen) sometimes being called twice when toggling
+ * fullscreen on and off via the window manager as opposed to the application itself.
+ * To protect against obscure issues where the client settings are stored or restored
+ * when they are not supposed to we add an additional bit-lock on the old state so that
+ * settings can only be stored and restored in that precise order. */
+ if (savestate && !(c->oldstate & (1 << 1))) {
c->oldbw = c->bw;
+ c->oldstate = c->isfloating | (1 << 1);
c->bw = 0;
c->isfloating = 1;
resizeclient(c, c->mon->mx, c->mon->my, c->mon->mw, c->mon->mh);
XRaiseWindow(dpy, c->win);
- } else if (!fullscreen && c->isfullscreen){
- XChangeProperty(dpy, c->win, netatom[NetWMState], XA_ATOM, 32,
- PropModeReplace, (unsigned char*)0, 0);
- c->isfullscreen = 0;
- c->isfloating = c->oldstate;
+ } else if (restorestate && (c->oldstate & (1 << 1))) {
c->bw = c->oldbw;
- c->x = c->oldx;
- c->y = c->oldy;
- c->w = c->oldw;
- c->h = c->oldh;
+ c->isfloating = c->oldstate = c->oldstate & 1;
+ if (restorefakefullscreen || c->fakefullscreen == 3)
+ c->fakefullscreen = 1;
+ /* The client may have been moved to another monitor whilst in fullscreen which if tiled
+ * we address by doing a full arrange of tiled clients. If the client is floating then the
+ * height and width may be larger than the monitor's window area, so we cap that by
+ * ensuring max / min values. */
+ if (c->isfloating) {
+ c->x = MAX(c->mon->wx, c->oldx);
+ c->y = MAX(c->mon->wy, c->oldy);
+ c->w = MIN(c->mon->ww - c->x - 2*c->bw, c->oldw);
+ c->h = MIN(c->mon->wh - c->y - 2*c->bw, c->oldh);
+ resizeclient(c, c->x, c->y, c->w, c->h);
+ restack(c->mon);
+ } else
+ arrange(c->mon);
+ } else
resizeclient(c, c->x, c->y, c->w, c->h);
- arrange(c->mon);
- }
+
+ /* Exception: if the client was in actual fullscreen and we exit out to fake fullscreen
+ * mode, then the focus would sometimes drift to whichever window is under the mouse cursor
+ * at the time. To avoid this we ask X for all EnterNotify events and just ignore them.
+ */
+ if (!c->isfullscreen)
+ while (XCheckMaskEvent(dpy, EnterWindowMask, &ev));
}
void
@@ -1669,9 +1740,19 @@ tag(const Arg *arg)
void
tagmon(const Arg *arg)
{
- if (!selmon->sel || !mons->next)
+ Client *c = selmon->sel;
+ if (!c || !mons->next)
return;
- sendmon(selmon->sel, dirtomon(arg->i));
+ if (c->isfullscreen) {
+ c->isfullscreen = 0;
+ sendmon(c, dirtomon(arg->i));
+ c->isfullscreen = 1;
+ if (c->fakefullscreen != 1) {
+ resizeclient(c, c->mon->mx, c->mon->my, c->mon->mw, c->mon->mh);
+ XRaiseWindow(dpy, c->win);
+ }
+ } else
+ sendmon(c, dirtomon(arg->i));
}
void
@@ -1711,18 +1792,51 @@ togglebar(const Arg *arg)
arrange(selmon);
}
+void
+togglefakefullscreen(const Arg *arg)
+{
+ Client *c = selmon->sel;
+ if (!c)
+ return;
+
+ if (c->fakefullscreen != 1 && c->isfullscreen) { // exit fullscreen --> fake fullscreen
+ c->fakefullscreen = 2;
+ setfullscreen(c, 0);
+ } else if (c->fakefullscreen == 1) {
+ setfullscreen(c, 0);
+ c->fakefullscreen = 0;
+ } else {
+ c->fakefullscreen = 1;
+ setfullscreen(c, 1);
+ }
+}
+
void
togglefloating(const Arg *arg)
{
- if (!selmon->sel)
+ Client *c = selmon->sel;
+ if (!c)
return;
- if (selmon->sel->isfullscreen) /* no support for fullscreen windows */
+ if (c->isfullscreen && c->fakefullscreen != 1) /* no support for fullscreen windows */
return;
- selmon->sel->isfloating = !selmon->sel->isfloating || selmon->sel->isfixed;
- if (selmon->sel->isfloating)
- resize(selmon->sel, selmon->sel->x, selmon->sel->y,
- selmon->sel->w, selmon->sel->h, 0);
- arrange(selmon);
+ c->isfloating = !c->isfloating || c->isfixed;
+ if (c->isfloating)
+ resize(c, c->x, c->y, c->w, c->h, 0);
+ arrange(c->mon);
+}
+
+void
+togglefullscreen(const Arg *arg)
+{
+ Client *c = selmon->sel;
+ if (!c)
+ return;
+
+ if (c->fakefullscreen == 1) { // fake fullscreen --> fullscreen
+ c->fakefullscreen = 2;
+ setfullscreen(c, 1);
+ } else
+ setfullscreen(c, !c->isfullscreen);
}
void
--
2.45.2

View File

@@ -1,173 +0,0 @@
From d06cefd6e1f8b5cd9bdfe694b7dc16da1f00d83e Mon Sep 17 00:00:00 2001
From: Bakkeby <bakkeby@gmail.com>
Date: Mon, 1 Jul 2024 22:19:15 +0200
Subject: [PATCH] Game rule patch
This patch adds a rule identifying clients as a "game" such that
if the client is in fullscreen and it loses focus (e.g. by moving
to another tag) then it will automatically be minimized (set to
IconicState and unmapped).
When the client receives focus again (e.g. by going back to its
tag) then it will automaticaly be unminimized (set to NormalState
and mapped). This should address many of the black screen or window
is tiny after having moved to another tag and back again.
This may conflict with the awesomebar patch which skips hidden
(iconic) windows when selecting which client to focus on, i.e. it
would be there but minimized and will not automatically unminimize.
The function names are minimize and unminimize compared to the same
functions hide and show in the awesomebar patch. The name change is
due to two reasons; 1) because hide and show do something very
different compared to the showhide function and 2) because when
minimizing and unminimizing we do not want to trigger arrange or
a change in focus (which would affect the stacking order and thus
prevent the window receiving focus when we move back to the previous
tag).
---
config.def.h | 4 +++-
dwm.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 50 insertions(+), 1 deletion(-)
diff --git a/config.def.h b/config.def.h
index 9efa774..9df3c97 100644
--- a/config.def.h
+++ b/config.def.h
@@ -26,9 +26,11 @@ static const Rule rules[] = {
* WM_CLASS(STRING) = instance, class
* WM_NAME(STRING) = title
*/
- /* class instance title tags mask isfloating monitor */
+ /* class instance title tags mask isfloating monitor isgame */
{ "Gimp", NULL, NULL, 0, 1, -1 },
{ "Firefox", NULL, NULL, 1 << 8, 0, -1 },
+ { "Steam", NULL, NULL, 0, 0, -1, 1 },
+ { "steam_app",NULL, NULL, 0, 0, -1, 1 },
};
/* layout(s) */
diff --git a/dwm.c b/dwm.c
index 1443802..29de39a 100644
--- a/dwm.c
+++ b/dwm.c
@@ -50,6 +50,7 @@
#define INTERSECT(x,y,w,h,m) (MAX(0, MIN((x)+(w),(m)->wx+(m)->ww) - MAX((x),(m)->wx)) \
* MAX(0, MIN((y)+(h),(m)->wy+(m)->wh) - MAX((y),(m)->wy)))
#define ISVISIBLE(C) ((C->tags & C->mon->tagset[C->mon->seltags]))
+#define MINIMIZED(C) ((getstate(C->win) == IconicState))
#define MOUSEMASK (BUTTONMASK|PointerMotionMask)
#define WIDTH(X) ((X)->w + 2 * (X)->bw)
#define HEIGHT(X) ((X)->h + 2 * (X)->bw)
@@ -92,6 +93,7 @@ struct Client {
int bw, oldbw;
unsigned int tags;
int isfixed, isfloating, isurgent, neverfocus, oldstate, isfullscreen;
+ int isgame;
Client *next;
Client *snext;
Monitor *mon;
@@ -138,6 +140,7 @@ typedef struct {
unsigned int tags;
int isfloating;
int monitor;
+ int isgame;
} Rule;
/* function declarations */
@@ -180,6 +183,7 @@ static void killclient(const Arg *arg);
static void manage(Window w, XWindowAttributes *wa);
static void mappingnotify(XEvent *e);
static void maprequest(XEvent *e);
+static void minimize(Client *c);
static void monocle(Monitor *m);
static void motionnotify(XEvent *e);
static void movemouse(const Arg *arg);
@@ -215,6 +219,7 @@ static void toggleview(const Arg *arg);
static void unfocus(Client *c, int setfocus);
static void unmanage(Client *c, int destroyed);
static void unmapnotify(XEvent *e);
+static void unminimize(Client *c);
static void updatebarpos(Monitor *m);
static void updatebars(void);
static void updateclientlist(void);
@@ -298,6 +303,7 @@ applyrules(Client *c)
{
c->isfloating = r->isfloating;
c->tags |= r->tags;
+ c->isgame = r->isgame;
for (m = mons; m && m->num != r->monitor; m = m->next);
if (m)
c->mon = m;
@@ -1109,6 +1115,29 @@ maprequest(XEvent *e)
manage(ev->window, &wa);
}
+void
+minimize(Client *c)
+{
+ if (!c || MINIMIZED(c))
+ return;
+
+ Window w = c->win;
+ static XWindowAttributes ra, ca;
+
+ // more or less taken directly from blackbox's hide() function
+ XGrabServer(dpy);
+ XGetWindowAttributes(dpy, root, &ra);
+ XGetWindowAttributes(dpy, w, &ca);
+ // prevent UnmapNotify events
+ XSelectInput(dpy, root, ra.your_event_mask & ~SubstructureNotifyMask);
+ XSelectInput(dpy, w, ca.your_event_mask & ~StructureNotifyMask);
+ XUnmapWindow(dpy, w);
+ setclientstate(c, IconicState);
+ XSelectInput(dpy, root, ra.your_event_mask);
+ XSelectInput(dpy, w, ca.your_event_mask);
+ XUngrabServer(dpy);
+}
+
void
monocle(Monitor *m)
{
@@ -1475,6 +1504,10 @@ setfocus(Client *c)
XA_WINDOW, 32, PropModeReplace,
(unsigned char *) &(c->win), 1);
}
+
+ if (c->isgame && c->isfullscreen)
+ unminimize(c);
+
sendevent(c, wmatom[WMTakeFocus]);
}
@@ -1766,6 +1799,10 @@ unfocus(Client *c, int setfocus)
{
if (!c)
return;
+
+ if (c->isgame && c->isfullscreen)
+ minimize(c);
+
grabbuttons(c, 0);
XSetWindowBorder(dpy, c->win, scheme[SchemeNorm][ColBorder].pixel);
if (setfocus) {
@@ -1814,6 +1851,16 @@ unmapnotify(XEvent *e)
}
}
+void
+unminimize(Client *c)
+{
+ if (!c || !MINIMIZED(c))
+ return;
+
+ XMapWindow(dpy, c->win);
+ setclientstate(c, NormalState);
+}
+
void
updatebars(void)
{
--
2.50.1