Xinqi Bao's Git
projects
/
dmenu.git
/ blobdiff
summary
|
log
|
commit
|
diff
|
tree
raw
|
inline
| side by side
fix crash if negative monitor (< -1) was passed
[dmenu.git]
/
dmenu.c
diff --git
a/dmenu.c
b/dmenu.c
index
0e7b70b
..
df51e76
100644
(file)
--- a/
dmenu.c
+++ b/
dmenu.c
@@
-81,10
+81,10
@@
calcoffsets(void)
n = mw - (promptw + inputw + TEXTW("<") + TEXTW(">"));
/* calculate which items will begin the next page and previous page */
for (i = 0, next = curr; next; next = next->right)
n = mw - (promptw + inputw + TEXTW("<") + TEXTW(">"));
/* calculate which items will begin the next page and previous page */
for (i = 0, next = curr; next; next = next->right)
- if ((i += (lines > 0) ? bh :
TEXTW(next->text
)) > n)
+ if ((i += (lines > 0) ? bh :
MIN(TEXTW(next->text), n
)) > n)
break;
for (i = 0, prev = curr; prev && prev->left; prev = prev->left)
break;
for (i = 0, prev = curr; prev && prev->left; prev = prev->left)
- if ((i += (lines > 0) ? bh :
TEXTW(prev->left->text
)) > n)
+ if ((i += (lines > 0) ? bh :
MIN(TEXTW(prev->left->text), n
)) > n)
break;
}
break;
}
@@
-480,7
+480,7
@@
readstdin(void)
}
if (items)
items[i].text = NULL;
}
if (items)
items[i].text = NULL;
- inputw =
TEXTW(items[imax].text)
;
+ inputw =
items ? TEXTW(items[imax].text) : 0
;
lines = MIN(lines, i);
}
lines = MIN(lines, i);
}
@@
-541,7
+541,7
@@
setup(void)
#ifdef XINERAMA
if ((info = XineramaQueryScreens(dpy, &n))) {
XGetInputFocus(dpy, &w, &di);
#ifdef XINERAMA
if ((info = XineramaQueryScreens(dpy, &n))) {
XGetInputFocus(dpy, &w, &di);
- if (mon
!= -1
&& mon < n)
+ if (mon
>= 0
&& mon < n)
i = mon;
else if (w != root && w != PointerRoot && w != None) {
/* find top-level window containing current input focus */
i = mon;
else if (w != root && w != PointerRoot && w != None) {
/* find top-level window containing current input focus */
@@
-558,7
+558,7
@@
setup(void)
}
}
/* no focused window is on screen, so use pointer location instead */
}
}
/* no focused window is on screen, so use pointer location instead */
- if (mon
== -1
&& !area && XQueryPointer(dpy, root, &dw, &dw, &x, &y, &di, &di, &du))
+ if (mon
< 0
&& !area && XQueryPointer(dpy, root, &dw, &dw, &x, &y, &di, &di, &du))
for (i = 0; i < n; i++)
if (INTERSECT(x, y, 1, 1, info[i]))
break;
for (i = 0; i < n; i++)
if (INTERSECT(x, y, 1, 1, info[i]))
break;