use games patch
This commit is contained in:
86
dwm.c
86
dwm.c
@@ -51,6 +51,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 HIDDEN(C) ((getstate(C->win) == IconicState))
|
||||
#define MOUSEMASK (BUTTONMASK|PointerMotionMask)
|
||||
#define WIDTH(X) ((X)->w + 2 * (X)->bw)
|
||||
@@ -114,7 +115,7 @@ struct Client {
|
||||
int bw, oldbw;
|
||||
unsigned int tags;
|
||||
int isfixed, isfloating, isurgent, neverfocus, oldstate, isfullscreen;
|
||||
int issteam;
|
||||
int isgame;
|
||||
int fakefullscreen;
|
||||
Client *next;
|
||||
Client *snext;
|
||||
@@ -169,6 +170,7 @@ typedef struct {
|
||||
unsigned int tags;
|
||||
int isfloating;
|
||||
int monitor;
|
||||
int isgame;
|
||||
} Rule;
|
||||
|
||||
typedef struct Systray Systray;
|
||||
@@ -226,6 +228,7 @@ static void losefullscreen(Client *next);
|
||||
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);
|
||||
@@ -282,6 +285,7 @@ static void togglewin(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 updatecurrentdesktop(void);
|
||||
static void updatebarpos(Monitor *m);
|
||||
static void updatebars(void);
|
||||
@@ -408,9 +412,6 @@ applyrules(Client *c)
|
||||
class = ch.res_class ? ch.res_class : broken;
|
||||
instance = ch.res_name ? ch.res_name : broken;
|
||||
|
||||
if (strstr(class, "Steam") || strstr(class, "steam_app_"))
|
||||
c->issteam = 1;
|
||||
|
||||
for (i = 0; i < LENGTH(rules); i++) {
|
||||
r = &rules[i];
|
||||
if ((!r->title || strstr(c->name, r->title))
|
||||
@@ -419,6 +420,7 @@ applyrules(Client *c)
|
||||
{
|
||||
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);
|
||||
@@ -800,15 +802,13 @@ configurerequest(XEvent *e)
|
||||
c->bw = ev->border_width;
|
||||
else if (c->isfloating || !selmon->lt[selmon->sellt]->arrange) {
|
||||
m = c->mon;
|
||||
if (!c->issteam) {
|
||||
if (ev->value_mask & CWX) {
|
||||
c->oldx = c->x;
|
||||
c->x = m->mx + ev->x;
|
||||
}
|
||||
if (ev->value_mask & CWY) {
|
||||
c->oldy = c->y;
|
||||
c->y = m->my + ev->y;
|
||||
}
|
||||
if (ev->value_mask & CWX) {
|
||||
c->oldx = c->x;
|
||||
c->x = m->mx + ev->x;
|
||||
}
|
||||
if (ev->value_mask & CWY) {
|
||||
c->oldy = c->y;
|
||||
c->y = m->my + ev->y;
|
||||
}
|
||||
if (ev->value_mask & CWWidth) {
|
||||
c->oldw = c->w;
|
||||
@@ -1566,6 +1566,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)
|
||||
{
|
||||
@@ -1832,17 +1855,19 @@ propertynotify(XEvent *e)
|
||||
void
|
||||
quit(const Arg *arg)
|
||||
{
|
||||
// fix: reloading dwm keeps all the hidden clients hidden
|
||||
Monitor *m;
|
||||
Client *c;
|
||||
for (m = mons; m; m = m->next) {
|
||||
if (m) {
|
||||
for (c = m->stack; c; c = c->next)
|
||||
if (c && HIDDEN(c)) showwin(c);
|
||||
if(arg->i) restart = 1;
|
||||
if (!restart) {
|
||||
// fix: reloading dwm keeps all the hidden clients hidden
|
||||
Monitor *m;
|
||||
Client *c;
|
||||
for (m = mons; m; m = m->next) {
|
||||
if (m) {
|
||||
for (c = m->stack; c; c = c->next)
|
||||
if (c && HIDDEN(c)) showwin(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(arg->i) restart = 1;
|
||||
running = 0;
|
||||
}
|
||||
|
||||
@@ -2134,8 +2159,9 @@ setfocus(Client *c)
|
||||
XA_WINDOW, 32, PropModeReplace,
|
||||
(unsigned char *) &(c->win), 1);
|
||||
}
|
||||
if (c->issteam)
|
||||
setclientstate(c, NormalState);
|
||||
|
||||
if (c->isgame && c->isfullscreen)
|
||||
unminimize(c);
|
||||
|
||||
sendevent(c->win, wmatom[WMTakeFocus], NoEventMask, wmatom[WMTakeFocus], CurrentTime, 0, 0, 0);
|
||||
}
|
||||
@@ -2662,6 +2688,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) {
|
||||
@@ -2716,6 +2746,16 @@ unmapnotify(XEvent *e)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
unminimize(Client *c)
|
||||
{
|
||||
if (!c || !MINIMIZED(c))
|
||||
return;
|
||||
|
||||
XMapWindow(dpy, c->win);
|
||||
setclientstate(c, NormalState);
|
||||
}
|
||||
|
||||
void
|
||||
updatebars(void)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user