Allow desktop to restore frames and windows on TTY frames
* lisp/frameset.el (frameset-persistent-filter-alist): Add 'top', 'left', 'bottom', and 'right' to frame parameters that are shelved and unshelved when switching from GUI to TTY frames and vice versa. (frameset--restore-frame): Accept two optional arguments DX and DY, and offset by them each frame restored from TTY desktop, to make such restored frames more prominently visible. Force such frames to be visible on GUI display, since the visibility parameter is meaningless for TTY frames. (frameset-restore): Pass DX and DY offsets to 'frameset--restore-frame', when restoring TTY frames on GUI display. * lisp/desktop.el (desktop-restore-frameset): Pass the :force-onscreen argument of 'frameset-restore' as nil when restoring frames on text-mode display. (desktop-restore-forces-onscreen): Document that this option has no real effect on restoring frames on text-mode display. (desktop-restoring-frameset-p): Allow restoring frames in non-GUI sessions, but disallow that when the selected frame is the daemon's initial frame. (Bug#55070)
This commit is contained in:
parent
a3a7279a4a
commit
39fb555a95
2 changed files with 38 additions and 6 deletions
|
@ -434,7 +434,9 @@ If `all', also restores frames that are partially offscreen onscreen.
|
|||
Note that checking of frame boundaries is only approximate.
|
||||
It can fail to reliably detect frames whose onscreen/offscreen state
|
||||
depends on a few pixels, especially near the right / bottom borders
|
||||
of the screen."
|
||||
of the screen.
|
||||
Text-mode frames are always considered onscreen, so this option has
|
||||
no effect on restoring frames in a non-GUI session."
|
||||
:type '(choice (const :tag "Only fully offscreen frames" t)
|
||||
(const :tag "Also partially offscreen frames" all)
|
||||
(const :tag "Do not force frames onscreen" nil))
|
||||
|
@ -1251,7 +1253,11 @@ This function also sets `desktop-dirname' to nil."
|
|||
;; ----------------------------------------------------------------------------
|
||||
(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 desktop-restore-frames desktop-saved-frameset
|
||||
;; Don't restore frames when the selected frame is the daemon's
|
||||
;; initial frame.
|
||||
(not (and (daemonp) (not (frame-parameter nil 'client))))
|
||||
t))
|
||||
|
||||
(defun desktop-restore-frameset ()
|
||||
"Restore the state of a set of frames.
|
||||
|
@ -1262,7 +1268,8 @@ being set (usually, by reading it from the desktop)."
|
|||
:reuse-frames (eq desktop-restore-reuses-frames t)
|
||||
:cleanup-frames (not (eq desktop-restore-reuses-frames 'keep))
|
||||
:force-display desktop-restore-in-current-display
|
||||
:force-onscreen desktop-restore-forces-onscreen)))
|
||||
:force-onscreen (and desktop-restore-forces-onscreen
|
||||
(display-graphic-p)))))
|
||||
|
||||
;; Just to silence the byte compiler.
|
||||
;; Dynamically bound in `desktop-read'.
|
||||
|
|
|
@ -448,6 +448,7 @@ DO NOT MODIFY. See `frameset-filter-alist' for a full description.")
|
|||
(defvar frameset-persistent-filter-alist
|
||||
(append
|
||||
'((background-color . frameset-filter-sanitize-color)
|
||||
(bottom . frameset-filter-shelve-param)
|
||||
(buffer-list . :never)
|
||||
(buffer-predicate . :never)
|
||||
(buried-buffer-list . :never)
|
||||
|
@ -464,13 +465,20 @@ DO NOT MODIFY. See `frameset-filter-alist' for a full description.")
|
|||
(frameset--text-pixel-height . :save)
|
||||
(frameset--text-pixel-width . :save)
|
||||
(fullscreen . frameset-filter-shelve-param)
|
||||
(GUI:bottom . frameset-filter-unshelve-param)
|
||||
(GUI:font . frameset-filter-unshelve-param)
|
||||
(GUI:fullscreen . frameset-filter-unshelve-param)
|
||||
(GUI:height . frameset-filter-unshelve-param)
|
||||
(GUI:left . frameset-filter-unshelve-param)
|
||||
(GUI:right . frameset-filter-unshelve-param)
|
||||
(GUI:top . frameset-filter-unshelve-param)
|
||||
(GUI:width . frameset-filter-unshelve-param)
|
||||
(height . frameset-filter-shelve-param)
|
||||
(left . frameset-filter-shelve-param)
|
||||
(parent-frame . :never)
|
||||
(mouse-wheel-frame . :never)
|
||||
(right . frameset-filter-shelve-param)
|
||||
(top . frameset-filter-shelve-param)
|
||||
(tty . frameset-filter-tty-to-GUI)
|
||||
(tty-type . frameset-filter-tty-to-GUI)
|
||||
(width . frameset-filter-shelve-param)
|
||||
|
@ -1010,13 +1018,15 @@ not be changed once the frame has been created. Internal use only."
|
|||
(cl-loop for param in '(left top width height border-width minibuffer)
|
||||
when (assq param parameters) collect it))
|
||||
|
||||
(defun frameset--restore-frame (parameters window-state filters force-onscreen)
|
||||
(defun frameset--restore-frame (parameters window-state filters force-onscreen
|
||||
&optional dx dy)
|
||||
"Set up and return a frame according to its saved state.
|
||||
That means either reusing an existing frame or creating one anew.
|
||||
PARAMETERS is the frame's parameter alist; WINDOW-STATE is its window state.
|
||||
For the meaning of FILTERS and FORCE-ONSCREEN, see `frameset-restore'.
|
||||
Internal use only."
|
||||
(let* ((fullscreen (cdr (assq 'fullscreen parameters)))
|
||||
(tty-to-GUI (frameset-switch-to-gui-p parameters))
|
||||
(filtered-cfg (frameset-filter-params parameters filters nil))
|
||||
(display (cdr (assq 'display filtered-cfg))) ;; post-filtering
|
||||
alt-cfg frame)
|
||||
|
@ -1093,6 +1103,14 @@ Internal use only."
|
|||
(not (eq (frame-parameter frame 'visibility) 'icon)))
|
||||
(frameset-move-onscreen frame force-onscreen))
|
||||
|
||||
;; Frames saved on TTY shall be all considered visible when
|
||||
;; restoring on GUI display. Also, offset each new such frame
|
||||
;; relative to the previous one, to make it more visible.
|
||||
(when tty-to-GUI
|
||||
(push '(visibility . t) alt-cfg)
|
||||
(when (and (numberp dx) (numberp dy))
|
||||
(push (cons 'left (+ (frame-parameter frame 'left) dx)) alt-cfg)
|
||||
(push (cons 'top (+ (frame-parameter frame 'top) dy)) alt-cfg)))
|
||||
;; Let's give the finishing touches (visibility, maximization).
|
||||
(when alt-cfg (modify-frame-parameters frame alt-cfg))
|
||||
;; Now restore window state.
|
||||
|
@ -1216,7 +1234,9 @@ All keyword parameters default to nil."
|
|||
((pred functionp)
|
||||
(cl-remove-if-not reuse-frames frames))
|
||||
(_
|
||||
(error "Invalid arg :reuse-frames %s" reuse-frames)))))
|
||||
(error "Invalid arg :reuse-frames %s" reuse-frames))))
|
||||
(dx 0)
|
||||
(dy 0))
|
||||
|
||||
;; Mark existing frames in the map; candidates to reuse are marked as :ignored;
|
||||
;; they will be reassigned later, if chosen.
|
||||
|
@ -1289,11 +1309,16 @@ All keyword parameters default to nil."
|
|||
(setq mb-window nil)))
|
||||
(when mb-window
|
||||
(push (cons 'minibuffer mb-window) frame-cfg))))))
|
||||
(when (frameset-switch-to-gui-p frame-cfg)
|
||||
;; Apply small offsets to each frame, so that they
|
||||
;; don't obscure each other.
|
||||
(setq dx (+ dx 20)
|
||||
dy (+ dy 10)))
|
||||
;; OK, we're ready at last to create (or reuse) a frame and
|
||||
;; restore the window config.
|
||||
(setq frame (frameset--restore-frame frame-cfg window-cfg
|
||||
(or filters frameset-filter-alist)
|
||||
force-onscreen))
|
||||
force-onscreen dx dy))
|
||||
;; Now reset any duplicate frameset--id
|
||||
(when (and duplicate (not (eq frame duplicate)))
|
||||
(set-frame-parameter duplicate 'frameset--id nil))
|
||||
|
|
Loading…
Add table
Reference in a new issue