Bug 1373581 - OSX: send fullscreen event on WillEnter/WillExit. r=mstange draft
authorJohann Hofmann <jhofmann@mozilla.com>
Wed, 13 Sep 2017 21:43:33 +0200
changeset 664235 a82f3f41d40d725ef03f9dfa26fd947d97d86b72
parent 664064 e5f80a639bfe68b68693a5be610f9d36b6c5ad00
child 731393 9e24271d0b2b407da57dbd0eb8450ce472bffae3
push id79643
push userbmo:jhofmann@mozilla.com
push dateWed, 13 Sep 2017 19:45:48 +0000
reviewersmstange
bugs1373581
milestone57.0a1
Bug 1373581 - OSX: send fullscreen event on WillEnter/WillExit. r=mstange MozReview-Commit-ID: 5HViEaCw15l
widget/cocoa/nsCocoaWindow.mm
--- a/widget/cocoa/nsCocoaWindow.mm
+++ b/widget/cocoa/nsCocoaWindow.mm
@@ -2618,24 +2618,29 @@ nsCocoaWindow::GetEditCommands(NativeKey
   }
 
   mGeckoWindow->ReportMoveEvent();
 }
 
 // Lion's full screen mode will bypass our internal fullscreen tracking, so
 // we need to catch it when we transition and call our own methods, which in
 // turn will fire "fullscreen" events.
-- (void)windowDidEnterFullScreen:(NSNotification *)notification
+// We send the event slightly early (on WillEnter instead of DidEnter),
+// to render resulting UI changes during the fullscreen transition.
+- (void)windowWillEnterFullScreen:(NSNotification *)notification
 {
   if (!mGeckoWindow) {
     return;
   }
 
   mGeckoWindow->EnteredFullScreen(true);
-
+}
+
+- (void)windowDidEnterFullScreen:(NSNotification *)notification
+{
   // On Yosemite, the NSThemeFrame class has two new properties --
   // titlebarView (an NSTitlebarView object) and titlebarContainerView (an
   // NSTitlebarContainerView object).  These are used to display the titlebar
   // in fullscreen mode.  In Safari they're not transparent.  But in Firefox
   // for some reason they are, which causes bug 1069658.  The following code
   // works around this Apple bug or design flaw.
   NSWindow *window = (NSWindow *) [notification object];
   NSView *frameView = [[window contentView] superview];
@@ -2650,17 +2655,19 @@ nsCocoaWindow::GetEditCommands(NativeKey
   if ([titlebarView respondsToSelector:@selector(setTransparent:)]) {
     [titlebarView setTransparent:NO];
   }
   if ([titlebarContainerView respondsToSelector:@selector(setTransparent:)]) {
     [titlebarContainerView setTransparent:NO];
   }
 }
 
-- (void)windowDidExitFullScreen:(NSNotification *)notification
+// We send the "fullscreen" event slightly early (on WillExit instead of DidExit),
+// to render resulting UI changes during the fullscreen transition.
+- (void)windowWillExitFullScreen:(NSNotification *)notification
 {
   if (!mGeckoWindow) {
     return;
   }
 
   mGeckoWindow->EnteredFullScreen(false);
 }