Changeset - ff723e73522e
[Not reviewed]
0 1 0
Sergey Pashinin - 11 years ago 2014-08-23 09:51:55
sergey@pashinin.com
restore maximized frame
1 file changed with 8 insertions and 4 deletions:
0 comments (0 inline, 0 general)
src/workgroups-wconfig.el
Show inline comments
 
@@ -177,63 +177,67 @@ ignored.
 
(defun wg-restore-frames ()
 
  "Try to recreate opened frames, take info from session's 'frame-list parameter."
 
  (interactive)
 
  (delete-other-frames)
 
  (when (wg-current-session t)
 
    (let ((fl (wg-session-parameter (wg-current-session t) 'frame-list nil))
 
          (frame (selected-frame)))
 
      (mapc (lambda (wconfig)
 
              (with-selected-frame (make-frame)
 
                ;;(wg-frame-resize-and-position wconfig)
 
                ;;(wg-restore-frame-size-position wconfig)
 
                ;;(wg-wconfig-restore-frame-position wconfig)
 
                (wg-restore-wconfig wconfig)
 
                )) fl)
 
      (select-frame-set-input-focus frame))))
 

	
 
;; FIXME: throw a specific error if the restoration was unsuccessful
 
(defun wg-restore-wconfig (wconfig &optional frame)
 
  "Restore a workgroup configuration WCONFIG in a FRAME.
 
Runs each time you're switching workgroups."
 
  (unless frame (setq frame (selected-frame)))
 
  (let ((wg-record-incorrectly-restored-bufs t)
 
        (wg-incorrectly-restored-bufs nil)
 
        (params (wg-wconfig-parameters wconfig))
 
        fullscreen wtree)
 
        fullscreen)
 
    (wg-barf-on-active-minibuffer)
 
    (when wg-restore-scroll-bars
 
      (wg-wconfig-restore-scroll-bars wconfig))
 

	
 
    ;; Restore buffers
 
    (wg-restore-window-tree
 
     (wg-scale-wconfig-to-frame wconfig))
 
    (when (null (wg-current-workgroup t))
 
      (set-frame-parameter frame 'fullscreen (if (assoc 'fullscreen params)
 
                                                 (cdr (assoc 'fullscreen params))
 
                                               nil)))
 

	
 
    ;; Restore frame position
 
    (when (and wg-restore-frame-position
 
               (not (frame-parameter nil 'fullscreen))
 
               (null (wg-current-workgroup t)))
 
      (wg-wconfig-restore-frame-position wconfig frame))
 

	
 
    ;; Restore buffers
 
    (wg-restore-window-tree (wg-scale-wconfig-to-frame wconfig))
 

	
 
    (when wg-incorrectly-restored-bufs
 
      (message "Unable to restore these buffers: %S\
 
If you want, restore them manually and try again."
 
               (mapcar 'wg-buf-name wg-incorrectly-restored-bufs)))))
 

	
 

	
 
;;; saved wconfig commands
 

	
 
(defun wg-save-wconfig ()
 
  "Save the current wconfig to the current workgroup's saved wconfigs."
 
  (interactive)
 
  (let* ((workgroup (wg-current-workgroup))
 
         (name (wg-read-saved-wconfig-name workgroup))
 
         (wconfig (wg-current-wconfig)))
 
    (setf (wg-wconfig-name wconfig) name)
 
    (wg-workgroup-save-wconfig workgroup wconfig)
 
    (wg-fontified-message
 
      (:cmd "Saved: ")
 
      (:cur name))))
 

	
 
(defun wg-restore-saved-wconfig ()
 
  "Restore one of the current workgroup's saved wconfigs in `selected-frame'."
 
  (interactive)
 
  (let ((workgroup (wg-current-workgroup)))
0 comments (0 inline, 0 general)