--- old/modules/graphics/src/main/native-glass/mac/GlassWindow+Java.m 2015-03-27 15:16:19.000000000 -0400 +++ new/modules/graphics/src/main/native-glass/mac/GlassWindow+Java.m 2015-03-27 15:16:19.000000000 -0400 @@ -50,6 +50,13 @@ @end +//#define VERBOSE +#ifndef VERBOSE +#define LOG(MSG, ...) +#else +#define LOG(MSG, ...) GLASS_LOG(MSG, ## __VA_ARGS__); +#endif + @implementation GlassWindow (Java) #pragma mark --- Callbacks @@ -296,11 +303,13 @@ - (void)_setWindowFrameWithRect:(NSRect)rect withDisplay:(jboolean)display withAnimate:(jboolean)animate { NSRect frame = [self _constrainFrame:rect]; + LOG("GlassWindow _setWindowFrameWithRect: constrained (%s)", [NSStringFromRect(frame) UTF8String]); [self _setFlipFrame:frame display:(BOOL)display animate:(BOOL)animate]; } -- (void)_setBounds:(jint)x y:(jint)y xSet:(jboolean)xSet ySet:(jboolean)ySet w:(jint)w h:(jint)h cw:(jint)cw ch:(jint)ch +- (void)_setBounds:(jint)x y:(jint)y xSet:(jboolean)xSet ySet:(jboolean)ySet + w:(jint)w h:(jint)h cw:(jint)cw ch:(jint)ch { NSPoint origin = [self _flipFrame].origin; NSSize size = [self->nsWindow frame].size; @@ -313,6 +322,8 @@ jint newH = (h > 0) ? h : (ch > 0) ? (jint)sizeForClient.height : (jint)size.height; [self _setWindowFrameWithRect:NSMakeRect(newX, newY, newW, newH) withDisplay:JNI_TRUE withAnimate:JNI_FALSE]; + + LOG("GlassWindow _setBounds(w: %d h %d)", newW, newH); } - (void)_restorePreZoomedRect @@ -340,20 +351,28 @@ - (void)_setFlipFrame:(NSRect)frameRect display:(BOOL)displayFlag animate:(BOOL)animateFlag { - //NSLog(@"_setFlipFrame: %.2f,%.2f %.2fx%.2f", frameRect.origin.x, frameRect.origin.y, frameRect.size.width, frameRect.size.height); + LOG("GlassWindow(Java) _setFlipFrame:display:animate: %s", [NSStringFromRect(frameRect) UTF8String]); + NSScreen * screen = [[NSScreen screens] objectAtIndex: 0]; NSRect screenFrame = screen.frame; - //NSLog(@" screenFrame: %.2f,%.2f %.2fx%.2f", screenFrame.origin.x, screenFrame.origin.y, screenFrame.size.width, screenFrame.size.height); + LOG("GlassWindow(Java) screenFrame: %s", [NSStringFromRect(screenFrame) UTF8String]); frameRect.origin.y = screenFrame.size.height - frameRect.size.height - frameRect.origin.y; - //NSLog(@" set to frameRect:%.2f,%.2f %.2fx%.2f", frameRect.origin.x, frameRect.origin.y, frameRect.size.width, frameRect.size.height); + if (frameRect.size.width > screenFrame.size.width) { + frameRect.size.width = screenFrame.size.width; + } + + if (frameRect.size.height > screenFrame.size.height) { + frameRect.size.height = screenFrame.size.height; + } + + LOG("GlassWindow(Java) set to frameRect: %s", [NSStringFromRect(frameRect) UTF8String]); + [self->nsWindow setFrame:frameRect display:displayFlag animate:animateFlag]; - //frameRect = [self _flipFrame]; - //NSLog(@" _flipFrame:%.2f,%.2f %.2fx%.2f", frameRect.origin.x, frameRect.origin.y, frameRect.size.width, frameRect.size.height); - //frameRect = [super frame]; - //NSLog(@" frame:%.2f,%.2f %.2fx%.2f", frameRect.origin.x, frameRect.origin.y, frameRect.size.width, frameRect.size.height); + frameRect = [self _flipFrame]; + LOG("GlassWindow(Java) _flipFrame: %s", [NSStringFromRect(frameRect) UTF8String]); } - (NSRect)_flipFrame @@ -362,11 +381,15 @@ NSRect screenFrame = screen.frame; NSRect frame = [self->nsWindow frame]; - //NSLog(@"_flipFrame: v.s.h=%.2f f.s.h=%.2f f.o.y=%.2f", screenFrame.size.height, frame.size.height, frame.origin.y); + LOG("GlassWindow(Java) _flipFrame: screenFrame %s windowFrame %s", + [NSStringFromRect(screenFrame) UTF8String], + [NSStringFromRect(frame) UTF8String]); + frame.origin.y = screenFrame.size.height - frame.size.height - frame.origin.y; - //NSLog(@" result: f.o.y=%.2f", frame.origin.y); + frame.origin.x = screenFrame.size.width - frame.size.width - frame.origin.x; - //NSLog(@"_flipFrame: %.2f,%.2f %.2fx%.2f", frame.origin.x, frame.origin.y, frame.size.width, frame.size.height); + LOG("GlassView3D _flipFrame: result %s", [NSStringFromPoint(frame.origin) UTF8String]); + return frame; }