src/windows/native/sun/windows/awt_Window.cpp

Print this page




1542 
1543     if (id == java_awt_event_WindowEvent_WINDOW_GAINED_FOCUS ||
1544         id == java_awt_event_WindowEvent_WINDOW_LOST_FOCUS)
1545     {
1546         jobject sequencedEvent = env->NewObject(sequencedEventCls,
1547                                                 sequencedEventConst,
1548                                                 event);
1549         DASSERT(!safe_ExceptionOccurred(env));
1550         DASSERT(sequencedEvent != NULL);
1551         env->DeleteLocalRef(event);
1552         event = sequencedEvent;
1553     }
1554 
1555     SendEvent(event);
1556 
1557     env->DeleteLocalRef(event);
1558 }
1559 
1560 BOOL AwtWindow::AwtSetActiveWindow(BOOL isMouseEventCause, UINT hittest)
1561 {
1562     // Fix for 6458497.
1563     // Retreat if current foreground window is out of both our and embedder process.
1564     // The exception is when activation is requested due to a mouse event.
1565     if (!isMouseEventCause) {
1566         HWND fgWindow = ::GetForegroundWindow();
1567         if (NULL != fgWindow) {
1568             DWORD fgProcessID;
1569             ::GetWindowThreadProcessId(fgWindow, &fgProcessID);
1570             if (fgProcessID != ::GetCurrentProcessId()
1571                 && !AwtToolkit::GetInstance().IsEmbedderProcessId(fgProcessID))
1572             {
1573                 return FALSE;
1574             }
1575         }
1576     }
1577 
1578     HWND proxyContainerHWnd = GetProxyToplevelContainer();
1579     HWND proxyHWnd = GetProxyFocusOwner();
1580 
1581     if (proxyContainerHWnd == NULL || proxyHWnd == NULL) {
1582         return FALSE;
1583     }
1584 
1585     // Activate the proxy toplevel container
1586     if (::GetActiveWindow() != proxyContainerHWnd) {
1587         sm_suppressFocusAndActivation = TRUE;
1588         ::BringWindowToTop(proxyContainerHWnd);
1589         ::SetForegroundWindow(proxyContainerHWnd);
1590         sm_suppressFocusAndActivation = FALSE;
1591 
1592         if (::GetActiveWindow() != proxyContainerHWnd) {
1593             return FALSE; // activation has been rejected
1594         }
1595     }
1596 




1542 
1543     if (id == java_awt_event_WindowEvent_WINDOW_GAINED_FOCUS ||
1544         id == java_awt_event_WindowEvent_WINDOW_LOST_FOCUS)
1545     {
1546         jobject sequencedEvent = env->NewObject(sequencedEventCls,
1547                                                 sequencedEventConst,
1548                                                 event);
1549         DASSERT(!safe_ExceptionOccurred(env));
1550         DASSERT(sequencedEvent != NULL);
1551         env->DeleteLocalRef(event);
1552         event = sequencedEvent;
1553     }
1554 
1555     SendEvent(event);
1556 
1557     env->DeleteLocalRef(event);
1558 }
1559 
1560 BOOL AwtWindow::AwtSetActiveWindow(BOOL isMouseEventCause, UINT hittest)
1561 {
1562     // We used to reject non mouse window activation if our app wasn't active.
1563     // This code since has been removed as the fix for 7185280













1564 
1565     HWND proxyContainerHWnd = GetProxyToplevelContainer();
1566     HWND proxyHWnd = GetProxyFocusOwner();
1567 
1568     if (proxyContainerHWnd == NULL || proxyHWnd == NULL) {
1569         return FALSE;
1570     }
1571 
1572     // Activate the proxy toplevel container
1573     if (::GetActiveWindow() != proxyContainerHWnd) {
1574         sm_suppressFocusAndActivation = TRUE;
1575         ::BringWindowToTop(proxyContainerHWnd);
1576         ::SetForegroundWindow(proxyContainerHWnd);
1577         sm_suppressFocusAndActivation = FALSE;
1578 
1579         if (::GetActiveWindow() != proxyContainerHWnd) {
1580             return FALSE; // activation has been rejected
1581         }
1582     }
1583