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.
dev
Jules Maselbas 2018-06-27 17:08:30 +02:00 committed by Hiltjo Posthuma
parent dc3b5babf1
commit 29f341da7c
1 changed files with 8 additions and 4 deletions

12
x.c
View File

@ -672,6 +672,8 @@ cresize(int width, int height)
col = (win.w - 2 * borderpx) / win.cw; col = (win.w - 2 * borderpx) / win.cw;
row = (win.h - 2 * borderpx) / win.ch; row = (win.h - 2 * borderpx) / win.ch;
col = MAX(1, col);
row = MAX(1, row);
tresize(col, row); tresize(col, row);
xresize(col, row); xresize(col, row);
@ -681,8 +683,8 @@ cresize(int width, int height)
void void
xresize(int col, int row) xresize(int col, int row)
{ {
win.tw = MAX(1, col * win.cw); win.tw = col * win.cw;
win.th = MAX(1, row * win.ch); win.th = row * win.ch;
XFreePixmap(xw.dpy, xw.buf); XFreePixmap(xw.dpy, xw.buf);
xw.buf = XCreatePixmap(xw.dpy, xw.win, win.w, win.h, xw.buf = XCreatePixmap(xw.dpy, xw.win, win.w, win.h,
@ -788,15 +790,17 @@ xhints(void)
sizeh = XAllocSizeHints(); sizeh = XAllocSizeHints();
sizeh->flags = PSize | PResizeInc | PBaseSize; sizeh->flags = PSize | PResizeInc | PBaseSize | PMinSize;
sizeh->height = win.h; sizeh->height = win.h;
sizeh->width = win.w; sizeh->width = win.w;
sizeh->height_inc = win.ch; sizeh->height_inc = win.ch;
sizeh->width_inc = win.cw; sizeh->width_inc = win.cw;
sizeh->base_height = 2 * borderpx; sizeh->base_height = 2 * borderpx;
sizeh->base_width = 2 * borderpx; sizeh->base_width = 2 * borderpx;
sizeh->min_height = win.ch + 2 * borderpx;
sizeh->min_width = win.cw + 2 * borderpx;
if (xw.isfixed) { if (xw.isfixed) {
sizeh->flags |= PMaxSize | PMinSize; sizeh->flags |= PMaxSize;
sizeh->min_width = sizeh->max_width = win.w; sizeh->min_width = sizeh->max_width = win.w;
sizeh->min_height = sizeh->max_height = win.h; sizeh->min_height = sizeh->max_height = win.h;
} }