From f67f7a7bd570e21f3e534c4ec6564c6e03534be4 Mon Sep 17 00:00:00 2001 From: "tony@chromium.org" Date: Mon, 25 Jul 2011 23:50:52 +0000 Subject: Update the window size to include Window decorations when the custom frame is off. We used to return the size without window decorations, which led to inconsistent behavior with the custom frame on or off. When setting the window size, we need to account for the window decoration sizes since gtk_window_resize doesn't. This is different from Firefox, which never includes the size of window decorations, but this seems more consistent with Win/Mac. BUG=88245 TEST=Open a popup window in app mode. Verify that window.innerHeight != window.outerHeight and the title bar is included in outerHeight. Review URL: http://codereview.chromium.org/7464044 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@93996 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/browser/ui/gtk/browser_window_gtk.cc | 49 ++++++++++++++++++++++------- 1 file changed, 37 insertions(+), 12 deletions(-) (limited to 'chrome/browser/ui/gtk/browser_window_gtk.cc') diff --git a/chrome/browser/ui/gtk/browser_window_gtk.cc b/chrome/browser/ui/gtk/browser_window_gtk.cc index a83747f..3aa5a9d 100644 --- a/chrome/browser/ui/gtk/browser_window_gtk.cc +++ b/chrome/browser/ui/gtk/browser_window_gtk.cc @@ -249,20 +249,45 @@ GdkCursorType GdkWindowEdgeToGdkCursorType(GdkWindowEdge edge) { // where setting the window size to the monitor size causes the WM to set the // EWMH for full screen mode. void SetWindowSize(GtkWindow* window, const gfx::Size& size) { - GdkScreen* screen = gtk_window_get_screen(window); - 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; + gfx::Size new_size = size; + + gint current_width = 0; + gint current_height = 0; + gtk_window_get_size(window, ¤t_width, ¤t_height); + GdkRectangle size_with_decorations = {0}; + if (GTK_WIDGET(window)->window) { + gdk_window_get_frame_extents(GTK_WIDGET(window)->window, + &size_with_decorations); + } + + if (current_width == size_with_decorations.width && + current_height == size_with_decorations.height) { + // 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). + GdkScreen* screen = gtk_window_get_screen(window); + gint num_monitors = gdk_screen_get_n_monitors(screen); + 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; + } + } + } else { + // gtk_window_resize is the size of the window not including decorations, + // but we are given the |size| including window decorations. + if (size_with_decorations.width > current_width) { + new_size.set_width(size.width() - size_with_decorations.width + + current_width); + } + if (size_with_decorations.height > current_height) { + new_size.set_height(size.height() - size_with_decorations.height + + current_height); } } - gtk_window_resize(window, size.width(), size.height()); + gtk_window_resize(window, new_size.width(), new_size.height()); } GQuark GetBrowserWindowQuarkKey() { -- cgit v1.1