Subject: bug#25818: 25.2; frame moved off display does not return (OS X)

From: Anders Lindgren <[email-masked]>
Date: Mon, 3 Apr 2017 10:33:04 +0200

Hi!

I think this is a good start. However, there is a case that your patch
miss. If you have multiple monitors arranged in, say, an L-shape, a frame
might be placed inside "multiscreenRect", without actually being visible on
any screen. (This typically occur when you have a large desktop monitor
connected to a laptop or when you have one monitor placed horizontally and
one vertically.)

Fortunately, it should be easy to fix. What about something like (in
pseudo-code):

     BOOL in_any_screen = NO;
     for (screen = /* Loop over all screens */ ...)
       {
         if (overlapping(frame, scree))
           {
              in_any_screen = YES;
              break;
           }
        }
     if ( ! in_any_screen )
       {
         /* Move the frame in */
       }

Anyway, I think that we're on the right track and I appreciate that you
have taken time to work on this!

    -- Anders

PS. I just found another, unrelated, problem, when comparing the NS and X11
versions. When passing a negative value to `set-frame-position' it is
supposed to place the frame relative to the right/bottom border of the
display, but in the NS version it doesn't. (The X11 version gets the Y
placement wrong with 48 pixels, but that is another story.)

On Sun, Apr 2, 2017 at 4:14 PM, Charles A. Roelli <[email-masked]> wrote:

> Hi Anders,
>
> Does the attached patch work for you?  It's still a bit rough around the
> edges, but seems to do the right thing.
>
> A quick test on 10.6:
>
> (setq ns-auto-hide-menu-bar t)
>
> ;; Places the frame just above the top of the screen.
> (set-frame-position (selected-frame) 0 -20)
>
> ;; Frame would be completely offscreen; so it's constrained and brought
> ;; back.
> (set-frame-position (selected-frame) 0 -10000)
>
> Cheers,
> Charles
>
>