Permalink
Browse files

Merge in Joseph Yen's frame parameter changes.

  • Loading branch information...
2 parents 9b0cfab + 8294790 commit 87032ba05b615bd7b2b6fc04b2e8ab479f7f4835 @caldwell caldwell committed Nov 9, 2010
Showing with 37 additions and 33 deletions.
  1. +37 −33 maxframe.el
View
@@ -139,53 +139,57 @@ specified by HEIGHT."
(min (display-pixel-height)
(or mf-max-height (display-pixel-height))))
-(defun x-maximize-frame ()
+(defun x-maximize-frame (&optional the-frame)
"Maximize the current frame (x or mac only)"
(interactive)
- (unless (or (frame-parameter nil 'mf-restore-width)
- (frame-parameter nil 'mf-restore-height)
- (frame-parameter nil 'mf-restore-top)
- (frame-parameter nil 'mf-restore-left))
- (set-frame-parameter (selected-frame) 'mf-restore-width (frame-width))
- (set-frame-parameter (selected-frame) 'mf-restore-height (frame-height))
- (set-frame-parameter (selected-frame) 'mf-restore-top (frame-parameter nil 'top))
- (set-frame-parameter (selected-frame) 'mf-restore-left (frame-parameter nil 'left)))
- (set-frame-parameter (selected-frame) 'mf-maximized t)
- (mf-set-frame-pixel-size (selected-frame)
- (mf-max-display-pixel-width)
- (mf-max-display-pixel-height))
- (set-frame-position (selected-frame) mf-offset-x mf-offset-y))
-
-(defun x-restore-frame ()
+ (let ((target-frame
+ (if the-frame the-frame (selected-frame))))
+ (unless (or (frame-parameter target-frame 'mf-restore-width)
+ (frame-parameter target-frame 'mf-restore-height)
+ (frame-parameter target-frame 'mf-restore-top)
+ (frame-parameter target-frame 'mf-restore-left))
+ (set-frame-parameter target-frame 'mf-restore-width (frame-width))
+ (set-frame-parameter target-frame 'mf-restore-height (frame-height))
+ (set-frame-parameter target-frame 'mf-restore-top (frame-parameter nil 'top))
+ (set-frame-parameter target-frame 'mf-restore-left (frame-parameter nil 'left)))
+ (set-frame-parameter target-frame 'mf-maximized t)
+ (mf-set-frame-pixel-size target-frame
+ (mf-max-display-pixel-width)
+ (mf-max-display-pixel-height))
+ (set-frame-position target-frame mf-offset-x mf-offset-y)))
+
+(defun x-restore-frame (&optional the-frame)
"Restore the current frame (x or mac only)"
(interactive)
- (let ((mf-restore-width (frame-parameter nil 'mf-restore-width))
- (mf-restore-height (frame-parameter nil 'mf-restore-height))
- (mf-restore-top (frame-parameter nil 'mf-restore-top))
- (mf-restore-left (frame-parameter nil 'mf-restore-left)))
- (when (and mf-restore-width mf-restore-height mf-restore-top mf-restore-left)
- (set-frame-size (selected-frame) mf-restore-width mf-restore-height)
- (set-frame-position (selected-frame)
- (if (consp mf-restore-left) 0 mf-restore-left)
+ (let ((target-frame
+ (if the-frame the-frame (selected-frame))))
+ (let ((mf-restore-width (frame-parameter target-frame 'mf-restore-width))
+ (mf-restore-height (frame-parameter target-frame 'mf-restore-height))
+ (mf-restore-top (frame-parameter target-frame 'mf-restore-top))
+ (mf-restore-left (frame-parameter target-frame 'mf-restore-left)))
+ (when (and mf-restore-width mf-restore-height mf-restore-top mf-restore-left)
+ (set-frame-size target-frame mf-restore-width mf-restore-height)
+ (set-frame-position target-frame
+ (if (consp mf-restore-left) 0 mf-restore-left)
mf-restore-top))
- (set-frame-parameter (selected-frame) 'mf-maximized nil)
- (set-frame-parameter (selected-frame) 'mf-restore-width nil)
- (set-frame-parameter (selected-frame) 'mf-restore-height nil)
- (set-frame-parameter (selected-frame) 'mf-restore-top nil)
- (set-frame-parameter (selected-frame) 'mf-restore-left nil)))
+ (set-frame-parameter target-frame 'mf-maximized nil)
+ (set-frame-parameter target-frame 'mf-restore-width nil)
+ (set-frame-parameter target-frame 'mf-restore-height nil)
+ (set-frame-parameter target-frame 'mf-restore-top nil)
+ (set-frame-parameter target-frame 'mf-restore-left nil))))
-(defun maximize-frame ()
+(defun maximize-frame ( &optional the-frame)
"Maximizes the frame to fit the display if under a windowing
system."
(interactive)
(cond ((eq window-system 'w32) (w32-maximize-frame))
- ((memq window-system '(x mac ns)) (x-maximize-frame))))
+ ((memq window-system '(x mac ns)) (x-maximize-frame the-frame))))
-(defun restore-frame ()
+(defun restore-frame ( &optional the-frame)
"Restores a maximized frame. See `maximize-frame'."
(interactive)
(cond ((eq window-system 'w32) (w32-restore-frame))
- ((memq window-system '(x mac ns)) (x-restore-frame))))
+ ((memq window-system '(x mac ns)) (x-restore-frame the-frame))))
(defalias 'mf 'maximize-frame)

0 comments on commit 87032ba

Please sign in to comment.