code-style: simplify some checks
main change here is making the `zoom()` logic saner. the rest of the changes are just small stuff which accumulated on my local branch. pop() must not be called with NULL. and `zoom()` achieves this, but in a very (unnecessarily) complicated way: if c == NULL then nexttiled() will return NULL as well, so we enter this branch: if (c == nexttiled(selmon->clients)) in here the !c check fails and the function returns before calling pop() if (!c || !(c = nexttiled(c->next))) return; however, none of this was needed. we can simply return early if c was NULL. Also `c` is set to `selmon->sel` so we can use `c` in the first check instead which makes things shorter.
This commit is contained in:
parent
5b2e5e7a40
commit
5e76e7e21d
17
dwm.c
17
dwm.c
|
@ -918,14 +918,12 @@ gettextprop(Window w, Atom atom, char *text, unsigned int size)
|
||||||
text[0] = '\0';
|
text[0] = '\0';
|
||||||
if (!XGetTextProperty(dpy, w, &name, atom) || !name.nitems)
|
if (!XGetTextProperty(dpy, w, &name, atom) || !name.nitems)
|
||||||
return 0;
|
return 0;
|
||||||
if (name.encoding == XA_STRING)
|
if (name.encoding == XA_STRING) {
|
||||||
strncpy(text, (char *)name.value, size - 1);
|
strncpy(text, (char *)name.value, size - 1);
|
||||||
else {
|
} else if (XmbTextPropertyToTextList(dpy, &name, &list, &n) >= Success && n > 0 && *list) {
|
||||||
if (XmbTextPropertyToTextList(dpy, &name, &list, &n) >= Success && n > 0 && *list) {
|
|
||||||
strncpy(text, *list, size - 1);
|
strncpy(text, *list, size - 1);
|
||||||
XFreeStringList(list);
|
XFreeStringList(list);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
text[size - 1] = '\0';
|
text[size - 1] = '\0';
|
||||||
XFree(name.value);
|
XFree(name.value);
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -1099,9 +1097,7 @@ maprequest(XEvent *e)
|
||||||
static XWindowAttributes wa;
|
static XWindowAttributes wa;
|
||||||
XMapRequestEvent *ev = &e->xmaprequest;
|
XMapRequestEvent *ev = &e->xmaprequest;
|
||||||
|
|
||||||
if (!XGetWindowAttributes(dpy, ev->window, &wa))
|
if (!XGetWindowAttributes(dpy, ev->window, &wa) || wa.override_redirect)
|
||||||
return;
|
|
||||||
if (wa.override_redirect)
|
|
||||||
return;
|
return;
|
||||||
if (!wintoclient(ev->window))
|
if (!wintoclient(ev->window))
|
||||||
manage(ev->window, &wa);
|
manage(ev->window, &wa);
|
||||||
|
@ -1603,7 +1599,6 @@ setup(void)
|
||||||
focus(NULL);
|
focus(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
seturgent(Client *c, int urg)
|
seturgent(Client *c, int urg)
|
||||||
{
|
{
|
||||||
|
@ -2124,11 +2119,9 @@ zoom(const Arg *arg)
|
||||||
{
|
{
|
||||||
Client *c = selmon->sel;
|
Client *c = selmon->sel;
|
||||||
|
|
||||||
if (!selmon->lt[selmon->sellt]->arrange
|
if (!selmon->lt[selmon->sellt]->arrange || !c || c->isfloating)
|
||||||
|| (selmon->sel && selmon->sel->isfloating))
|
|
||||||
return;
|
return;
|
||||||
if (c == nexttiled(selmon->clients))
|
if (c == nexttiled(selmon->clients) && !(c = nexttiled(c->next)))
|
||||||
if (!c || !(c = nexttiled(c->next)))
|
|
||||||
return;
|
return;
|
||||||
pop(c);
|
pop(c);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue