Subject: Re: bug#76275: 31.0.50; frame-inhibit-implied-resize broken on recent master

From: martin rudalics <[email-masked]>
Date: Tue, 18 Feb 2025 11:08:38 +0100

> It does fix the resizing problem.  However, now my entry in
 > window-size-change-functions doesn't run at all, and so the font size in
 > the new frame is wrong.
 >
 > I'm not sure whether this is a bug, but it might count as a change that
 > should be called out in NEWS?  window-size-change-functions is no longer
 > guaranteed to be called when frames are simply created.

The reason why I have to delay applying 'frame-inhibit-implied-resize'
in "normal" use is that people want the number of lines and columns
shown by the window manager when they drag frame borders with the mouse
match exactly the values specified in 'initial-frame-alist'.  OTOH, one
reason for implementing 'frame-inhibit-implied-resize' was to make using
Emacs with tiling WMs simpler.  Hence instead of all the tribulations
with running spw/scale-default from 'window-size-change-functions' we
should be able to find a better solution.

With the patch attached would

(defun spw/sway-completing-read (prompt collection &rest optional-args)
   (let* ((frame-inhibit-implied-resize 'force)
	 (frame (make-frame `((title . "Emacs Sway input")
			      (minibuffer . only)
			      (display . ,(getenv "WAYLAND_DISPLAY"))))))

     (set-face-attribute 'default frame :height 120)

     (unwind-protect
	(with-selected-frame frame
	  (set-window-scroll-bars (minibuffer-window frame) 0 nil 0 nil t)
	  (apply #'completing-read prompt collection optional-args))
       (delete-frame frame))))

do what you want?

 > I'm not sure what you mean "while the function with the same name
 > returned false" -- there isn't a function called
 > frame_inhibit_implied_resize, I think?

Right.  I meant the function frame_inhibit_resize.

martin

diff --git a/lisp/cus-start.el b/lisp/cus-start.el
index 5d35edd212b..637f9c92fcd 100644
--- a/lisp/cus-start.el
+++ b/lisp/cus-start.el
@@ -347,6 +347,7 @@ minibuffer-prompt-properties--setter
 					   (choice
 					    (const :tag "Never" nil)
 					    (const :tag "Always" t)
+					    (const :tag "Force" force)
 					    (repeat (symbol :tag "Parameter")))
 					   "27.1")
 	     (iconify-child-frame frames
diff --git a/src/frame.c b/src/frame.c
index 2ccdec6fc41..e5b251cb2c5 100644
--- a/src/frame.c
+++ b/src/frame.c
@@ -181,18 +181,19 @@ frame_inhibit_resize (struct frame *f, bool horizontal, Lisp_Object parameter)
 {
   Lisp_Object fullscreen = get_frame_param (f, Qfullscreen);
 
-  return (f->after_make_frame
+  return (EQ (frame_inhibit_implied_resize, Qforce)
+	  || (f->after_make_frame
 #ifdef USE_GTK
-	  && f->tool_bar_resized
+	      && f->tool_bar_resized
 #endif
-	  && (EQ (frame_inhibit_implied_resize, Qt)
-	      || (CONSP (frame_inhibit_implied_resize)
-		  && !NILP (Fmemq (parameter, frame_inhibit_implied_resize)))
-	      || (horizontal
-		  && !NILP (fullscreen) && !EQ (fullscreen, Qfullheight))
-	      || (!horizontal
-		  && !NILP (fullscreen) && !EQ (fullscreen, Qfullwidth))
-	      || FRAME_TERMCAP_P (f) || FRAME_MSDOS_P (f)));
+	      && (EQ (frame_inhibit_implied_resize, Qt)
+		  || (CONSP (frame_inhibit_implied_resize)
+		      && !NILP (Fmemq (parameter, frame_inhibit_implied_resize)))
+		  || (horizontal
+		      && !NILP (fullscreen) && !EQ (fullscreen, Qfullheight))
+		  || (!horizontal
+		      && !NILP (fullscreen) && !EQ (fullscreen, Qfullwidth))
+		  || FRAME_TERMCAP_P (f) || FRAME_MSDOS_P (f))));
 }

@@ -6849,6 +6850,7 @@ syms_of_frame (void)
   DEFSYM (Qmake_invisible, "make-invisible");
   DEFSYM (Quse_frame_synchronization, "use-frame-synchronization");
   DEFSYM (Qfont_parameter, "font-parameter");
+  DEFSYM (Qforce, "force");
 
   for (int i = 0; i < ARRAYELTS (frame_parms); i++)
     {