add games patch

This commit is contained in:
2026-06-17 12:43:37 +02:00
parent d96dee00d5
commit 98d969c333
8 changed files with 367 additions and 19 deletions

47
dwm.c
View File

@@ -57,6 +57,7 @@
* MAX(0, MIN((y)+(h),(m)->wy+(m)->wh) - MAX((y),(m)->wy)))
#define ISVISIBLEONTAG(C, T) ((C->tags & T))
#define ISVISIBLE(C) ISVISIBLEONTAG(C, 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)
@@ -118,6 +119,7 @@ struct Client {
int bw, oldbw;
unsigned int tags;
int isfixed, isfloating, isurgent, neverfocus, oldstate, isfullscreen, isterminal, noswallow;
int isgame;
pid_t pid;
Client *next;
Client *snext;
@@ -172,6 +174,7 @@ typedef struct {
int isterminal;
int noswallow;
int monitor;
int isgame;
} Rule;
typedef struct Systray Systray;
@@ -223,6 +226,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);
@@ -268,6 +272,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);
@@ -411,6 +416,7 @@ applyrules(Client *c)
c->noswallow = r->noswallow;
c->isfloating = r->isfloating;
c->tags |= r->tags;
c->isgame = r->isgame;
if ((r->tags & SPTAGMASK) && r->isfloating) {
c->x = c->mon->wx + (c->mon->ww / 2 - WIDTH(c) / 2);
c->y = c->mon->wy + (c->mon->wh / 2 - HEIGHT(c) / 2);
@@ -1469,6 +1475,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)
{
@@ -1997,6 +2026,10 @@ setfocus(Client *c)
XA_WINDOW, 32, PropModeReplace,
(unsigned char *) &(c->win), 1);
}
if (c->isgame && c->isfullscreen)
unminimize(c);
sendevent(c->win, wmatom[WMTakeFocus], NoEventMask, wmatom[WMTakeFocus], CurrentTime, 0, 0, 0);
}
@@ -2359,6 +2392,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) {
@@ -2430,6 +2467,16 @@ unmapnotify(XEvent *e)
}
}
void
unminimize(Client *c)
{
if (!c || !MINIMIZED(c))
return;
XMapWindow(dpy, c->win);
setclientstate(c, NormalState);
}
void
updatebars(void)
{