aboutsummarylogtreecommitdiffstats
path: root/x.c
diff options
context:
space:
mode:
authorJules Maselbas2018-06-27 17:08:30 +0200
committerHiltjo Posthuma2018-06-30 20:51:46 +0200
commit75cb367348c0559cbb54b715e844f023b10eb3c8 (patch)
treea9aac6379940c8d1122ccb6b338cb1261366fbfa /x.c
parentb9667195bdcafa1634faf6f1cf86bcde0f050f62 (diff)
downloadaur-75cb367348c0559cbb54b715e844f023b10eb3c8.tar.gz
Fix crash on resize
Prevent to realloc xw.specbuc with a negative number of col. Add proper hints for the minimal size, for one character.
Diffstat (limited to 'x.c')
-rw-r--r--x.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/x.c b/x.c
index c0bd89036699..00cb6b18658a 100644
--- a/x.c
+++ b/x.c
@@ -672,6 +672,8 @@ cresize(int width, int height)
col = (win.w - 2 * borderpx) / win.cw;
row = (win.h - 2 * borderpx) / win.ch;
+ col = MAX(1, col);
+ row = MAX(1, row);
tresize(col, row);
xresize(col, row);
@@ -681,8 +683,8 @@ cresize(int width, int height)
void
xresize(int col, int row)
{
- win.tw = MAX(1, col * win.cw);
- win.th = MAX(1, row * win.ch);
+ win.tw = col * win.cw;
+ win.th = row * win.ch;
XFreePixmap(xw.dpy, xw.buf);
xw.buf = XCreatePixmap(xw.dpy, xw.win, win.w, win.h,
@@ -788,15 +790,17 @@ xhints(void)
sizeh = XAllocSizeHints();
- sizeh->flags = PSize | PResizeInc | PBaseSize;
+ sizeh->flags = PSize | PResizeInc | PBaseSize | PMinSize;
sizeh->height = win.h;
sizeh->width = win.w;
sizeh->height_inc = win.ch;
sizeh->width_inc = win.cw;
sizeh->base_height = 2 * borderpx;
sizeh->base_width = 2 * borderpx;
+ sizeh->min_height = win.ch + 2 * borderpx;
+ sizeh->min_width = win.cw + 2 * borderpx;
if (xw.isfixed) {
- sizeh->flags |= PMaxSize | PMinSize;
+ sizeh->flags |= PMaxSize;
sizeh->min_width = sizeh->max_width = win.w;
sizeh->min_height = sizeh->max_height = win.h;
}