commit d3733666d8d291bf0651354aa859f57179157cc9
parent dc1c6462cb9a88223d18e4e2792ff9b56aaee594
Author: Lucas de Sena <lucas@seninha.org>
Date: Sat, 15 Jul 2023 13:43:09 -0300
lint source files
Diffstat:
5 files changed, 17 insertions(+), 19 deletions(-)
diff --git a/shodc.c b/shodc.c
@@ -330,7 +330,7 @@ longlist(Window win)
Atom *as;
int x, y;
unsigned int w, h, b, du;
- int desk;
+ long desk;
unsigned long i, natoms, l;
char state[] = "--------";
char *name;
@@ -402,13 +402,13 @@ longlist(Window win)
XFree(as);
}
l = getcardprop(win, atoms[_NET_WM_DESKTOP]);
- desk = (l == 0xFFFFFFFF) ? -1 : l;
+ desk = (l == 0xFFFFFFFF) ? -1 : (long)l;
name = getwinname(win);
XGetGeometry(dpy, win, &dw, &x, &y, &w, &h, &b, &du);
XTranslateCoordinates(dpy, win, root, x, y, &x, &y, &dw);
- printf("%s\t%d\t%dx%d%+d%+d\t0x%08lx\t0x%08lx\t0x%08lx\t%s\n", state, desk, w, h, x, y, container, tab, win, name);
+ printf("%s\t%ld\t%dx%d%+d%+d\t0x%08lx\t0x%08lx\t0x%08lx\t%s\n", state, desk, w, h, x, y, container, tab, win, name);
free(name);
}
@@ -483,9 +483,7 @@ list(int argc, char *argv[])
break;
}
}
- argc -= optind;
- argv += optind;
- if (argc > 1)
+ if (argc - optind > 1)
usage();
nwins = getwins(&wins, sflag);
for (i = 0; i < nwins; i++) {
diff --git a/xcontainer.c b/xcontainer.c
@@ -397,7 +397,7 @@ colnew(void)
struct Column *col;
col = emalloc(sizeof(*col));
- *col = (struct Column){ };
+ *col = (struct Column){ 0 };
TAILQ_INIT(&col->rowq);
col->div = XCreateWindow(dpy, root, 0, 0, 1, 1, 0,
CopyFromParent, InputOnly, CopyFromParent, CWCursor,
@@ -1391,11 +1391,11 @@ containerplace(struct Container *c, struct Monitor *mon, int desk, int userplace
for (h = 1; i+h < DIV && grid[i + h][j] == lowest; h++) {
for (k = 0; k < w && grid[i + h][j + k] == lowest; k++)
;
- if (k < w)
+ if (k < w) {
+ h--;
break;
+ }
}
- if (k < w)
- h--;
if (w * h > subw * subh) {
subw = w;
subh = h;
diff --git a/xdraw.c b/xdraw.c
@@ -65,7 +65,7 @@ drawtitle(Drawable pix, const char *text, int w, int drawlines, int style, int p
color = &theme.colors[style][COLOR_LIGHT];
draw = XftDrawCreate(dpy, pix, visual, colormap);
len = strlen(text);
- XftTextExtentsUtf8(dpy, theme.font, text, len, &box);
+ XftTextExtentsUtf8(dpy, theme.font, (FcChar8 *)text, len, &box);
x = max(0, (w - box.width) / 2 + box.x);
y = (config.titlewidth - box.height) / 2 + box.y;
for (i = 3; drawlines && i < config.titlewidth - 3; i += 3) {
@@ -80,7 +80,7 @@ drawtitle(Drawable pix, const char *text, int w, int drawlines, int style, int p
XFillRectangle(dpy, pix, gc, 4, i, x - 8, 1);
XFillRectangle(dpy, pix, gc, w - x + 2, i, x - 6, 1);
}
- XftDrawStringUtf8(draw, color, theme.font, x, y, text, len);
+ XftDrawStringUtf8(draw, color, theme.font, x, y, (FcChar8 *)text, len);
XftDrawDestroy(draw);
}
diff --git a/xevents.c b/xevents.c
@@ -825,8 +825,8 @@ mouseretab(struct Tab *tab, int xroot, int yroot, int x, int y)
XUnmapWindow(dpy, tab->title);
XMoveWindow(
dpy, wm.dragwin,
- ev.xmotion.x_root - DNDDIFF - (2 * config.borderwidth + config.titlewidth),
- ev.xmotion.y_root - DNDDIFF - (2 * config.borderwidth + config.titlewidth)
+ xroot - DNDDIFF - (2 * config.borderwidth + config.titlewidth),
+ yroot - DNDDIFF - (2 * config.borderwidth + config.titlewidth)
);
XRaiseWindow(dpy, wm.dragwin);
while (!XMaskEvent(dpy, MOUSEEVENTMASK, &ev)) {
@@ -1057,7 +1057,6 @@ mousemove(Window win, int type, void *p, int xroot, int yroot, enum Octant o)
containerdecorate(c, NULL, NULL, 0, o);
frame = c->frame;
}
- x = y = 0;
lasttime = 0;
if (win != None)
XDefineCursor(dpy, win, wm.cursors[CURSOR_MOVE]);
@@ -1119,7 +1118,6 @@ mouseretile(struct Container *c, struct Column *cdiv, struct Row *rdiv, int xpre
curs = wm.cursors[CURSOR_V];
else
return;
- x = y = 0;
lasttime = 0;
containerdecorate(c, cdiv, rdiv, 0, 0);
if (XGrabPointer(dpy, c->frame, False, ButtonReleaseMask | PointerMotionMask, GrabModeAsync, GrabModeAsync, None, curs, CurrentTime) != GrabSuccess)
@@ -1286,7 +1284,7 @@ xeventbuttonpress(XEvent *e)
o = getquadrant(menu->w, menu->h, x, y);
mouseresize(FLOAT_MENU, menu, ev->x_root, ev->y_root, o);
}
- } else if (tab != NULL) {
+ } else if (tab != NULL && c != NULL) {
if (!XTranslateCoordinates(dpy, ev->window, c->frame, ev->x, ev->y, &x, &y, &dw))
goto done;
if (ev->window == tab->title && ev->button == Button1) {
diff --git a/xmon.c b/xmon.c
@@ -107,12 +107,14 @@ next:
/* delete monitors that do not exist anymore */
delselmon = 0;
while ((mon = TAILQ_FIRST(&wm.monq)) != NULL) {
- if (mon == wm.selmon)
+ if (mon == wm.selmon) {
delselmon = 1;
+ wm.selmon = NULL;
+ }
mondel(mon);
}
if (delselmon) {
- wm.selmon = TAILQ_FIRST(&wm.monq);
+ wm.selmon = TAILQ_FIRST(&monq);
}
/* commit new list of monitor */