diff options
author | tc@google.com <tc@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-20 21:12:28 +0000 |
---|---|---|
committer | tc@google.com <tc@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-20 21:12:28 +0000 |
commit | 1e74d39a70506cfcad8b224230d9f302c2f96ae7 (patch) | |
tree | 5433f41b13cbfcce727de49d125994cce69b3ae9 /chrome/browser | |
parent | 7120f1327bcd3f0c33a983ee4a61c277747bb566 (diff) | |
download | chromium_src-1e74d39a70506cfcad8b224230d9f302c2f96ae7.zip chromium_src-1e74d39a70506cfcad8b224230d9f302c2f96ae7.tar.gz chromium_src-1e74d39a70506cfcad8b224230d9f302c2f96ae7.tar.bz2 |
Change fullscreen mode to be determined by the window manager.
We used to have a bool that determined whether we were in full
screen mode or not, but that's not always in sync with the WM
so wait for the WM to tell us that we're in full screen mode.
Also, change it so when we're in full screen mode, we don't save our
window bounds because that causes us to restart in full screen mode
which is all sorts of broken.
BUG=16602
Review URL: http://codereview.chromium.org/159087
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@21103 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r-- | chrome/browser/gtk/browser_window_gtk.cc | 47 | ||||
-rw-r--r-- | chrome/browser/gtk/browser_window_gtk.h | 4 |
2 files changed, 30 insertions, 21 deletions
diff --git a/chrome/browser/gtk/browser_window_gtk.cc b/chrome/browser/gtk/browser_window_gtk.cc index 06063ac..4bc4123d 100644 --- a/chrome/browser/gtk/browser_window_gtk.cc +++ b/chrome/browser/gtk/browser_window_gtk.cc @@ -378,7 +378,6 @@ std::map<XID, GtkWindow*> BrowserWindowGtk::xid_map_; BrowserWindowGtk::BrowserWindowGtk(Browser* browser) : browser_(browser), - full_screen_(false), #if defined(OS_CHROMEOS) drag_active_(false), panel_controller_(NULL), @@ -647,26 +646,17 @@ bool BrowserWindowGtk::IsMaximized() const { } void BrowserWindowGtk::SetFullscreen(bool fullscreen) { - full_screen_ = fullscreen; - UpdateCustomFrame(); - + // gtk_window_(un)fullscreen asks the window manager to toggle the EWMH + // for fullscreen windows. Not all window managers support this. if (fullscreen) { - // These four balanced by ShowSupportedWindowFeatures(). - toolbar_->Hide(); - tabstrip_->Hide(); - bookmark_bar_->Hide(false); - extension_shelf_->Hide(); - gtk_window_fullscreen(window_); } else { - ShowSupportedWindowFeatures(); - gtk_window_unfullscreen(window_); } } bool BrowserWindowGtk::IsFullscreen() const { - return full_screen_; + return (state_ & GDK_WINDOW_STATE_FULLSCREEN); } LocationBar* BrowserWindowGtk::GetLocationBar() const { @@ -896,7 +886,7 @@ void BrowserWindowGtk::MaybeShowBookmarkBar(TabContents* contents, bool animate) { // Don't change the visibility state when the browser is full screen or if // the bookmark bar isn't supported. - if (full_screen_ || !IsBookmarkBarSupported()) + if (IsFullscreen() || !IsBookmarkBarSupported()) return; bool show_bar = false; @@ -970,8 +960,26 @@ void BrowserWindowGtk::OnBoundsChanged(const gfx::Rect& bounds) { } void BrowserWindowGtk::OnStateChanged(GdkWindowState state) { + // If we care about more than full screen changes, we should pass through + // |changed_mask| from GdkEventWindowState. + bool fullscreen_state_changed = (state_ & GDK_WINDOW_STATE_FULLSCREEN) != + (state & GDK_WINDOW_STATE_FULLSCREEN); + state_ = state; + if (fullscreen_state_changed) { + if (state & GDK_WINDOW_STATE_FULLSCREEN) { + UpdateCustomFrame(); + toolbar_->Hide(); + tabstrip_->Hide(); + bookmark_bar_->Hide(false); + extension_shelf_->Hide(); + } else { + UpdateCustomFrame(); + ShowSupportedWindowFeatures(); + } + } + UpdateWindowShape(bounds_.width(), bounds_.height()); SaveWindowPosition(); } @@ -1217,7 +1225,7 @@ void BrowserWindowGtk::OnSizeChanged(int width, int height) { } void BrowserWindowGtk::UpdateWindowShape(int width, int height) { - if (use_custom_frame_.GetValue() && !full_screen_ && !IsMaximized()) { + if (use_custom_frame_.GetValue() && !IsFullscreen() && !IsMaximized()) { // Make the top corners rounded. We set a mask that includes most of the // window except for a few pixels in the top two corners. GdkRectangle top_rect = { 3, 0, width - 6, 1 }; @@ -1263,13 +1271,18 @@ void BrowserWindowGtk::ConnectAccelerators() { } void BrowserWindowGtk::UpdateCustomFrame() { - bool enable = use_custom_frame_.GetValue() && !full_screen_; - gtk_window_set_decorated(window_, !enable); + bool enable = use_custom_frame_.GetValue() && !IsFullscreen(); + gtk_window_set_decorated(window_, !use_custom_frame_.GetValue()); titlebar_->UpdateCustomFrame(enable); UpdateWindowShape(bounds_.width(), bounds_.height()); } void BrowserWindowGtk::SaveWindowPosition() { + // Don't save the window position if it's in full screen mode because we + // don't want to restart the browser in full screen mode. + if (IsFullscreen()) + return; + // Browser::SaveWindowPlacement is used for session restore. if (browser_->ShouldSaveWindowPlacement()) browser_->SaveWindowPlacement(bounds_, IsMaximized()); diff --git a/chrome/browser/gtk/browser_window_gtk.h b/chrome/browser/gtk/browser_window_gtk.h index 0267e41..110f1e5 100644 --- a/chrome/browser/gtk/browser_window_gtk.h +++ b/chrome/browser/gtk/browser_window_gtk.h @@ -272,10 +272,6 @@ class BrowserWindowGtk : public BrowserWindow, gfx::Rect bounds_; GdkWindowState state_; - // Whether we are full screen. Since IsFullscreen() gets called before - // OnStateChanged(), we can't rely on |state_| & GDK_WINDOW_STATE_FULLSCREEN. - bool full_screen_; - // The container for the titlebar + tab strip. scoped_ptr<BrowserTitlebar> titlebar_; |