src/windows/native/sun/windows/awt_Frame.cpp

Print this page




  88  */
  89 
  90 jfieldID AwtFrame::handleID;
  91 
  92 jfieldID AwtFrame::undecoratedID;
  93 jmethodID AwtFrame::getExtendedStateMID;
  94 jmethodID AwtFrame::setExtendedStateMID;
  95 
  96 jmethodID AwtFrame::activateEmbeddingTopLevelMID;
  97 
  98 Hashtable AwtFrame::sm_BlockedThreads("AWTBlockedThreads");
  99 
 100 /************************************************************************
 101  * AwtFrame methods
 102  */
 103 
 104 AwtFrame::AwtFrame() {
 105     m_parentWnd = NULL;
 106     menuBar = NULL;
 107     m_isEmbedded = FALSE;

 108     m_ignoreWmSize = FALSE;
 109     m_isMenuDropped = FALSE;
 110     m_isInputMethodWindow = FALSE;
 111     m_isUndecorated = FALSE;
 112     m_imeTargetComponent = NULL;
 113     m_actualFocusedWindow = NULL;
 114     m_iconic = FALSE;
 115     m_zoomed = FALSE;
 116     m_maxBoundsSet = FALSE;
 117     m_forceResetZoomed = FALSE;
 118 
 119     isInManualMoveOrSize = FALSE;
 120     grabbedHitTest = 0;
 121 }
 122 
 123 AwtFrame::~AwtFrame()
 124 {
 125 }
 126 
 127 void AwtFrame::Dispose()


 153     try {
 154         target = env->GetObjectField(self, AwtObject::targetID);
 155         JNI_CHECK_NULL_GOTO(target, "target", done);
 156 
 157         if (parent != NULL) {
 158             JNI_CHECK_PEER_GOTO(parent, done);
 159             {
 160                 AwtFrame* parent = (AwtFrame *)pData;
 161                 hwndParent = parent->GetHWnd();
 162             }
 163         }
 164 
 165         frame = new AwtFrame();
 166 
 167         {
 168             /*
 169              * A variation on Netscape's hack for embedded frames: the client
 170              * area of the browser is a Java Frame for parenting purposes, but
 171              * really a Windows child window
 172              */


 173             cls = env->FindClass("sun/awt/EmbeddedFrame");
 174             if (cls == NULL) {
 175                 return NULL;
 176             }
 177             INT_PTR handle;
 178             jboolean isEmbeddedInstance = env->IsInstanceOf(target, cls);
 179             jboolean isEmbedded = FALSE;
 180 
 181             if (isEmbeddedInstance) {
 182                 handle = static_cast<INT_PTR>(env->GetLongField(target, AwtFrame::handleID));
 183                 if (handle != 0) {
 184                     isEmbedded = TRUE;
 185                 }
 186             }
 187             frame->m_isEmbedded = isEmbedded;
 188 







 189             if (isEmbedded) {
 190                 hwndParent = (HWND)handle;
 191                 RECT rect;
 192                 ::GetClientRect(hwndParent, &rect);
 193                 //Fix for 6328675: SWT_AWT.new_Frame doesn't occupy client area under JDK6
 194                 frame->m_isUndecorated = true;
 195                 /*
 196                  * Fix for BugTraq ID 4337754.
 197                  * Initialize m_peerObject before the first call
 198                  * to AwtFrame::GetClassName().
 199                  */
 200                 frame->m_peerObject = env->NewGlobalRef(self);
 201                 frame->RegisterClass();
 202                 DWORD exStyle = WS_EX_NOPARENTNOTIFY;
 203 
 204                 if (GetRTL()) {
 205                     exStyle |= WS_EX_RIGHT | WS_EX_LEFTSCROLLBAR;
 206                     if (GetRTLReadingOrder())
 207                         exStyle |= WS_EX_RTLREADING;
 208                 }


 213                                                  0, 0,
 214                                                  rect.right, rect.bottom,
 215                                                  hwndParent, NULL,
 216                                                  AwtToolkit::GetInstance().GetModuleHandle(),
 217                                                  NULL);
 218                 frame->LinkObjects(env, self);
 219                 frame->SubclassHWND();
 220 
 221                 // Update target's dimensions to reflect this embedded window.
 222                 ::GetClientRect(frame->m_hwnd, &rect);
 223                 ::MapWindowPoints(frame->m_hwnd, hwndParent, (LPPOINT)&rect, 2);
 224 
 225                 env->SetIntField(target, AwtComponent::xID, rect.left);
 226                 env->SetIntField(target, AwtComponent::yID, rect.top);
 227                 env->SetIntField(target, AwtComponent::widthID,
 228                                  rect.right-rect.left);
 229                 env->SetIntField(target, AwtComponent::heightID,
 230                                  rect.bottom-rect.top);
 231                 frame->InitPeerGraphicsConfig(env, self);
 232                 AwtToolkit::GetInstance().RegisterEmbedderProcessId(hwndParent);

















 233             } else {
 234                 jint state = env->CallIntMethod(self, AwtFrame::getExtendedStateMID);
 235                 DWORD exStyle;
 236                 DWORD style;
 237 
 238                // for input method windows, use minimal decorations
 239                inputMethodWindowCls = env->FindClass("sun/awt/im/InputMethodWindow");
 240                if ((inputMethodWindowCls != NULL) && env->IsInstanceOf(target, inputMethodWindowCls)) {
 241                    //for below-the-spot composition window, use no decoration
 242                    if (env->GetBooleanField(target, AwtFrame::undecoratedID) == JNI_TRUE){
 243                         exStyle = 0;
 244                         style = WS_POPUP|WS_CLIPCHILDREN;
 245                         frame->m_isUndecorated = TRUE;
 246                    } else {
 247                         exStyle = WS_EX_PALETTEWINDOW;
 248                         style = WS_CLIPCHILDREN;
 249                    }
 250                    frame->m_isInputMethodWindow = TRUE;
 251                 } else if (env->GetBooleanField(target, AwtFrame::undecoratedID) == JNI_TRUE) {
 252                     exStyle = 0;


 328         case WM_IME_KEYUP:
 329         case WM_INPUTLANGCHANGEREQUEST:
 330         case WM_INPUTLANGCHANGE:
 331             if (message == WM_IME_STARTCOMPOSITION) {
 332                 SetImeTargetComponent(sm_focusOwner);
 333             }
 334             imeTargetComponent = AwtComponent::GetComponent(GetImeTargetComponent());
 335             if (imeTargetComponent != NULL &&
 336                 imeTargetComponent != this) // avoid recursive calls
 337             {
 338                 retValue = imeTargetComponent->WindowProc(message, wParam, lParam);
 339                 mr = mrConsume;
 340             }
 341             if (message == WM_IME_ENDCOMPOSITION) {
 342                 SetImeTargetComponent(NULL);
 343             }
 344             break;
 345         case WM_SETFOCUS:
 346             if (sm_inSynthesizeFocus) break; // pass it up the WindowProc chain
 347 
 348             if (!sm_suppressFocusAndActivation && IsEmbeddedFrame()) {

 349                 AwtSetActiveWindow();
 350             }

 351             mr = mrConsume;
 352             break;
 353         case WM_KILLFOCUS:
 354             if (sm_inSynthesizeFocus) break; // pass it up the WindowProc chain
 355 
 356             if (!sm_suppressFocusAndActivation && IsEmbeddedFrame()) {

 357                 AwtWindow::SynthesizeWmActivate(FALSE, GetHWnd(), NULL);

 358 
 359             } else if (sm_restoreFocusAndActivation) {
 360                 if (AwtComponent::GetFocusedWindow() != NULL) {
 361                     AwtWindow *focusedWindow = (AwtWindow*)GetComponent(AwtComponent::GetFocusedWindow());
 362                     if (focusedWindow != NULL) {
 363                         // Will just silently restore native focus & activation.
 364                         focusedWindow->AwtSetActiveWindow();
 365                     }
 366                 }
 367             }
 368             mr = mrConsume;
 369             break;
 370         case 0x0127: // WM_CHANGEUISTATE
 371         case 0x0128: // WM_UPDATEUISTATE
 372             mr = mrConsume;
 373             break;
 374     }
 375 
 376     return retValue;
 377 }


 623     // (calling ShowWindow(SW_RESTORE) would fire an
 624     //  activation event which we don't want)
 625         LONG    style = GetStyle();
 626         DASSERT(style & WS_MAXIMIZE);
 627         style ^= WS_MAXIMIZE;
 628         SetStyle(style);
 629     }
 630 
 631     AwtWindow::Reshape(x, y, width, height);
 632 }
 633 
 634 
 635 /* Show the frame in it's current state */
 636 void
 637 AwtFrame::Show()
 638 {
 639     m_visible = true;
 640     HWND hwnd = GetHWnd();
 641     JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
 642 




 643     DTRACE_PRINTLN3("AwtFrame::Show:%s%s%s",
 644                   m_iconic ? " iconic" : "",
 645                   m_zoomed ? " zoomed" : "",
 646                   m_iconic || m_zoomed ? "" : " normal");
 647 
 648     BOOL locationByPlatform = env->GetBooleanField(GetTarget(env), AwtWindow::locationByPlatformID);
 649 
 650     if (locationByPlatform) {
 651          moveToDefaultLocation();
 652     }
 653     EnableTranslucency(TRUE);
 654 
 655     BOOL autoRequestFocus = IsAutoRequestFocus();
 656 
 657     if (m_iconic) {
 658         if (m_zoomed) {
 659             // This whole function could probably be rewritten to use
 660             // ::SetWindowPlacement but MS docs doesn't tell if
 661             // ::SetWindowPlacement is a proper superset of
 662             // ::ShowWindow.  So let's be conservative and only use it


 975                 if (oppositeWindow && oppositeWindow != this &&
 976                     oppositeWindow->GetOwningFrameOrDialog() != this)
 977                 {
 978                     m_actualFocusedWindow = focusedWindow;
 979                 }
 980             } else {
 981                  m_actualFocusedWindow = focusedWindow;
 982             }
 983         }
 984     }
 985 }
 986 
 987 BOOL AwtFrame::AwtSetActiveWindow(BOOL isMouseEventCause, UINT hittest)
 988 {
 989     if (hittest == HTCLIENT) {
 990         // Don't let the actualFocusedWindow to steal focus if:
 991         // a) the frame is clicked in its client area;
 992         // b) focus is requested to some of the frame's child.
 993         m_actualFocusedWindow = NULL;
 994     }



 995     return AwtWindow::AwtSetActiveWindow(isMouseEventCause);
 996 }
 997 
 998 MsgRouting AwtFrame::WmEnterMenuLoop(BOOL isTrackPopupMenu)
 999 {
1000     if ( !isTrackPopupMenu ) {
1001         m_isMenuDropped = TRUE;
1002     }
1003     return mrDoDefault;
1004 }
1005 
1006 MsgRouting AwtFrame::WmExitMenuLoop(BOOL isTrackPopupMenu)
1007 {
1008     if ( !isTrackPopupMenu ) {
1009         m_isMenuDropped = FALSE;
1010     }
1011     return mrDoDefault;
1012 }
1013 
1014 AwtMenuBar* AwtFrame::GetMenuBar()


1856     jobject result = (jobject)AwtToolkit::GetInstance().SyncCall(
1857         (void *(*)(void *))AwtFrame::_GetBoundsPrivate,
1858         env->NewGlobalRef(self));
1859     // global ref is deleted in _GetBoundsPrivate
1860 
1861     if (result != NULL)
1862     {
1863         jobject resultLocalRef = env->NewLocalRef(result);
1864         env->DeleteGlobalRef(result);
1865         return resultLocalRef;
1866     }
1867     else
1868     {
1869         return NULL;
1870     }
1871 
1872     CATCH_BAD_ALLOC_RET(NULL);
1873 }
1874 
1875 JNIEXPORT void JNICALL
1876 Java_sun_awt_windows_WEmbeddedFramePeer_synthesizeWmActivate(JNIEnv *env, jobject self, jboolean doActivate)
1877 {
1878     TRY;
1879 
1880     SynthesizeWmActivateStruct *sas = new SynthesizeWmActivateStruct;
1881     sas->frame = env->NewGlobalRef(self);
1882     sas->doActivate = doActivate;
1883 
1884     /*
1885      * WARNING: invoking this function without synchronization by m_Sync CriticalSection.
1886      * Taking this lock results in a deadlock.
1887      */
1888     AwtToolkit::GetInstance().InvokeFunction(AwtFrame::_SynthesizeWmActivate, sas);
1889     // global ref and sas are deleted in _SynthesizeWmActivate()
1890 
1891     CATCH_BAD_ALLOC;
1892 }
1893 
1894 } /* extern "C" */


  88  */
  89 
  90 jfieldID AwtFrame::handleID;
  91 
  92 jfieldID AwtFrame::undecoratedID;
  93 jmethodID AwtFrame::getExtendedStateMID;
  94 jmethodID AwtFrame::setExtendedStateMID;
  95 
  96 jmethodID AwtFrame::activateEmbeddingTopLevelMID;
  97 
  98 Hashtable AwtFrame::sm_BlockedThreads("AWTBlockedThreads");
  99 
 100 /************************************************************************
 101  * AwtFrame methods
 102  */
 103 
 104 AwtFrame::AwtFrame() {
 105     m_parentWnd = NULL;
 106     menuBar = NULL;
 107     m_isEmbedded = FALSE;
 108     m_isLightweight = FALSE;
 109     m_ignoreWmSize = FALSE;
 110     m_isMenuDropped = FALSE;
 111     m_isInputMethodWindow = FALSE;
 112     m_isUndecorated = FALSE;
 113     m_imeTargetComponent = NULL;
 114     m_actualFocusedWindow = NULL;
 115     m_iconic = FALSE;
 116     m_zoomed = FALSE;
 117     m_maxBoundsSet = FALSE;
 118     m_forceResetZoomed = FALSE;
 119 
 120     isInManualMoveOrSize = FALSE;
 121     grabbedHitTest = 0;
 122 }
 123 
 124 AwtFrame::~AwtFrame()
 125 {
 126 }
 127 
 128 void AwtFrame::Dispose()


 154     try {
 155         target = env->GetObjectField(self, AwtObject::targetID);
 156         JNI_CHECK_NULL_GOTO(target, "target", done);
 157 
 158         if (parent != NULL) {
 159             JNI_CHECK_PEER_GOTO(parent, done);
 160             {
 161                 AwtFrame* parent = (AwtFrame *)pData;
 162                 hwndParent = parent->GetHWnd();
 163             }
 164         }
 165 
 166         frame = new AwtFrame();
 167 
 168         {
 169             /*
 170              * A variation on Netscape's hack for embedded frames: the client
 171              * area of the browser is a Java Frame for parenting purposes, but
 172              * really a Windows child window
 173              */
 174             BOOL isEmbeddedInstance = FALSE;
 175             BOOL isEmbedded = FALSE;
 176             cls = env->FindClass("sun/awt/EmbeddedFrame");
 177             if (cls) {
 178                 isEmbeddedInstance = env->IsInstanceOf(target, cls);
 179             }
 180             INT_PTR handle;



 181             if (isEmbeddedInstance) {
 182                 handle = static_cast<INT_PTR>(env->GetLongField(target, AwtFrame::handleID));
 183                 if (handle != 0) {
 184                     isEmbedded = TRUE;
 185                 }
 186             }
 187             frame->m_isEmbedded = isEmbedded;
 188 
 189             BOOL isLightweight = FALSE;
 190             cls = env->FindClass("sun/awt/LightweightFrame");
 191             if (cls) {
 192                 isLightweight = env->IsInstanceOf(target, cls);
 193             }
 194             frame->m_isLightweight = isLightweight;
 195 
 196             if (isEmbedded) {
 197                 hwndParent = (HWND)handle;
 198                 RECT rect;
 199                 ::GetClientRect(hwndParent, &rect);
 200                 //Fix for 6328675: SWT_AWT.new_Frame doesn't occupy client area under JDK6
 201                 frame->m_isUndecorated = true;
 202                 /*
 203                  * Fix for BugTraq ID 4337754.
 204                  * Initialize m_peerObject before the first call
 205                  * to AwtFrame::GetClassName().
 206                  */
 207                 frame->m_peerObject = env->NewGlobalRef(self);
 208                 frame->RegisterClass();
 209                 DWORD exStyle = WS_EX_NOPARENTNOTIFY;
 210 
 211                 if (GetRTL()) {
 212                     exStyle |= WS_EX_RIGHT | WS_EX_LEFTSCROLLBAR;
 213                     if (GetRTLReadingOrder())
 214                         exStyle |= WS_EX_RTLREADING;
 215                 }


 220                                                  0, 0,
 221                                                  rect.right, rect.bottom,
 222                                                  hwndParent, NULL,
 223                                                  AwtToolkit::GetInstance().GetModuleHandle(),
 224                                                  NULL);
 225                 frame->LinkObjects(env, self);
 226                 frame->SubclassHWND();
 227 
 228                 // Update target's dimensions to reflect this embedded window.
 229                 ::GetClientRect(frame->m_hwnd, &rect);
 230                 ::MapWindowPoints(frame->m_hwnd, hwndParent, (LPPOINT)&rect, 2);
 231 
 232                 env->SetIntField(target, AwtComponent::xID, rect.left);
 233                 env->SetIntField(target, AwtComponent::yID, rect.top);
 234                 env->SetIntField(target, AwtComponent::widthID,
 235                                  rect.right-rect.left);
 236                 env->SetIntField(target, AwtComponent::heightID,
 237                                  rect.bottom-rect.top);
 238                 frame->InitPeerGraphicsConfig(env, self);
 239                 AwtToolkit::GetInstance().RegisterEmbedderProcessId(hwndParent);
 240             } else if (isLightweight) {
 241                 frame->m_isUndecorated = true;
 242                 frame->m_peerObject = env->NewGlobalRef(self);
 243                 frame->RegisterClass();
 244 
 245                 DWORD exStyle = 0;
 246                 DWORD style = WS_POPUP;
 247 
 248                 frame->CreateHWnd(env, L"",
 249                                   style,
 250                                   exStyle,
 251                                   0, 0, 0, 0,
 252                                   0,
 253                                   NULL,
 254                                   ::GetSysColor(COLOR_WINDOWTEXT),
 255                                   ::GetSysColor(COLOR_WINDOWFRAME),
 256                                   self);
 257             } else {
 258                 jint state = env->CallIntMethod(self, AwtFrame::getExtendedStateMID);
 259                 DWORD exStyle;
 260                 DWORD style;
 261 
 262                // for input method windows, use minimal decorations
 263                inputMethodWindowCls = env->FindClass("sun/awt/im/InputMethodWindow");
 264                if ((inputMethodWindowCls != NULL) && env->IsInstanceOf(target, inputMethodWindowCls)) {
 265                    //for below-the-spot composition window, use no decoration
 266                    if (env->GetBooleanField(target, AwtFrame::undecoratedID) == JNI_TRUE){
 267                         exStyle = 0;
 268                         style = WS_POPUP|WS_CLIPCHILDREN;
 269                         frame->m_isUndecorated = TRUE;
 270                    } else {
 271                         exStyle = WS_EX_PALETTEWINDOW;
 272                         style = WS_CLIPCHILDREN;
 273                    }
 274                    frame->m_isInputMethodWindow = TRUE;
 275                 } else if (env->GetBooleanField(target, AwtFrame::undecoratedID) == JNI_TRUE) {
 276                     exStyle = 0;


 352         case WM_IME_KEYUP:
 353         case WM_INPUTLANGCHANGEREQUEST:
 354         case WM_INPUTLANGCHANGE:
 355             if (message == WM_IME_STARTCOMPOSITION) {
 356                 SetImeTargetComponent(sm_focusOwner);
 357             }
 358             imeTargetComponent = AwtComponent::GetComponent(GetImeTargetComponent());
 359             if (imeTargetComponent != NULL &&
 360                 imeTargetComponent != this) // avoid recursive calls
 361             {
 362                 retValue = imeTargetComponent->WindowProc(message, wParam, lParam);
 363                 mr = mrConsume;
 364             }
 365             if (message == WM_IME_ENDCOMPOSITION) {
 366                 SetImeTargetComponent(NULL);
 367             }
 368             break;
 369         case WM_SETFOCUS:
 370             if (sm_inSynthesizeFocus) break; // pass it up the WindowProc chain
 371 
 372             if (!sm_suppressFocusAndActivation) {
 373                 if (IsLightweightFrame() || IsEmbeddedFrame()) {
 374                     AwtSetActiveWindow();
 375                 }
 376             }
 377             mr = mrConsume;
 378             break;
 379         case WM_KILLFOCUS:
 380             if (sm_inSynthesizeFocus) break; // pass it up the WindowProc chain
 381 
 382             if (!sm_suppressFocusAndActivation) {
 383                 if (IsLightweightFrame() || IsEmbeddedFrame()) {
 384                     AwtWindow::SynthesizeWmActivate(FALSE, GetHWnd(), NULL);
 385                 }
 386 
 387             } else if (sm_restoreFocusAndActivation) {
 388                 if (AwtComponent::GetFocusedWindow() != NULL) {
 389                     AwtWindow *focusedWindow = (AwtWindow*)GetComponent(AwtComponent::GetFocusedWindow());
 390                     if (focusedWindow != NULL) {
 391                         // Will just silently restore native focus & activation.
 392                         focusedWindow->AwtSetActiveWindow();
 393                     }
 394                 }
 395             }
 396             mr = mrConsume;
 397             break;
 398         case 0x0127: // WM_CHANGEUISTATE
 399         case 0x0128: // WM_UPDATEUISTATE
 400             mr = mrConsume;
 401             break;
 402     }
 403 
 404     return retValue;
 405 }


 651     // (calling ShowWindow(SW_RESTORE) would fire an
 652     //  activation event which we don't want)
 653         LONG    style = GetStyle();
 654         DASSERT(style & WS_MAXIMIZE);
 655         style ^= WS_MAXIMIZE;
 656         SetStyle(style);
 657     }
 658 
 659     AwtWindow::Reshape(x, y, width, height);
 660 }
 661 
 662 
 663 /* Show the frame in it's current state */
 664 void
 665 AwtFrame::Show()
 666 {
 667     m_visible = true;
 668     HWND hwnd = GetHWnd();
 669     JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
 670 
 671     if (IsLightweightFrame()) {
 672         return;
 673     }
 674 
 675     DTRACE_PRINTLN3("AwtFrame::Show:%s%s%s",
 676                   m_iconic ? " iconic" : "",
 677                   m_zoomed ? " zoomed" : "",
 678                   m_iconic || m_zoomed ? "" : " normal");
 679 
 680     BOOL locationByPlatform = env->GetBooleanField(GetTarget(env), AwtWindow::locationByPlatformID);
 681 
 682     if (locationByPlatform) {
 683          moveToDefaultLocation();
 684     }
 685     EnableTranslucency(TRUE);
 686 
 687     BOOL autoRequestFocus = IsAutoRequestFocus();
 688 
 689     if (m_iconic) {
 690         if (m_zoomed) {
 691             // This whole function could probably be rewritten to use
 692             // ::SetWindowPlacement but MS docs doesn't tell if
 693             // ::SetWindowPlacement is a proper superset of
 694             // ::ShowWindow.  So let's be conservative and only use it


1007                 if (oppositeWindow && oppositeWindow != this &&
1008                     oppositeWindow->GetOwningFrameOrDialog() != this)
1009                 {
1010                     m_actualFocusedWindow = focusedWindow;
1011                 }
1012             } else {
1013                  m_actualFocusedWindow = focusedWindow;
1014             }
1015         }
1016     }
1017 }
1018 
1019 BOOL AwtFrame::AwtSetActiveWindow(BOOL isMouseEventCause, UINT hittest)
1020 {
1021     if (hittest == HTCLIENT) {
1022         // Don't let the actualFocusedWindow to steal focus if:
1023         // a) the frame is clicked in its client area;
1024         // b) focus is requested to some of the frame's child.
1025         m_actualFocusedWindow = NULL;
1026     }
1027     if (IsLightweightFrame()) {
1028         return TRUE;
1029     }
1030     return AwtWindow::AwtSetActiveWindow(isMouseEventCause);
1031 }
1032 
1033 MsgRouting AwtFrame::WmEnterMenuLoop(BOOL isTrackPopupMenu)
1034 {
1035     if ( !isTrackPopupMenu ) {
1036         m_isMenuDropped = TRUE;
1037     }
1038     return mrDoDefault;
1039 }
1040 
1041 MsgRouting AwtFrame::WmExitMenuLoop(BOOL isTrackPopupMenu)
1042 {
1043     if ( !isTrackPopupMenu ) {
1044         m_isMenuDropped = FALSE;
1045     }
1046     return mrDoDefault;
1047 }
1048 
1049 AwtMenuBar* AwtFrame::GetMenuBar()


1891     jobject result = (jobject)AwtToolkit::GetInstance().SyncCall(
1892         (void *(*)(void *))AwtFrame::_GetBoundsPrivate,
1893         env->NewGlobalRef(self));
1894     // global ref is deleted in _GetBoundsPrivate
1895 
1896     if (result != NULL)
1897     {
1898         jobject resultLocalRef = env->NewLocalRef(result);
1899         env->DeleteGlobalRef(result);
1900         return resultLocalRef;
1901     }
1902     else
1903     {
1904         return NULL;
1905     }
1906 
1907     CATCH_BAD_ALLOC_RET(NULL);
1908 }
1909 
1910 JNIEXPORT void JNICALL
1911 Java_sun_awt_windows_WFramePeer_synthesizeWmActivate(JNIEnv *env, jobject self, jboolean doActivate)
1912 {
1913     TRY;
1914 
1915     SynthesizeWmActivateStruct *sas = new SynthesizeWmActivateStruct;
1916     sas->frame = env->NewGlobalRef(self);
1917     sas->doActivate = doActivate;
1918 
1919     /*
1920      * WARNING: invoking this function without synchronization by m_Sync CriticalSection.
1921      * Taking this lock results in a deadlock.
1922      */
1923     AwtToolkit::GetInstance().InvokeFunction(AwtFrame::_SynthesizeWmActivate, sas);
1924     // global ref and sas are deleted in _SynthesizeWmActivate()
1925 
1926     CATCH_BAD_ALLOC;
1927 }
1928 
1929 } /* extern "C" */