Adding monitor rules patch

This commit is contained in:
bakkeby 2019-09-11 08:28:00 +02:00
parent 5d33aebaaf
commit e89f262323
4 changed files with 76 additions and 15 deletions

View File

@ -13,6 +13,8 @@ Refer to [https://dwm.suckless.org/](https://dwm.suckless.org/) for details on t
### Changelog: ### Changelog:
2019-09-11 - Added monitor rules patch.
2019-09-10 - Minor tweaks to awesomebar patch (incl. alpha and systray compatibility). Added floatbordercolor patch. 2019-09-10 - Minor tweaks to awesomebar patch (incl. alpha and systray compatibility). Added floatbordercolor patch.
2019-09-09 - Added deck, fibonacci (dwindle and spiral), gridmode, gapplessgrid, horizgrid, nrowgrid, centeredmaster and flextile layouts. Added alternativetags and awesomebar patches. 2019-09-09 - Added deck, fibonacci (dwindle and spiral), gridmode, gapplessgrid, horizgrid, nrowgrid, centeredmaster and flextile layouts. Added alternativetags and awesomebar patches.
@ -75,6 +77,10 @@ Refer to [https://dwm.suckless.org/](https://dwm.suckless.org/) for details on t
- it is also possible to spawn new windows (e.g. a terminal) that end up getting focus while the previous window remains in fullscreen - it is also possible to spawn new windows (e.g. a terminal) that end up getting focus while the previous window remains in fullscreen
- this patch ensures that in such scenarios the previous window loses fullscreen - this patch ensures that in such scenarios the previous window loses fullscreen
- monitorrules
- adds rules per monitor, e.g. have default layouts per monitor
- the use case for this is if the second monitor is vertical (i.e. rotated) then you may want to use a different default layout for this monitor than what is used for the main monitor (for example normal vertical split for main monitor and horizontal split for the second)
- [pertag](https://dwm.suckless.org/patches/pertag/) - [pertag](https://dwm.suckless.org/patches/pertag/)
- adds nmaster, mfact, layouts and more per tag rather than per monitor - adds nmaster, mfact, layouts and more per tag rather than per monitor

View File

@ -108,18 +108,30 @@ static const Rule rules[] = {
#endif // granted the above will be confusing, do remember to delete rule entries for patches that you do not take #endif // granted the above will be confusing, do remember to delete rule entries for patches that you do not take
}; };
/* layout(s) */ #if MONITOR_RULES_PATCH
static const float mfact = 0.55; /* factor of master area size [0.05..0.95] */ static const MonitorRule monrules[] = {
static const int nmaster = 1; /* number of clients in master area */ #if FLEXTILE_LAYOUT
static const int resizehints = 1; /* 1 means respect size hints in tiled resizals */ /* monitor layout axis master stack */
{ 1, 0, SPLIT_HORIZONTAL, LEFT_TO_RIGHT, GRID, }, // use a different layout for the second monitor
#if FLEXTILE_LAYOUT { -1, 0, SPLIT_VERTICAL, TOP_TO_BOTTOM, TOP_TO_BOTTOM, }, // default
#else
/* monitor layout */
{ 1, 2 }, // use a different layout for the second monitor
{ -1, 0 }, // default
#endif // FLEXTILE_LAYOUT
};
#elif FLEXTILE_LAYOUT
static const int layoutaxis[] = { static const int layoutaxis[] = {
SPLIT_VERTICAL, /* layout axis: 1 = x, 2 = y; negative values mirror the layout, setting the master area to the right / bottom instead of left / top */ SPLIT_VERTICAL, /* layout axis: 1 = x, 2 = y; negative values mirror the layout, setting the master area to the right / bottom instead of left / top */
TOP_TO_BOTTOM, /* master axis: 1 = x (from left to right), 2 = y (from top to bottom), 3 = z (monocle), 4 = grid */ TOP_TO_BOTTOM, /* master axis: 1 = x (from left to right), 2 = y (from top to bottom), 3 = z (monocle), 4 = grid */
TOP_TO_BOTTOM, /* stack axis: 1 = x (from left to right), 2 = y (from top to bottom), 3 = z (monocle), 4 = grid */ TOP_TO_BOTTOM, /* stack axis: 1 = x (from left to right), 2 = y (from top to bottom), 3 = z (monocle), 4 = grid */
}; };
#endif #endif // MONITOR_RULES_PATCH
/* layout(s) */
static const float mfact = 0.55; /* factor of master area size [0.05..0.95] */
static const int nmaster = 1; /* number of clients in master area */
static const int resizehints = 1; /* 1 means respect size hints in tiled resizals */
#if NROWGRID_LAYOUT #if NROWGRID_LAYOUT
#define FORCE_VSPLIT 1 #define FORCE_VSPLIT 1

47
dwm.c
View File

@ -204,6 +204,18 @@ typedef struct {
int monitor; int monitor;
} Rule; } Rule;
#if MONITOR_RULES_PATCH
typedef struct {
int monitor;
int layout;
#if FLEXTILE_LAYOUT
int layoutaxis;
int masteraxis;
int stackaxis;
#endif
} MonitorRule;
#endif // MONITOR_RULES_PATCH
/* function declarations */ /* function declarations */
static void applyrules(Client *c); static void applyrules(Client *c);
static int applysizehints(Client *c, int *x, int *y, int *w, int *h, int interact); static int applysizehints(Client *c, int *x, int *y, int *w, int *h, int interact);
@ -838,9 +850,14 @@ Monitor *
createmon(void) createmon(void)
{ {
Monitor *m; Monitor *m;
#if PERTAG_PATCH #if PERTAG_PATCH || MONITOR_RULES_PATCH
int i; int i;
#endif // PERTAG_PATCH #endif // PERTAG_PATCH / MONITOR_RULES_PATCH
#if MONITOR_RULES_PATCH
int mc;
Monitor *mi;
const MonitorRule *mr;
#endif // MONITOR_RULES_PATCH
m = ecalloc(1, sizeof(Monitor)); m = ecalloc(1, sizeof(Monitor));
m->tagset[0] = m->tagset[1] = 1; m->tagset[0] = m->tagset[1] = 1;
@ -854,20 +871,38 @@ createmon(void)
m->gappoh = gappoh; m->gappoh = gappoh;
m->gappov = gappov; m->gappov = gappov;
#endif // VANITYGAPS_PATCH #endif // VANITYGAPS_PATCH
m->lt[0] = &layouts[0]; #if MONITOR_RULES_PATCH
m->lt[1] = &layouts[1 % LENGTH(layouts)]; for (mc = 0, mi = mons; mi; mi = mi->next, mc++);
strncpy(m->ltsymbol, layouts[0].symbol, sizeof m->ltsymbol); for (i = 0; i < LENGTH(monrules); i++) {
mr = &monrules[i];
if (mr->monitor == -1 || mr->monitor == mc) {
m->lt[0] = &layouts[mr->layout];
m->lt[1] = &layouts[1 % LENGTH(layouts)];
strncpy(m->ltsymbol, layouts[mr->layout].symbol, sizeof m->ltsymbol);
#if FLEXTILE_LAYOUT
m->ltaxis[0] = mr->layoutaxis;
m->ltaxis[1] = mr->masteraxis;
m->ltaxis[2] = mr->stackaxis;
#endif // FLEXTILE_LAYOUT
break;
}
}
#else
#if FLEXTILE_LAYOUT #if FLEXTILE_LAYOUT
m->ltaxis[0] = layoutaxis[0]; m->ltaxis[0] = layoutaxis[0];
m->ltaxis[1] = layoutaxis[1]; m->ltaxis[1] = layoutaxis[1];
m->ltaxis[2] = layoutaxis[2]; m->ltaxis[2] = layoutaxis[2];
#endif // FLEXTILE_LAYOUT #endif // FLEXTILE_LAYOUT
m->lt[0] = &layouts[0];
m->lt[1] = &layouts[1 % LENGTH(layouts)];
strncpy(m->ltsymbol, layouts[0].symbol, sizeof m->ltsymbol);
#endif // MONITOR_RULES_PATCH
#if PERTAG_PATCH #if PERTAG_PATCH
if (!(m->pertag = (Pertag *)calloc(1, sizeof(Pertag)))) if (!(m->pertag = (Pertag *)calloc(1, sizeof(Pertag))))
die("fatal: could not malloc() %u bytes\n", sizeof(Pertag)); die("fatal: could not malloc() %u bytes\n", sizeof(Pertag));
m->pertag->curtag = m->pertag->prevtag = 1; m->pertag->curtag = m->pertag->prevtag = 1;
for (i=0; i <= LENGTH(tags); i++) { for (i = 0; i <= LENGTH(tags); i++) {
/* init nmaster */ /* init nmaster */
m->pertag->nmasters[i] = m->nmaster; m->pertag->nmasters[i] = m->nmaster;

View File

@ -105,8 +105,16 @@
*/ */
#define LOSEFULLSCREEN_PATCH 0 #define LOSEFULLSCREEN_PATCH 0
/* The pertag patch adds nmaster, mfacts and layouts per tag rather /* Adds rules per monitor, e.g. have default layouts per monitor.
* than per monitor (default). * The use case for this is if the second monitor is vertical (i.e. rotated) then
* you may want to use a different default layout for this monitor than what is
* used for the main monitor. E.g. normal vertical split for main monitor and
* horizontal split for the second.
*/
#define MONITOR_RULES_PATCH 0
/* The pertag patch adds nmaster, mfacts and layouts per tag rather than per
* monitor (default).
* https://dwm.suckless.org/patches/pertag/ * https://dwm.suckless.org/patches/pertag/
*/ */
#define PERTAG_PATCH 0 #define PERTAG_PATCH 0