Subject: bug#18637: 24.4.50; doc of frame parameter DISPLAY vs actual value on MS Windows

From: Drew Adams <[email-masked]>
Date: Tue, 7 Oct 2014 11:12:56 -0700 (PDT)

> That's my understanding as well, but someone who has access to such
> a system should actually try that and report back.
> 
> > I guess that would mean that frame-position coordinates (`left',
> > `top') are then interpreted relative to that other monitor (?).
> > Is that right?
> 
> No, I think they are "ignored".  That is, the coordinates are
> interpreted in the virtual coordinate system, but then Windows
> decides on its own how to position the frame, using the criterion
> described above.

By "criterion described above, do you mean just based on which monitor
is showing more of the frame?

(Note too that I am using MS Windows, but the OP who reported the
problem is, I think, not on Windows.)

> > Here is what I guess I still do not understand.  Are the values of
> > `left' etc. frame parameters relative to just the virtual display
> > (which is the envelope of all of the monitors, at least on
> > Windows)?
> 
> Yes, according to my reading of the code and the MSDN documentation.
> But again, actually trying that will bring a much more reliable
> information.
> 
> > But if that were the case then I would think that restoring a
> > recorded `left' etc. parameter later would put the frame back
> > where it was, which is apparently not what is happening.
> 
> Except that Windows has its own rules, see above, at least when you
> create a frame that didn't exist (i.e. restore it from information
> recorded in some file).

This code does not create any new frames.  It just calls
`modify-frame-parameters' on an existing frame, setting its `left',
`top', `width', and `height' parameters.

> > The Windows doc you pointed to also says that the primary monitor
> > is not necessarily at the left.  So if `left' etc were not
> > absolute but relative to the monitor origin then maybe this is what
> > happened:
> >
> > 1. The OP had a frame in the left monitor, but the right monitor
> >    was primary.  Since the primary monitor has the virtual screen's
> >    origin at its top left, positions in the left monitor would have
> >    negative horizontal positions.
> >
> >    Dunno whether that means they should also have negative `left'
> >    positions, for Emacs.  If `left' etc. are relative to the
> >    virtual screen then yes, they would.  If `left' etc. is relative
> >    to the current monitor then no, they would not.
> 
> Again, my understanding is that they are relative to the visrtual
> coordinate system.
> 
> > The relevant code snippet is what I sent earlier
> > (`frcmds-available-screen-pixel-bounds'), plus functions
> > `maximize-frame' and `restore-frame', here:
> > http://www.emacswiki.org/emacs-en/download/frame-cmds.el
> >
> > In those two commands I do the following.
> >
> > For `maximize-frame':
> >
> > 1. Save the current `left' etc. as parameters `restore-left' etc.
> > 2. Calculate the available screen size, using
> >    `frcmds-available-screen-pixel-bounds'.
> > 3. Set `left' and `top' both to 0 and `width' and `height' to the
> >    calculated screen size.
> >
> > For `restore-frame':
> >
> > Restore `left' etc. from the saved values `restore-left' etc.
> 
> That's a lot of code, and I have no way of trying it.

If you are interested, you can try it easily, by downloading these
two files:
http://www.emacswiki.org/emacs-en/download/frame-cmds.el
http://www.emacswiki.org/emacs-en/download/frame-fns.el

> I think at this stage it is best for the user in question to try
> some simple code that reports frame coordinates and creates a frame
> given specific coordinates, and then see what that means for us.

I've sent him a mail, but I don't know whether he will have the time
or interest to follow up on this.

> Oh, and I think this is no longer about the docs, so probably a new
> bug report is in order, specifically about restoring frames on
> multi-monitor displays.

Agreed.  And thanks for your input.