Better default position for window on macOS
This commit is contained in:
parent
5fa7ba487e
commit
c7d3670472
|
@ -367,6 +367,8 @@ static void defaultOnPositionContentSizeChanged(uiWindow *w, void *data)
|
|||
// do nothing
|
||||
}
|
||||
|
||||
static NSPoint lastTopLeftPoint;
|
||||
|
||||
uiWindow *uiNewWindow(const char *title, int width, int height, int hasMenubar)
|
||||
{
|
||||
uiWindow *w;
|
||||
|
@ -381,6 +383,13 @@ uiWindow *uiNewWindow(const char *title, int width, int height, int hasMenubar)
|
|||
defer:YES];
|
||||
[w->window setTitle:toNSString(title)];
|
||||
|
||||
if (NSEqualPoints(lastTopLeftPoint, NSZeroPoint)) {
|
||||
// issue "cascadeTopLeftFromPoint" twice on first time
|
||||
// to have window position in a good place
|
||||
lastTopLeftPoint = [w->window cascadeTopLeftFromPoint:lastTopLeftPoint];
|
||||
}
|
||||
lastTopLeftPoint = [w->window cascadeTopLeftFromPoint:lastTopLeftPoint];
|
||||
|
||||
// do NOT release when closed
|
||||
// we manually do this in uiWindowDestroy() above
|
||||
[w->window setReleasedWhenClosed:NO];
|
||||
|
|
Loading…
Reference in New Issue