summaryrefslogtreecommitdiffstats
path: root/src/newt/native
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2011-10-13 03:49:14 +0200
committerSven Gothel <[email protected]>2011-10-13 03:49:14 +0200
commit96c50e94f4dbc0e18762a97c026b7e6986cea8e7 (patch)
treece42f5905af08820fdbabe74be8f31a1dbc25ccd /src/newt/native
parente7329d99aa6b44b976d0a5d2dd6f0d19c25d661c (diff)
NEWT/OSX: Fix resize behavior / Cleanup coordinate transormation (client-space/top-level, child/parent)
At resizing a perent window w/ a NEWT OSX child, the window position needs to be updated since it's absolute. Re-adding sending *Changed notifications via the appropriate WindowImpl methods. Turns out they are missing in some parent/child situations (fullscreen for example). Native getLocationOnScreen0(..) queries totalHeight by it's own to have correct values.
Diffstat (limited to 'src/newt/native')
-rw-r--r--src/newt/native/MacWindow.m26
1 files changed, 17 insertions, 9 deletions
diff --git a/src/newt/native/MacWindow.m b/src/newt/native/MacWindow.m
index 4e4dc3173..670deaf1d 100644
--- a/src/newt/native/MacWindow.m
+++ b/src/newt/native/MacWindow.m
@@ -57,11 +57,15 @@ static NSString* jstringToNSString(JNIEnv* env, jstring jstr)
return str;
}
-static void setFrameTopLeftPoint(NSWindow* pWin, NSWindow* mWin, jint x, jint y, jint totalHeight) {
+static void setFrameTopLeftPoint(NSWindow* pWin, NewtMacWindow* mWin, jint x, jint y) {
NSScreen* screen = [mWin screen];
NSRect screenTotal = [screen frame];
+ NSView* mView = [mWin contentView];
+ NSRect mViewFrame = [mView frame];
+ int totalHeight = mViewFrame.size.height + mWin->cachedInsets[2] + mWin->cachedInsets[3]; // height + insets[top+bottom]
+
NSPoint pS = NSMakePoint(screenTotal.origin.x + x, screenTotal.origin.y + screenTotal.size.height - y - totalHeight);
#ifdef VERBOSE_ON
@@ -315,6 +319,7 @@ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_macosx_MacWindow_createWindow0
defer: NO
screen: myScreen];
[myWindow setReleasedWhenClosed: YES]; // default
+ [myWindow setPreservesContentDuringLiveResize: NO];
NSObject *nsParentObj = (NSObject*) ((intptr_t) parent);
NSWindow* parentWindow = NULL;
@@ -337,6 +342,9 @@ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_macosx_MacWindow_createWindow0
if(opaque) {
[myWindow setOpaque: YES];
+ if (!fullscreen) {
+ [myWindow setShowsResizeIndicator: YES];
+ }
} else {
[myWindow setOpaque: NO];
[myWindow setBackgroundColor: [NSColor clearColor]];
@@ -355,7 +363,7 @@ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_macosx_MacWindow_createWindow0
(void) changeContentView(env, jthis, parentWindow, parentView, myWindow, myView);
// Immediately re-position the window based on an upper-left coordinate system
- setFrameTopLeftPoint(parentWindow, myWindow, x, y, h+myWindow->cachedInsets[2]+myWindow->cachedInsets[3]); // h+insets[top+bottom]
+ setFrameTopLeftPoint(parentWindow, myWindow, x, y);
NS_DURING
// Available >= 10.5 - Makes the menubar disapear
@@ -390,7 +398,7 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_MacWindow_makeKeyAndOrderF
DBG_PRINT( "makeKeyAndOrderFront0 - window: %p (START)\n", win);
- // [win performSelectorOnMainThread:@selector(makeKeyAndOrderFront:) withObject:win waitUntilDone:NO];
+ // [win performSelectorOnMainThread:@selector(makeKeyAndOrderFront:) withObject:win waitUntilDone:YES];
[win makeKeyAndOrderFront: win];
DBG_PRINT( "makeKeyAndOrderFront0 - window: %p (END)\n", win);
@@ -411,7 +419,7 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_MacWindow_makeKey0
DBG_PRINT( "makeKey0 - window: %p (START)\n", win);
- // [win performSelectorOnMainThread:@selector(makeKeyWindow:) withObject:nil waitUntilDone:NO];
+ // [win performSelectorOnMainThread:@selector(makeKeyWindow:) withObject:nil waitUntilDone:YES];
[win makeKeyWindow];
DBG_PRINT( "makeKey0 - window: %p (END)\n", win);
@@ -499,8 +507,8 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_MacWindow_setTitle0
NSString* str = jstringToNSString(env, title);
[str autorelease];
- [win performSelectorOnMainThread:@selector(setTitle:) withObject:str waitUntilDone:NO];
- // [win setTitle: str];
+ // [win performSelectorOnMainThread:@selector(setTitle:) withObject:str waitUntilDone:NO];
+ [win setTitle: str];
DBG_PRINT( "setTitle0 - window: %p (END)\n", win);
@@ -592,10 +600,10 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_MacWindow_setContentSize0
* Signature: (JJII)V
*/
JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_MacWindow_setFrameTopLeftPoint0
- (JNIEnv *env, jobject unused, jlong parent, jlong window, jint x, jint y, jint totalHeight)
+ (JNIEnv *env, jobject unused, jlong parent, jlong window, jint x, jint y)
{
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
- NSWindow* mWin = (NSWindow*) ((intptr_t) window);
+ NewtMacWindow* mWin = (NewtMacWindow*) ((intptr_t) window);
NSObject *nsParentObj = (NSObject*) ((intptr_t) parent);
NSWindow* pWin = NULL;
@@ -608,7 +616,7 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_MacWindow_setFrameTopLeftP
DBG_PRINT( "setFrameTopLeftPoint0 - window: %p, parent %p (START)\n", mWin, pWin);
- setFrameTopLeftPoint(pWin, mWin, x, y, totalHeight);
+ setFrameTopLeftPoint(pWin, mWin, x, y);
DBG_PRINT( "setFrameTopLeftPoint0 - window: %p, parent %p (END)\n", mWin, pWin);