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

From: Anders Lindgren <[email-masked]>
Date: Sat, 29 Apr 2017 19:23:14 +0200

Hi!

If I understand correctly, when the menu bar is visible, macOS will force
any window down below it. It's not something one can do about it, as far as
I know.

However, when the menu bar is hidden, or on secondary monitors (i.e. one
that don't have a menu bar), a window can be placed above the top
programmatically (but it's not possible for a user to drag it there).

The reason the Emacs code checks if spaces are enabled is historical. The
original NS code in Emacs 23 didn't support stretching a frame across two
monitors (whereas Emacs 22 supported this). When this was fixed for Emacs
23 the maintainer of the time, Jan Djärv, decided to retain the original
behaviour when spaces are enabled (since a frame can't be stretched across
multiple monitors). Maybe this is something we could revisit now. (One
thing I'm curious about is if it is possible to hide the menu bar and place
the frame above the top of the display, if spaces are enabled -- I suspect
that it's not possible but I haven't tested.)

    -- Anders

On Sat, Apr 29, 2017 at 1:15 PM, Charles A. Roelli <[email-masked]> wrote:

> With the current master branch, a child frame might be constrained on OS X
> 10.9+ with the "Spaces" windowing feature turned on, meaning that a child
> frame could be forced back into the screen area -- so yes, there could be a
> case where a child frame doesn't move together with its parent.  Maybe that
> will have to be fixed too; I'm on 10.6 though so I can't test.
>
> Otherwise, though, when child/parent frames are not brought off screen, a
> child frame always moves with its parent.
>
> My updated patch takes into account the case where "Spaces" is off or
> unavailable -- if you read the part above what I added:
>
> #ifdef NS_IMPL_COCOA
> #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_9
>   // If separate spaces is on, it is like each screen is independent.
> There is
>   // no spanning of frames across screens.
>   if ([NSScreen screensHaveSeparateSpaces])
>     {
>       NSTRACE_MSG ("Screens have separate spaces");
>       frameRect = [super constrainFrameRect:frameRect toScreen:screen];
>       NSTRACE_RETURN_RECT (frameRect);
>       return frameRect;
>     }
> #endif
>
> there is nothing there to prevent a child frame from being constrained --
> so I will need input from somebody else on that.
>
>
>
> On 29/04/2017 12:30, martin rudalics wrote:
>
>> > I fixed the patch so that child frames are never constrained (after
>> > some testing, it seems that a child frame cannot get stuck off screen
>> > as long as its parent is still visible).  To test this out, evaluate
>> > the following from emacs -Q,
>> >
>> > (progn
>> >    (setq test-frame (make-frame `((parent-frame . ,(selected-frame)))))
>> >    (set-frame-position test-frame 0 500))
>> >
>> > and drag the parent frame down until its child is off screen.
>>
>> Does this mean that the child frame does _not_ move together with its
>> parent frame?  That would constitute a major deviation from the other
>> platforms.
>>
>> martin
>>
>
>