diff options
| author | bakkeby <[email protected]> | 2022-08-07 10:41:01 +0200 |
|---|---|---|
| committer | bakkeby <[email protected]> | 2022-08-07 10:41:01 +0200 |
| commit | 6a0e5b884ef6d27171ada6c2c279a666a7039494 (patch) | |
| tree | eb79c4f30b07d3deb8cb7455be240b181210869e /dwm.c | |
| parent | 10aa27171f87b88bfb48747e9d57361ec7bdaacd (diff) | |
| download | dwm-flexipatch-6a0e5b884ef6d27171ada6c2c279a666a7039494.tar.gz dwm-flexipatch-6a0e5b884ef6d27171ada6c2c279a666a7039494.zip | |
Bump to 5e76e7e.
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.
Ref.
https://git.suckless.org/dwm/commit/5e76e7e21da042c493c59235ca82d7275f20a7e4.html
Diffstat (limited to 'dwm.c')
| -rw-r--r-- | dwm.c | 34 |
1 files changed, 12 insertions, 22 deletions
@@ -2222,13 +2222,11 @@ gettextprop(Window w, Atom atom, char *text, unsigned int size) text[0] = '\0'; if (!XGetTextProperty(dpy, w, &name, atom) || !name.nitems) return 0; - if (name.encoding == XA_STRING) + if (name.encoding == XA_STRING) { strncpy(text, (char *)name.value, size - 1); - else { - if (XmbTextPropertyToTextList(dpy, &name, &list, &n) >= Success && n > 0 && *list) { - strncpy(text, *list, size - 1); - XFreeStringList(list); - } + } else if (XmbTextPropertyToTextList(dpy, &name, &list, &n) >= Success && n > 0 && *list) { + strncpy(text, *list, size - 1); + XFreeStringList(list); } text[size - 1] = '\0'; XFree(name.value); @@ -2625,9 +2623,7 @@ maprequest(XEvent *e) } #endif // BAR_SYSTRAY_PATCH - if (!XGetWindowAttributes(dpy, ev->window, &wa)) - return; - if (wa.override_redirect) + if (!XGetWindowAttributes(dpy, ev->window, &wa) || wa.override_redirect) return; #if BAR_ANYBAR_PATCH if (wmclasscontains(ev->window, altbarclass, "")) @@ -4961,12 +4957,7 @@ zoom(const Arg *arg) c->mon->pertag->prevclient[c->mon->pertag->curtag] = nexttiled(c->mon->clients); #endif // SWAPFOCUS_PATCH - if (!c->mon->lt[c->mon->sellt]->arrange - || (c && c->isfloating) - #if ZOOMSWAP_PATCH - || !c - #endif // ZOOMSWAP_PATCH - ) + if (!c->mon->lt[c->mon->sellt]->arrange || !c || c->isfloating) return; #if ZOOMSWAP_PATCH @@ -5019,14 +5010,13 @@ zoom(const Arg *arg) } focus(c); arrange(c->mon); + #elif SWAPFOCUS_PATCH && PERTAG_PATCH + if (c == nexttiled(c->mon->clients) && !(c = c->mon->pertag->prevclient[c->mon->pertag->curtag] = nexttiled(c->next))) + return; + pop(c); #else - if (c == nexttiled(c->mon->clients)) - #if SWAPFOCUS_PATCH && PERTAG_PATCH - if (!c || !(c = c->mon->pertag->prevclient[c->mon->pertag->curtag] = nexttiled(c->next))) - #else - if (!c || !(c = nexttiled(c->next))) - #endif // SWAPFOCUS_PATCH - return; + if (c == nexttiled(selmon->clients) && !(c = nexttiled(c->next))) + return; pop(c); #endif // ZOOMSWAP_PATCH } |
