< prev index next >
src/java.desktop/macosx/native/libawt_lwawt/awt/AWTWindow.m
Print this page
rev 51957 : add support for full window content view and transparent title bar
rev 51960 : update full window content change to avoid unnecessary blocking
rev 51961 : Update
*** 204,213 ****
--- 204,214 ----
if (IS(styleBits, DECORATED)) {
type |= NSTitledWindowMask;
if (IS(styleBits, CLOSEABLE)) type |= NSClosableWindowMask;
if (IS(styleBits, MINIMIZABLE)) type |= NSMiniaturizableWindowMask;
if (IS(styleBits, RESIZABLE)) type |= NSResizableWindowMask;
+ if (IS(styleBits, FULL_WINDOW_CONTENT)) type |= NSFullSizeContentViewWindowMask;
} else {
type |= NSBorderlessWindowMask;
}
if (IS(styleBits, TEXTURED)) type |= NSTexturedBackgroundWindowMask;
*** 261,270 ****
--- 262,275 ----
[self.nsWindow setCollectionBehavior:(1 << 7) /*NSWindowCollectionBehaviorFullScreenPrimary*/];
} else {
[self.nsWindow setCollectionBehavior:NSWindowCollectionBehaviorDefault];
}
}
+
+ if (IS(mask, TRANSPARENT_TITLE_BAR) && [self.nsWindow respondsToSelector:@selector(setTitlebarAppearsTransparent:)]) {
+ [self.nsWindow setTitlebarAppearsTransparent:IS(bits, TRANSPARENT_TITLE_BAR)];
+ }
}
- (id) initWithPlatformWindow:(JNFWeakJObjectWrapper *)platformWindow
ownerWindow:owner
styleBits:(jint)bits
*** 588,621 ****
}
// NSWindowDelegate methods
! - (void) _deliverMoveResizeEvent {
! AWT_ASSERT_APPKIT_THREAD;
!
! // deliver the event if this is a user-initiated live resize or as a side-effect
! // of a Java initiated resize, because AppKit can override the bounds and force
! // the bounds of the window to avoid the Dock or remain on screen.
! [AWTToolkit eventCountPlusPlus];
! JNIEnv *env = [ThreadUtilities getJNIEnv];
! jobject platformWindow = [self.javaPlatformWindow jObjectWithEnv:env];
if (platformWindow == NULL) {
// TODO: create generic AWT assert
}
- NSRect frame = ConvertNSScreenRect(env, [self.nsWindow frame]);
-
static JNF_MEMBER_CACHE(jm_deliverMoveResizeEvent, jc_CPlatformWindow, "deliverMoveResizeEvent", "(IIIIZ)V");
JNFCallVoidMethod(env, platformWindow, jm_deliverMoveResizeEvent,
(jint)frame.origin.x,
(jint)frame.origin.y,
(jint)frame.size.width,
(jint)frame.size.height,
! (jboolean)[self.nsWindow inLiveResize]);
(*env)->DeleteLocalRef(env, platformWindow);
[AWTWindow synthesizeMouseEnteredExitedEventsForAllWindows];
}
- (void)windowDidMove:(NSNotification *)notification {
AWT_ASSERT_APPKIT_THREAD;
--- 593,629 ----
}
// NSWindowDelegate methods
! static void deliverMoveResizeEvent(JNIEnv *env, NSRect frame, JNFWeakJObjectWrapper *javaPlatformWindow,
! BOOL inLiveResize) {
! jobject platformWindow = [javaPlatformWindow jObjectWithEnv:env];
if (platformWindow == NULL) {
// TODO: create generic AWT assert
}
static JNF_MEMBER_CACHE(jm_deliverMoveResizeEvent, jc_CPlatformWindow, "deliverMoveResizeEvent", "(IIIIZ)V");
JNFCallVoidMethod(env, platformWindow, jm_deliverMoveResizeEvent,
(jint)frame.origin.x,
(jint)frame.origin.y,
(jint)frame.size.width,
(jint)frame.size.height,
! (jboolean)inLiveResize);
(*env)->DeleteLocalRef(env, platformWindow);
+ }
+
+ - (void) _deliverMoveResizeEvent {
+ AWT_ASSERT_APPKIT_THREAD;
+ // deliver the event if this is a user-initiated live resize or as a side-effect
+ // of a Java initiated resize, because AppKit can override the bounds and force
+ // the bounds of the window to avoid the Dock or remain on screen.
+ [AWTToolkit eventCountPlusPlus];
+ JNIEnv *env = [ThreadUtilities getJNIEnv];
+ NSRect frame = ConvertNSScreenRect(env, [self.nsWindow frame]);
+ deliverMoveResizeEvent(env, frame, self.javaPlatformWindow, [self.nsWindow inLiveResize]);
[AWTWindow synthesizeMouseEnteredExitedEventsForAllWindows];
}
- (void)windowDidMove:(NSNotification *)notification {
AWT_ASSERT_APPKIT_THREAD;
*** 1056,1073 ****
(JNIEnv *env, jclass clazz, jlong windowPtr, jint mask, jint bits)
{
JNF_COCOA_ENTER(env);
NSWindow *nsWindow = OBJC(windowPtr);
! [ThreadUtilities performOnMainThreadWaiting:NO block:^(){
AWTWindow *window = (AWTWindow*)[nsWindow delegate];
// scans the bit field, and only updates the values requested by the mask
! // (this implicity handles the _CALLBACK_PROP_BITMASK case, since those are passive reads)
jint newBits = window.styleBits & ~mask | bits & mask;
// resets the NSWindow's style mask if the mask intersects any of those bits
if (mask & MASK(_STYLE_PROP_BITMASK)) {
[nsWindow setStyleMask:[AWTWindow styleMaskForStyleBits:newBits]];
}
--- 1064,1106 ----
(JNIEnv *env, jclass clazz, jlong windowPtr, jint mask, jint bits)
{
JNF_COCOA_ENTER(env);
NSWindow *nsWindow = OBJC(windowPtr);
! __block BOOL resized = NO;
! __block NSRect resizeFrame;
! __block JNFWeakJObjectWrapper *javaPlatformWindow;
!
! BOOL shouldWait = IS(mask, FULL_WINDOW_CONTENT); // delay upcall until window changes are made
!
! [ThreadUtilities performOnMainThreadWaiting:shouldWait block:^(){
AWTWindow *window = (AWTWindow*)[nsWindow delegate];
// scans the bit field, and only updates the values requested by the mask
! // (this implicitly handles the _CALLBACK_PROP_BITMASK case, since those are passive reads)
jint newBits = window.styleBits & ~mask | bits & mask;
+ // Check for a change to the full window content view option.
+ // The content view must be resized first, otherwise the window will be resized to fit the existing
+ // content view.
+ if (IS(mask, FULL_WINDOW_CONTENT)) {
+ if (IS(newBits, FULL_WINDOW_CONTENT) != IS(window.styleBits, FULL_WINDOW_CONTENT)) {
+ NSRect frame = [nsWindow frame];
+ NSUInteger styleMask = [AWTWindow styleMaskForStyleBits:newBits];
+ NSRect screenContentRect = [NSWindow contentRectForFrameRect:frame styleMask:styleMask];
+ NSRect contentFrame = NSMakeRect(screenContentRect.origin.x - frame.origin.x,
+ screenContentRect.origin.y - frame.origin.y,
+ screenContentRect.size.width,
+ screenContentRect.size.height);
+ nsWindow.contentView.frame = contentFrame;
+ resized = YES;
+ resizeFrame = [nsWindow frame];
+ javaPlatformWindow = window.javaPlatformWindow;
+ }
+ }
+
// resets the NSWindow's style mask if the mask intersects any of those bits
if (mask & MASK(_STYLE_PROP_BITMASK)) {
[nsWindow setStyleMask:[AWTWindow styleMaskForStyleBits:newBits]];
}
*** 1077,1086 ****
--- 1110,1126 ----
}
window.styleBits = newBits;
}];
+ if (resized) {
+ [AWTToolkit eventCountPlusPlus];
+ NSRect frame = ConvertNSScreenRect(env, resizeFrame);
+ deliverMoveResizeEvent(env, frame, javaPlatformWindow, NO);
+ [AWTWindow synthesizeMouseEnteredExitedEventsForAllWindows];
+ }
+
JNF_COCOA_EXIT(env);
}
/*
* Class: sun_lwawt_macosx_CPlatformWindow
< prev index next >