invert layout now inverts layout symbol

This commit is contained in:
Arthur 2023-10-06 09:27:14 +03:00
parent 1768a404cf
commit 03e68b9f11
2 changed files with 44 additions and 20 deletions

View file

@ -8,7 +8,7 @@ static const unsigned int gappov = 10;
static int smartgaps = 1; static int smartgaps = 1;
static const int showbar = 1; static const int showbar = 1;
static const int topbar = 1; static const int topbar = 1;
static const char *fonts[] = { "Mononoki Nerd Font:size=12", "Noto Color Emoji" }; static const char *fonts[] = { "Mononoki Nerd Font:size=12", "Noto Color Emoji:size=11" };
static const char dmenufont[] = "Mononoki Nerd Font:size=12"; static const char dmenufont[] = "Mononoki Nerd Font:size=12";
static const char col_gray1[] = "#222222"; static const char col_gray1[] = "#222222";
static const char col_gray2[] = "#444444"; static const char col_gray2[] = "#444444";
@ -47,17 +47,17 @@ static const float mfact = 0.60;
static const int nmaster = 1; static const int nmaster = 1;
static const int resizehints = 1; static const int resizehints = 1;
static const int lockfullscreen = 1; static const int lockfullscreen = 1;
int inversedirection = 1; int spawnmaster = 0;
#define FORCE_VSPLIT 1 #define FORCE_VSPLIT 1
#include "vanitygaps.c" #include "vanitygaps.c"
static const Layout layouts[] = { static const Layout layouts[] = {
/* symbol arrange function */ /* symbol reverse function */
{ "[\\]", dwindle}, { "[/]", "[\\]", dwindle},
{ "[]=", tile }, { "[]=", "=[]", tile },
{ "[M]", monocle }, { "[M]", "[M]", monocle },
{ "><>", NULL }, { "><>", "<><", NULL },
}; };
/* key definitions */ /* key definitions */

50
dwm.c
View file

@ -110,6 +110,7 @@ typedef struct {
typedef struct { typedef struct {
const char *symbol; const char *symbol;
const char *symbolrev;
void (*arrange)(Monitor *); void (*arrange)(Monitor *);
} Layout; } Layout;
@ -413,7 +414,11 @@ arrange(Monitor *m)
void void
arrangemon(Monitor *m) arrangemon(Monitor *m)
{ {
strncpy(m->ltsymbol, m->lt[m->sellt]->symbol, sizeof m->ltsymbol); if (spawnmaster) {
strncpy(selmon->ltsymbol, selmon->lt[selmon->sellt]->symbol, sizeof selmon->ltsymbol);
} else {
strncpy(selmon->ltsymbol, selmon->lt[selmon->sellt]->symbolrev, sizeof selmon->ltsymbol);
}
if (m->lt[m->sellt]->arrange) if (m->lt[m->sellt]->arrange)
m->lt[m->sellt]->arrange(m); m->lt[m->sellt]->arrange(m);
} }
@ -673,7 +678,11 @@ createmon(void)
m->gappov = gappov; m->gappov = gappov;
m->lt[0] = &layouts[0]; m->lt[0] = &layouts[0];
m->lt[1] = &layouts[1 % LENGTH(layouts)]; m->lt[1] = &layouts[1 % LENGTH(layouts)];
strncpy(m->ltsymbol, layouts[0].symbol, sizeof m->ltsymbol); if (spawnmaster) {
strncpy(m->ltsymbol, layouts[0].symbol, sizeof m->ltsymbol);
} else {
strncpy(m->ltsymbol, layouts[0].symbolrev, sizeof m->ltsymbol);
}
return m; return m;
} }
@ -1021,7 +1030,18 @@ incnmaster(const Arg *arg)
static void static void
invertdir(const Arg *arg) invertdir(const Arg *arg)
{ {
inversedirection = !inversedirection; spawnmaster = !spawnmaster;
if (spawnmaster) {
strncpy(selmon->ltsymbol, selmon->lt[selmon->sellt]->symbol, sizeof selmon->ltsymbol);
} else {
strncpy(selmon->ltsymbol, selmon->lt[selmon->sellt]->symbolrev, sizeof selmon->ltsymbol);
}
if (selmon->sel)
arrange(selmon);
else
drawbar(selmon);
} }
#ifdef XINERAMA #ifdef XINERAMA
@ -1115,10 +1135,10 @@ manage(Window w, XWindowAttributes *wa)
c->isfloating = c->oldstate = trans != None || c->isfixed; c->isfloating = c->oldstate = trans != None || c->isfixed;
if (c->isfloating) if (c->isfloating)
XRaiseWindow(dpy, c->win); XRaiseWindow(dpy, c->win);
if (inversedirection) { if (spawnmaster) {
attachbottom(c);
} else {
attach(c); attach(c);
} else {
attachbottom(c);
} }
attachstack(c); attachstack(c);
XChangeProperty(dpy, root, netatom[NetClientList], XA_WINDOW, 32, PropModeAppend, XChangeProperty(dpy, root, netatom[NetClientList], XA_WINDOW, 32, PropModeAppend,
@ -1477,10 +1497,10 @@ sendmon(Client *c, Monitor *m)
detachstack(c); detachstack(c);
c->mon = m; c->mon = m;
c->tags = m->tagset[m->seltags]; /* assign tags of target monitor */ c->tags = m->tagset[m->seltags]; /* assign tags of target monitor */
if (inversedirection) { if (spawnmaster) {
attachbottom(c);
} else {
attach(c); attach(c);
} else {
attachbottom(c);
} }
attachstack(c); attachstack(c);
focus(NULL); focus(NULL);
@ -1568,7 +1588,11 @@ setlayout(const Arg *arg)
selmon->sellt ^= 1; selmon->sellt ^= 1;
if (arg && arg->v) if (arg && arg->v)
selmon->lt[selmon->sellt] = (Layout *)arg->v; selmon->lt[selmon->sellt] = (Layout *)arg->v;
strncpy(selmon->ltsymbol, selmon->lt[selmon->sellt]->symbol, sizeof selmon->ltsymbol); if (spawnmaster) {
strncpy(selmon->ltsymbol, selmon->lt[selmon->sellt]->symbol, sizeof selmon->ltsymbol);
} else {
strncpy(selmon->ltsymbol, selmon->lt[selmon->sellt]->symbolrev, sizeof selmon->ltsymbol);
}
if (selmon->sel) if (selmon->sel)
arrange(selmon); arrange(selmon);
else else
@ -1985,10 +2009,10 @@ updategeom(void)
m->clients = c->next; m->clients = c->next;
detachstack(c); detachstack(c);
c->mon = mons; c->mon = mons;
if (inversedirection) { if (spawnmaster) {
attachbottom(c);
} else {
attach(c); attach(c);
} else {
attachbottom(c);
} }
attach(c); attach(c);
attachstack(c); attachstack(c);