JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
applied Hiltjos' BUGS patch from 23 Mar, sorry took a while :)
[dwm.git] / dwm.c
diff --git a/dwm.c b/dwm.c
index d171fe2..7b5fa4e 100644 (file)
--- a/dwm.c
+++ b/dwm.c
@@ -980,7 +980,7 @@ grabkeys(void) {
 void
 initfont(const char *fontstr) {
        char *def, **missing;
-       int i, n;
+       int n;
 
        missing = NULL;
        dc.font.set = XCreateFontSet(dpy, fontstr, &missing, &n, &def);
@@ -996,7 +996,7 @@ initfont(const char *fontstr) {
                dc.font.ascent = dc.font.descent = 0;
                XExtentsOfFontSet(dc.font.set);
                n = XFontsOfFontSet(dc.font.set, &xfonts, &font_names);
-               for(i = 0, dc.font.ascent = 0, dc.font.descent = 0; i < n; i++) {
+               while(n--) {
                        dc.font.ascent = MAX(dc.font.ascent, (*xfonts)->ascent);
                        dc.font.descent = MAX(dc.font.descent,(*xfonts)->descent);
                        xfonts++;
@@ -1014,14 +1014,13 @@ initfont(const char *fontstr) {
 
 Bool
 isprotodel(Client *c) {
-       int i, n;
+       int n;
        Atom *protocols;
        Bool ret = False;
 
        if(XGetWMProtocols(dpy, c->win, &protocols, &n)) {
-               for(i = 0; !ret && i < n; i++)
-                       if(protocols[i] == wmatom[WMDelete])
-                               ret = True;
+               while(!ret && n--)
+                       ret = protocols[n] == wmatom[WMDelete];
                XFree(protocols);
        }
        return ret;
@@ -1029,12 +1028,10 @@ isprotodel(Client *c) {
 
 #ifdef XINERAMA
 static Bool
-isuniquegeom(XineramaScreenInfo *unique, size_t len, XineramaScreenInfo *info) {
-       unsigned int i;
-
-       for(i = 0; i < len; i++)
-               if(unique[i].x_org == info->x_org && unique[i].y_org == info->y_org
-               && unique[i].width == info->width && unique[i].height == info->height)
+isuniquegeom(XineramaScreenInfo *unique, size_t n, XineramaScreenInfo *info) {
+       while(n--)
+               if(unique[n].x_org == info->x_org && unique[n].y_org == info->y_org
+               && unique[n].width == info->width && unique[n].height == info->height)
                        return False;
        return True;
 }
@@ -1205,7 +1202,7 @@ movemouse(const Arg *arg) {
                case MotionNotify:
                        nx = ocx + (ev.xmotion.x - x);
                        ny = ocy + (ev.xmotion.y - y);
-                       if(snap && nx >= selmon->wx && nx <= selmon->wx + selmon->ww
+                       if(nx >= selmon->wx && nx <= selmon->wx + selmon->ww
                        && ny >= selmon->wy && ny <= selmon->wy + selmon->wh) {
                                if(abs(selmon->wx - nx) < snap)
                                        nx = selmon->wx;
@@ -1368,8 +1365,8 @@ resizemouse(const Arg *arg) {
                case MotionNotify:
                        nw = MAX(ev.xmotion.x - ocx - 2 * c->bw + 1, 1);
                        nh = MAX(ev.xmotion.y - ocy - 2 * c->bw + 1, 1);
-                       if(snap && nw >= selmon->wx && nw <= selmon->wx + selmon->ww
-                       && nh >= selmon->wy && nh <= selmon->wy + selmon->wh)
+                       if(snap && 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
                                && (abs(nw - c->w) > snap || abs(nh - c->h) > snap))