summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormdm@chromium.org <mdm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-25 21:04:34 +0000
committermdm@chromium.org <mdm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-25 21:04:34 +0000
commitcdf1631fc06845fd91ced97dd00314bf072ded70 (patch)
treef696d238465c5eb3b02b2f9a30edd505d9486e40
parentdb889036b4cae9c6798db1bbff8630a9ab8678be (diff)
downloadchromium_src-cdf1631fc06845fd91ced97dd00314bf072ded70.zip
chromium_src-cdf1631fc06845fd91ced97dd00314bf072ded70.tar.gz
chromium_src-cdf1631fc06845fd91ced97dd00314bf072ded70.tar.bz2
Linux: work around browser windows that get stuck maximized by the WM.
BUG=22807 TEST=none Review URL: http://codereview.chromium.org/218040 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@27247 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/gtk/browser_titlebar.cc2
-rw-r--r--chrome/browser/gtk/browser_window_gtk.cc13
-rw-r--r--chrome/browser/gtk/browser_window_gtk.h4
3 files changed, 17 insertions, 2 deletions
diff --git a/chrome/browser/gtk/browser_titlebar.cc b/chrome/browser/gtk/browser_titlebar.cc
index 248b945..72e03a9 100644
--- a/chrome/browser/gtk/browser_titlebar.cc
+++ b/chrome/browser/gtk/browser_titlebar.cc
@@ -469,7 +469,7 @@ void BrowserTitlebar::OnButtonClicked(GtkWidget* button,
if (titlebar->close_button_->widget() == button) {
titlebar->browser_window_->Close();
} else if (titlebar->restore_button_->widget() == button) {
- gtk_window_unmaximize(titlebar->window_);
+ titlebar->browser_window_->UnMaximize();
} else if (titlebar->maximize_button_->widget() == button) {
gtk_window_maximize(titlebar->window_);
} else if (titlebar->minimize_button_->widget() == button) {
diff --git a/chrome/browser/gtk/browser_window_gtk.cc b/chrome/browser/gtk/browser_window_gtk.cc
index f060ff8..0235e15 100644
--- a/chrome/browser/gtk/browser_window_gtk.cc
+++ b/chrome/browser/gtk/browser_window_gtk.cc
@@ -1385,6 +1385,17 @@ void BrowserWindowGtk::OnStateChanged(GdkWindowState state,
SaveWindowPosition();
}
+void BrowserWindowGtk::UnMaximize() {
+ // It can happen that you end up with a window whose restore size is the same
+ // as the size of the screen, so unmaximizing it merely remaximizes it due to
+ // the same WM feature that SetWindowSize() works around. We try to detect
+ // this and resize the window to work around the issue.
+ if (bounds_.size() == restored_bounds_.size())
+ gtk_window_resize(window_, bounds_.width(), bounds_.height() - 1);
+ else
+ gtk_window_unmaximize(window_);
+}
+
bool BrowserWindowGtk::CanClose() const {
#if defined(OS_CHROMEOS)
if (drag_active_)
@@ -2002,7 +2013,7 @@ gboolean BrowserWindowGtk::OnButtonPressEvent(GtkWidget* widget,
if (has_hit_titlebar) {
// Maximize/restore on double click.
if (browser->IsMaximized()) {
- gtk_window_unmaximize(browser->window_);
+ browser->UnMaximize();
} else {
gtk_window_maximize(browser->window_);
}
diff --git a/chrome/browser/gtk/browser_window_gtk.h b/chrome/browser/gtk/browser_window_gtk.h
index f556012..172529a 100644
--- a/chrome/browser/gtk/browser_window_gtk.h
+++ b/chrome/browser/gtk/browser_window_gtk.h
@@ -144,6 +144,10 @@ class BrowserWindowGtk : public BrowserWindow,
void OnDebouncedBoundsChanged();
void OnStateChanged(GdkWindowState state, GdkWindowState changed_mask);
+ // Request the underlying window to unmaximize. Also tries to work around
+ // a window manager "feature" that can prevent this in some edge cases.
+ void UnMaximize();
+
// Returns false if we're not ready to close yet. E.g., a tab may have an
// onbeforeunload handler that prevents us from closing.
bool CanClose() const;