emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: How to restore the layout?


From: Drew Adams
Subject: RE: How to restore the layout?
Date: Sat, 29 Jun 2013 16:48:36 -0700 (PDT)

> > Moving the frame outside the current display is an issue; it would be
> > nice if the restore could detect that, and keep the frames in view.
> 
> How can I do that? Is there any way to get from Emacs the maximum
> dimensions of a frame in the current display, other than
> 
> (let ((frame (make-frame '((fullscreen . maximized)))))
>   (prog1
>       (cons (frame-width frame) (frame-height frame))
>     (delete-frame frame)))
> 
> which has the downside of being noticeable to the user?

Dunno whether it helps, but this is what I do in frame-cmds.el,
to determine the screen space available for positioning and
resizing frames, e.g., for moving them about or tiling them.

1. Provide a user option, `available-screen-pixel-bounds', which
defaults to nil and otherwise is a list of the pixel coordinates
of the upper left and the lower right corners of the available
screen space, measured from screen absolute origin, (0, 0), at
the upper left.

For example,  (x0 y0 x1 y1), where (x0, y0) is the upper left
position and (x1, y1) is the lower right position.

2. If the option is nil then the available space is calculated
by the function with the same name.  It tries to return the
currently available screen area.  The option is available to
let you declare some known outside area off limits (e.g., the MS
Windows task bar).

(defun available-screen-pixel-bounds ()
  (or available-screen-pixel-bounds
      (if (fboundp 'mac-display-available-pixel-bounds) ; Mac-OS
          (mac-display-available-pixel-bounds)
        (list 0 0 (x-display-pixel-width)
                  (x-display-pixel-height)))))

3. Function `effective-screen-pixel-bounds' starts with
`available-screen-pixel-bounds' and removes the space used by
the standalone minibuffer frame of oneonone.el:

(defun effective-screen-pixel-bounds ()
  (if (boundp '1on1-minibuffer-frame)
      (append
       (butlast (available-screen-pixel-bounds))
       (list
        (frame-geom-value-numeric
         'top (cdr (assq 'top (frame-parameters
                               1on1-minibuffer-frame))))))
    (available-screen-pixel-bounds)))

[`frame-geom-value-numeric' returns a numeric value (pixels)
 that is equivalent to a frame geometry spec.  Examples: 

  Assuming display height/width=1024, frame height/width=600:
  300 inside display edge:                   300  =>  300
                                         (+  300) =>  300
  300 inside opposite display edge:      (-  300) => -300
                                            -300  => -300
  300 beyond display edge
   (= 724 inside opposite display edge): (+ -300) => -724
  300 beyond display edge
   (= 724 inside opposite display edge): (- -300) =>  724

 In the last two examples, the returned value is relative to the
 opposite frame edge from the edge indicated in the input spec.]

Again, dunno whether such an approach helps you.  It is based on
`x-display-pixel-(width|height)'.  Whether that helps when using
multiple monitors etc., I'm not sure.  The idea of letting users
override an available-space calculation might be something to
consider, at least.

4. In the same library, frame-cmds.el, I have commands that
move a frame incrementally up/down/left/right.  You can easily
move a frame off the display that way, so you no longer see it.
Or you can move it back onto the display, if off.

There is a user option, `move-frame-wrap-within-display-flag',
that determines whether continuing to move a frame in some
direction brings it back around from the opposite screen border,
i.e., wraps the movement so the frame comes back onto the display.
If the option is nil then you can keep moving a frame as far off
the display as you like.

IIRC, with multiple displays, moving a frame off of one display
can move it onto another.

HTH.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]