Bug 1641546 - Make sure alwaysontop windows don't pull focus when first opening on macOS. r=mstange
authorMike Conley <mconley@mozilla.com>
Fri, 05 Jun 2020 02:35:54 +0000
changeset 598238 041cd14e38935afd3d72c6b72c46494bcd61abe8
parent 598237 56cc12211adf546d4fdb7505399b62a1b33f7361
child 598239 2dc2a430c2e7d950f13753450c4f086ab04d0879
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)
reviewersmstange
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 macOS. r=mstange Differential Revision: https://phabricator.services.mozilla.com/D77503
widget/cocoa/nsCocoaWindow.mm
--- a/widget/cocoa/nsCocoaWindow.mm
+++ b/widget/cocoa/nsCocoaWindow.mm
@@ -876,17 +876,24 @@ void nsCocoaWindow::Show(bool bState) {
             case nsIWidget::eGenericWindowAnimation:
               behavior = NSWindowAnimationBehaviorDefault;
               break;
           }
         }
         [mWindow setAnimationBehavior:behavior];
         mWindowAnimationBehavior = behavior;
       }
-      [mWindow makeKeyAndOrderFront:nil];
+
+      // We don't want alwaysontop windows to pull focus when they're opened,
+      // as these tend to be for peripheral indicators and displays.
+      if (mAlwaysOnTop) {
+        [mWindow orderFront:nil];
+      } else {
+        [mWindow makeKeyAndOrderFront:nil];
+      }
       NS_OBJC_END_TRY_ABORT_BLOCK;
       SendSetZLevelEvent();
     }
   } else {
     // roll up any popups if a top-level window is going away
     if (mWindowType == eWindowType_toplevel || mWindowType == eWindowType_dialog) RollUpPopups();
 
     // now get rid of the window/sheet