Subject: bug#74750: clone-frame and make-frame pixelwise issues

From: martin rudalics <[email-masked]>
Date: Tue, 10 Dec 2024 16:56:22 +0100

>> clone-frame does not correctly clone frames on a pixelwise basis.
 >>
 >> make-frame's text-pixels geometry support does not produce specified
 >> pixelwise geometry. This also impacts frameset-restore's ability to
 >> precisely reproduce pixelwise frame sizes.

This would be a bug in frameset.el.  One problem I see is that
'frame-resize-pixelwise' must be set "very early" when restoring a
session - at least _before_ the first time we send size hints to the
window manager.

 >> I consider these to be related as clone-frame's use of make-frame could be
 >> using text-pixels but if that doesn't work then pixelwise cloning won't
 >> work. I did read through the code base as best as I could but could not
 >> find the source of the text-pixels issue.
 >>
 >> The following reproducer, under -Q, shows the same results on 29.4 and
 >> 30.0.92. My main platform is NS and I also did some testing on GTK. GTK's
 >> issues seem a bit "messier" and I didn't spend any time trying to
 >> understand them in depth as I was more interested to know if GTK worked
 >> correctly or not, which it doesn't.

Your code binds 'frame-resize-pixelwise' temporarily.  This cannot work
reliably.  That variable should never change in an Emacs session because
its value affects the way we send size hint increments to the window
manager.

This is, admittedly, a design error that would have to be fixed as
follows:

- Implement a new frame parameter 'resize-pixelwise'.

- Send size hints according to the value of this parameter.  When the
   parameter is set, new size hints must be sent.

Alternatively, we could send new size hints for all live frames whenever
'frame-resize-pixelwise' is changed.  This would have to be done with a
variable watcher.  Still, let-binding this variable would confuse the
hell out of our interactions with the window manager.  When the scope of
the let-binding is left, we would have to send size hints again.

 >> This is an implementation of clone-frame that uses text-pixels under
 >> make-frame. This depends on make-frame text-pixels being corrected. Happy
 >> to supply this as a patch should the discussion of these issues progress in
 >> that direction.
 >>
 >> (defun clone-frame (&optional frame no-windows pixelwise)

What would the WM do in a situation where PIXELWISE is non-nil and
'frame-resize-pixelwise' is nil?

martin