summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
authortony@chromium.org <tony@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-30 17:16:11 +0000
committertony@chromium.org <tony@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-30 17:16:11 +0000
commitbd5ac9d9d2072b96edf5d766fb77c3fbd03d5bb6 (patch)
treea2f8a5d7ba3b48a1fe463755748be06839538dc6 /chrome/browser
parent938ddcaf07183384815094f391e3898f4a237686 (diff)
downloadchromium_src-bd5ac9d9d2072b96edf5d766fb77c3fbd03d5bb6.zip
chromium_src-bd5ac9d9d2072b96edf5d766fb77c3fbd03d5bb6.tar.gz
chromium_src-bd5ac9d9d2072b96edf5d766fb77c3fbd03d5bb6.tar.bz2
Fix a bug with detecting window sizes that match the monitor size.
The previous code was comparing the window size to the screen size, but that doesn't work properly for twinview or other cases where there are multiple monitors that make up a single screen. Instead, compare the window size against all monitors (since we don't know which monitor the window is going to be placed on) and resize if it matches any monitor size. Also fix a bug in BoundsMatchMonitorSize where we should just be comparing sizes, not rectangle positions. BUG=32347 Review URL: http://codereview.chromium.org/3060032 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@54332 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r--chrome/browser/gtk/browser_window_gtk.cc28
1 files changed, 17 insertions, 11 deletions
diff --git a/chrome/browser/gtk/browser_window_gtk.cc b/chrome/browser/gtk/browser_window_gtk.cc
index 184fc3d..f015ac9 100644
--- a/chrome/browser/gtk/browser_window_gtk.cc
+++ b/chrome/browser/gtk/browser_window_gtk.cc
@@ -263,17 +263,23 @@ GdkColor SkColorToGdkColor(const SkColor& color) {
// A helper method for setting the GtkWindow size that should be used in place
// of calling gtk_window_resize directly. This is done to avoid a WM "feature"
-// where setting the window size to the screen size causes the WM to set the
+// where setting the window size to the monitor size causes the WM to set the
// EWMH for full screen mode.
-void SetWindowSize(GtkWindow* window, int width, int height) {
+void SetWindowSize(GtkWindow* window, const gfx::Size& size) {
GdkScreen* screen = gtk_window_get_screen(window);
- if (width >= gdk_screen_get_width(screen) &&
- height >= gdk_screen_get_height(screen)) {
- // Adjust the height so we don't trigger the WM feature.
- gtk_window_resize(window, width, height - 1);
- } else {
- gtk_window_resize(window, width, height);
+ gint num_monitors = gdk_screen_get_n_monitors(screen);
+ // Make sure the window doesn't match any monitor size. We compare against
+ // all monitors because we don't know which monitor the window is going to
+ // open on (the WM decides that).
+ for (gint i = 0; i < num_monitors; ++i) {
+ GdkRectangle monitor_size;
+ gdk_screen_get_monitor_geometry(screen, i, &monitor_size);
+ if (gfx::Size(monitor_size.width, monitor_size.height) == size) {
+ gtk_window_resize(window, size.width(), size.height() - 1);
+ return;
+ }
}
+ gtk_window_resize(window, size.width(), size.height());
}
GQuark GetBrowserWindowQuarkKey() {
@@ -648,7 +654,7 @@ void BrowserWindowGtk::SetBoundsImpl(const gfx::Rect& bounds, bool exterior) {
gtk_window_move(window_, x, y);
if (exterior) {
- SetWindowSize(window_, width, height);
+ SetWindowSize(window_, gfx::Size(width, height));
} else {
gtk_widget_set_size_request(contents_container_->widget(),
width, height);
@@ -1490,7 +1496,7 @@ void BrowserWindowGtk::SetGeometryHints() {
SetBoundsImpl(bounds, !is_popup);
} else {
// Ignore the position but obey the size.
- SetWindowSize(window_, bounds.width(), bounds.height());
+ SetWindowSize(window_, bounds.size());
}
}
@@ -2124,7 +2130,7 @@ bool BrowserWindowGtk::BoundsMatchMonitorSize() {
GdkRectangle monitor_size;
gdk_screen_get_monitor_geometry(screen, monitor_num, &monitor_size);
- return bounds_ == gfx::Rect(monitor_size);
+ return bounds_.size() == gfx::Size(monitor_size.width, monitor_size.height);
}
void BrowserWindowGtk::PlaceBookmarkBar(bool is_floating) {