Hi!
 
Following your idea, here's an updated patch that works equivalently.
Please let me know what you think.

It looks really good! I've applied it and it works for my use case (placing the menu bar above the top of the screen) and also for your (the frame isn't visible at all). Also, I'm sure it will work with L-shaped layouts as well, even though I haven't tried it.

I've got two minor comments. And when I say "minor" they really are minor, feel free to disregard them if you like:

* The nsterm.m file is (almost) tab free, so I would appreciate if you would untabify the code.

* Replace the comment with something like the following:

    // Check that the proposed frame placement is visible in at least
    // one screen.  If it is not, ask the system to reposition it.

If someone doesn't understand what the code does and why, the original comment doesn't help as it only repeats the algorithm of the code. Also, I don't see the need to refer to a bug number in the comment, except under very special circumstances -- that information is available in the git commit message.


> 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.)

Hm... but what if a second display is in the negative coordinate space?
How would you place a frame on it programmatically?

You can set the `left' and `top' frame parameters. If they are assigned an integer they act like `set-frame-position' is supposed to work. However, if they are assigned `(+ INTEGER)' or `(- INTEGER)' the value is specified relative to the left (top) or right (bottom) edge of the display, respectively. This allows a frame to be placed anywhere.


In any case I'll
try to build the X11 version and see how it does it -- I wasn't aware
that it still works on Mac OS.

It does. I've been using it as "the" reference implementation, whenever the documentation isn't 100% clear.

    -- Anders

Cheers,
Charles

>> 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)