diff options
author | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-30 18:57:52 +0000 |
---|---|---|
committer | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-30 18:57:52 +0000 |
commit | bed993526f4cbc826d9cf82dea03a9e18ee17501 (patch) | |
tree | e09941f28a4b04db3e562a964f01ba4d62029f24 /chrome/browser/gtk | |
parent | 99f85220286b80eff1a83ae2ad6da432bc5e8a29 (diff) | |
download | chromium_src-bed993526f4cbc826d9cf82dea03a9e18ee17501.zip chromium_src-bed993526f4cbc826d9cf82dea03a9e18ee17501.tar.gz chromium_src-bed993526f4cbc826d9cf82dea03a9e18ee17501.tar.bz2 |
Update the browser window's shape on state change.
When launching the browser we restore the maximized state. However, the maximize call is asynchronous, so we don't actually observe the change to |state_| until later. So we need to update the shape on that later state-changed signal.
Usually if the user maximizes the window, it will change sizes. To avoid setting the window's shape more often than necessary, cache its current state (custom shape or no custom shape).
BUG=none
TEST=maximize the window, close chrome, re open chrome. It should not have a custom shape.
Review URL: http://codereview.chromium.org/150081
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@19625 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/gtk')
-rw-r--r-- | chrome/browser/gtk/browser_window_gtk.cc | 15 | ||||
-rw-r--r-- | chrome/browser/gtk/browser_window_gtk.h | 3 |
2 files changed, 15 insertions, 3 deletions
diff --git a/chrome/browser/gtk/browser_window_gtk.cc b/chrome/browser/gtk/browser_window_gtk.cc index 06eee56..9cc45d62 100644 --- a/chrome/browser/gtk/browser_window_gtk.cc +++ b/chrome/browser/gtk/browser_window_gtk.cc @@ -355,6 +355,7 @@ std::map<XID, GtkWindow*> BrowserWindowGtk::xid_map_; BrowserWindowGtk::BrowserWindowGtk(Browser* browser) : browser_(browser), full_screen_(false), + showing_custom_window_shape_(false), #if defined(LINUX2) drag_active_(false), #endif @@ -534,8 +535,7 @@ void BrowserWindowGtk::UpdateTitleBar() { std::wstring title = browser_->GetCurrentPageTitle(); gtk_window_set_title(window_, WideToUTF8(title).c_str()); if (ShouldShowWindowIcon()) { - // If we're showing a title bar, we should update the app icon. - NOTIMPLEMENTED(); + // TODO(tc): If we're showing a title bar, we should update the app icon. } } @@ -567,7 +567,7 @@ void BrowserWindowGtk::LoadingAnimationCallback() { } else if (ShouldShowWindowIcon()) { // ... or in the window icon area for popups and app windows. // http://code.google.com/p/chromium/issues/detail?id=9380 - NOTIMPLEMENTED(); + // TODO(willchan): implement this. } } @@ -838,6 +838,7 @@ void BrowserWindowGtk::OnBoundsChanged(const gfx::Rect& bounds) { void BrowserWindowGtk::OnStateChanged(GdkWindowState state) { state_ = state; + UpdateWindowShape(bounds_.width(), bounds_.height()); SaveWindowPosition(); } @@ -1059,6 +1060,10 @@ void BrowserWindowGtk::OnSizeChanged(int width, int height) { void BrowserWindowGtk::UpdateWindowShape(int width, int height) { if (use_custom_frame_.GetValue() && !full_screen_ && !IsMaximized()) { + if (showing_custom_window_shape_) + return; + showing_custom_window_shape_ = true; + // 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 }; @@ -1072,6 +1077,10 @@ void BrowserWindowGtk::UpdateWindowShape(int width, int height) { gtk_alignment_set_padding(GTK_ALIGNMENT(window_container_), 1, kFrameBorderThickness, kFrameBorderThickness, kFrameBorderThickness); } else { + if (!showing_custom_window_shape_) + return; + showing_custom_window_shape_ = false; + // Disable rounded corners. gdk_window_shape_combine_region(GTK_WIDGET(window_)->window, NULL, 0, 0); gtk_alignment_set_padding(GTK_ALIGNMENT(window_container_), 0, 0, 0, 0); diff --git a/chrome/browser/gtk/browser_window_gtk.h b/chrome/browser/gtk/browser_window_gtk.h index 458858a..ea734a3 100644 --- a/chrome/browser/gtk/browser_window_gtk.h +++ b/chrome/browser/gtk/browser_window_gtk.h @@ -288,6 +288,9 @@ class BrowserWindowGtk : public BrowserWindow, // decorations. BooleanPrefMember use_custom_frame_; + // Used to avoid setting the custom window shape more often than necessary. + bool showing_custom_window_shape_; + #if defined(LINUX2) // True if a drag is active. See description above setter for details. bool drag_active_; |