aboutsummaryrefslogtreecommitdiffstats
path: root/dwm.c
diff options
context:
space:
mode:
Diffstat (limited to 'dwm.c')
-rw-r--r--dwm.c75
1 files changed, 29 insertions, 46 deletions
diff --git a/dwm.c b/dwm.c
index 437dd70..ede7ce4 100644
--- a/dwm.c
+++ b/dwm.c
@@ -88,6 +88,7 @@ typedef struct Client Client;
struct Client {
char name[256];
float mina, maxa;
+ float cfact;
int x, y, w, h;
int oldx, oldy, oldw, oldh;
int basew, baseh, incw, inch, maxw, maxh, minw, minh, hintsvalid;
@@ -121,7 +122,10 @@ struct Monitor {
int by; /* bar geometry */
int mx, my, mw, mh; /* screen size */
int wx, wy, ww, wh; /* window area */
- int gappx; /* gaps between windows */
+ 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];
@@ -207,8 +211,8 @@ 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(const Arg *arg);
static void setlayout(const Arg *arg);
+static void setcfact(const Arg *arg);
static void setmfact(const Arg *arg);
static void setup(void);
static void seturgent(Client *c, int urg);
@@ -218,7 +222,6 @@ static void tag(const Arg *arg);
static void tagmon(const Arg *arg);
static void tagtoleft(const Arg *arg);
static void tagtoright(const Arg *arg);
-static void tile(Monitor *m);
static void togglebar(const Arg *arg);
static void togglefloating(const Arg *arg);
static void togglermaster(const Arg *arg);
@@ -666,7 +669,10 @@ createmon(void)
m->rmaster = rmaster;
m->showbar = showbar;
m->topbar = topbar;
- m->gappx = gappx;
+ 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);
@@ -1166,6 +1172,7 @@ manage(Window w, XWindowAttributes *wa)
c->w = c->oldw = wa->width;
c->h = c->oldh = wa->height;
c->oldbw = wa->border_width;
+ c->cfact = 1.0;
updatetitle(c);
if (XGetTransientForHint(dpy, w, &trans) && (t = wintoclient(trans))) {
@@ -1722,16 +1729,6 @@ setfullscreen(Client *c, int fullscreen)
}
void
-setgaps(const Arg *arg)
-{
- if ((arg->i == 0) || (selmon->gappx + arg->i < 0))
- selmon->gappx = 0;
- else
- selmon->gappx += arg->i;
- arrange(selmon);
-}
-
-void
setlayout(const Arg *arg)
{
if (!arg || !arg->v || arg->v != selmon->lt[selmon->sellt])
@@ -1745,6 +1742,24 @@ setlayout(const Arg *arg)
drawbar(selmon);
}
+void
+setcfact(const Arg *arg) {
+ float f;
+ Client *c;
+
+ c = selmon->sel;
+
+ if(!arg || !c || !selmon->lt[selmon->sellt]->arrange)
+ return;
+ f = arg->f + c->cfact;
+ if(arg->f == 0.0)
+ f = 1.0;
+ else if(f < 0.25 || f > 4.0)
+ return;
+ c->cfact = f;
+ arrange(selmon);
+}
+
/* arg > 1.0 will set mfact absolutely */
void
setmfact(const Arg *arg)
@@ -1931,38 +1946,6 @@ tagtoright(const Arg *arg) {
}
void
-tile(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->rmaster ? 1.0 - m->mfact : m->mfact)
- : 0;
- else
- mw = m->ww - m->gappx;
- for (i = 0, my = ty = m->gappx, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++)
- if (i < m->nmaster) {
- h = (m->wh - my) / (MIN(n, m->nmaster) - i) - m->gappx;
- resize(c, m->rmaster ? m->wx + m->ww - mw : m->wx,
- m->wy + my, mw - (2*c->bw), h - (2*c->bw), 0);
- if (my + HEIGHT(c) + m->gappx < m->wh)
- my += HEIGHT(c) + m->gappx;
- } else {
- h = (m->wh - ty) / (n - i) - m->gappx;
- resize(c, m->rmaster ? m->wx : m->wx + mw, m->wy + ty,
- m->ww - mw - (2*c->bw), h - (2*c->bw), 0);
- if (ty + HEIGHT(c) + m->gappx < m->wh)
- ty += HEIGHT(c) + m->gappx;
- }
-}
-
-void
togglebar(const Arg *arg)
{
selmon->showbar = selmon->pertag->showbars[selmon->pertag->curtag] = !selmon->showbar;