diff options
| author | Mitchell Riedstra <mitch@riedstra.dev> | 2022-12-27 23:12:30 -0500 |
|---|---|---|
| committer | Mitchell Riedstra <mitch@riedstra.dev> | 2022-12-27 23:12:30 -0500 |
| commit | f2d52d23f74c065f288d9d4b399404fe50f38fc3 (patch) | |
| tree | bf8b1d23872b745544db0cea28a63169367d50d6 | |
| parent | 7cde3ec842070c0cabd0e796789856ed745483fa (diff) | |
| download | dwm-f2d52d23f74c065f288d9d4b399404fe50f38fc3.tar.gz dwm-f2d52d23f74c065f288d9d4b399404fe50f38fc3.tar.xz | |
Move the layouts. Add a function for a new custom layout and change a few config options
| -rw-r--r-- | config.h | 10 | ||||
| -rw-r--r-- | dwm.c | 103 | ||||
| -rw-r--r-- | layouts.c | 132 |
3 files changed, 139 insertions, 106 deletions
@@ -47,6 +47,8 @@ static const Rule rules[] = { { "Google-chrome", NULL, NULL, 1<<8, 0, -1 }, { "Chromium", NULL, NULL, 1<<8, 0, -1 }, { "Firefox", NULL, NULL, 1<<8, 0, -1 }, + { "firefox", NULL, NULL, 1<<8, 0, -1 }, + { "code-oss", NULL, NULL, 1<<1, 0, -1 }, }; /* layout(s) */ @@ -66,6 +68,7 @@ static const Layout layouts[] = { { "HHH", grid }, { "[@]", spiral }, { "[\\]", dwindle }, + { "C", layoutCenter }, }; /* key definitions */ @@ -88,15 +91,15 @@ static char dmenumon[2] = "0"; /* component of dmenucmd, manipulated in spawn() static const char *dmenucmd[] = { "dmenu_run", DMENU_FLAGS, NULL }; static const char *ddmenucmd[] = { "ddmenu", DMENU_FLAGS, NULL }; // static const char *termcmd[] = { "st", NULL }; -static const char *termcmd[] = { "konsole", NULL }; +static const char *termcmd[] = { "xfce4-terminal", NULL }; static const char *termcmdLarge[] = { "st", "-f", PROFONT_LARGE, NULL }; static const char *termcmdYuge[] = { "st", "-f", TERMINUS_YUGE, NULL }; static const char *passcmd[] = { "dpw-menu", DMENU_FLAGS, NULL }; static const char *passcmd_type[] = { "dpw-menu", "--type", DMENU_FLAGS, NULL }; static const char *passcmd_otp_type[] = { "dpw-menu", "--type", "--otp", DMENU_FLAGS, NULL }; static const char *snip_cmd[] = { "snipmenu", DMENU_FLAGS, NULL }; -static const char *screenshot_cmd[] = { "scrot", "-s", "/tmp/screenshot.png", NULL }; -static const char *file_cmd[] = { "dolphin", NULL }; +static const char *screenshot_cmd[] = { "xfce4-screenshooter", NULL }; +static const char *file_cmd[] = { "thunar", NULL }; // static const char *file_cmd[] = { "thunar", NULL }; static const char *slock_cmd[] = { "slock", NULL }; static const char *volup_cmd[] = { "vol", "up", NULL }; @@ -139,6 +142,7 @@ static Key keys[] = { { MODKEY, XK_g, setlayout, {.v = &layouts[5]} }, { MODKEY, XK_v, setlayout, {.v = &layouts[6]} }, { MODKEY|ShiftMask, XK_v, setlayout, {.v = &layouts[7]} }, + { MODKEY|Mod1Mask, XK_v, setlayout, {.v = &layouts[8]} }, { MODKEY, XK_space, setlayout, {0} }, { MODKEY|ShiftMask, XK_space, togglefloating, {0} }, { MODKEY, XK_0, view, {.ui = ~0 } }, @@ -2161,109 +2161,6 @@ main(int argc, char *argv[]) } void -centeredmaster(Monitor *m) -{ - unsigned int i, n, h, mw, mx, my, oty, ety, tw; - Client *c; - - /* count number of clients in the selected monitor */ - for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++); - if (n == 0) - return; - - /* initialize areas */ - mw = m->ww; - mx = 0; - my = 0; - tw = mw; - - if (n > m->nmaster) { - /* go mfact box in the center if more than nmaster clients */ - mw = m->nmaster ? m->ww * m->mfact : 0; - tw = m->ww - mw; - - if (n - m->nmaster > 1) { - /* only one client */ - mx = (m->ww - mw) / 2; - tw = (m->ww - mw) / 2; - } - } - - oty = 0; - ety = 0; - for (i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) - if (i < m->nmaster) { - /* nmaster clients are stacked vertically, in the center - * of the screen */ - h = (m->wh - my) / (MIN(n, m->nmaster) - i); - resize(c, m->wx + mx, m->wy + my, mw - (2*c->bw), - h - (2*c->bw), 0); - my += HEIGHT(c); - } else { - /* stack clients are stacked vertically */ - if ((i - m->nmaster) % 2 ) { - h = (m->wh - ety) / ( (1 + n - i) / 2); - resize(c, m->wx, m->wy + ety, tw - (2*c->bw), - h - (2*c->bw), 0); - ety += HEIGHT(c); - } else { - h = (m->wh - oty) / ((1 + n - i) / 2); - resize(c, m->wx + mx + mw, m->wy + oty, - tw - (2*c->bw), h - (2*c->bw), 0); - oty += HEIGHT(c); - } - } -} - -void -centeredfloatingmaster(Monitor *m) -{ - unsigned int i, n, w, mh, mw, mx, mxo, my, myo, tx; - Client *c; - - /* count number of clients in the selected monitor */ - for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++); - if (n == 0) - return; - - /* initialize nmaster area */ - if (n > m->nmaster) { - /* go mfact box in the center if more than nmaster clients */ - if (m->ww > m->wh) { - mw = m->nmaster ? m->ww * m->mfact : 0; - mh = m->nmaster ? m->wh * 0.9 : 0; - } else { - mh = m->nmaster ? m->wh * m->mfact : 0; - mw = m->nmaster ? m->ww * 0.9 : 0; - } - mx = mxo = (m->ww - mw) / 2; - my = myo = (m->wh - mh) / 2; - } else { - /* go fullscreen if all clients are in the master area */ - mh = m->wh; - mw = m->ww; - mx = mxo = 0; - my = myo = 0; - } - - for(i = tx = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) - if (i < m->nmaster) { - /* nmaster clients are stacked horizontally, in the center - * of the screen */ - w = (mw + mxo - mx) / (MIN(n, m->nmaster) - i); - resize(c, m->wx + mx, m->wy + my, w - (2*c->bw), - mh - (2*c->bw), 0); - mx += WIDTH(c); - } else { - /* stack clients are stacked horizontally */ - w = (m->ww - tx) / (n - i); - resize(c, m->wx + tx, m->wy, w - (2*c->bw), - m->wh - (2*c->bw), 0); - tx += WIDTH(c); - } -} - -void togglefullscr(const Arg *arg) { if(selmon->sel) @@ -92,3 +92,135 @@ void spiral(Monitor *mon) { fibonacci(mon, 0); } + +void +centeredmaster(Monitor *m) +{ + unsigned int i, n, h, mw, mx, my, oty, ety, tw; + Client *c; + + /* count number of clients in the selected monitor */ + for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++); + if (n == 0) + return; + + /* initialize areas */ + mw = m->ww; + mx = 0; + my = 0; + tw = mw; + + if (n > m->nmaster) { + /* go mfact box in the center if more than nmaster clients */ + mw = m->nmaster ? m->ww * m->mfact : 0; + tw = m->ww - mw; + + if (n - m->nmaster > 1) { + /* only one client */ + mx = (m->ww - mw) / 2; + tw = (m->ww - mw) / 2; + } + } + + oty = 0; + ety = 0; + for (i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) + if (i < m->nmaster) { + /* nmaster clients are stacked vertically, in the center + * of the screen */ + h = (m->wh - my) / (MIN(n, m->nmaster) - i); + resize(c, m->wx + mx, m->wy + my, mw - (2*c->bw), + h - (2*c->bw), 0); + my += HEIGHT(c); + } else { + /* stack clients are stacked vertically */ + if ((i - m->nmaster) % 2 ) { + h = (m->wh - ety) / ( (1 + n - i) / 2); + resize(c, m->wx, m->wy + ety, tw - (2*c->bw), + h - (2*c->bw), 0); + ety += HEIGHT(c); + } else { + h = (m->wh - oty) / ((1 + n - i) / 2); + resize(c, m->wx + mx + mw, m->wy + oty, + tw - (2*c->bw), h - (2*c->bw), 0); + oty += HEIGHT(c); + } + } +} + +void +centeredfloatingmaster(Monitor *m) +{ + unsigned int i, n, w, mh, mw, mx, mxo, my, myo, tx; + Client *c; + + /* count number of clients in the selected monitor */ + for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++); + if (n == 0) + return; + + /* initialize nmaster area */ + if (n > m->nmaster) { + /* go mfact box in the center if more than nmaster clients */ + if (m->ww > m->wh) { + mw = m->nmaster ? m->ww * m->mfact : 0; + mh = m->nmaster ? m->wh * 0.9 : 0; + } else { + mh = m->nmaster ? m->wh * m->mfact : 0; + mw = m->nmaster ? m->ww * 0.9 : 0; + } + mx = mxo = (m->ww - mw) / 2; + my = myo = (m->wh - mh) / 2; + } else { + /* go fullscreen if all clients are in the master area */ + mh = m->wh; + mw = m->ww; + mx = mxo = 0; + my = myo = 0; + } + + for(i = tx = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) + if (i < m->nmaster) { + /* nmaster clients are stacked horizontally, in the center + * of the screen */ + w = (mw + mxo - mx) / (MIN(n, m->nmaster) - i); + resize(c, m->wx + mx, m->wy + my, w - (2*c->bw), + mh - (2*c->bw), 0); + mx += WIDTH(c); + } else { + /* stack clients are stacked horizontally */ + w = (m->ww - tx) / (n - i); + resize(c, m->wx + tx, m->wy, w - (2*c->bw), + m->wh - (2*c->bw), 0); + tx += WIDTH(c); + } +} + +/* Simply a copy of the default layout for the moment.... */ +void +layoutCenter(Monitor *m) +{ + unsigned int i, n, h, mw, my, ty; + Client *c; + + for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++); + if (n == 0) + return; + + if (n > m->nmaster) + mw = m->nmaster ? m->ww * m->mfact : 0; + else + mw = m->ww; + for (i = my = ty = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) + if (i < m->nmaster) { + h = (m->wh - my) / (MIN(n, m->nmaster) - i); + resize(c, m->wx, m->wy + my, mw - (2*c->bw), h - (2*c->bw), 0); + if (my + HEIGHT(c) < m->wh) + my += HEIGHT(c); + } else { + h = (m->wh - ty) / (n - i); + resize(c, m->wx + mw, m->wy + ty, m->ww - mw - (2*c->bw), h - (2*c->bw), 0); + if (ty + HEIGHT(c) < m->wh) + ty += HEIGHT(c); + } +} |
