diff options
-rw-r--r-- | src/native/newt/MacWindow.m | 38 | ||||
-rw-r--r-- | src/native/newt/NewtMacWindow.m | 12 |
2 files changed, 12 insertions, 38 deletions
diff --git a/src/native/newt/MacWindow.m b/src/native/newt/MacWindow.m index 1e8555282..aa09486bf 100644 --- a/src/native/newt/MacWindow.m +++ b/src/native/newt/MacWindow.m @@ -52,45 +52,13 @@ NSString* jstringToNSString(JNIEnv* env, jstring jstr) return str; } -static BOOL initializedMenuHeight = NO; -static CGFloat menuHeight = 0; -static BOOL DEBUG = NO; - void setFrameTopLeftPoint(NSWindow* win, jint x, jint y) { NSScreen* screen = [NSScreen mainScreen]; - NSRect screenRect = [screen frame]; + NSRect visibleScreenRect = [screen visibleFrame]; NSPoint pt; - - if (!initializedMenuHeight) { - NSMenu* menu = [NSApp mainMenu]; - BOOL mustRelease = NO; - - if (menu == nil) { - if (DEBUG) { - printf("main menu was nil, trying services menu\n"); - } - menu = [NSApp servicesMenu]; - } - - if (menu == nil) { - if (DEBUG) { - printf("services menu was nil, trying an empty menu instance\n"); - } - menu = [[[NSMenu alloc] initWithTitle: @"Foo"] retain]; - mustRelease = YES; - } - - menuHeight = [menu menuBarHeight]; - - if (mustRelease) { - [menu release]; - } - - initializedMenuHeight = YES; - } - - pt = NSMakePoint(x, screenRect.origin.y + screenRect.size.height - menuHeight - y); + + pt = NSMakePoint(x, visibleScreenRect.origin.y + visibleScreenRect.size.height - y); [win setFrameTopLeftPoint: pt]; } diff --git a/src/native/newt/NewtMacWindow.m b/src/native/newt/NewtMacWindow.m index d0cf6ad15..7c3e4745b 100644 --- a/src/native/newt/NewtMacWindow.m +++ b/src/native/newt/NewtMacWindow.m @@ -249,6 +249,10 @@ static jint mods2JavaMods(NSUInteger mods) - (void)windowDidMove: (NSNotification*) notification { NSRect rect = [self frame]; + NSScreen* menuBarScreen = NULL; + NSScreen* screen = NULL; + NSRect screenRect; + NSPoint pt; if (env == NULL) { return; @@ -258,11 +262,13 @@ static jint mods2JavaMods(NSUInteger mods) return; } - // FIXME: this result isn't consistent with setFrameTopLeftPoint + // FIXME: unclear whether this works correctly in multiple monitor situations + screen = [self screen]; + screenRect = [screen visibleFrame]; + pt = NSMakePoint(rect.origin.x, screenRect.origin.y + screenRect.size.height - rect.origin.y - rect.size.height); (*env)->CallVoidMethod(env, javaWindowObject, positionChangedID, - (jint) rect.origin.x, - (jint) rect.origin.y); + (jint) pt.x, (jint) pt.y); } - (void)windowWillClose: (NSNotification*) notification |