Hi Martin and Keith!

Unfortunately, removing the suggested lines break another feature.

The system is designed so that it should be possible to programmatically place the top of the frame above the top of the screen (when the menu bar is hidden). This is useful to hide the window title so that the full height of the screen can be utilised to edit text. When the suggested patch is applied, this no longer is possible.

I would say that the problem is not related to this, but to `make-frame' itself. When a weight higher than the default is specified, it should adjust the window to start further down. As it is today, it always seem to start mid screen.

Below is a small test file I have used to test the frame placement features. If you come up with another solution, you can use it to check that it doesn't break existing features. By the way, it's not intended to be loaded, instead follow the comment and evaluate the expression one by one and check that the result is as described in the file.

Sincerely,
    Anders Lindgren

;; ns-frame-test.el --- test for NextStep (Mac OS X) frame positioning.

;; Author: Anders Lindgren

;; This file is *not* intended to be loaded into Emacs. Instead, it
;; contains individual expressions that should be evaluated one by
;; one, with accompanying manual test steps.

;; Future development:
;;
;; * Add more test cases, like resolution change, frame stretching
;;   multiple screens, and dragging between different sized screens.
;;
;; * Automatic testing using a unit test framework, for example ert.
;;
(error "You should not load this file, read the file comments for details")

;; ----------------------------------------
;; Basics
;;

;; Initially, Emacs should be placed under the menu bar.

;; After each test in this section, it should be possible to drag the
;; frame around, but it should not be possible to drag it in under the
;; menu bar.

;; The following should not place the window under the menu bar.
(set-frame-position (selected-frame) 0 -10)

;; The following will create a frame taller than screen. (90 is
;; suitable for a 1200 pixel display, you mileage may wary.)
;;
;; The frame should not be resized to fit the screen.
(set-frame-size (selected-frame) 80 90)

;; The following should move the frame down a bit. It should not be
;; resized to fit the screen.
(set-frame-position (selected-frame) 0 50)


;; ----------------------------------------
;; Auto hide menu
;;

;; In this section, the auto-hide feature of the menu bar is
;; tested. After each step it should be possible do drag the window
;; around. It should not be possible to drag the window from within
;; the screen to above the screen. However, if it already is above the
;; screen, it should be possible to drag it around there.

;; Start with a frame smaller than the screen.
(set-frame-size (selected-frame) 80 50)

;; After this, the menu bar should be hidden (unless the mouse pointer
;; is at the top of the screen).
(setq ns-auto-hide-menu-bar t)

;; This will place the window title *above* the top of the screen (as
;; intended).
(set-frame-position (selected-frame) 0 -10)

;; Frame will be higher than screen.
(set-frame-size (selected-frame) 80 90)


;; ----------------------------------------
;; Exit auto hide menu
;;

;; Redisplay the menu bar. After this, the frame should be placed
;; *below* the menu bar.
(setq ns-auto-hide-menu-bar nil)

;; ns-frame-test.el ends here.

On Sat, Sep 12, 2015 at 1:11 PM, martin rudalics <rudalics@gmx.at> wrote:
> Commenting out the following small segment in `nsterm.m` fixes the
> problem with large frames being created partially above the top of the
> display -- i.e., it is no longer necessary to correct the bug by
> following a `make-frame` with `set-frame-position` (to move it
> squarely onto the screen) when `ns-auto-hide-menu-bar` is set to `t`.
> As it stands now, the default position is `top 0` and `left 0` --
> perfect!
>
>     if (ns_menu_bar_should_be_hidden ())
>       return frameRect;

That check probably had a purpose.  Anders, what's your opinion on
removing it?

Thanks, martin