Bug 1641546 - Make sure alwaysontop windows don't pull focus when first opening on Windows. r=mhowell
authorMike Conley <mconley@mozilla.com>
Fri, 05 Jun 2020 02:35:54 +0000
changeset 598239 2dc2a430c2e7d950f13753450c4f086ab04d0879
parent 598238 041cd14e38935afd3d72c6b72c46494bcd61abe8
child 598240 a2b64d290c0b11b0dd8fb98a44b0a5a7f5ca844a
push id13310
push userffxbld-merge
push dateMon, 29 Jun 2020 14:50:06 +0000
treeherdermozilla-beta@15a59a0afa5c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmhowell
bugs1641546
milestone79.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1641546 - Make sure alwaysontop windows don't pull focus when first opening on Windows. r=mhowell Depends on D77503 Differential Revision: https://phabricator.services.mozilla.com/D77528
widget/windows/nsWindow.cpp
--- a/widget/windows/nsWindow.cpp
+++ b/widget/windows/nsWindow.cpp
@@ -1607,30 +1607,31 @@ void nsWindow::Show(bool bState) {
             break;
           case nsSizeMode_Maximized:
             ::ShowWindow(mWnd, SW_SHOWMAXIMIZED);
             break;
           case nsSizeMode_Minimized:
             ::ShowWindow(mWnd, SW_SHOWMINIMIZED);
             break;
           default:
-            if (CanTakeFocus()) {
+            if (CanTakeFocus() && !mAlwaysOnTop) {
               ::ShowWindow(mWnd, SW_SHOWNORMAL);
             } else {
               ::ShowWindow(mWnd, SW_SHOWNOACTIVATE);
               // Don't flicker the window if we're restoring session
               if (!sIsRestoringSession) {
                 Unused << GetAttention(2);
               }
             }
             break;
         }
       } else {
         DWORD flags = SWP_NOSIZE | SWP_NOMOVE | SWP_SHOWWINDOW;
         if (wasVisible) flags |= SWP_NOZORDER;
+        if (mAlwaysOnTop) flags |= SWP_NOACTIVATE;
 
         if (mWindowType == eWindowType_popup) {
           // ensure popups are the topmost of the TOPMOST
           // layer. Remember not to set the SWP_NOZORDER
           // flag as that might allow the taskbar to overlap
           // the popup.
           flags |= SWP_NOACTIVATE;
           HWND owner = ::GetWindow(mWnd, GW_OWNER);