summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorbakkeby <[email protected]>2019-09-08 00:23:30 +0200
committerbakkeby <[email protected]>2019-09-08 00:25:48 +0200
commit747512af21fabae327a1a4e7b01bfd00af8eeb15 (patch)
treeba2126d5089d665b8b727feac6ceca40e903fa44
parent8a71375fed01c134d3215b84b24df67f7d5a4531 (diff)
downloaddwm-flexipatch-747512af21fabae327a1a4e7b01bfd00af8eeb15.tar.gz
dwm-flexipatch-747512af21fabae327a1a4e7b01bfd00af8eeb15.zip
Adding center patch
-rw-r--r--README.md8
-rw-r--r--config.def.h34
-rw-r--r--dwm.c39
-rw-r--r--patches.h18
4 files changed, 92 insertions, 7 deletions
diff --git a/README.md b/README.md
index 8c9d09d..726acd6 100644
--- a/README.md
+++ b/README.md
@@ -11,7 +11,7 @@ Refer to [https://dwm.suckless.org/](https://dwm.suckless.org/) for details on t
### Changelog:
-2019-09-07 - Added cyclelayouts, resizecorners, rotatestack, savefloats, statuspadding and windowrolerule patches
+2019-09-07 - Added cyclelayouts, resizecorners, rotatestack, savefloats, statuspadding, switchtag, center and windowrolerule patches
2019-09-06 - Added attachabove, attachaside, attachbelow, attachbottom, autostart, fancybar, focusonnetactive and losefullscreen patches
@@ -37,6 +37,9 @@ Refer to [https://dwm.suckless.org/](https://dwm.suckless.org/) for details on t
- [autostart](https://dwm.suckless.org/patches/autostart/)
- makes dwm run `~/.dwm/autostart_blocking.sh` and `~/.dwm/autostart.sh &` on startup
+ - [center](https://dwm.suckless.org/patches/center/)
+ - adds an iscentered rule to automatically center clients on the current monitor
+
- [cyclelayouts](https://dwm.suckless.org/patches/cyclelayouts/)
- lets you cycle through all your layouts
@@ -72,6 +75,9 @@ Refer to [https://dwm.suckless.org/](https://dwm.suckless.org/) for details on t
- [systray](https://dwm.suckless.org/patches/systray/)
- adds system tray in the status bar
+ - [switchtag](https://github.com/bakkeby/dwm-vanitygaps/blob/master/patches/dwm-switchtag-6.2.diff)
+ - when an application opens on a specific tab this patch adds the option to also switch to that tag when the application starts
+
- [tagallmon](https://github.com/bakkeby/dwm-vanitygaps/blob/master/patches/dwm-tagallmon-6.2.diff)
- move all visible windows to an adjacent monitor
diff --git a/config.def.h b/config.def.h
index e8edf1b..36bc4ec 100644
--- a/config.def.h
+++ b/config.def.h
@@ -46,15 +46,39 @@ static const Rule rules[] = {
* WM_NAME(STRING) = title
* WM_WINDOW_ROLE(STRING) = role
*/
- #if WINDOWROLERULE_PATCH
- /* class role instance title tags mask isfloating monitor */
- { "Gimp", NULL, NULL, NULL, 0, 1, -1 },
- { "Firefox", NULL, NULL, NULL, 1 << 8, 0, -1 },
+ #if WINDOWROLERULE_PATCH && SWITCHTAG_PATCH && CENTER_PATCH
+ /* class role instance title tags mask switchtag iscentered isfloating monitor */
+ { "Gimp", NULL, NULL, NULL, 0, 1, 0, 1, -1 },
+ { "Firefox", NULL, NULL, NULL, 1 << 8, 1, 0, 0, -1 },
+ #elif WINDOWROLERULE_PATCH && !SWITCHTAG_PATCH && CENTER_PATCH
+ /* class role instance title tags mask iscentered isfloating monitor */
+ { "Gimp", NULL, NULL, NULL, 0, 0, 1, -1 },
+ { "Firefox", NULL, NULL, NULL, 1 << 8, 0, 0, -1 },
+ #elif WINDOWROLERULE_PATCH && SWITCHTAG_PATCH && !CENTER_PATCH
+ /* class role instance title tags mask switchtag isfloating monitor */
+ { "Gimp", NULL, NULL, NULL, 0, 1, 1, -1 },
+ { "Firefox", NULL, NULL, NULL, 1 << 8, 1, 0, -1 },
+ #elif !WINDOWROLERULE_PATCH && SWITCHTAG_PATCH && CENTER_PATCH
+ /* class instance title tags mask switchtag iscentered isfloating monitor */
+ { "Gimp", NULL, NULL, 0, 1, 0, 1, -1 },
+ { "Firefox", NULL, NULL, 1 << 8, 1, 0, 0, -1 },
+ #elif WINDOWROLERULE_PATCH && !SWITCHTAG_PATCH && !CENTER_PATCH
+ /* class role instance title tags mask isfloating monitor */
+ { "Gimp", NULL, NULL, NULL, 0, 1, -1 },
+ { "Firefox", NULL, NULL, NULL, 1 << 8, 0, -1 },
+ #elif !WINDOWROLERULE_PATCH && SWITCHTAG_PATCH && !CENTER_PATCH
+ /* class instance title tags mask switchtag isfloating monitor */
+ { "Gimp", NULL, NULL, 0, 1, 1, -1 },
+ { "Firefox", NULL, NULL, 1 << 8, 1, 0, -1 },
+ #elif !WINDOWROLERULE_PATCH && !SWITCHTAG_PATCH && CENTER_PATCH
+ /* class instance title tags mask iscentered isfloating monitor */
+ { "Gimp", NULL, NULL, 0, 0, 1, -1 },
+ { "Firefox", NULL, NULL, 1 << 8, 0, 0, -1 },
#else
/* class instance title tags mask isfloating monitor */
{ "Gimp", NULL, NULL, 0, 1, -1 },
{ "Firefox", NULL, NULL, 1 << 8, 0, -1 },
- #endif
+ #endif // granted the above will be confusing, do remember to delete rule entries for patches that you do not take
};
/* layout(s) */
diff --git a/dwm.c b/dwm.c
index 9293609..92bb52a 100644
--- a/dwm.c
+++ b/dwm.c
@@ -112,6 +112,9 @@ struct Client {
int bw, oldbw;
unsigned int tags;
int isfixed, isfloating, isurgent, neverfocus, oldstate, isfullscreen;
+ #if CENTER_PATCH
+ int iscentered;
+ #endif // CENTER_PATCH
Client *next;
Client *snext;
Monitor *mon;
@@ -165,6 +168,12 @@ typedef struct {
const char *instance;
const char *title;
unsigned int tags;
+ #if SWITCHTAG_PATCH
+ int switchtag;
+ #endif // SWITCHTAG_PATCH
+ #if CENTER_PATCH
+ int iscentered;
+ #endif // CENTER_PATCH
int isfloating;
int monitor;
} Rule;
@@ -351,11 +360,29 @@ applyrules(Client *c)
#endif // WINDOWROLERULE_PATCH
&& (!r->instance || strstr(instance, r->instance)))
{
+ #if CENTER_PATCH
+ c->iscentered = r->iscentered;
+ #endif // CENTER_PATCH
c->isfloating = r->isfloating;
c->tags |= r->tags;
for (m = mons; m && m->num != r->monitor; m = m->next);
if (m)
c->mon = m;
+
+ #if SWITCHTAG_PATCH
+ if (r->switchtag) {
+ unsigned int newtagset;
+ if (r->switchtag == 2)
+ newtagset = c->mon->tagset[c->mon->seltags] ^ c->tags;
+ else
+ newtagset = c->tags;
+
+ if (newtagset) {
+ c->mon->tagset[c->mon->seltags] = newtagset;
+ arrange(c->mon);
+ }
+ }
+ #endif // SWITCHTAG_PATCH
}
}
if (ch.res_class)
@@ -1340,6 +1367,12 @@ manage(Window w, XWindowAttributes *wa)
updatewindowtype(c);
updatesizehints(c);
updatewmhints(c);
+ #if CENTER_PATCH
+ if (c->iscentered) {
+ c->x = c->mon->mx + (c->mon->mw - WIDTH(c)) / 2;
+ c->y = c->mon->my + (c->mon->mh - HEIGHT(c)) / 2;
+ }
+ #endif // CENTER_PATCH
#if SAVEFLOATS_PATCH
c->sfx = -9999;
c->sfy = -9999;
@@ -2591,8 +2624,12 @@ updatewindowtype(Client *c)
if (state == netatom[NetWMFullscreen])
setfullscreen(c, 1);
- if (wtype == netatom[NetWMWindowTypeDialog])
+ if (wtype == netatom[NetWMWindowTypeDialog]) {
+ #if CENTER_PATCH
+ c->iscentered = 1;
+ #endif // CENTER_PATCH
c->isfloating = 1;
+ }
}
void
diff --git a/patches.h b/patches.h
index 00e3d26..5be6d9b 100644
--- a/patches.h
+++ b/patches.h
@@ -44,6 +44,11 @@
*/
#define AUTOSTART_PATCH 0
+/* This patch adds an iscentered rule to automatically center clients on the current monitor.
+ * https://dwm.suckless.org/patches/center/
+ */
+#define CENTER_PATCH 0
+
/* The cyclelayouts patch lets you cycle through all your layouts.
* https://dwm.suckless.org/patches/cyclelayouts/
*/
@@ -109,6 +114,19 @@
*/
#define SYSTRAY_PATCH 0
+/* By default dwm allow you to set application specific rules so that you can have your browser,
+ * for example, start up on tag 9 optionally on a given monitor when you open your browser it is
+ * then automatically moved to the configured tag, but you have to manually enable the tag to see
+ * the newly opened application.
+ * This patch adds an extra configuration option for individual rules where:
+ * 0 is default behaviour
+ * 1 automatically moves you to the tag of the newly opened application and
+ * 2 enables the tag of the newly opened application in addition to your existing enabled tags
+
+ * https://github.com/bakkeby/dwm-vanitygaps/blob/master/patches/dwm-switchtag-6.2.diff
+ */
+#define SWITCHTAG_PATCH 0
+
/* This patch allows you to move all visible windows on a monitor to an adjacent monitor.
* https://github.com/bakkeby/dwm-vanitygaps/blob/master/patches/dwm-tagallmon-6.2.diff
*/