]> git.eshelyaron.com Git - emacs.git/commitdiff
Support pixelwise frame cloning (Bug#74750)
authorShip Mints <shipmints@gmail.com>
Mon, 16 Dec 2024 16:58:10 +0000 (17:58 +0100)
committerEshel Yaron <me@eshelyaron.com>
Mon, 23 Dec 2024 15:01:41 +0000 (16:01 +0100)
* lisp/frame.el (clone-frame): Honor 'frame-resize-pixelwise'
when cloning a frame's geometry via the 'text-pixels' feature of
'make-frame' (Bug#74750).  Correctly specify source frame in
'display-graphic-p' test for tty selection behavior.

(cherry picked from commit 61f1d7fc682c28b3e67a9d8f529ff7046dfdbff1)

lisp/frame.el

index 69ddd28c7de09bc0d8e9a36da67c30285cba81c9..092f93bf9413a9f1af75350d31f01e2ab3aa115d 100644 (file)
@@ -863,6 +863,9 @@ When called from Lisp, returns the new frame."
 (defun clone-frame (&optional frame no-windows)
   "Make a new frame with the same parameters and windows as FRAME.
 With a prefix arg NO-WINDOWS, don't clone the window configuration.
+When the user option `frame-resize-pixelwise' is non-nil, and FRAME is
+not text-only, clone the originating frame's pixel size.  Otherwise, use
+the number of FRAME's columns and lines for the clone.
 
 FRAME defaults to the selected frame.  The frame is created on the
 same terminal as FRAME.  If the terminal is a text-only terminal then
@@ -875,10 +878,17 @@ also select the new frame."
           (seq-remove (lambda (elem)
                         (memq (car elem) frame-internal-parameters))
                       (frame-parameters frame)))
-         (new-frame (make-frame)))
+         new-frame)
+    (when (and frame-resize-pixelwise
+               (display-graphic-p frame))
+      (push (cons 'width (cons 'text-pixels (frame-text-width frame)))
+            default-frame-alist)
+      (push (cons 'height (cons 'text-pixels (frame-text-height frame)))
+            default-frame-alist))
+    (setq new-frame (make-frame))
     (when windows
       (window-state-put windows (frame-root-window new-frame) 'safe))
-    (unless (display-graphic-p)
+    (unless (display-graphic-p frame)
       (select-frame new-frame))
     new-frame))