Bug 1161802 part 1 - Add FullscreenChanged callback in WidgetListener. r=roc
authorXidorn Quan <quanxunzhen@gmail.com>
Wed, 10 Jun 2015 23:13:12 +1200
changeset 278808 08bf76069c26c40442b50fac74fcca85e64709f9
parent 278807 d17480aae980fb6b44e68cef9f2aabeac89383f7
child 278809 4949729a35bb501ce6d842df3fb68d909ee18558
push id4932
push userjlund@mozilla.com
push dateMon, 10 Aug 2015 18:23:06 +0000
treeherdermozilla-beta@6dd5a4f5f745 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersroc
bugs1161802
milestone41.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 1161802 part 1 - Add FullscreenChanged callback in WidgetListener. r=roc
widget/cocoa/nsCocoaWindow.mm
widget/gonk/nsWindow.cpp
widget/gtk/nsWindow.cpp
widget/nsIWidgetListener.cpp
widget/nsIWidgetListener.h
widget/windows/nsWindow.cpp
--- a/widget/cocoa/nsCocoaWindow.mm
+++ b/widget/cocoa/nsCocoaWindow.mm
@@ -1274,16 +1274,19 @@ void nsCocoaWindow::PrepareForDOMFullscr
 void nsCocoaWindow::EnteredFullScreen(bool aFullScreen, bool aNativeMode)
 {
   mInFullScreenTransition = false;
   mInFullScreenMode = aFullScreen;
   if (aNativeMode || mInNativeFullScreenMode) {
     mInNativeFullScreenMode = aFullScreen;
   }
   DispatchSizeModeEvent();
+  if (mWidgetListener) {
+    mWidgetListener->FullscreenChanged(aFullScreen);
+  }
 }
 
 inline bool nsCocoaWindow::ShouldToggleNativeFullscreen(bool aFullScreen)
 {
   if (!mSupportsNativeFullScreen) {
     // If we cannot use native fullscreen, don't touch it.
     return false;
   }
--- a/widget/gonk/nsWindow.cpp
+++ b/widget/gonk/nsWindow.cpp
@@ -600,16 +600,20 @@ nsWindow::MakeFullScreen(bool aFullScree
         // unpainted.
         nsIntRect virtualBounds;
         mScreen->GetRect(&virtualBounds.x, &virtualBounds.y,
                          &virtualBounds.width, &virtualBounds.height);
         Resize(virtualBounds.x, virtualBounds.y,
                virtualBounds.width, virtualBounds.height,
                /*repaint*/true);
     }
+
+    if (nsIWidgetListener* listener = GetWidgetListener()) {
+      listener->FullscreenChanged(aFullScreen);
+    }
     return NS_OK;
 }
 
 static gralloc_module_t const*
 gralloc_module()
 {
     hw_module_t const *module;
     if (hw_get_module(GRALLOC_HARDWARE_MODULE_ID, &module)) {
--- a/widget/gtk/nsWindow.cpp
+++ b/widget/gtk/nsWindow.cpp
@@ -3251,16 +3251,17 @@ nsWindow::OnWindowStateEvent(GtkWidget *
     // states
     if ((aEvent->changed_mask
          & (GDK_WINDOW_STATE_ICONIFIED |
             GDK_WINDOW_STATE_MAXIMIZED |
             GDK_WINDOW_STATE_FULLSCREEN)) == 0) {
         return;
     }
 
+    bool wasInFullscreen = mSizeState == nsSizeMode_Fullscreen;
     if (aEvent->new_window_state & GDK_WINDOW_STATE_ICONIFIED) {
         LOG(("\tIconified\n"));
         mSizeState = nsSizeMode_Minimized;
 #ifdef ACCESSIBILITY
         DispatchMinimizeEventAccessible();
 #endif //ACCESSIBILITY
     }
     else if (aEvent->new_window_state & GDK_WINDOW_STATE_FULLSCREEN) {
@@ -3277,18 +3278,24 @@ nsWindow::OnWindowStateEvent(GtkWidget *
     else {
         LOG(("\tNormal\n"));
         mSizeState = nsSizeMode_Normal;
 #ifdef ACCESSIBILITY
         DispatchRestoreEventAccessible();
 #endif //ACCESSIBILITY
     }
 
-    if (mWidgetListener)
+    if (mWidgetListener) {
       mWidgetListener->SizeModeChanged(mSizeState);
+
+      bool isInFullscreen = mSizeState == nsSizeMode_Fullscreen;
+      if (isInFullscreen != wasInFullscreen) {
+        mWidgetListener->FullscreenChanged(isInFullscreen);
+      }
+    }
 }
 
 void
 nsWindow::ThemeChanged()
 {
     NotifyThemeChanged();
 
     if (!mGdkWindow || MOZ_UNLIKELY(mIsDestroyed))
--- a/widget/nsIWidgetListener.cpp
+++ b/widget/nsIWidgetListener.cpp
@@ -49,16 +49,21 @@ nsIWidgetListener::WindowResized(nsIWidg
   return false;
 }
 
 void
 nsIWidgetListener::SizeModeChanged(nsSizeMode aSizeMode)
 {
 }
 
+void
+nsIWidgetListener::FullscreenChanged(bool aInFullscreen)
+{
+}
+
 bool
 nsIWidgetListener::ZLevelChanged(bool aImmediate,
                                  nsWindowZ* aPlacement,
                                  nsIWidget* aRequestBelow,
                                  nsIWidget** aActualBelow)
 {
   return false;
 }
--- a/widget/nsIWidgetListener.h
+++ b/widget/nsIWidgetListener.h
@@ -82,16 +82,21 @@ public:
    * window to place below. On return, aActualBelow will be set to the
    * window actually behind. This generally only applies to Windows.
    */
   virtual bool ZLevelChanged(bool aImmediate, nsWindowZ* aPlacement,
                              nsIWidget* aRequestBelow,
                              nsIWidget** aActualBelow);
 
   /**
+   * Called when the window entered or left the fullscreen state.
+   */
+  virtual void FullscreenChanged(bool aInFullscreen);
+
+  /**
    * Called when the window is activated and focused.
    */
   virtual void WindowActivated();
 
   /**
    * Called when the window is deactivated and no longer focused.
    */
   virtual void WindowDeactivated();
--- a/widget/windows/nsWindow.cpp
+++ b/widget/windows/nsWindow.cpp
@@ -2892,18 +2892,20 @@ nsWindow::MakeFullScreen(bool aFullScree
     }
   }
 
   // Notify the taskbar that we have exited full screen mode.
   if (!aFullScreen && taskbarInfo) {
     taskbarInfo->PrepareFullScreenHWND(mWnd, FALSE);
   }
 
-  if (mWidgetListener)
+  if (mWidgetListener) {
     mWidgetListener->SizeModeChanged(mSizeMode);
+    mWidgetListener->FullscreenChanged(aFullScreen);
+  }
 
   return rv;
 }
 
 /**************************************************************
  *
  * SECTION: Native data storage
  *