From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.bugs Subject: bug#55070: 28.1; desktop-load doesn't work in -nw (non-gui) emacs Date: Tue, 26 Apr 2022 18:28:18 +0300 Organization: LINKOV.NET Message-ID: <86h76fu9q5.fsf@mail.linkov.net> References: <83fsm4pbs4.fsf@gnu.org> <6961B895-263C-4632-AA4E-8DE29D6160BC@swenson.org> <83sfq3op15.fsf@gnu.org> <86wnfcxnvf.fsf@mail.linkov.net> <87mtg8i1za.fsf@gnus.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="35094"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (x86_64-pc-linux-gnu) Cc: Eric Swenson , 55070@debbugs.gnu.org To: Lars Ingebrigtsen Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Apr 26 17:56:10 2022 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 1njNXu-00090i-6x for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 26 Apr 2022 17:56:10 +0200 Original-Received: from localhost ([::1]:43886 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1njNXt-0006Cc-2l for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 26 Apr 2022 11:56:09 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:35728) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1njNVq-0004fO-P1 for bug-gnu-emacs@gnu.org; Tue, 26 Apr 2022 11:54:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:46436) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1njNVq-0005un-Gv for bug-gnu-emacs@gnu.org; Tue, 26 Apr 2022 11:54:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1njNVq-0000lE-Gf for bug-gnu-emacs@gnu.org; Tue, 26 Apr 2022 11:54:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 26 Apr 2022 15:54:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 55070 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: moreinfo Original-Received: via spool by 55070-submit@debbugs.gnu.org id=B55070.16509884352892 (code B ref 55070); Tue, 26 Apr 2022 15:54:02 +0000 Original-Received: (at 55070) by debbugs.gnu.org; 26 Apr 2022 15:53:55 +0000 Original-Received: from localhost ([127.0.0.1]:40331 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1njNVj-0000ka-1f for submit@debbugs.gnu.org; Tue, 26 Apr 2022 11:53:55 -0400 Original-Received: from relay6-d.mail.gandi.net ([217.70.183.198]:36125) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1njNVh-0000kA-EJ for 55070@debbugs.gnu.org; Tue, 26 Apr 2022 11:53:53 -0400 Original-Received: (Authenticated sender: juri@linkov.net) by mail.gandi.net (Postfix) with ESMTPSA id 0A588C0003; Tue, 26 Apr 2022 15:53:45 +0000 (UTC) In-Reply-To: <87mtg8i1za.fsf@gnus.org> (Lars Ingebrigtsen's message of "Tue, 26 Apr 2022 12:16:25 +0200") 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" Xref: news.gmane.io gmane.emacs.bugs:230738 Archived-At: --=-=-= Content-Type: text/plain > I think the reason for disabling restoring frames on -nw wasn't because > of technical reasons, but because of most users not being aware that an > -nw Emacs can have frames, so they ended up with very confusing setups > after restoring from desktop. > > But this is an issue that's come up again and again, so I think we > should introduce a new user option to allow desktop to restore frames on > -nw. (And that means that we should also apply your patch, I think?) Indeed, this is what an old comment in desktop.el used to say: ;; People don't expect emacs -nw, or --daemon, ;; to create graphical frames (bug#17693). ;; TODO perhaps there should be a separate value ;; for desktop-restore-frames to control this startup behavior? So this patch creates such separate values: --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=desktop-restore-frames.patch diff --git a/lisp/desktop.el b/lisp/desktop.el index cd581e028b..b46c41e0e4 100644 --- a/lisp/desktop.el +++ b/lisp/desktop.el @@ -412,7 +412,10 @@ desktop-restore-frames "When non-nil, save and restore the frame and window configuration. See related options `desktop-restore-reuses-frames', `desktop-restore-in-current-display', and `desktop-restore-forces-onscreen'." - :type 'boolean + :type '(choice (const :tag "Don't restore frames" nil) + (const :tag "Restore frames" t) + (const :tag "Restore only graphical frames" x) + (const :tag "Restore only -nw frames" tty)) :group 'desktop :version "24.4") @@ -1245,7 +1248,13 @@ desktop-lazy-timer ;; ---------------------------------------------------------------------------- (defun desktop-restoring-frameset-p () "True if calling `desktop-restore-frameset' will actually restore it." - (and desktop-restore-frames desktop-saved-frameset (display-graphic-p) t)) + (and (pcase desktop-restore-frames + ('x (display-graphic-p)) + ('tty (not (display-graphic-p))) + ('nil nil) + (_ t)) + desktop-saved-frameset + t)) (defun desktop-restore-frameset () "Restore the state of a set of frames. diff --git a/lisp/frameset.el b/lisp/frameset.el index 05884eed3a..32966376d8 100644 --- a/lisp/frameset.el +++ b/lisp/frameset.el @@ -883,8 +883,8 @@ frameset-move-onscreen (pcase-let* ((`(,left ,top ,width ,height) (cdadr (frame-monitor-attributes frame))) (right (+ left width -1)) (bottom (+ top height -1)) - (fr-left (frameset-compute-pos (frame-parameter frame 'left) left right)) - (fr-top (frameset-compute-pos (frame-parameter frame 'top) top bottom)) + (fr-left (frameset-compute-pos (or (frame-parameter frame 'left) 0) left right)) + (fr-top (frameset-compute-pos (or (frame-parameter frame 'top) 0) top bottom)) (ch-width (frame-char-width frame)) (ch-height (frame-char-height frame)) (fr-width (max (frame-pixel-width frame) (* ch-width (frame-width frame)))) --=-=-=--