[hackers] [dwm] use canarrange over sellmon->sellt repeated pattern || Daniel Cousens
commit e5873e25bca7b1c1c2845ad6952e2c811bb27db8
Author: Daniel Cousens <github_AT_dcousens.com>
AuthorDate: Sun Apr 23 18:46:47 2017 +1000
Commit: Daniel Cousens <github_AT_dcousens.com>
CommitDate: Wed Oct 11 07:55:14 2017 +1100
use canarrange over sellmon->sellt repeated pattern
diff --git a/dwm.c b/dwm.c
index d9858cd..e45b33d 100644
--- a/dwm.c
+++ b/dwm.c
_AT_@ -227,6 +227,10 @@ static int xerrorstart(Display *dpy, XErrorEvent *ee);
static void restart(const Arg *arg);
static void zoom(const Arg *arg);
+int canarrange (Monitor* m) {
+ return m->lt[m->sellt]->arrange != NULL;
+}
+
/* variables */
static const char broken[] = "broken";
static char stext[256];
_AT_@ -322,7 +326,7 @@ applysizehints(Client *c, int *x, int *y, int *w, int *h, int interact)
*h = bh;
if (*w < bh)
*w = bh;
- if (resizehints || c->isfloating || !c->mon->lt[c->mon->sellt]->arrange) {
+ if (resizehints || c->isfloating || !canarrange(c->mon)) {
/* see last two sentences in ICCCM 4.1.2.3 */
baseismin = c->basew == c->minw && c->baseh == c->minh;
if (!baseismin) { /* temporarily remove base dimensions */
_AT_@ -374,7 +378,7 @@ void
arrangemon(Monitor *m)
{
strncpy(m->ltsymbol, m->lt[m->sellt]->symbol, sizeof m->ltsymbol);
- if (m->lt[m->sellt]->arrange)
+ if (canarrange(m))
m->lt[m->sellt]->arrange(m);
}
_AT_@ -561,7 +565,7 @@ configurerequest(XEvent *e)
if ((c = wintoclient(ev->window))) {
if (ev->value_mask & CWBorderWidth)
c->bw = ev->border_width;
- else if (c->isfloating || !selmon->lt[selmon->sellt]->arrange) {
+ else if (c->isfloating || !canarrange(selmon)) {
m = c->mon;
if (ev->value_mask & CWX) {
c->oldx = c->x;
_AT_@ -1149,10 +1153,10 @@ movemouse(const Arg *arg)
ny = selmon->wy;
else if (abs((selmon->wy + selmon->wh) - (ny + HEIGHT(c))) < snap)
ny = selmon->wy + selmon->wh - HEIGHT(c);
- if (!c->isfloating && selmon->lt[selmon->sellt]->arrange
+ if (!c->isfloating && canarrange(selmon)
&& (abs(nx - c->x) > snap || abs(ny - c->y) > snap))
togglefloating(NULL);
- if (!selmon->lt[selmon->sellt]->arrange || c->isfloating)
+ if (!canarrange(selmon) || c->isfloating)
resize(c, nx, ny, c->w, c->h, 1);
break;
}
_AT_@ -1298,11 +1302,11 @@ resizemouse(const Arg *arg)
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)
{
- if (!c->isfloating && selmon->lt[selmon->sellt]->arrange
+ if (!c->isfloating && canarrange(selmon)
&& (abs(nw - c->w) > snap || abs(nh - c->h) > snap))
togglefloating(NULL);
}
- if (!selmon->lt[selmon->sellt]->arrange || c->isfloating)
+ if (!canarrange(selmon) || c->isfloating)
resize(c, c->x, c->y, nw, nh, 1);
break;
}
_AT_@ -1327,9 +1331,9 @@ restack(Monitor *m)
drawbar(m);
if (!m->sel)
return;
- if (m->sel->isfloating || !m->lt[m->sellt]->arrange)
+ if (m->sel->isfloating || !canarrange(m))
XRaiseWindow(dpy, m->sel->win);
- if (m->lt[m->sellt]->arrange) {
+ if (canarrange(m)) {
wc.stack_mode = Below;
wc.sibling = m->barwin;
for (c = m->stack; c; c = c->snext)
_AT_@ -1490,7 +1494,7 @@ setmfact(const Arg *arg)
{
float f;
- if (!arg || !selmon->lt[selmon->sellt]->arrange)
+ if (!arg || !canarrange(selmon))
return;
f = arg->f < 1.0 ? arg->f + selmon->mfact : arg->f - 1.0;
if (f < 0.1 || f > 0.9)
_AT_@ -1591,7 +1595,7 @@ showhide(Client *c)
if (ISVISIBLE(c)) {
/* show clients top down */
XMoveWindow(dpy, c->win, c->x, c->y);
- if ((!c->mon->lt[c->mon->sellt]->arrange || c->isfloating) && !c->isfullscreen)
+ if ((!canarrange(c->mon) || c->isfloating) && !c->isfullscreen)
resize(c, c->x, c->y, c->w, c->h, 0);
showhide(c->snext);
} else {
_AT_@ -2087,7 +2091,7 @@ zoom(const Arg *arg)
{
Client *c = selmon->sel;
- if (!selmon->lt[selmon->sellt]->arrange
+ if (!canarrange(selmon)
|| (selmon->sel && selmon->sel->isfloating))
return;
if (c == nexttiled(selmon->clients))
Received on Wed Oct 11 2017 - 09:19:32 CEST
This archive was generated by hypermail 2.3.0
: Wed Oct 11 2017 - 09:24:47 CEST