1390 1391 /* Add in menuBar, if any. */ 1392 if (JNU_IsInstanceOfByName(env, target, "java/awt/Frame") > 0 && 1393 ((AwtFrame*)this)->GetMenuBar()) { 1394 m_insets.top += ::GetSystemMetrics(SM_CYMENU); 1395 } 1396 if (env->ExceptionCheck()) { 1397 env->DeleteLocalRef(target); 1398 return FALSE; 1399 } 1400 m_insets.bottom += extraBottomInsets; 1401 env->DeleteLocalRef(target); 1402 } 1403 1404 BOOL insetsChanged = FALSE; 1405 1406 jobject peer = GetPeer(env); 1407 /* Get insets into our peer directly */ 1408 jobject peerInsets = (env)->GetObjectField(peer, AwtPanel::insets_ID); 1409 DASSERT(!safe_ExceptionOccurred(env)); 1410 if (peerInsets != NULL) { // may have been called during creation 1411 (env)->SetIntField(peerInsets, AwtInsets::topID, m_insets.top); 1412 (env)->SetIntField(peerInsets, AwtInsets::bottomID, 1413 m_insets.bottom); 1414 (env)->SetIntField(peerInsets, AwtInsets::leftID, m_insets.left); 1415 (env)->SetIntField(peerInsets, AwtInsets::rightID, m_insets.right); 1416 } 1417 /* Get insets into the Inset object (if any) that was passed */ 1418 if (insets != NULL) { 1419 (env)->SetIntField(insets, AwtInsets::topID, m_insets.top); 1420 (env)->SetIntField(insets, AwtInsets::bottomID, m_insets.bottom); 1421 (env)->SetIntField(insets, AwtInsets::leftID, m_insets.left); 1422 (env)->SetIntField(insets, AwtInsets::rightID, m_insets.right); 1423 } 1424 env->DeleteLocalRef(peerInsets); 1425 1426 insetsChanged = !::EqualRect( &m_old_insets, &m_insets ); 1427 ::CopyRect( &m_old_insets, &m_insets ); 1428 1429 if (insetsChanged) { 1430 // Since insets are changed we need to update the surfaceData object 1431 // to reflect that change 1432 env->CallVoidMethod(peer, AwtComponent::replaceSurfaceDataLaterMID); 1433 } 1434 1435 return insetsChanged; 1436 } 1437 1438 /** 1439 * Sometimes we need the hWnd that actually owns this Window's hWnd (if 1440 * there is an owner). 1441 */ 1442 HWND AwtWindow::GetTopLevelHWnd() 1718 1719 if (m_screenNum == -1) { 1720 // Set initial value 1721 m_screenNum = GetScreenImOn(); 1722 } 1723 else { 1724 CheckIfOnNewScreen(); 1725 } 1726 1727 /* Update the java AWT target component's fields directly */ 1728 JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2); 1729 if (env->EnsureLocalCapacity(1) < 0) { 1730 return mrConsume; 1731 } 1732 jobject peer = GetPeer(env); 1733 jobject target = env->GetObjectField(peer, AwtObject::targetID); 1734 1735 RECT rect; 1736 ::GetWindowRect(GetHWnd(), &rect); 1737 1738 (env)->SetIntField(target, AwtComponent::xID, rect.left); 1739 (env)->SetIntField(target, AwtComponent::yID, rect.top); 1740 (env)->SetIntField(peer, AwtWindow::sysXID, rect.left); 1741 (env)->SetIntField(peer, AwtWindow::sysYID, rect.top); 1742 SendComponentEvent(java_awt_event_ComponentEvent_COMPONENT_MOVED); 1743 1744 env->DeleteLocalRef(target); 1745 return AwtComponent::WmMove(x, y); 1746 } 1747 1748 MsgRouting AwtWindow::WmGetMinMaxInfo(LPMINMAXINFO lpmmi) 1749 { 1750 MsgRouting r = AwtCanvas::WmGetMinMaxInfo(lpmmi); 1751 if ((m_minSize.x == 0) && (m_minSize.y == 0)) { 1752 return r; 1753 } 1754 lpmmi->ptMinTrackSize.x = m_minSize.x; 1755 lpmmi->ptMinTrackSize.y = m_minSize.y; 1756 return mrConsume; 1757 } 1758 1759 MsgRouting AwtWindow::WmSizing() 1760 { 1761 if (!AwtToolkit::GetInstance().IsDynamicLayoutActive()) { 1786 * and below can be resized from outside of java (by user) 1787 */ 1788 MsgRouting AwtWindow::WmSize(UINT type, int w, int h) 1789 { 1790 currentWmSizeState = type; 1791 1792 if (type == SIZE_MINIMIZED) { 1793 UpdateSecurityWarningVisibility(); 1794 return mrDoDefault; 1795 } 1796 1797 JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2); 1798 if (env->EnsureLocalCapacity(1) < 0) 1799 return mrDoDefault; 1800 jobject target = GetTarget(env); 1801 // fix 4167248 : ensure the insets are up-to-date before using 1802 BOOL insetsChanged = UpdateInsets(NULL); 1803 int newWidth = w + m_insets.left + m_insets.right; 1804 int newHeight = h + m_insets.top + m_insets.bottom; 1805 1806 (env)->SetIntField(target, AwtComponent::widthID, newWidth); 1807 (env)->SetIntField(target, AwtComponent::heightID, newHeight); 1808 1809 jobject peer = GetPeer(env); 1810 (env)->SetIntField(peer, AwtWindow::sysWID, newWidth); 1811 (env)->SetIntField(peer, AwtWindow::sysHID, newHeight); 1812 1813 if (!AwtWindow::IsResizing()) { 1814 WindowResized(); 1815 } 1816 1817 env->DeleteLocalRef(target); 1818 return AwtComponent::WmSize(type, w, h); 1819 } 1820 1821 MsgRouting AwtWindow::WmPaint(HDC) 1822 { 1823 PaintUpdateRgn(&m_insets); 1824 return mrConsume; 1825 } 1826 1827 MsgRouting AwtWindow::WmSettingChange(UINT wFlag, LPCTSTR pszSection) 1828 { 1829 if (wFlag == SPI_SETNONCLIENTMETRICS) { 1830 // user changed window metrics in 1831 // Control Panel->Display->Appearance 3055 void AwtWindow::_SetFullScreenExclusiveModeState(void *param) 3056 { 3057 JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2); 3058 3059 SetFullScreenExclusiveModeStateStruct * data = 3060 (SetFullScreenExclusiveModeStateStruct*)param; 3061 jobject self = data->window; 3062 jboolean state = data->isFSEMState; 3063 3064 PDATA pData; 3065 JNI_CHECK_PEER_GOTO(self, ret); 3066 AwtWindow *window = (AwtWindow *)pData; 3067 3068 window->setFullScreenExclusiveModeState(state != 0); 3069 3070 ret: 3071 env->DeleteGlobalRef(self); 3072 delete data; 3073 } 3074 3075 extern "C" { 3076 3077 /* 3078 * Class: java_awt_Window 3079 * Method: initIDs 3080 * Signature: ()V 3081 */ 3082 JNIEXPORT void JNICALL 3083 Java_java_awt_Window_initIDs(JNIEnv *env, jclass cls) 3084 { 3085 TRY; 3086 3087 CHECK_NULL(AwtWindow::warningStringID = 3088 env->GetFieldID(cls, "warningString", "Ljava/lang/String;")); 3089 CHECK_NULL(AwtWindow::locationByPlatformID = 3090 env->GetFieldID(cls, "locationByPlatform", "Z")); 3091 CHECK_NULL(AwtWindow::securityWarningWidthID = 3092 env->GetFieldID(cls, "securityWarningWidth", "I")); 3093 CHECK_NULL(AwtWindow::securityWarningHeightID = 3094 env->GetFieldID(cls, "securityWarningHeight", "I")); 3282 * Method: reshapeFrame 3283 * Signature: (IIII)V 3284 */ 3285 JNIEXPORT void JNICALL 3286 Java_sun_awt_windows_WWindowPeer_reshapeFrame(JNIEnv *env, jobject self, 3287 jint x, jint y, jint w, jint h) 3288 { 3289 TRY; 3290 3291 ReshapeFrameStruct *rfs = new ReshapeFrameStruct; 3292 rfs->frame = env->NewGlobalRef(self); 3293 rfs->x = x; 3294 rfs->y = y; 3295 rfs->w = w; 3296 rfs->h = h; 3297 3298 AwtToolkit::GetInstance().SyncCall(AwtWindow::_ReshapeFrame, rfs); 3299 // global ref and rfs are deleted in _ReshapeFrame() 3300 3301 CATCH_BAD_ALLOC; 3302 } 3303 3304 /* 3305 * Class: sun_awt_windows_WWindowPeer 3306 * Method: getSysMinWidth 3307 * Signature: ()I 3308 */ 3309 JNIEXPORT jint JNICALL 3310 Java_sun_awt_windows_WWindowPeer_getSysMinWidth(JNIEnv *env, jclass self) 3311 { 3312 TRY; 3313 3314 return ::GetSystemMetrics(SM_CXMIN); 3315 3316 CATCH_BAD_ALLOC_RET(0); 3317 } 3318 3319 /* 3320 * Class: sun_awt_windows_WWindowPeer 3321 * Method: getSysMinHeight | 1390 1391 /* Add in menuBar, if any. */ 1392 if (JNU_IsInstanceOfByName(env, target, "java/awt/Frame") > 0 && 1393 ((AwtFrame*)this)->GetMenuBar()) { 1394 m_insets.top += ::GetSystemMetrics(SM_CYMENU); 1395 } 1396 if (env->ExceptionCheck()) { 1397 env->DeleteLocalRef(target); 1398 return FALSE; 1399 } 1400 m_insets.bottom += extraBottomInsets; 1401 env->DeleteLocalRef(target); 1402 } 1403 1404 BOOL insetsChanged = FALSE; 1405 1406 jobject peer = GetPeer(env); 1407 /* Get insets into our peer directly */ 1408 jobject peerInsets = (env)->GetObjectField(peer, AwtPanel::insets_ID); 1409 DASSERT(!safe_ExceptionOccurred(env)); 1410 1411 if (peerInsets != NULL) { // may have been called during creation 1412 (env)->SetIntField(peerInsets, AwtInsets::topID, ScaleDownY(m_insets.top)); 1413 (env)->SetIntField(peerInsets, AwtInsets::bottomID, ScaleDownY(m_insets.bottom)); 1414 (env)->SetIntField(peerInsets, AwtInsets::leftID, ScaleDownX(m_insets.left)); 1415 (env)->SetIntField(peerInsets, AwtInsets::rightID, ScaleDownX(m_insets.right)); 1416 } 1417 /* Get insets into the Inset object (if any) that was passed */ 1418 if (insets != NULL) { 1419 (env)->SetIntField(insets, AwtInsets::topID, ScaleDownY(m_insets.top)); 1420 (env)->SetIntField(insets, AwtInsets::bottomID, ScaleDownY(m_insets.bottom)); 1421 (env)->SetIntField(insets, AwtInsets::leftID, ScaleDownX(m_insets.left)); 1422 (env)->SetIntField(insets, AwtInsets::rightID, ScaleDownX(m_insets.right)); 1423 } 1424 env->DeleteLocalRef(peerInsets); 1425 1426 insetsChanged = !::EqualRect( &m_old_insets, &m_insets ); 1427 ::CopyRect( &m_old_insets, &m_insets ); 1428 1429 if (insetsChanged) { 1430 // Since insets are changed we need to update the surfaceData object 1431 // to reflect that change 1432 env->CallVoidMethod(peer, AwtComponent::replaceSurfaceDataLaterMID); 1433 } 1434 1435 return insetsChanged; 1436 } 1437 1438 /** 1439 * Sometimes we need the hWnd that actually owns this Window's hWnd (if 1440 * there is an owner). 1441 */ 1442 HWND AwtWindow::GetTopLevelHWnd() 1718 1719 if (m_screenNum == -1) { 1720 // Set initial value 1721 m_screenNum = GetScreenImOn(); 1722 } 1723 else { 1724 CheckIfOnNewScreen(); 1725 } 1726 1727 /* Update the java AWT target component's fields directly */ 1728 JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2); 1729 if (env->EnsureLocalCapacity(1) < 0) { 1730 return mrConsume; 1731 } 1732 jobject peer = GetPeer(env); 1733 jobject target = env->GetObjectField(peer, AwtObject::targetID); 1734 1735 RECT rect; 1736 ::GetWindowRect(GetHWnd(), &rect); 1737 1738 (env)->SetIntField(target, AwtComponent::xID, ScaleDownX(rect.left)); 1739 (env)->SetIntField(target, AwtComponent::yID, ScaleDownY(rect.top)); 1740 (env)->SetIntField(peer, AwtWindow::sysXID, ScaleDownX(rect.left)); 1741 (env)->SetIntField(peer, AwtWindow::sysYID, ScaleDownY(rect.top)); 1742 SendComponentEvent(java_awt_event_ComponentEvent_COMPONENT_MOVED); 1743 1744 env->DeleteLocalRef(target); 1745 return AwtComponent::WmMove(x, y); 1746 } 1747 1748 MsgRouting AwtWindow::WmGetMinMaxInfo(LPMINMAXINFO lpmmi) 1749 { 1750 MsgRouting r = AwtCanvas::WmGetMinMaxInfo(lpmmi); 1751 if ((m_minSize.x == 0) && (m_minSize.y == 0)) { 1752 return r; 1753 } 1754 lpmmi->ptMinTrackSize.x = m_minSize.x; 1755 lpmmi->ptMinTrackSize.y = m_minSize.y; 1756 return mrConsume; 1757 } 1758 1759 MsgRouting AwtWindow::WmSizing() 1760 { 1761 if (!AwtToolkit::GetInstance().IsDynamicLayoutActive()) { 1786 * and below can be resized from outside of java (by user) 1787 */ 1788 MsgRouting AwtWindow::WmSize(UINT type, int w, int h) 1789 { 1790 currentWmSizeState = type; 1791 1792 if (type == SIZE_MINIMIZED) { 1793 UpdateSecurityWarningVisibility(); 1794 return mrDoDefault; 1795 } 1796 1797 JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2); 1798 if (env->EnsureLocalCapacity(1) < 0) 1799 return mrDoDefault; 1800 jobject target = GetTarget(env); 1801 // fix 4167248 : ensure the insets are up-to-date before using 1802 BOOL insetsChanged = UpdateInsets(NULL); 1803 int newWidth = w + m_insets.left + m_insets.right; 1804 int newHeight = h + m_insets.top + m_insets.bottom; 1805 1806 (env)->SetIntField(target, AwtComponent::widthID, ScaleDownX(newWidth)); 1807 (env)->SetIntField(target, AwtComponent::heightID, ScaleDownY(newHeight)); 1808 1809 jobject peer = GetPeer(env); 1810 (env)->SetIntField(peer, AwtWindow::sysWID, ScaleDownX(newWidth)); 1811 (env)->SetIntField(peer, AwtWindow::sysHID, ScaleDownY(newHeight)); 1812 1813 if (!AwtWindow::IsResizing()) { 1814 WindowResized(); 1815 } 1816 1817 env->DeleteLocalRef(target); 1818 return AwtComponent::WmSize(type, w, h); 1819 } 1820 1821 MsgRouting AwtWindow::WmPaint(HDC) 1822 { 1823 PaintUpdateRgn(&m_insets); 1824 return mrConsume; 1825 } 1826 1827 MsgRouting AwtWindow::WmSettingChange(UINT wFlag, LPCTSTR pszSection) 1828 { 1829 if (wFlag == SPI_SETNONCLIENTMETRICS) { 1830 // user changed window metrics in 1831 // Control Panel->Display->Appearance 3055 void AwtWindow::_SetFullScreenExclusiveModeState(void *param) 3056 { 3057 JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2); 3058 3059 SetFullScreenExclusiveModeStateStruct * data = 3060 (SetFullScreenExclusiveModeStateStruct*)param; 3061 jobject self = data->window; 3062 jboolean state = data->isFSEMState; 3063 3064 PDATA pData; 3065 JNI_CHECK_PEER_GOTO(self, ret); 3066 AwtWindow *window = (AwtWindow *)pData; 3067 3068 window->setFullScreenExclusiveModeState(state != 0); 3069 3070 ret: 3071 env->DeleteGlobalRef(self); 3072 delete data; 3073 } 3074 3075 void AwtWindow::_GetNativeWindowSize(void* param) { 3076 3077 JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2); 3078 3079 SizeStruct *ss = (SizeStruct *)param; 3080 jobject self = ss->window; 3081 AwtWindow *window = NULL; 3082 PDATA pData; 3083 JNI_CHECK_PEER_RETURN(self); 3084 window = (AwtWindow *)pData; 3085 3086 RECT rc; 3087 ::GetWindowRect(window->GetHWnd(), &rc); 3088 ss->w = rc.right - rc.left; 3089 ss->h = rc.bottom - rc.top; 3090 3091 env->DeleteGlobalRef(self); 3092 } 3093 3094 extern "C" { 3095 3096 /* 3097 * Class: java_awt_Window 3098 * Method: initIDs 3099 * Signature: ()V 3100 */ 3101 JNIEXPORT void JNICALL 3102 Java_java_awt_Window_initIDs(JNIEnv *env, jclass cls) 3103 { 3104 TRY; 3105 3106 CHECK_NULL(AwtWindow::warningStringID = 3107 env->GetFieldID(cls, "warningString", "Ljava/lang/String;")); 3108 CHECK_NULL(AwtWindow::locationByPlatformID = 3109 env->GetFieldID(cls, "locationByPlatform", "Z")); 3110 CHECK_NULL(AwtWindow::securityWarningWidthID = 3111 env->GetFieldID(cls, "securityWarningWidth", "I")); 3112 CHECK_NULL(AwtWindow::securityWarningHeightID = 3113 env->GetFieldID(cls, "securityWarningHeight", "I")); 3301 * Method: reshapeFrame 3302 * Signature: (IIII)V 3303 */ 3304 JNIEXPORT void JNICALL 3305 Java_sun_awt_windows_WWindowPeer_reshapeFrame(JNIEnv *env, jobject self, 3306 jint x, jint y, jint w, jint h) 3307 { 3308 TRY; 3309 3310 ReshapeFrameStruct *rfs = new ReshapeFrameStruct; 3311 rfs->frame = env->NewGlobalRef(self); 3312 rfs->x = x; 3313 rfs->y = y; 3314 rfs->w = w; 3315 rfs->h = h; 3316 3317 AwtToolkit::GetInstance().SyncCall(AwtWindow::_ReshapeFrame, rfs); 3318 // global ref and rfs are deleted in _ReshapeFrame() 3319 3320 CATCH_BAD_ALLOC; 3321 } 3322 3323 /* 3324 * Class: sun_awt_windows_WWindowPeer 3325 * Method: getNativeWindowSize 3326 * Signature: ()Ljava/awt/Dimension; 3327 */ 3328 JNIEXPORT jobject JNICALL Java_sun_awt_windows_WWindowPeer_getNativeWindowSize 3329 (JNIEnv *env, jobject self) { 3330 3331 jobject res = NULL; 3332 TRY; 3333 SizeStruct *ss = new SizeStruct; 3334 ss->window = env->NewGlobalRef(self); 3335 3336 AwtToolkit::GetInstance().SyncCall(AwtWindow::_GetNativeWindowSize, ss); 3337 3338 int w = ss->w; 3339 int h = ss->h; 3340 3341 delete ss; 3342 // global ref is deleted in _GetNativeWindowSize() 3343 3344 static jmethodID dimMID = NULL; 3345 static jclass dimClassID = NULL; 3346 if (dimClassID == NULL) { 3347 jclass dimClassIDLocal = env->FindClass("java/awt/Dimension"); 3348 CHECK_NULL_RETURN(dimClassIDLocal, NULL); 3349 dimClassID = (jclass)env->NewGlobalRef(dimClassIDLocal); 3350 env->DeleteLocalRef(dimClassIDLocal); 3351 } 3352 3353 if (dimMID == NULL) { 3354 dimMID = env->GetMethodID(dimClassID, "<init>", "(II)V"); 3355 CHECK_NULL_RETURN(dimMID, NULL); 3356 } 3357 3358 return env->NewObject(dimClassID, dimMID, w, h); 3359 3360 CATCH_BAD_ALLOC_RET(NULL); 3361 } 3362 3363 /* 3364 * Class: sun_awt_windows_WWindowPeer 3365 * Method: getSysMinWidth 3366 * Signature: ()I 3367 */ 3368 JNIEXPORT jint JNICALL 3369 Java_sun_awt_windows_WWindowPeer_getSysMinWidth(JNIEnv *env, jclass self) 3370 { 3371 TRY; 3372 3373 return ::GetSystemMetrics(SM_CXMIN); 3374 3375 CATCH_BAD_ALLOC_RET(0); 3376 } 3377 3378 /* 3379 * Class: sun_awt_windows_WWindowPeer 3380 * Method: getSysMinHeight |