Bug 510546 - support for sizemode=fullscreen on gtk2. r=stuart.
authorDoug Turner <dougt@meer.net>
Fri, 14 Aug 2009 12:56:56 -0700
changeset 31567 ac92849658c39ab9fdbc036d594faf5df828e6cc
parent 31566 549f8ed44c5e113f990d5a88883146786e938354
child 31568 23491f65cc3e064b0723e12d05bf0e4aa09360b8
push id8583
push userdougt@mozilla.com
push dateFri, 14 Aug 2009 20:11:11 +0000
treeherdermozilla-central@ac92849658c3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersstuart
bugs510546
milestone1.9.3a1pre
Bug 510546 - support for sizemode=fullscreen on gtk2. r=stuart.
widget/src/gtk2/nsWindow.cpp
--- a/widget/src/gtk2/nsWindow.cpp
+++ b/widget/src/gtk2/nsWindow.cpp
@@ -1013,16 +1013,22 @@ nsWindow::Show(PRBool aState)
 
     // If someone is hiding this widget, clear any needing show flag.
     if (!aState)
         mNeedsShow = PR_FALSE;
 
     // If someone is showing this window and it needs a resize then
     // resize the widget.
     if (aState) {
+        
+        // Sizemode can be set before the window is created.  If it is,
+        // we want to force fullscreen, if needed.
+        if (mSizeMode == nsSizeMode_Fullscreen)
+            MakeFullScreen(PR_TRUE);
+
         if (mNeedsMove) {
             LOG(("\tresizing\n"));
             NativeResize(mBounds.x, mBounds.y, mBounds.width, mBounds.height,
                          PR_FALSE);
         } else if (mNeedsResize) {
             NativeResize(mBounds.width, mBounds.height, PR_FALSE);
         }
     }
@@ -1275,16 +1281,20 @@ nsWindow::SetSizeMode(PRInt32 aMode)
 
     switch (aMode) {
     case nsSizeMode_Maximized:
         gtk_window_maximize(GTK_WINDOW(mShell));
         break;
     case nsSizeMode_Minimized:
         gtk_window_iconify(GTK_WINDOW(mShell));
         break;
+    case nsSizeMode_Fullscreen:
+        MakeFullScreen(PR_TRUE);
+        break;
+
     default:
         // nsSizeMode_Normal, really.
         if (mSizeState == nsSizeMode_Minimized)
             gtk_window_deiconify(GTK_WINDOW(mShell));
         else if (mSizeState == nsSizeMode_Maximized)
             gtk_window_unmaximize(GTK_WINDOW(mShell));
         break;
     }
@@ -3365,16 +3375,21 @@ nsWindow::OnWindowStateEvent(GtkWidget *
         event.mSizeMode = nsSizeMode_Minimized;
         mSizeState = nsSizeMode_Minimized;
     }
     else if (aEvent->new_window_state & GDK_WINDOW_STATE_MAXIMIZED) {
         LOG(("\tMaximized\n"));
         event.mSizeMode = nsSizeMode_Maximized;
         mSizeState = nsSizeMode_Maximized;
     }
+    else if (aEvent->new_window_state & GDK_WINDOW_STATE_FULLSCREEN) {
+        LOG(("\tFullscreen\n"));
+        event.mSizeMode = nsSizeMode_Fullscreen;
+        mSizeState = nsSizeMode_Fullscreen;
+    }
     else {
         LOG(("\tNormal\n"));
         event.mSizeMode = nsSizeMode_Normal;
         mSizeState = nsSizeMode_Normal;
     }
 
     nsEventStatus status;
     DispatchEvent(&event, status);
@@ -4976,19 +4991,24 @@ nsWindow::ConvertBorderStyles(nsBorderSt
     }
 
     return w;
 }
 
 NS_IMETHODIMP
 nsWindow::MakeFullScreen(PRBool aFullScreen)
 {
+    LOG(("nsWindow::MakeFullScreen [%p] aFullScreen %d\n",
+         (void *)this, aFullScreen));
+
 #if GTK_CHECK_VERSION(2,2,0)
-    if (aFullScreen)
+    if (aFullScreen) {
+        mSizeMode = nsSizeMode_Fullscreen;
         gdk_window_fullscreen (mShell->window);
+    }
     else
         gdk_window_unfullscreen (mShell->window);
     return NS_OK;
 #else
     return nsBaseWidget::MakeFullScreen(aFullScreen);
 #endif
 }