mirror of
https://github.com/mintycube/dwm.git
synced 2024-10-22 14:05:45 +02:00
Adding monitor rules patch
This commit is contained in:
parent
5d33aebaaf
commit
e89f262323
@ -13,6 +13,8 @@ Refer to [https://dwm.suckless.org/](https://dwm.suckless.org/) for details on t
|
||||
|
||||
### 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-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
|
||||
- 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/)
|
||||
- adds nmaster, mfact, layouts and more per tag rather than per monitor
|
||||
|
||||
|
26
config.def.h
26
config.def.h
@ -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
|
||||
};
|
||||
|
||||
/* 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 FLEXTILE_LAYOUT
|
||||
#if MONITOR_RULES_PATCH
|
||||
static const MonitorRule monrules[] = {
|
||||
#if FLEXTILE_LAYOUT
|
||||
/* monitor layout axis master stack */
|
||||
{ 1, 0, SPLIT_HORIZONTAL, LEFT_TO_RIGHT, GRID, }, // use a different layout for the second monitor
|
||||
{ -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[] = {
|
||||
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, /* 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
|
||||
#define FORCE_VSPLIT 1
|
||||
|
47
dwm.c
47
dwm.c
@ -204,6 +204,18 @@ typedef struct {
|
||||
int monitor;
|
||||
} 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 */
|
||||
static void applyrules(Client *c);
|
||||
static int applysizehints(Client *c, int *x, int *y, int *w, int *h, int interact);
|
||||
@ -838,9 +850,14 @@ Monitor *
|
||||
createmon(void)
|
||||
{
|
||||
Monitor *m;
|
||||
#if PERTAG_PATCH
|
||||
#if PERTAG_PATCH || MONITOR_RULES_PATCH
|
||||
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->tagset[0] = m->tagset[1] = 1;
|
||||
@ -854,20 +871,38 @@ createmon(void)
|
||||
m->gappoh = gappoh;
|
||||
m->gappov = gappov;
|
||||
#endif // VANITYGAPS_PATCH
|
||||
m->lt[0] = &layouts[0];
|
||||
m->lt[1] = &layouts[1 % LENGTH(layouts)];
|
||||
strncpy(m->ltsymbol, layouts[0].symbol, sizeof m->ltsymbol);
|
||||
#if MONITOR_RULES_PATCH
|
||||
for (mc = 0, mi = mons; mi; mi = mi->next, mc++);
|
||||
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
|
||||
m->ltaxis[0] = layoutaxis[0];
|
||||
m->ltaxis[1] = layoutaxis[1];
|
||||
m->ltaxis[2] = layoutaxis[2];
|
||||
#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 (!(m->pertag = (Pertag *)calloc(1, sizeof(Pertag))))
|
||||
die("fatal: could not malloc() %u bytes\n", sizeof(Pertag));
|
||||
m->pertag->curtag = m->pertag->prevtag = 1;
|
||||
for (i=0; i <= LENGTH(tags); i++) {
|
||||
for (i = 0; i <= LENGTH(tags); i++) {
|
||||
/* init nmaster */
|
||||
m->pertag->nmasters[i] = m->nmaster;
|
||||
|
||||
|
12
patches.h
12
patches.h
@ -105,8 +105,16 @@
|
||||
*/
|
||||
#define LOSEFULLSCREEN_PATCH 0
|
||||
|
||||
/* The pertag patch adds nmaster, mfacts and layouts per tag rather
|
||||
* than per monitor (default).
|
||||
/* 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. 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/
|
||||
*/
|
||||
#define PERTAG_PATCH 0
|
||||
|
Loading…
Reference in New Issue
Block a user