Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(569)

Unified Diff: chrome/browser/gtk/browser_window_gtk.cc

Issue 203027: Linux: avoid browser windows moving around by the size of WM decorations over restart. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/gtk/browser_window_gtk.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/gtk/browser_window_gtk.cc
===================================================================
--- chrome/browser/gtk/browser_window_gtk.cc (revision 26487)
+++ chrome/browser/gtk/browser_window_gtk.cc (working copy)
@@ -125,6 +125,16 @@
// is off.
const int kCustomFrameBackgroundVerticalOffset = 15;
+// When a window is moved or resized, GTK will call MainWindowConfigured below.
tony 2009/09/18 18:45:12 Nit: I expect this comment to either be in the hea
Mike Mammarella 2009/09/18 21:18:40 Done.
+// The GdkEventConfigure* that we get doesn't have quite the right coordinates
+// though (they're relative to the drawable window area, rather than any window
+// manager decorations, if enabled), so we need to call gtk_window_get_position
+// to get the right values. (Otherwise session restore, if enabled, will
+// restore windows to incorrect positions.) That's a round trip to the X server
+// though, so we set a debounce timer and only call it after we haven't seen a
+// reconfigure event in a short while.
+const int kDebounceTimeoutMilliseconds = 100;
+
base::LazyInstance<ActiveWindowWatcher>
g_active_window_watcher(base::LINKER_INITIALIZED);
@@ -1361,6 +1371,20 @@
bounds_ = bounds;
if (!IsFullscreen() && !IsMaximized())
restored_bounds_ = bounds;
+
+ // We don't use Reset() because the timer may not yet be running.
+ // (In that case Stop() is a no-op.)
+ mainwin_configure_debounce_timer_.Stop();
+ mainwin_configure_debounce_timer_.Start(base::TimeDelta::FromMilliseconds(
+ kDebounceTimeoutMilliseconds), this,
+ &BrowserWindowGtk::OnDebouncedBoundsChanged);
+}
+
+void BrowserWindowGtk::OnDebouncedBoundsChanged() {
+ gint x, y;
+ gtk_window_get_position(window_, &x, &y);
+ gfx::Point origin(x, y);
+ bounds_.set_origin(origin);
tony 2009/09/18 18:45:12 Should we update restored_bounds_ too?
Mike Mammarella 2009/09/18 21:18:40 Done.
SaveWindowPosition();
}
@@ -1484,13 +1508,16 @@
maximize_after_show_ = browser_->GetSavedMaximizedState();
gfx::Rect bounds = browser_->GetSavedWindowBounds();
- // We don't blindly call SetBounds here, that sets a forced position
+ // We don't blindly call SetBounds here: that sets a forced position
// on the window and we intentionally *don't* do that for normal
- // windows. We tested many programs and none of them restored their
- // position on Linux.
+ // windows. Most programs do not restore their window position on
+ // Linux, instead letting the window manager choose a position.
//
// However, in cases like dropping a tab where the bounds are
- // specifically set, we do want to position explicitly.
+ // specifically set, we do want to position explicitly. We also
+ // force the position as part of session restore, as applications
+ // that restore other, similar state (for instance GIMP, audacity,
+ // pidgin, dia, and gkrellm) do tend to restore their positions.
if (browser_->bounds_overridden()) {
// For popups, bounds are set in terms of the client area rather than the
// entire window.
« no previous file with comments | « chrome/browser/gtk/browser_window_gtk.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698