Compare commits

..

20 commits

4 changed files with 198 additions and 246 deletions

2
.gitignore vendored
View file

@ -6,6 +6,6 @@ config.h
# Patches
*.diff
*.patch
*.rej
# Copies
*.orig
*.rej

View file

@ -1,8 +1,16 @@
/* See LICENSE file for copyright and license details. */
#define TERMINAL "st"
#define BROWSER "firefox"
/* appearance */
static unsigned int borderpx = 1; /* border pixel of windows */
static unsigned int snap = 32; /* snap pixel */
static unsigned int gappih = 16; /* horiz inner gap between windows */
static unsigned int gappiv = 16; /* vert inner gap between windows */
static unsigned int gappoh = 8; /* horiz outer gap between windows and screen edge */
static unsigned int gappov = 8; /* vert outer gap between windows and screen edge */
static int smartgaps = 0; /* 1 means no outer gap when there is only one window */
static int showbar = 1; /* 0 means no bar */
static int topbar = 1; /* 0 means bottom bar */
static char font[] = "monospace:size=10";
@ -28,7 +36,10 @@ static const Rule rules[] = {
* WM_NAME(STRING) = title
*/
/* class instance title tags mask isfloating monitor */
{ NULL, NULL, NULL, 0, 0, -1 },
{ "firefox", NULL, NULL, 1 << 1, 0, -1 },
{ "firefox", NULL, "Picture-in-Picture", 0, 1, -1 },
{ "Signal", NULL, NULL, 1 << 3, 0, -1 },
{ "vesktop", NULL, NULL, 1 << 3, 0, -1 },
};
/* layout(s) */
@ -42,7 +53,6 @@ static const Layout layouts[] = {
{ "[]=", tile }, /* first entry is default */
{ "><>", NULL }, /* no layout function means floating behavior */
{ "[M]", monocle },
{ "TTT", bstack },
};
/* key definitions */
@ -56,9 +66,12 @@ static const Layout layouts[] = {
/* helper for spawning shell commands in the pre dwm-5.0 fashion */
#define SHCMD(cmd) { .v = (const char*[]){ "/bin/sh", "-c", cmd, NULL } }
#define TERMCMD(cmd) { .v = (const char*[]){ TERMINAL, "-e", cmd, NULL } }
/* commands */
static char dmenumon[2] = "0"; /* component of dmenucmd, manipulated in spawn() */
static const char *dmenucmd[] = { "dmenu_run", "-g", "8", "-l", "4", "-m", dmenumon, "-fn", font, "-nb", normbgcolor, "-nf", normfgcolor, "-sb", selbgcolor, "-sf", selfgcolor, NULL };
static const char *dmenucmd[] = { "ezrun", NULL };
static const char *termcmd[] = { "st", NULL };
/*
* Xresources preferences to load at startup
@ -78,48 +91,58 @@ ResourcePref resources[] = {
{ "nmaster", INTEGER, &nmaster },
{ "resizehints", INTEGER, &resizehints },
{ "mfact", FLOAT, &mfact },
{ "gappih", INTEGER, &gappih },
{ "gappiv", INTEGER, &gappiv },
{ "gappoh", INTEGER, &gappoh },
{ "gappov", INTEGER, &gappov },
{ "smartgaps", INTEGER, &smartgaps },
};
#include <X11/XF86keysym.h>
#include "shiftview.c"
static const Key keys[] = {
/* modifier key function argument */
/* stack control */
{ MODKEY, XK_p, spawn, {.v = dmenucmd } },
{ MODKEY, XK_Return, spawn, {.v = termcmd } },
{ MODKEY, XK_w, spawn, SHCMD(BROWSER) },
{ MODKEY, XK_v, spawn, TERMCMD("pulsemixer") },
{ MODKEY, XK_e, spawn, SHCMD("thunar") },
{ ControlMask|Mod1Mask, XK_u, spawn, TERMCMD("htop") },
{ ControlMask|Mod1Mask, XK_p, spawn, SHCMD("screenshot select") },
{ ControlMask|Mod1Mask, XK_o, spawn, SHCMD("screenshot full") },
{ MODKEY, XK_b, togglebar, {0} },
{ MODKEY, XK_j, focusstack, {.i = +1 } },
{ MODKEY, XK_k, focusstack, {.i = -1 } },
{ MODKEY|ShiftMask, XK_j, pushdown, {0} },
{ MODKEY|ShiftMask, XK_k, pushup, {0} },
{ MODKEY|ShiftMask, XK_Return, zoom, {0} },
/* master control */
{ MODKEY, XK_i, incnmaster, {.i = +1 } },
{ MODKEY, XK_d, incnmaster, {.i = -1 } },
{ MODKEY, XK_h, setmfact, {.f = -0.05} },
{ MODKEY, XK_l, setmfact, {.f = +0.05} },
/* layouts */
{ MODKEY, XK_t, setlayout, {.v = &layouts[0]} },
{ MODKEY, XK_f, setlayout, {.v = &layouts[1]} },
{ MODKEY, XK_m, setlayout, {.v = &layouts[2]} },
{ MODKEY, XK_u, setlayout, {.v = &layouts[3]} },
/* client actions */
{ MODKEY, XK_h, setmfact, {.f = -0.0125} },
{ MODKEY, XK_l, setmfact, {.f = +0.0125} },
{ MODKEY|ShiftMask, XK_h, setmfact, {.f = -0.05} },
{ MODKEY|ShiftMask, XK_l, setmfact, {.f = +0.05} },
{ MODKEY, XK_bracketright, incrgaps, {.i = +4 } },
{ MODKEY, XK_bracketleft, incrgaps, {.i = -4 } },
{ MODKEY, XK_equal, togglegaps, {0} },
{ MODKEY|ShiftMask, XK_equal, defaultgaps, {0} },
{ MODKEY|ShiftMask, XK_Return, zoom, {0} },
{ MODKEY, XK_Tab, view, {0} },
{ MODKEY|ShiftMask, XK_c, killclient, {0} },
{ MODKEY, XK_t, setlayout, {.v = &layouts[0]} }, /* tile */
{ MODKEY, XK_f, setlayout, {.v = &layouts[1]} }, /* floating */
{ MODKEY, XK_m, setlayout, {.v = &layouts[2]} }, /* monocle */
{ MODKEY, XK_space, setlayout, {0} },
{ MODKEY|ShiftMask, XK_space, togglefloating, {0} },
{ MODKEY|ShiftMask, XK_f, togglefullscr, {0} },
{ MODKEY|ShiftMask, XK_s, togglesticky, {0} },
/* monitors */
{ MODKEY, XK_0, view, {.ui = ~0 } },
{ MODKEY|ShiftMask, XK_0, tag, {.ui = ~0 } },
{ MODKEY, XK_y, shiftview, {.i = +1 } },
{ MODKEY|ShiftMask, XK_y, shiftview, {.i = -1 } },
{ MODKEY, XK_comma, focusmon, {.i = -1 } },
{ MODKEY, XK_period, focusmon, {.i = +1 } },
{ MODKEY|ShiftMask, XK_comma, tagmon, {.i = -1 } },
{ MODKEY|ShiftMask, XK_period, tagmon, {.i = +1 } },
/* tags */
{ MODKEY, XK_y, shiftview, {.i = +1 } },
{ MODKEY|ShiftMask, XK_y, shiftview, {.i = -1 } },
{ MODKEY, XK_0, view, {.ui = ~0 } },
{ MODKEY|ShiftMask, XK_0, tag, {.ui = ~0 } },
TAGKEYS( XK_1, 0)
TAGKEYS( XK_2, 1)
TAGKEYS( XK_3, 2)
@ -129,36 +152,22 @@ static const Key keys[] = {
TAGKEYS( XK_7, 6)
TAGKEYS( XK_8, 7)
TAGKEYS( XK_9, 8)
{ MODKEY, XK_Tab, view, {0} },
/* session */
{ Mod1Mask|ControlMask, XK_r, quit, {0} },
{ Mod1Mask|ControlMask, XK_Delete, spawn, SHCMD("pkill xinit") },
/* programs/ui */
{ MODKEY, XK_p, spawn, {.v = dmenucmd } },
{ MODKEY, XK_Return, spawn, SHCMD("st") },
{ MODKEY, XK_w, spawn, SHCMD("firefox") },
{ MODKEY, XK_v, spawn, SHCMD("st -e pulsemixer") },
{ MODKEY|ControlMask, XK_l, spawn, SHCMD("xidlehook-client --socket $XIDLEHOOK_SOCK control --action trigger --timer 0") },
{ MODKEY|ControlMask, XK_t, spawn, SHCMD("screenshot -cs full") },
{ MODKEY|ControlMask, XK_r, spawn, SHCMD("screenshot -cs select") },
{ MODKEY, XK_b, togglebar, {0} },
/* etc. */
{ 0, XF86XK_MonBrightnessDown, spawn, SHCMD("lightctrl acpi_video0 5%- Display") },
{ 0, XF86XK_MonBrightnessUp, spawn, SHCMD("lightctrl acpi_video0 5%+ Display") },
{ 0, XF86XK_KbdBrightnessDown, spawn, SHCMD("lightctrl smc::kbd_backlight 5%- Keyboard") },
{ 0, XF86XK_KbdBrightnessUp, spawn, SHCMD("lightctrl smc::kbd_backlight 5%+ Keyboard") },
{ 0, XF86XK_AudioMute, spawn, SHCMD("volumectrl toggle") },
{ 0, XF86XK_AudioLowerVolume, spawn, SHCMD("volumectrl 5%-") },
{ 0, XF86XK_AudioRaiseVolume, spawn, SHCMD("volumectrl 5%+") },
{ ControlMask|Mod1Mask, XK_r, quit, {0} },
{ ControlMask|Mod1Mask, XK_Delete, spawn, SHCMD("pkill xinit") },
{ MODKEY, XK_F9, spawn, SHCMD("sys-volume toggle") },
{ MODKEY, XK_F10, spawn, SHCMD("sys-volume 5%-") },
{ MODKEY, XK_F11, spawn, SHCMD("sys-volume 5%+") },
{ MODKEY, XK_F12, spawn, SHCMD("sys-lock") },
};
/* button definitions */
/* click can be ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle, ClkClientWin, or ClkRootWin */
static const Button buttons[] = {
/* click event mask button function argument */
{ ClkLtSymbol, 0, Button1, setlayout, {0} },
{ ClkLtSymbol, 0, Button3, setlayout, {.v = &layouts[2]} },
{ ClkWinTitle, 0, Button2, zoom, {0} },
{ ClkStatusText, 0, Button2, spawn, {.v = termcmd } },
{ ClkClientWin, MODKEY, Button1, movemouse, {0} },
{ ClkClientWin, MODKEY, Button2, togglefloating, {0} },
{ ClkClientWin, MODKEY, Button3, resizemouse, {0} },

314
dwm.c
View file

@ -121,6 +121,10 @@ struct Monitor {
int by; /* bar geometry */
int mx, my, mw, mh; /* screen size */
int wx, wy, ww, wh; /* window area */
int gappih; /* horizontal gap between windows */
int gappiv; /* vertical gap between windows */
int gappoh; /* horizontal outer gaps */
int gappov; /* vertical outer gaps */
unsigned int seltags;
unsigned int sellt;
unsigned int tagset[2];
@ -180,7 +184,6 @@ static void detachstack(Client *c);
static Monitor *dirtomon(int dir);
static void drawbar(Monitor *m);
static void drawbars(void);
static int drawstatusbar(Monitor *m, int bh, char* text);
static void enternotify(XEvent *e);
static void expose(XEvent *e);
static void focus(Client *c);
@ -221,12 +224,15 @@ static void sendmon(Client *c, Monitor *m);
static void setclientstate(Client *c, long state);
static void setfocus(Client *c);
static void setfullscreen(Client *c, int fullscreen);
static void setgaps(int oh, int ov, int ih, int iv);
static void incrgaps(const Arg *arg);
static void togglegaps(const Arg *arg);
static void defaultgaps(const Arg *arg);
static void setsticky(Client *c, int sticky);
static void setlayout(const Arg *arg);
static void setmfact(const Arg *arg);
static void setup(void);
static void seturgent(Client *c, int urg);
static void shiftview(const Arg *arg);
static void showhide(Client *c);
static void spawn(const Arg *arg);
static void tag(const Arg *arg);
@ -260,14 +266,14 @@ static int xerrorstart(Display *dpy, XErrorEvent *ee);
static void zoom(const Arg *arg);
static void load_xresources(void);
static void resource_load(XrmDatabase db, char *name, enum resource_type rtype, void *dst);
static void bstack(Monitor *m);
/* variables */
static const char broken[] = "broken";
static char stext[1024];
static char stext[256];
static int screen;
static int sw, sh; /* X display screen geometry width, height */
static int bh; /* bar height */
static int enablegaps = 1; /* enables gaps, used by togglegaps */
static int lrpad; /* sum of left and right padding for text */
static int (*xerrorxlib)(Display *, XErrorEvent *);
static unsigned int numlockmask = 0;
@ -537,7 +543,7 @@ cleanup(void)
cleanupmon(mons);
for (i = 0; i < CurLast; i++)
drw_cur_free(drw, cursor[i]);
for (i = 0; i < LENGTH(colors) + 1; i++)
for (i = 0; i < LENGTH(colors); i++)
free(scheme[i]);
free(scheme);
XDestroyWindow(dpy, wmcheckwin);
@ -697,6 +703,10 @@ createmon(void)
m->nmaster = nmaster;
m->showbar = showbar;
m->topbar = topbar;
m->gappih = gappih;
m->gappiv = gappiv;
m->gappoh = gappoh;
m->gappov = gappov;
m->lt[0] = &layouts[0];
m->lt[1] = &layouts[1 % LENGTH(layouts)];
strncpy(m->ltsymbol, layouts[0].symbol, sizeof m->ltsymbol);
@ -766,114 +776,6 @@ dirtomon(int dir)
return m;
}
int
drawstatusbar(Monitor *m, int bh, char* stext) {
int ret, i, w, x, len;
short isCode = 0;
char *text;
char *p;
len = strlen(stext) + 1 ;
if (!(text = (char*) malloc(sizeof(char)*len)))
die("malloc");
p = text;
memcpy(text, stext, len);
/* compute width of the status text */
w = 0;
i = -1;
while (text[++i]) {
if (text[i] == '^') {
if (!isCode) {
isCode = 1;
text[i] = '\0';
w += TEXTW(text) - lrpad;
text[i] = '^';
if (text[++i] == 'f')
w += atoi(text + ++i);
} else {
isCode = 0;
text = text + i + 1;
i = -1;
}
}
}
if (!isCode)
w += TEXTW(text) - lrpad;
else
isCode = 0;
text = p;
w += 2; /* 1px padding on both sides */
ret = x = m->ww - w;
drw_setscheme(drw, scheme[LENGTH(colors)]);
drw->scheme[ColFg] = scheme[SchemeNorm][ColFg];
drw->scheme[ColBg] = scheme[SchemeNorm][ColBg];
drw_rect(drw, x, 0, w, bh, 1, 1);
x++;
/* process status text */
i = -1;
while (text[++i]) {
if (text[i] == '^' && !isCode) {
isCode = 1;
text[i] = '\0';
w = TEXTW(text) - lrpad;
drw_text(drw, x, 0, w, bh, 0, text, 0);
x += w;
/* process code */
while (text[++i] != '^') {
if (text[i] == 'c') {
char buf[8];
memcpy(buf, (char*)text+i+1, 7);
buf[7] = '\0';
drw_clr_create(drw, &drw->scheme[ColFg], buf);
i += 7;
} else if (text[i] == 'b') {
char buf[8];
memcpy(buf, (char*)text+i+1, 7);
buf[7] = '\0';
drw_clr_create(drw, &drw->scheme[ColBg], buf);
i += 7;
} else if (text[i] == 'd') {
drw->scheme[ColFg] = scheme[SchemeNorm][ColFg];
drw->scheme[ColBg] = scheme[SchemeNorm][ColBg];
} else if (text[i] == 'r') {
int rx = atoi(text + ++i);
while (text[++i] != ',');
int ry = atoi(text + ++i);
while (text[++i] != ',');
int rw = atoi(text + ++i);
while (text[++i] != ',');
int rh = atoi(text + ++i);
drw_rect(drw, rx + x, ry, rw, rh, 1, 0);
} else if (text[i] == 'f') {
x += atoi(text + ++i);
}
}
text = text + i + 1;
i=-1;
isCode = 0;
}
}
if (!isCode) {
w = TEXTW(text) - lrpad;
drw_text(drw, x, 0, w, bh, 0, text, 0);
}
drw_setscheme(drw, scheme[SchemeNorm]);
free(p);
return ret;
}
void
drawbar(Monitor *m)
{
@ -888,7 +790,9 @@ drawbar(Monitor *m)
/* draw status first so it can be overdrawn by tags later */
if (m == selmon) { /* status is only drawn on selected monitor */
tw = m->ww - drawstatusbar(m, bh, stext);
drw_setscheme(drw, scheme[SchemeNorm]);
tw = TEXTW(stext) - lrpad + 2; /* 2px right padding */
drw_text(drw, m->ww - tw, 0, tw, bh, 0, stext, 0);
}
for (c = m->clients; c; c = c->next) {
@ -1291,16 +1195,49 @@ maprequest(XEvent *e)
void
monocle(Monitor *m)
{
unsigned int n = 0;
unsigned int n = 0, oe = enablegaps;
Client *c;
for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
if (n == 0)
return;
if (smartgaps == n) {
oe = 0; // outer gaps disabled
}
n = 0;
for (c = m->clients; c; c = c->next)
if (ISVISIBLE(c))
n++;
if (n > 0) /* override layout symbol */
snprintf(m->ltsymbol, sizeof m->ltsymbol, "[%d]", n);
for (c = nexttiled(m->clients); c; c = nexttiled(c->next))
resize(c, m->wx, m->wy, m->ww - 2 * c->bw, m->wh - 2 * c->bw, 0);
int newx, newy, neww, newh;
for (c = nexttiled(m->clients); c; c = nexttiled(c->next)) {
if (m->gappoh == 0) {
newx = m->wx - c->bw;
newy = m->wy - c->bw;
neww = m->ww;
newh = m->wh;
} else {
newx = m->wx + m->gappoh*oe - c->bw;
newy = m->wy + m->gappoh*oe - c->bw;
neww = m->ww - 2 * (m->gappoh*oe + c->bw);
newh = m->wh - 2 * (m->gappoh*oe + c->bw);
}
applysizehints(c, &newx, &newy, &neww, &newh, 0);
if (neww < m->ww) {
newx = m->wx + (m->ww - (neww + 2 * c->bw)) / 2;
}
if (newh < m->wh) {
newy = m->wy + (m->wh - (newh + 2 * c->bw)) / 2;
resize(c, newx, newy, neww, newh, 0);
}
}
}
void
@ -1327,7 +1264,6 @@ movemouse(const Arg *arg)
Client *c;
Monitor *m;
XEvent ev;
Time lasttime = 0;
if (!(c = selmon->sel))
return;
@ -1350,10 +1286,6 @@ movemouse(const Arg *arg)
handler[ev.type](&ev);
break;
case MotionNotify:
if ((ev.xmotion.time - lasttime) <= (1000 / 120))
continue;
lasttime = ev.xmotion.time;
nx = ocx + (ev.xmotion.x - x);
ny = ocy + (ev.xmotion.y - y);
if (abs(selmon->wx - nx) < snap)
@ -1531,23 +1463,23 @@ resizeclient(Client *c, int x, int y, int w, int h)
void
resizemouse(const Arg *arg)
{
int ocx, ocy, nw, nh;
int x, y, ocw, och, nw, nh;
Client *c;
Monitor *m;
XEvent ev;
Time lasttime = 0;
if (!(c = selmon->sel))
return;
if (c->isfullscreen) /* no support resizing fullscreen windows by mouse */
return;
restack(selmon);
ocx = c->x;
ocy = c->y;
ocw = c->w;
och = c->h;
if (XGrabPointer(dpy, root, False, MOUSEMASK, GrabModeAsync, GrabModeAsync,
None, cursor[CurResize]->cursor, CurrentTime) != GrabSuccess)
return;
XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w + c->bw - 1, c->h + c->bw - 1);
if(!getrootptr(&x, &y))
return;
do {
XMaskEvent(dpy, MOUSEMASK|ExposureMask|SubstructureRedirectMask, &ev);
switch(ev.type) {
@ -1557,12 +1489,8 @@ resizemouse(const Arg *arg)
handler[ev.type](&ev);
break;
case MotionNotify:
if ((ev.xmotion.time - lasttime) <= (1000 / 60))
continue;
lasttime = ev.xmotion.time;
nw = MAX(ev.xmotion.x - ocx - 2 * c->bw + 1, 1);
nh = MAX(ev.xmotion.y - ocy - 2 * c->bw + 1, 1);
nw = MAX(ocw + (ev.xmotion.x - x), 1);
nh = MAX(och + (ev.xmotion.y - y), 1);
if (c->mon->wx + nw >= selmon->wx && c->mon->wx + nw <= selmon->wx + selmon->ww
&& c->mon->wy + nh >= selmon->wy && c->mon->wy + nh <= selmon->wy + selmon->wh)
{
@ -1575,7 +1503,6 @@ resizemouse(const Arg *arg)
break;
}
} while (ev.type != ButtonRelease);
XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w + c->bw - 1, c->h + c->bw - 1);
XUngrabPointer(dpy, CurrentTime);
while (XCheckMaskEvent(dpy, EnterWindowMask, &ev));
if ((m = recttomon(c->x, c->y, c->w, c->h)) != selmon) {
@ -1585,6 +1512,45 @@ resizemouse(const Arg *arg)
}
}
void
setgaps(int oh, int ov, int ih, int iv)
{
if (oh < 0) oh = 0;
if (ov < 0) ov = 0;
if (ih < 0) ih = 0;
if (iv < 0) iv = 0;
selmon->gappoh = oh;
selmon->gappov = ov;
selmon->gappih = ih;
selmon->gappiv = iv;
arrange(selmon);
}
void
togglegaps(const Arg *arg)
{
enablegaps = !enablegaps;
arrange(selmon);
}
void
defaultgaps(const Arg *arg)
{
setgaps(gappoh, gappov, gappih, gappiv);
}
void
incrgaps(const Arg *arg)
{
setgaps(
selmon->gappoh + arg->i,
selmon->gappov + arg->i,
selmon->gappih + arg->i,
selmon->gappiv + arg->i
);
}
void
restack(Monitor *m)
{
@ -1836,8 +1802,7 @@ setup(void)
cursor[CurResize] = drw_cur_create(drw, XC_sizing);
cursor[CurMove] = drw_cur_create(drw, XC_fleur);
/* init appearance */
scheme = ecalloc(LENGTH(colors) + 1, sizeof(Clr *));
scheme[LENGTH(colors)] = drw_scm_create(drw, colors[0], 3);
scheme = ecalloc(LENGTH(colors), sizeof(Clr *));
for (i = 0; i < LENGTH(colors); i++)
scheme[i] = drw_scm_create(drw, colors[i], 3);
/* init bars */
@ -1879,21 +1844,6 @@ seturgent(Client *c, int urg)
XFree(wmh);
}
void
shiftview(const Arg *arg) {
Arg shifted;
if(arg->i > 0) // left circular shift
shifted.ui = (selmon->tagset[selmon->seltags] << arg->i)
| (selmon->tagset[selmon->seltags] >> (LENGTH(tags) - arg->i));
else // right circular shift
shifted.ui = selmon->tagset[selmon->seltags] >> (- arg->i)
| selmon->tagset[selmon->seltags] << (LENGTH(tags) + arg->i);
view(&shifted);
}
void
showhide(Client *c)
{
@ -1955,28 +1905,34 @@ tagmon(const Arg *arg)
void
tile(Monitor *m)
{
unsigned int i, n, h, mw, my, ty;
unsigned int i, n, h, r, oe = enablegaps, ie = enablegaps, mw, my, ty;
Client *c;
for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
if (n == 0)
return;
if (smartgaps == n) {
oe = 0; // outer gaps disabled
}
if (n > m->nmaster)
mw = m->nmaster ? m->ww * m->mfact : 0;
mw = m->nmaster ? (m->ww + m->gappiv*ie) * m->mfact : 0;
else
mw = m->ww;
for (i = my = ty = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++)
mw = m->ww - 2*m->gappov*oe + m->gappiv*ie;
for (i = 0, my = ty = m->gappoh*oe, 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);
r = MIN(n, m->nmaster) - i;
h = (m->wh - my - m->gappoh*oe - m->gappih*ie * (r - 1)) / r;
resize(c, m->wx + m->gappov*oe, m->wy + my, mw - (2*c->bw) - m->gappiv*ie, h - (2*c->bw), 0);
if (my + HEIGHT(c) + m->gappih*ie < m->wh)
my += HEIGHT(c) + m->gappih*ie;
} 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);
r = n - i;
h = (m->wh - ty - m->gappoh*oe - m->gappih*ie * (r - 1)) / r;
resize(c, m->wx + mw + m->gappov*oe, m->wy + ty, m->ww - mw - (2*c->bw) - 2*m->gappov*oe, h - (2*c->bw), 0);
if (ty + HEIGHT(c) + m->gappih*ie < m->wh)
ty += HEIGHT(c) + m->gappih*ie;
}
}
@ -2545,35 +2501,3 @@ main(int argc, char *argv[])
return EXIT_SUCCESS;
}
static void
bstack(Monitor *m) {
int w, h, mh, mx, tx, ty, tw;
unsigned int i, n;
Client *c;
for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
if (n == 0)
return;
if (n > m->nmaster) {
mh = m->nmaster ? m->mfact * m->wh : 0;
tw = m->ww / (n - m->nmaster);
ty = m->wy + mh;
} else {
mh = m->wh;
tw = m->ww;
ty = m->wy;
}
for (i = mx = 0, tx = m->wx, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) {
if (i < m->nmaster) {
w = (m->ww - mx) / (MIN(n, m->nmaster) - i);
resize(c, m->wx + mx, m->wy, w - (2 * c->bw), mh - (2 * c->bw), 0);
mx += WIDTH(c);
} else {
h = m->wh - mh;
resize(c, tx, ty, tw - (2 * c->bw), h - (2 * c->bw), 0);
if (tw != m->ww)
tx += WIDTH(c);
}
}
}

19
shiftview.c Normal file
View file

@ -0,0 +1,19 @@
/** Function to shift the current view to the left/right
*
* @param: "arg->i" stores the number of tags to shift right (positive value)
* or left (negative value)
*/
void
shiftview(const Arg *arg) {
Arg shifted;
if(arg->i > 0) // left circular shift
shifted.ui = (selmon->tagset[selmon->seltags] << arg->i)
| (selmon->tagset[selmon->seltags] >> (LENGTH(tags) - arg->i));
else // right circular shift
shifted.ui = selmon->tagset[selmon->seltags] >> (- arg->i)
| selmon->tagset[selmon->seltags] << (LENGTH(tags) + arg->i);
view(&shifted);
}