1577 AwtDialog *d = (AwtDialog *)pData; 1578 1579 if ((f != NULL) && ::IsWindow(f->GetHWnd())) 1580 { 1581 // get an HWND of the toplevel window this embedded frame is within 1582 HWND fHWnd = f->GetHWnd(); 1583 while (::GetParent(fHWnd) != NULL) { 1584 fHWnd = ::GetParent(fHWnd); 1585 } 1586 // we must get a toplevel hwnd here, however due to some strange 1587 // behaviour of Java Plugin (a bug?) when running in IE at 1588 // this moment the embedded frame hasn't been placed into the 1589 // browser yet and fHWnd is not a toplevel, so we shouldn't install 1590 // the hook here 1591 if ((::GetWindowLong(fHWnd, GWL_STYLE) & WS_CHILD) == 0) { 1592 // if this toplevel is created in another thread, we should install 1593 // the modal hook into it to track window activation and mouse events 1594 DWORD fThread = ::GetWindowThreadProcessId(fHWnd, NULL); 1595 if (fThread != AwtToolkit::GetInstance().MainThread()) { 1596 // check if this thread has been already blocked 1597 BlockedThreadStruct *blockedThread = (BlockedThreadStruct *)sm_BlockedThreads.get((void *)fThread); 1598 if (blocked) { 1599 if (blockedThread == NULL) { 1600 blockedThread = new BlockedThreadStruct; 1601 blockedThread->framesCount = 1; 1602 blockedThread->modalHook = ::SetWindowsHookEx(WH_CBT, (HOOKPROC)AwtDialog::ModalFilterProc, 1603 0, fThread); 1604 blockedThread->mouseHook = ::SetWindowsHookEx(WH_MOUSE, (HOOKPROC)AwtDialog::MouseHookProc_NonTT, 1605 0, fThread); 1606 sm_BlockedThreads.put((void *)fThread, blockedThread); 1607 } else { 1608 blockedThread->framesCount++; 1609 } 1610 } else { 1611 // see the comment above: if Java Plugin behaviour when running in IE 1612 // was right, blockedThread would be always not NULL here 1613 if (blockedThread != NULL) { 1614 DASSERT(blockedThread->framesCount > 0); 1615 if ((blockedThread->framesCount) == 1) { 1616 ::UnhookWindowsHookEx(blockedThread->modalHook); 1617 ::UnhookWindowsHookEx(blockedThread->mouseHook); 1618 sm_BlockedThreads.remove((void *)fThread); 1619 delete blockedThread; 1620 } else { 1621 blockedThread->framesCount--; 1622 } 1623 } 1624 } 1625 } 1626 } 1627 } 1628 1629 env->DeleteGlobalRef(self); 1630 env->DeleteGlobalRef(peer); 1631 env->DeleteGlobalRef(blockerPeer); 1632 1633 delete nmbs; 1634 } 1635 1636 /************************************************************************ 1637 * WFramePeer native methods 1638 */ | 1577 AwtDialog *d = (AwtDialog *)pData; 1578 1579 if ((f != NULL) && ::IsWindow(f->GetHWnd())) 1580 { 1581 // get an HWND of the toplevel window this embedded frame is within 1582 HWND fHWnd = f->GetHWnd(); 1583 while (::GetParent(fHWnd) != NULL) { 1584 fHWnd = ::GetParent(fHWnd); 1585 } 1586 // we must get a toplevel hwnd here, however due to some strange 1587 // behaviour of Java Plugin (a bug?) when running in IE at 1588 // this moment the embedded frame hasn't been placed into the 1589 // browser yet and fHWnd is not a toplevel, so we shouldn't install 1590 // the hook here 1591 if ((::GetWindowLong(fHWnd, GWL_STYLE) & WS_CHILD) == 0) { 1592 // if this toplevel is created in another thread, we should install 1593 // the modal hook into it to track window activation and mouse events 1594 DWORD fThread = ::GetWindowThreadProcessId(fHWnd, NULL); 1595 if (fThread != AwtToolkit::GetInstance().MainThread()) { 1596 // check if this thread has been already blocked 1597 BlockedThreadStruct *blockedThread = (BlockedThreadStruct *)sm_BlockedThreads.get((void *)(uintptr_t)fThread); 1598 if (blocked) { 1599 if (blockedThread == NULL) { 1600 blockedThread = new BlockedThreadStruct; 1601 blockedThread->framesCount = 1; 1602 blockedThread->modalHook = ::SetWindowsHookEx(WH_CBT, (HOOKPROC)AwtDialog::ModalFilterProc, 1603 0, fThread); 1604 blockedThread->mouseHook = ::SetWindowsHookEx(WH_MOUSE, (HOOKPROC)AwtDialog::MouseHookProc_NonTT, 1605 0, fThread); 1606 sm_BlockedThreads.put((void *)(uintptr_t)fThread, blockedThread); 1607 } else { 1608 blockedThread->framesCount++; 1609 } 1610 } else { 1611 // see the comment above: if Java Plugin behaviour when running in IE 1612 // was right, blockedThread would be always not NULL here 1613 if (blockedThread != NULL) { 1614 DASSERT(blockedThread->framesCount > 0); 1615 if ((blockedThread->framesCount) == 1) { 1616 ::UnhookWindowsHookEx(blockedThread->modalHook); 1617 ::UnhookWindowsHookEx(blockedThread->mouseHook); 1618 sm_BlockedThreads.remove((void *)(uintptr_t)fThread); 1619 delete blockedThread; 1620 } else { 1621 blockedThread->framesCount--; 1622 } 1623 } 1624 } 1625 } 1626 } 1627 } 1628 1629 env->DeleteGlobalRef(self); 1630 env->DeleteGlobalRef(peer); 1631 env->DeleteGlobalRef(blockerPeer); 1632 1633 delete nmbs; 1634 } 1635 1636 /************************************************************************ 1637 * WFramePeer native methods 1638 */ |