mirror of
https://github.com/mintycube/dwm.git
synced 2024-10-22 14:05:45 +02:00
Adding center patch
This commit is contained in:
parent
8a71375fed
commit
747512af21
@ -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
|
||||
|
||||
|
28
config.def.h
28
config.def.h
@ -46,15 +46,39 @@ static const Rule rules[] = {
|
||||
* WM_NAME(STRING) = title
|
||||
* WM_WINDOW_ROLE(STRING) = role
|
||||
*/
|
||||
#if WINDOWROLERULE_PATCH
|
||||
#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) */
|
||||
|
39
dwm.c
39
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,9 +2624,13 @@ 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
|
||||
updatewmhints(Client *c)
|
||||
|
18
patches.h
18
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
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user