Adding center patch

pull/32/head
bakkeby 5 years ago
parent 8a71375fed
commit 747512af21

@ -11,7 +11,7 @@ Refer to [https://dwm.suckless.org/](https://dwm.suckless.org/) for details on t
### Changelog: ### 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 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/) - [autostart](https://dwm.suckless.org/patches/autostart/)
- makes dwm run `~/.dwm/autostart_blocking.sh` and `~/.dwm/autostart.sh &` on startup - 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/) - [cyclelayouts](https://dwm.suckless.org/patches/cyclelayouts/)
- lets you cycle through all your layouts - 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/) - [systray](https://dwm.suckless.org/patches/systray/)
- adds system tray in the status bar - 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) - [tagallmon](https://github.com/bakkeby/dwm-vanitygaps/blob/master/patches/dwm-tagallmon-6.2.diff)
- move all visible windows to an adjacent monitor - move all visible windows to an adjacent monitor

@ -46,15 +46,39 @@ static const Rule rules[] = {
* WM_NAME(STRING) = title * WM_NAME(STRING) = title
* WM_WINDOW_ROLE(STRING) = role * WM_WINDOW_ROLE(STRING) = role
*/ */
#if WINDOWROLERULE_PATCH #if WINDOWROLERULE_PATCH && SWITCHTAG_PATCH && CENTER_PATCH
/* class role instance title tags mask isfloating monitor */ /* class role instance title tags mask switchtag iscentered isfloating monitor */
{ "Gimp", NULL, NULL, NULL, 0, 1, -1 }, { "Gimp", NULL, NULL, NULL, 0, 1, 0, 1, -1 },
{ "Firefox", NULL, NULL, NULL, 1 << 8, 0, -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 #else
/* class instance title tags mask isfloating monitor */ /* class instance title tags mask isfloating monitor */
{ "Gimp", NULL, NULL, 0, 1, -1 }, { "Gimp", NULL, NULL, 0, 1, -1 },
{ "Firefox", NULL, NULL, 1 << 8, 0, -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) */ /* layout(s) */

39
dwm.c

@ -112,6 +112,9 @@ struct Client {
int bw, oldbw; int bw, oldbw;
unsigned int tags; unsigned int tags;
int isfixed, isfloating, isurgent, neverfocus, oldstate, isfullscreen; int isfixed, isfloating, isurgent, neverfocus, oldstate, isfullscreen;
#if CENTER_PATCH
int iscentered;
#endif // CENTER_PATCH
Client *next; Client *next;
Client *snext; Client *snext;
Monitor *mon; Monitor *mon;
@ -165,6 +168,12 @@ typedef struct {
const char *instance; const char *instance;
const char *title; const char *title;
unsigned int tags; unsigned int tags;
#if SWITCHTAG_PATCH
int switchtag;
#endif // SWITCHTAG_PATCH
#if CENTER_PATCH
int iscentered;
#endif // CENTER_PATCH
int isfloating; int isfloating;
int monitor; int monitor;
} Rule; } Rule;
@ -351,11 +360,29 @@ applyrules(Client *c)
#endif // WINDOWROLERULE_PATCH #endif // WINDOWROLERULE_PATCH
&& (!r->instance || strstr(instance, r->instance))) && (!r->instance || strstr(instance, r->instance)))
{ {
#if CENTER_PATCH
c->iscentered = r->iscentered;
#endif // CENTER_PATCH
c->isfloating = r->isfloating; c->isfloating = r->isfloating;
c->tags |= r->tags; c->tags |= r->tags;
for (m = mons; m && m->num != r->monitor; m = m->next); for (m = mons; m && m->num != r->monitor; m = m->next);
if (m) if (m)
c->mon = 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) if (ch.res_class)
@ -1340,6 +1367,12 @@ manage(Window w, XWindowAttributes *wa)
updatewindowtype(c); updatewindowtype(c);
updatesizehints(c); updatesizehints(c);
updatewmhints(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 #if SAVEFLOATS_PATCH
c->sfx = -9999; c->sfx = -9999;
c->sfy = -9999; c->sfy = -9999;
@ -2591,8 +2624,12 @@ updatewindowtype(Client *c)
if (state == netatom[NetWMFullscreen]) if (state == netatom[NetWMFullscreen])
setfullscreen(c, 1); setfullscreen(c, 1);
if (wtype == netatom[NetWMWindowTypeDialog]) if (wtype == netatom[NetWMWindowTypeDialog]) {
#if CENTER_PATCH
c->iscentered = 1;
#endif // CENTER_PATCH
c->isfloating = 1; c->isfloating = 1;
}
} }
void void

@ -44,6 +44,11 @@
*/ */
#define AUTOSTART_PATCH 0 #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. /* The cyclelayouts patch lets you cycle through all your layouts.
* https://dwm.suckless.org/patches/cyclelayouts/ * https://dwm.suckless.org/patches/cyclelayouts/
*/ */
@ -109,6 +114,19 @@
*/ */
#define SYSTRAY_PATCH 0 #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. /* 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 * https://github.com/bakkeby/dwm-vanitygaps/blob/master/patches/dwm-tagallmon-6.2.diff
*/ */

Loading…
Cancel
Save