diff --git a/config.def.h.rej b/config.def.h.rej index 36b8c7c..d121ec2 100644 --- a/config.def.h.rej +++ b/config.def.h.rej @@ -1,15 +1,15 @@ --- config.def.h +++ config.def.h -@@ -26,9 +26,11 @@ static const Rule rules[] = { +@@ -26,11 +26,9 @@ 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 */ +- /* class instance title tags mask isfloating monitor isgame */ ++ /* class instance title tags mask isfloating monitor */ { "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 }, +- { "Steam", NULL, NULL, 0, 0, -1, 1 }, +- { "steam_app",NULL, NULL, 0, 0, -1, 1 }, }; /* layout(s) */ diff --git a/config.h b/config.h index 286db91..f8bb3b5 100644 --- a/config.h +++ b/config.h @@ -52,20 +52,19 @@ static const Rule rules[] = { * WM_CLASS(STRING) = instance, class * WM_NAME(STRING) = title */ - /* class instance title tags mask isfloating monitor isgame */ - { "Playground", NULL, NULL, 0, 1, -1, 0 }, + /* class instance title tags mask isfloating monitor */ + { "Playground", NULL, NULL, 0, 1, -1, }, - { "Steam", NULL, NULL, 1 << 1, 0, -1, 1 }, - { "steam_app", NULL, NULL, 0, 0, -1, 1 }, + { "steam", NULL, NULL, 1 << 1, 0, -1, }, - { "Firefox", NULL, NULL, 1 << 2, 0, -1, 0 }, - { "brave-browser", NULL, NULL, 1 << 3, 0, -1, 0 }, - { "discord", NULL, NULL, 1 << 4, 0, -1, 0 }, - { "feishin", NULL, NULL, 1 << 5, 0, -1, 0 }, + { "Firefox", NULL, NULL, 1 << 2, 0, -1, }, + { "brave-browser", NULL, NULL, 1 << 3, 0, -1, }, + { "discord", NULL, NULL, 1 << 4, 0, -1, }, + { "feishin", NULL, NULL, 1 << 5, 0, -1, }, - { NULL, "spterm", NULL, SPTAG(0), 1, -1, 0 }, - { NULL, "spfm", NULL, SPTAG(1), 1, -1, 0 }, - { NULL, "keepassxc", NULL, SPTAG(2), 0, -1, 0 }, + { NULL, "spterm", NULL, SPTAG(0), 1, -1, }, + { NULL, "spfm", NULL, SPTAG(1), 1, -1, }, + { NULL, "keepassxc", NULL, SPTAG(2), 0, -1, }, }; /* layout(s) */ diff --git a/dwm b/dwm index cf4538b..8681cae 100755 Binary files a/dwm and b/dwm differ diff --git a/dwm.c b/dwm.c index 1a1b86b..adde2ab 100644 --- a/dwm.c +++ b/dwm.c @@ -51,7 +51,6 @@ * 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) @@ -115,7 +114,7 @@ struct Client { int bw, oldbw; unsigned int tags; int isfixed, isfloating, isurgent, neverfocus, oldstate, isfullscreen; - int isgame; + int issteam; int fakefullscreen; Client *next; Client *snext; @@ -170,7 +169,6 @@ typedef struct { unsigned int tags; int isfloating; int monitor; - int isgame; } Rule; typedef struct Systray Systray; @@ -228,7 +226,6 @@ 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); @@ -285,7 +282,6 @@ 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); @@ -412,6 +408,9 @@ 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)) @@ -420,7 +419,6 @@ 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); @@ -802,13 +800,15 @@ configurerequest(XEvent *e) c->bw = ev->border_width; else if (c->isfloating || !selmon->lt[selmon->sellt]->arrange) { m = c->mon; - 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 (!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 & CWWidth) { c->oldw = c->w; @@ -1566,29 +1566,6 @@ 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) { @@ -2159,9 +2136,8 @@ setfocus(Client *c) XA_WINDOW, 32, PropModeReplace, (unsigned char *) &(c->win), 1); } - - if (c->isgame && c->isfullscreen) - unminimize(c); + if (c->issteam) + setclientstate(c, NormalState); sendevent(c->win, wmatom[WMTakeFocus], NoEventMask, wmatom[WMTakeFocus], CurrentTime, 0, 0, 0); } @@ -2688,10 +2664,6 @@ 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) { @@ -2746,16 +2718,6 @@ unmapnotify(XEvent *e) } } -void -unminimize(Client *c) -{ - if (!c || !MINIMIZED(c)) - return; - - XMapWindow(dpy, c->win); - setclientstate(c, NormalState); -} - void updatebars(void) { diff --git a/dwm.c.orig b/dwm.c.orig index 4fbf4c0..a2be27f 100644 --- a/dwm.c.orig +++ b/dwm.c.orig @@ -51,7 +51,6 @@ * 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) @@ -115,8 +114,6 @@ 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; @@ -171,7 +168,6 @@ typedef struct { unsigned int tags; int isfloating; int monitor; - int isgame; } Rule; typedef struct Systray Systray; @@ -229,7 +225,6 @@ 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); @@ -286,7 +281,6 @@ 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); @@ -413,9 +407,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)) @@ -424,7 +415,6 @@ 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); @@ -806,15 +796,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; @@ -1572,29 +1560,6 @@ 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) { @@ -2166,12 +2131,6 @@ setfocus(Client *c) (unsigned char *) &(c->win), 1); } - if (c->isgame && c->isfullscreen) - unminimize(c); - - if (c->issteam) - setclientstate(c, NormalState); - sendevent(c->win, wmatom[WMTakeFocus], NoEventMask, wmatom[WMTakeFocus], CurrentTime, 0, 0, 0); } @@ -2697,10 +2656,6 @@ 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) { @@ -2755,16 +2710,6 @@ unmapnotify(XEvent *e) } } -void -unminimize(Client *c) -{ - if (!c || !MINIMIZED(c)) - return; - - XMapWindow(dpy, c->win); - setclientstate(c, NormalState); -} - void updatebars(void) { diff --git a/dwm.c.rej b/dwm.c.rej index 660493a..f62ea2b 100644 --- a/dwm.c.rej +++ b/dwm.c.rej @@ -1,19 +1,19 @@ --- dwm.c +++ dwm.c -@@ -92,7 +92,6 @@ struct Client { +@@ -92,6 +92,7 @@ struct Client { int bw, oldbw; unsigned int tags; int isfixed, isfloating, isurgent, neverfocus, oldstate, isfullscreen; -- int issteam; ++ int issteam; Client *next; Client *snext; Monitor *mon; -@@ -1476,8 +1470,6 @@ setfocus(Client *c) +@@ -1480,6 +1486,8 @@ setfocus(Client *c) XA_WINDOW, 32, PropModeReplace, (unsigned char *) &(c->win), 1); } -- if (c->issteam) -- setclientstate(c, NormalState); ++ if (c->issteam) ++ setclientstate(c, NormalState); sendevent(c, wmatom[WMTakeFocus]); } diff --git a/dwm.o b/dwm.o index f4392cd..4ca3950 100644 Binary files a/dwm.o and b/dwm.o differ diff --git a/patches/dwm-games-6.6.diff b/patches/dwm-games-6.6.diff deleted file mode 100644 index ce4bbdb..0000000 --- a/patches/dwm-games-6.6.diff +++ /dev/null @@ -1,173 +0,0 @@ -From d06cefd6e1f8b5cd9bdfe694b7dc16da1f00d83e Mon Sep 17 00:00:00 2001 -From: Bakkeby -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 - diff --git a/patches/dwm-steam-6.6.diff b/patches/dwm-steam-6.6.diff new file mode 100644 index 0000000..c6f5fd7 --- /dev/null +++ b/patches/dwm-steam-6.6.diff @@ -0,0 +1,72 @@ +From df7d9a685f38b64b8087faa3c72f05acf0190383 Mon Sep 17 00:00:00 2001 +From: Bakkeby +Date: Wed, 26 Jun 2024 23:06:37 +0200 +Subject: [PATCH] Steam patch + +Steam, and steam windows (games), trigger a ConfigureNotify request every time the window +gets focus. More so, the configure event passed along from Steam tends to have the wrong +x and y co-ordinates which can make the window, if floating, jump around the screen. + +This patch works around this age-old issue by ignoring the x and y co-ordinates for +ConfigureNotify requests relating to Steam windows. +--- + dwm.c | 22 +++++++++++++++------- + 1 file changed, 15 insertions(+), 7 deletions(-) + +diff --git a/dwm.c b/dwm.c +index 1443802..d99a6fb 100644 +--- a/dwm.c ++++ b/dwm.c +@@ -92,6 +92,7 @@ struct Client { + int bw, oldbw; + unsigned int tags; + int isfixed, isfloating, isurgent, neverfocus, oldstate, isfullscreen; ++ int issteam; + Client *next; + Client *snext; + Monitor *mon; +@@ -290,6 +291,9 @@ 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)) +@@ -590,13 +594,15 @@ configurerequest(XEvent *e) + c->bw = ev->border_width; + else if (c->isfloating || !selmon->lt[selmon->sellt]->arrange) { + m = c->mon; +- 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 (!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 & CWWidth) { + c->oldw = c->w; +@@ -1475,6 +1481,8 @@ setfocus(Client *c) + XA_WINDOW, 32, PropModeReplace, + (unsigned char *) &(c->win), 1); + } ++ if (c->issteam) ++ setclientstate(c, NormalState); + sendevent(c, wmatom[WMTakeFocus]); + } + +-- +2.50.1 +