1154
1155 if ([nsWindow isKeyWindow] || [nsWindow isMainWindow]) {
1156 [window.javaMenuBar deactivate];
1157 }
1158
1159 window.javaMenuBar = menuBar;
1160
1161 CMenuBar* actualMenuBar = menuBar;
1162 if (actualMenuBar == nil) {
1163 actualMenuBar = [[ApplicationDelegate sharedDelegate] defaultMenuBar];
1164 }
1165
1166 if ([nsWindow isKeyWindow] || [nsWindow isMainWindow]) {
1167 [CMenuBar activate:actualMenuBar modallyDisabled:NO];
1168 }
1169 }];
1170
1171 JNF_COCOA_EXIT(env);
1172 }
1173
1174 /*
1175 * Class: sun_lwawt_macosx_CPlatformWindow
1176 * Method: nativeGetNSWindowInsets
1177 * Signature: (J)Ljava/awt/Insets;
1178 */
1179 JNIEXPORT jobject JNICALL Java_sun_lwawt_macosx_CPlatformWindow_nativeGetNSWindowInsets
1180 (JNIEnv *env, jclass clazz, jlong windowPtr)
1181 {
1182 jobject ret = NULL;
1183
1184 JNF_COCOA_ENTER(env);
1185
1186 NSWindow *nsWindow = OBJC(windowPtr);
1187 __block NSRect contentRect = NSZeroRect;
1188 __block NSRect frame = NSZeroRect;
1189
1190 [ThreadUtilities performOnMainThreadWaiting:YES block:^(){
1191
1192 frame = [nsWindow frame];
1193 contentRect = [NSWindow contentRectForFrameRect:frame styleMask:[nsWindow styleMask]];
1194 }];
1195
1196 jint top = (jint)(frame.size.height - contentRect.size.height);
1197 jint left = (jint)(contentRect.origin.x - frame.origin.x);
1198 jint bottom = (jint)(contentRect.origin.y - frame.origin.y);
1199 jint right = (jint)(frame.size.width - (contentRect.size.width + left));
1200
1201 static JNF_CLASS_CACHE(jc_Insets, "java/awt/Insets");
1202 static JNF_CTOR_CACHE(jc_Insets_ctor, jc_Insets, "(IIII)V");
1203 ret = JNFNewObject(env, jc_Insets_ctor, top, left, bottom, right);
1204
1205 JNF_COCOA_EXIT(env);
1206 return ret;
1207 }
1208
1209 /*
1210 * Class: sun_lwawt_macosx_CPlatformWindow
1211 * Method: nativeSetNSWindowBounds
1212 * Signature: (JDDDD)V
1213 */
1214 JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CPlatformWindow_nativeSetNSWindowBounds
1215 (JNIEnv *env, jclass clazz, jlong windowPtr, jdouble originX, jdouble originY, jdouble width, jdouble height)
1216 {
1217 JNF_COCOA_ENTER(env);
1218
1219 NSRect jrect = NSMakeRect(originX, originY, width, height);
|
1154
1155 if ([nsWindow isKeyWindow] || [nsWindow isMainWindow]) {
1156 [window.javaMenuBar deactivate];
1157 }
1158
1159 window.javaMenuBar = menuBar;
1160
1161 CMenuBar* actualMenuBar = menuBar;
1162 if (actualMenuBar == nil) {
1163 actualMenuBar = [[ApplicationDelegate sharedDelegate] defaultMenuBar];
1164 }
1165
1166 if ([nsWindow isKeyWindow] || [nsWindow isMainWindow]) {
1167 [CMenuBar activate:actualMenuBar modallyDisabled:NO];
1168 }
1169 }];
1170
1171 JNF_COCOA_EXIT(env);
1172 }
1173
1174 extern jboolean metalEnabled;
1175
1176 /*
1177 * Class: sun_lwawt_macosx_CPlatformWindow
1178 * Method: nativeGetNSWindowInsets
1179 * Signature: (J)Ljava/awt/Insets;
1180 */
1181 JNIEXPORT jobject JNICALL Java_sun_lwawt_macosx_CPlatformWindow_nativeGetNSWindowInsets
1182 (JNIEnv *env, jclass clazz, jlong windowPtr)
1183 {
1184 jobject ret = NULL;
1185
1186 JNF_COCOA_ENTER(env);
1187
1188 NSWindow *nsWindow = OBJC(windowPtr);
1189 __block NSRect contentRect = NSZeroRect;
1190 __block NSRect frame = NSZeroRect;
1191
1192 [ThreadUtilities performOnMainThreadWaiting:YES block:^(){
1193
1194 frame = [nsWindow frame];
1195 contentRect = [NSWindow contentRectForFrameRect:frame styleMask:[nsWindow styleMask]];
1196 }];
1197
1198 jint top = (jint)(frame.size.height - contentRect.size.height);
1199 jint left = (jint)(contentRect.origin.x - frame.origin.x);
1200 jint bottom = (jint)(contentRect.origin.y - frame.origin.y);
1201 jint right = (jint)(frame.size.width - (contentRect.size.width + left));
1202 if (metalEnabled == JNI_TRUE) {
1203 bottom -= top;
1204 top = 0;
1205 }
1206
1207 static JNF_CLASS_CACHE(jc_Insets, "java/awt/Insets");
1208 static JNF_CTOR_CACHE(jc_Insets_ctor, jc_Insets, "(IIII)V");
1209 ret = JNFNewObject(env, jc_Insets_ctor, top, left, bottom, right);
1210
1211 JNF_COCOA_EXIT(env);
1212 return ret;
1213 }
1214
1215 /*
1216 * Class: sun_lwawt_macosx_CPlatformWindow
1217 * Method: nativeSetNSWindowBounds
1218 * Signature: (JDDDD)V
1219 */
1220 JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CPlatformWindow_nativeSetNSWindowBounds
1221 (JNIEnv *env, jclass clazz, jlong windowPtr, jdouble originX, jdouble originY, jdouble width, jdouble height)
1222 {
1223 JNF_COCOA_ENTER(env);
1224
1225 NSRect jrect = NSMakeRect(originX, originY, width, height);
|