emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 136495f178 2/2: Gently nudge Xt into always setting size hints


From: Po Lu
Subject: master 136495f178 2/2: Gently nudge Xt into always setting size hints
Date: Tue, 30 Aug 2022 22:18:02 -0400 (EDT)

branch: master
commit 136495f178ccd36b23ffc347fe2b6680fd689e34
Author: Po Lu <luangruo@yahoo.com>
Commit: Po Lu <luangruo@yahoo.com>

    Gently nudge Xt into always setting size hints
    
    * src/widget.c (update_wm_hints): Force a resource to change
    every time this function is called.  (bug#57475)
    (EmacsFrameInitialize): Initialize new field.
    * src/widgetprv.h (EmacsFramePart): New field `size_switch'.
    * src/xterm.c (x_wm_set_size_hint): Don't change flags if flags
    is 0.
---
 src/widget.c    | 16 ++++++++++------
 src/widgetprv.h |  2 ++
 src/xterm.c     |  7 +++++--
 3 files changed, 17 insertions(+), 8 deletions(-)

diff --git a/src/widget.c b/src/widget.c
index b125b4caee..5a75cdaca8 100644
--- a/src/widget.c
+++ b/src/widget.c
@@ -292,18 +292,20 @@ update_wm_hints (Widget wmshell, EmacsFrame ew)
   base_height = (wmshell->core.height - ew->core.height
                 + (rounded_height - (char_height * ch)));
 
-  /* This is kind of sleazy, but I can't see how else to tell it to
-     make it mark the WM_SIZE_HINTS size as user specified.
-   */
-/*  ((WMShellWidget) wmshell)->wm.size_hints.flags |= USSize;*/
+  /* Ensure that Xt actually sets window manager hint flags specified
+     by the caller by making sure XtNminWidth (a relatively harmless
+     resource) always changes each time this function is invoked.  */
+  ew->emacs_frame.size_switch = !ew->emacs_frame.size_switch;
 
   XtVaSetValues (wmshell,
                 XtNbaseWidth, (XtArgVal) base_width,
                 XtNbaseHeight, (XtArgVal) base_height,
                 XtNwidthInc, (XtArgVal) (frame_resize_pixelwise ? 1 : cw),
                 XtNheightInc, (XtArgVal) (frame_resize_pixelwise ? 1 : ch),
-                XtNminWidth, (XtArgVal) base_width,
-                XtNminHeight, (XtArgVal) base_height,
+                XtNminWidth, (XtArgVal) (base_width
+                                         + ew->emacs_frame.size_switch),
+                XtNminHeight, (XtArgVal) (base_height
+                                          + ew->emacs_frame.size_switch),
                 NULL);
 }
 
@@ -355,6 +357,8 @@ EmacsFrameInitialize (Widget request, Widget new,
       exit (1);
     }
 
+  ew->emacs_frame.size_switch = 1;
+
   update_from_various_frame_slots (ew);
   set_frame_size (ew);
 }
diff --git a/src/widgetprv.h b/src/widgetprv.h
index 960f814e16..fe960326b0 100644
--- a/src/widgetprv.h
+++ b/src/widgetprv.h
@@ -49,6 +49,8 @@ typedef struct {
 
   Boolean      visual_bell;            /* flash instead of beep */
   int          bell_volume;            /* how loud is beep */
+  int          size_switch;            /* hack to make setting size
+                                          hints work correctly */
 
   /* private state */
 
diff --git a/src/xterm.c b/src/xterm.c
index 3c05bc7807..e8c56d68ea 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -27484,8 +27484,11 @@ x_wm_set_size_hint (struct frame *f, long flags, bool 
user_position)
       eassert (XtIsWMShell (f->output_data.x->widget));
       shell = (WMShellWidget) f->output_data.x->widget;
 
-      shell->wm.size_hints.flags &= ~(PPosition | USPosition);
-      shell->wm.size_hints.flags |= flags & (PPosition | USPosition);
+      if (flags)
+       {
+         shell->wm.size_hints.flags &= ~(PPosition | USPosition);
+         shell->wm.size_hints.flags |= flags & (PPosition | USPosition);
+       }
 
       if (user_position)
        {



reply via email to

[Prev in Thread] Current Thread [Next in Thread]