6770457: Using ToolTips causes inactive app window to exhibit active window behavior

Reviewed-by: art, ant
This commit is contained in:
Dmitry Cherepanov 2009-04-20 17:05:34 +04:00
parent 75d9b0f986
commit 76fedc71ad
3 changed files with 16 additions and 27 deletions

View File

@ -1843,8 +1843,13 @@ LRESULT AwtComponent::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
case WM_AWT_SETALWAYSONTOP: { case WM_AWT_SETALWAYSONTOP: {
AwtWindow* w = (AwtWindow*)lParam; AwtWindow* w = (AwtWindow*)lParam;
BOOL value = (BOOL)wParam; 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), ::SetWindowPos(w->GetHWnd(), (value != 0 ? HWND_TOPMOST : HWND_NOTOPMOST),
0,0,0,0, SWP_NOMOVE|SWP_NOSIZE); 0,0,0,0, flags);
break; break;
} }

View File

@ -165,7 +165,6 @@ jmethodID AwtWindow::calculateSecurityWarningPositionMID;
int AwtWindow::ms_instanceCounter = 0; int AwtWindow::ms_instanceCounter = 0;
HHOOK AwtWindow::ms_hCBTFilter; HHOOK AwtWindow::ms_hCBTFilter;
AwtWindow * AwtWindow::m_grabbedWindow = NULL; AwtWindow * AwtWindow::m_grabbedWindow = NULL;
HWND AwtWindow::sm_retainingHierarchyZOrderInShow = NULL;
BOOL AwtWindow::sm_resizing = FALSE; BOOL AwtWindow::sm_resizing = FALSE;
UINT AwtWindow::untrustedWindowsCounter = 0; UINT AwtWindow::untrustedWindowsCounter = 0;
@ -341,23 +340,6 @@ MsgRouting AwtWindow::WmNcMouseDown(WPARAM hitTest, int x, int y, int button) {
} }
MsgRouting AwtWindow::WmWindowPosChanging(LPARAM windowPos) { 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; return mrDoDefault;
} }
@ -377,12 +359,6 @@ void AwtWindow::RepositionSecurityWarning(JNIEnv *env)
MsgRouting AwtWindow::WmWindowPosChanged(LPARAM windowPos) { MsgRouting AwtWindow::WmWindowPosChanged(LPARAM windowPos) {
WINDOWPOS * wp = (WINDOWPOS *)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 // Reposition the warning window
if (IsUntrusted() && warningWindow != NULL) { if (IsUntrusted() && warningWindow != NULL) {
if (wp->flags & SWP_HIDEWINDOW) { if (wp->flags & SWP_HIDEWINDOW) {
@ -1251,7 +1227,16 @@ void AwtWindow::Show()
} }
} }
if (!done) { 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); env->DeleteLocalRef(target);
} }

View File

@ -248,7 +248,6 @@ private:
static int ms_instanceCounter; static int ms_instanceCounter;
static HHOOK ms_hCBTFilter; static HHOOK ms_hCBTFilter;
static LRESULT CALLBACK CBTFilter(int nCode, WPARAM wParam, LPARAM lParam); 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 */ static BOOL sm_resizing; /* in the middle of a resizing operation */
RECT m_insets; /* a cache of the insets being used */ RECT m_insets; /* a cache of the insets being used */