From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#74750: clone-frame and make-frame pixelwise issues Date: Tue, 10 Dec 2024 14:27:25 +0200 Message-ID: <861pyfd8pe.fsf@gnu.org> References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="1187"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 74750@debbugs.gnu.org To: Ship Mints , martin rudalics Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Dec 10 13:30:31 2024 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1tKzNm-0000AU-Nb for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 10 Dec 2024 13:30:31 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tKzNO-00088d-Um; Tue, 10 Dec 2024 07:30:08 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tKzNL-00086i-Kn for bug-gnu-emacs@gnu.org; Tue, 10 Dec 2024 07:30:04 -0500 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tKzNL-0003BR-8i for bug-gnu-emacs@gnu.org; Tue, 10 Dec 2024 07:30:03 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-version:References:In-Reply-To:From:Date:To:Subject; bh=smA9ylQ2DPLGapdu4OSQ/eKBtoovxBdPOcUZz47Y6BQ=; b=pI1c1yIRwM08BKS2T6X6+Xqszm8xG094qkturh1nvz+FvIA8DIhvkqTrs0/T0qeFuWK9pnMfvxhnmVX8jKDSGKUGfzWsaQWZJYdCjbV6Aw6fGR2L/6bby15sbBThrytye4ptLkyvo1J5o8CVIOMB+rUyxVgMHYkGl8EU1OgDcxmDg7u83tzp7aoctWv/NOOGBn5S/lXunOdFQd5SvP5CK4t0F9+djy/dOxiQ1SnCMFga+I4iy2fQ/puC9veqJT1iquVJCy5tPxsaoJSMICNLcAgX02KCk4Eg/33kjx+9jlRbJQbx7WN9Niod7sMvX2/IO1Em4rpFkKQ1Z23tU7ZmzA==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tKzNK-0000nF-SP for bug-gnu-emacs@gnu.org; Tue, 10 Dec 2024 07:30:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 10 Dec 2024 12:30:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 74750 X-GNU-PR-Package: emacs Original-Received: via spool by 74750-submit@debbugs.gnu.org id=B74750.17338337892985 (code B ref 74750); Tue, 10 Dec 2024 12:30:02 +0000 Original-Received: (at 74750) by debbugs.gnu.org; 10 Dec 2024 12:29:49 +0000 Original-Received: from localhost ([127.0.0.1]:57232 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tKzN6-0000m0-QE for submit@debbugs.gnu.org; Tue, 10 Dec 2024 07:29:49 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:33596) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tKzN4-0000lV-LW for 74750@debbugs.gnu.org; Tue, 10 Dec 2024 07:29:47 -0500 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tKzKr-0002oV-L5; Tue, 10 Dec 2024 07:27:29 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From: Date; bh=smA9ylQ2DPLGapdu4OSQ/eKBtoovxBdPOcUZz47Y6BQ=; b=YWXVYDqtPp/glmtcGwyE 186kqgaWMk54Lz6BYgRoKapqEZDKOathWnkNHrQoYTGf1ZfGiQq5WnC0NQVQOqYtbIl7Bdi03VfJz SRfpOSTZPvzV1C/fK1Zd2NKyKxwTFrUUeyFt05uhZmnuU1E0tNkon5GicqUmxFNnX7YZwz5X2qikB cWT7YcctXGRToAV+xQTuYvfvWsnK1rBLv7cIxyeR/IAwJ4Qd8Y3aZWS/6J5udpTVNKesbMhc3FmNw +eZLsQTrQMOBGPxkrPl//9PD4SfMQF5Z+lVvKYvi9jyrnBIhN+K9oM+lDzUBlS2xnWimkmFUjY2wg /NNyQgsXjFe0mg==; In-Reply-To: (message from Ship Mints on Mon, 9 Dec 2024 10:51:23 -0500) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:296745 Archived-At: > From: Ship Mints > Date: Mon, 9 Dec 2024 10:51:23 -0500 > > While trying to reconcile pixelwise frame sizing behaviors, I narrowed down > two related issues. > > 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. > > 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. > > (switch-to-buffer "*Messages*") > (let ((target-text-width 1700) > (target-text-height 1000) > (native-width) > (native-height) > (msg (lambda (s frame) > (message "%s text-width=%d (Δ%d) text-height=%d (Δ%d) > native-width=%d (Δ%d) native-height %d (Δ%d)\n" > s > (frame-text-width frame) (- (frame-text-width frame) > target-text-width) > (frame-text-height frame) (- (frame-text-height > frame) target-text-height) > (frame-native-width frame) (- (frame-native-width > frame) native-width) > (frame-native-height frame) (- (frame-native-height > frame) native-height))))) > (set-frame-position nil 0 0) > (set-frame-size nil target-text-width target-text-height 'pixelwise) > (setq native-width (frame-native-width) > native-height (frame-native-height)) > (message "Targets: text-width=%d text-height=%d\n" target-text-width > target-text-height) > (funcall msg "orig" (selected-frame)) > > (message "clone-frame under frame-resize-pixelwise nil; expectation: use > lines/columns geometry; outcome: met") > (let ((frame-resize-pixelwise nil)) > (let ((new-frame (clone-frame))) > (funcall msg "new" new-frame) > (delete-frame new-frame))) > > (message "clone-frame under frame-resize-pixelwise t; expectation: > pixelwise geometry; outcome: unmet") > (let ((frame-resize-pixelwise t)) > (let ((new-frame (clone-frame))) > (funcall msg "new" new-frame) > (delete-frame new-frame))) > > (message "clone-frame followed by manual resize; expectation: pixelwise > geometry; outcome: met (but two steps)") > (let ((new-frame (clone-frame))) > (set-frame-size new-frame target-text-width target-text-height > 'pixelwise) > (funcall msg "new" new-frame) > (delete-frame new-frame)) > > (message "manual clone under frame-resize-pixelwise using text-pixels; > expectation: pixelwise geometry; outcome: unmet") > ;; code lifted from clone-frame > ;; incorrect width offset seems to be equal to frame-scroll-bar-width > (let* ((frame-resize-pixelwise t) > (frame (selected-frame)) > (no-windows nil) > (windows (unless no-windows > (window-state-get (frame-root-window frame)))) > (default-frame-alist > (seq-remove (lambda (elem) > (memq (car elem) frame-internal-parameters)) > (frame-parameters frame))) > (new-frame)) > (when (and (display-graphic-p frame) frame-resize-pixelwise) > (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 frame) > (select-frame new-frame)) > (funcall msg "new" new-frame) > (delete-frame new-frame))) > > 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) > "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 > PIXELWISE is non-nil or if `frame-resize-pixelwise' is non-nil, and frame > is not text-only, clone the originating frame's pixel size. > > 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 > also select the new frame." > (interactive (list (selected-frame) current-prefix-arg)) > (let* ((frame (or frame (selected-frame))) > (windows (unless no-windows > (window-state-get (frame-root-window frame)))) > (default-frame-alist > (seq-remove (lambda (elem) > (memq (car elem) frame-internal-parameters)) > (frame-parameters frame))) > (new-frame)) > (when (and (display-graphic-p frame) > (or pixelwise frame-resize-pixelwise)) > (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 frame) > (select-frame new-frame)) > new-frame)) Thanks. I hope Martin (CC'ed) will have some useful inputs.