Subject: [PATCH v3] Allow Emacs to be resized arbitrarily

From: Konstantin Kharlamov <[email-masked]>
Date: Sun, 16 Jun 2019 21:55:14 +0300

This constraint disallows standard compliant window managers to make
Emacs fullscreen on certain screen resolutions (ones that are not
multiple of width_inc and height_inc), or to expand Emacs to fill free
space on the screen (on certain sizes too).

It doesn't seem to do anything useful otherwise; besides some WMs
(like i3wm) just ignore this property anyway.

Fixes bug#36250

* src/xterm.c (x_wm_set_size_hint): don't set width_inc, height_inc, and
  GDK_HINT_RESIZE_INC.
* src/gtkutil.c (x_wm_set_size_hint): don't set width_inc, height_inc, and
  PResizeInc.
* src/emacsgtkfixed.c (XSetWMSizeHints): don't set width_inc and height_inc.
* etc/NEWS: describe changes
---

v3: add description in NEWS file

 etc/NEWS            | 8 ++++++++
 src/emacsgtkfixed.c | 2 --
 src/gtkutil.c       | 9 +--------
 src/xterm.c         | 5 +----
 4 files changed, 10 insertions(+), 14 deletions(-)

diff --git a/etc/NEWS b/etc/NEWS
index 723f0a0fb0..e78ac326d0 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -171,6 +171,14 @@ This allows disabling the new feature introduced in Emacs 26.1 which
 loads files during completion of 'C-h f' and 'C-h v' according to
 'definition-prefixes'.
 
++++
+** Resize step is not forced anymore
+This should help users of standard-complaint window managers, such as KWin.
+Before this change they couldn't make Emacs full-screen on certain sizes, or
+even make it fill all free space on the screen.
+Users of window managers that ignored that hint, such as i3wm, won't notice
+any change.
+
 
 * Changes in Emacs 27.1
 
diff --git a/src/emacsgtkfixed.c b/src/emacsgtkfixed.c
index 6b2b4f7018..352883a12f 100644
--- a/src/emacsgtkfixed.c
+++ b/src/emacsgtkfixed.c
@@ -222,8 +222,6 @@ XSetWMSizeHints (Display *d,
   data[6] = hints->min_height;
   data[7] = hints->max_width;
   data[8] = hints->max_height;
-  data[9] = hints->width_inc;
-  data[10] = hints->height_inc;
   data[11] = hints->min_aspect.x;
   data[12] = hints->min_aspect.y;
   data[13] = hints->max_aspect.x;
diff --git a/src/gtkutil.c b/src/gtkutil.c
index dccee15925..88ea38b557 100644
--- a/src/gtkutil.c
+++ b/src/gtkutil.c
@@ -1428,12 +1428,7 @@ x_wm_set_size_hint (struct frame *f, long int flags, bool user_position)
 
   size_hints = f->output_data.x->size_hints;
   hint_flags = f->output_data.x->hint_flags;
-
-  hint_flags |= GDK_HINT_RESIZE_INC | GDK_HINT_MIN_SIZE;
-  size_hints.width_inc = frame_resize_pixelwise ? 1 : FRAME_COLUMN_WIDTH (f);
-  size_hints.height_inc = frame_resize_pixelwise ? 1 : FRAME_LINE_HEIGHT (f);
-
-  hint_flags |= GDK_HINT_BASE_SIZE;
+  hint_flags |= GDK_HINT_MIN_SIZE | GDK_HINT_BASE_SIZE;
   /* Use one row/col here so base_height/width does not become zero.
      Gtk+ and/or Unity on Ubuntu 12.04 can't handle it.
      Obviously this makes the row/col value displayed off by 1.  */
@@ -1486,8 +1481,6 @@ x_wm_set_size_hint (struct frame *f, long int flags, bool user_position)
 
   size_hints.base_width /= scale;
   size_hints.base_height /= scale;
-  size_hints.width_inc /= scale;
-  size_hints.height_inc /= scale;
 
   if (hint_flags != f->output_data.x->hint_flags
       || memcmp (&size_hints,
diff --git a/src/xterm.c b/src/xterm.c
index bc56e99513..cff74e4f22 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -12124,7 +12124,7 @@ x_wm_set_size_hint (struct frame *f, long flags, bool user_position)
 #endif
 
   /* Setting PMaxSize caused various problems.  */
-  size_hints.flags = PResizeInc | PMinSize /* | PMaxSize */;
+  size_hints.flags = PMinSize /* | PMaxSize */;
 
   size_hints.x = f->left_pos;
   size_hints.y = f->top_pos;
@@ -12132,9 +12132,6 @@ x_wm_set_size_hint (struct frame *f, long flags, bool user_position)
   size_hints.width = FRAME_PIXEL_WIDTH (f);
   size_hints.height = FRAME_PIXEL_HEIGHT (f);
 
-  size_hints.width_inc = frame_resize_pixelwise ? 1 : FRAME_COLUMN_WIDTH (f);
-  size_hints.height_inc = frame_resize_pixelwise ? 1 : FRAME_LINE_HEIGHT (f);
-
   size_hints.max_width = x_display_pixel_width (FRAME_DISPLAY_INFO (f))
     - FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f, 0);
   size_hints.max_height = x_display_pixel_height (FRAME_DISPLAY_INFO (f))
-- 
2.22.0