6770457: Using ToolTips causes inactive app window to exhibit active window behavior
authordcherepanov
Mon, 20 Apr 2009 17:05:34 +0400
changeset 2646 ab13ed73d1f5
parent 2645 5dfb43cecd32
child 2647 ea80a312972e
6770457: Using ToolTips causes inactive app window to exhibit active window behavior Reviewed-by: art, ant
jdk/src/windows/native/sun/windows/awt_Component.cpp
jdk/src/windows/native/sun/windows/awt_Window.cpp
jdk/src/windows/native/sun/windows/awt_Window.h
--- a/jdk/src/windows/native/sun/windows/awt_Component.cpp	Mon Apr 20 14:41:24 2009 -0400
+++ b/jdk/src/windows/native/sun/windows/awt_Component.cpp	Mon Apr 20 17:05:34 2009 +0400
@@ -1843,8 +1843,13 @@
       case WM_AWT_SETALWAYSONTOP: {
         AwtWindow* w = (AwtWindow*)lParam;
         BOOL value = (BOOL)wParam;
+        UINT flags = SWP_NOMOVE | SWP_NOSIZE;
+        // transient windows shouldn't change the owner window's position in the z-order
+        if (w->IsRetainingHierarchyZOrder()) {
+            flags |= SWP_NOOWNERZORDER;
+        }
         ::SetWindowPos(w->GetHWnd(), (value != 0 ? HWND_TOPMOST : HWND_NOTOPMOST),
-                       0,0,0,0, SWP_NOMOVE|SWP_NOSIZE);
+                       0,0,0,0, flags);
         break;
       }
 
--- a/jdk/src/windows/native/sun/windows/awt_Window.cpp	Mon Apr 20 14:41:24 2009 -0400
+++ b/jdk/src/windows/native/sun/windows/awt_Window.cpp	Mon Apr 20 17:05:34 2009 +0400
@@ -165,7 +165,6 @@
 int AwtWindow::ms_instanceCounter = 0;
 HHOOK AwtWindow::ms_hCBTFilter;
 AwtWindow * AwtWindow::m_grabbedWindow = NULL;
-HWND AwtWindow::sm_retainingHierarchyZOrderInShow = NULL;
 BOOL AwtWindow::sm_resizing = FALSE;
 UINT AwtWindow::untrustedWindowsCounter = 0;
 
@@ -341,23 +340,6 @@
 }
 
 MsgRouting AwtWindow::WmWindowPosChanging(LPARAM windowPos) {
-    /*
-     * See 6178004.
-     * Some windows shouldn't trigger a change in z-order of
-     * any window from the hierarchy.
-     */
-    if (IsRetainingHierarchyZOrder()) {
-        if (((WINDOWPOS *)windowPos)->flags & SWP_SHOWWINDOW) {
-            sm_retainingHierarchyZOrderInShow = GetHWnd();
-        }
-    } else if (sm_retainingHierarchyZOrderInShow != NULL) {
-        HWND ancestor = ::GetAncestor(sm_retainingHierarchyZOrderInShow, GA_ROOTOWNER);
-        HWND windowAncestor = ::GetAncestor(GetHWnd(), GA_ROOTOWNER);
-
-        if (windowAncestor == ancestor) {
-            ((WINDOWPOS *)windowPos)->flags |= SWP_NOZORDER;
-        }
-    }
     return mrDoDefault;
 }
 
@@ -377,12 +359,6 @@
 MsgRouting AwtWindow::WmWindowPosChanged(LPARAM windowPos) {
     WINDOWPOS * wp = (WINDOWPOS *)windowPos;
 
-    if (IsRetainingHierarchyZOrder() && wp->flags & SWP_SHOWWINDOW) {
-        // By this time all the windows from the hierarchy are already notified about z-order change.
-        // Thus we may and we should reset the trigger in order not to affect other changes.
-        sm_retainingHierarchyZOrderInShow = NULL;
-    }
-
     // Reposition the warning window
     if (IsUntrusted() && warningWindow != NULL) {
         if (wp->flags & SWP_HIDEWINDOW) {
@@ -1251,7 +1227,16 @@
         }
     }
     if (!done) {
-        ::ShowWindow(GetHWnd(), nCmdShow);
+        // transient windows shouldn't change the owner window's position in the z-order
+        if (IsRetainingHierarchyZOrder()){
+            UINT flags = SWP_NOSIZE | SWP_NOMOVE | SWP_SHOWWINDOW | SWP_NOOWNERZORDER;
+            if (nCmdShow == SW_SHOWNA) {
+                flags |= SWP_NOACTIVATE;
+            }
+            ::SetWindowPos(GetHWnd(), HWND_TOPMOST, 0, 0, 0, 0, flags);
+        } else {
+            ::ShowWindow(GetHWnd(), nCmdShow);
+        }
     }
     env->DeleteLocalRef(target);
 }
--- a/jdk/src/windows/native/sun/windows/awt_Window.h	Mon Apr 20 14:41:24 2009 -0400
+++ b/jdk/src/windows/native/sun/windows/awt_Window.h	Mon Apr 20 17:05:34 2009 +0400
@@ -248,7 +248,6 @@
     static int ms_instanceCounter;
     static HHOOK ms_hCBTFilter;
     static LRESULT CALLBACK CBTFilter(int nCode, WPARAM wParam, LPARAM lParam);
-    static HWND sm_retainingHierarchyZOrderInShow; // a referred window in the process of show
     static BOOL sm_resizing;        /* in the middle of a resizing operation */
 
     RECT m_insets;          /* a cache of the insets being used */