we check variable == value, and not the other way - the other way is for beginner programmers.

pull/1/head
Anselm R. Garbe 17 years ago
parent 951d022dfc
commit 35efafe8ac
  1. 31
      dwm.c

31
dwm.c

@ -303,7 +303,7 @@ buttonpress(XEvent *e) {
Client *c; Client *c;
XButtonPressedEvent *ev = &e->xbutton; XButtonPressedEvent *ev = &e->xbutton;
if(barwin == ev->window) { if(ev->window == barwin) {
x = 0; x = 0;
for(i = 0; i < LENGTH(tags); i++) { for(i = 0; i < LENGTH(tags); i++) {
x += textw(tags[i]); x += textw(tags[i]);
@ -331,7 +331,7 @@ buttonpress(XEvent *e) {
if(CLEANMASK(ev->state) != MODKEY) if(CLEANMASK(ev->state) != MODKEY)
return; return;
if(ev->button == Button1) { if(ev->button == Button1) {
if((floating == layout->arrange) || c->isfloating) if((layout->arrange == floating) || c->isfloating)
restack(); restack();
else else
togglefloating(NULL); togglefloating(NULL);
@ -662,8 +662,8 @@ void
expose(XEvent *e) { expose(XEvent *e) {
XExposeEvent *ev = &e->xexpose; XExposeEvent *ev = &e->xexpose;
if(0 == ev->count) { if(ev->count == 0) {
if(barwin == ev->window) if(ev->window == barwin)
drawbar(); drawbar();
} }
} }
@ -777,7 +777,7 @@ gettextprop(Window w, Atom atom, char *text, unsigned int size) {
int n; int n;
XTextProperty name; XTextProperty name;
if(!text || 0 == size) if(!text || size == 0)
return False; return False;
text[0] = '\0'; text[0] = '\0';
XGetTextProperty(dpy, w, &name, atom); XGetTextProperty(dpy, w, &name, atom);
@ -787,8 +787,7 @@ gettextprop(Window w, Atom atom, char *text, unsigned int size) {
strncpy(text, (char *)name.value, size - 1); strncpy(text, (char *)name.value, size - 1);
else { else {
if(XmbTextPropertyToTextList(dpy, &name, &list, &n) >= Success if(XmbTextPropertyToTextList(dpy, &name, &list, &n) >= Success
&& n > 0 && *list) && n > 0 && *list) {
{
strncpy(text, *list, size - 1); strncpy(text, *list, size - 1);
XFreeStringList(list); XFreeStringList(list);
} }
@ -1123,7 +1122,7 @@ propertynotify(XEvent *e) {
default: break; default: break;
case XA_WM_TRANSIENT_FOR: case XA_WM_TRANSIENT_FOR:
XGetTransientForHint(dpy, c->win, &trans); XGetTransientForHint(dpy, c->win, &trans);
if(!c->isfloating && (c->isfloating = (NULL != getclient(trans)))) if(!c->isfloating && (c->isfloating = (getclient(trans) != NULL)))
arrange(); arrange();
break; break;
case XA_WM_NORMAL_HINTS: case XA_WM_NORMAL_HINTS:
@ -1257,9 +1256,9 @@ restack(void) {
drawbar(); drawbar();
if(!sel) if(!sel)
return; return;
if(sel->isfloating || (floating == layout->arrange)) if(sel->isfloating || (layout->arrange == floating))
XRaiseWindow(dpy, sel->win); XRaiseWindow(dpy, sel->win);
if(floating != layout->arrange) { if(layout->arrange != floating) {
wc.stack_mode = Below; wc.stack_mode = Below;
wc.sibling = barwin; wc.sibling = barwin;
if(!sel->isfloating) { if(!sel->isfloating) {
@ -1396,9 +1395,9 @@ setmwfact(const char *arg) {
if(!domwfact) if(!domwfact)
return; return;
/* arg handling, manipulate mwfact */ /* arg handling, manipulate mwfact */
if(NULL == arg) if(arg == NULL)
mwfact = MWFACT; mwfact = MWFACT;
else if(1 == sscanf(arg, "%lf", &delta)) { else if(sscanf(arg, "%lf", &delta) == 1) {
if(arg[0] == '+' || arg[0] == '-') if(arg[0] == '+' || arg[0] == '-')
mwfact += delta; mwfact += delta;
else else
@ -1513,8 +1512,8 @@ spawn(const char *arg) {
return; return;
/* The double-fork construct avoids zombie processes and keeps the code /* The double-fork construct avoids zombie processes and keeps the code
* clean from stupid signal handlers. */ * clean from stupid signal handlers. */
if(0 == fork()) { if(fork() == 0) {
if(0 == fork()) { if(fork() == 0) {
if(dpy) if(dpy)
close(ConnectionNumber(dpy)); close(ConnectionNumber(dpy));
setsid(); setsid();
@ -1575,7 +1574,7 @@ tile(void) {
nw = 0; /* gcc stupidity requires this */ nw = 0; /* gcc stupidity requires this */
for(i = 0, c = mc = nexttiled(clients); c; c = nexttiled(c->next), i++) { for(i = 0, c = mc = nexttiled(clients); c; c = nexttiled(c->next), i++) {
c->ismax = False; c->ismax = False;
if(0 == i) { /* master */ if(i == 0) { /* master */
nw = mw - 2 * c->border; nw = mw - 2 * c->border;
nh = wah - 2 * c->border; nh = wah - 2 * c->border;
} }
@ -1626,7 +1625,7 @@ togglemax(const char *arg) {
if(!sel || sel->isfixed) if(!sel || sel->isfixed)
return; return;
if((sel->ismax = !sel->ismax)) { if((sel->ismax = !sel->ismax)) {
if((floating == layout->arrange) || sel->isfloating) if((layout->arrange == floating) || sel->isfloating)
sel->wasfloating = True; sel->wasfloating = True;
else { else {
togglefloating(NULL); togglefloating(NULL);

Loading…
Cancel
Save