From 74c07733698b95eb455edcafab8634a700a3194f Mon Sep 17 00:00:00 2001 From: Po Lu Date: Thu, 17 Feb 2022 10:28:02 +0800 Subject: [PATCH] * src/emacsgtkfixed.c (XSetWMSizeHints): Improve fix for bug#8919. --- src/emacsgtkfixed.c | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/src/emacsgtkfixed.c b/src/emacsgtkfixed.c index a38ba35ad80..cd5d1d14353 100644 --- a/src/emacsgtkfixed.c +++ b/src/emacsgtkfixed.c @@ -164,11 +164,30 @@ XSetWMSizeHints (Display *d, if ((hints->flags & PMinSize) && f) { - int w = f->output_data.x->size_hints.min_width; - int h = f->output_data.x->size_hints.min_height; - - data[5] = w; - data[6] = h; + /* Overriding the size hints with our own values of min_width + and min_height used to work, but these days just results in + frames resizing unpredictably and emitting GTK warnings while + Emacs fights with GTK over the size of the frame. So instead + of doing that, just respect the hints set by GTK, but make + sure they are an integer multiple of the resize increments so + that bug#8919 stays fixed. */ + + /* int w = f->output_data.x->size_hints.min_width; + int h = f->output_data.x->size_hints.min_height; + + data[5] = w; + data[6] = h; */ + + /* Make sure min_width and min_height are multiples of width_inc + and height_inc. */ + + if (hints->flags & PResizeInc) + { + if (data[5] % hints->width_inc) + data[5] += (hints->width_inc - (data[5] % hints->width_inc)); + if (data[6] % hints->height_inc) + data[6] += (hints->height_inc - (data[6] % hints->height_inc)); + } } XChangeProperty (d, w, prop, XA_WM_SIZE_HINTS, 32, PropModeReplace, -- 2.39.5