OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/gtk/browser_window_gtk.h" | 5 #include "chrome/browser/gtk/browser_window_gtk.h" |
6 | 6 |
7 #include <gdk/gdkkeysyms.h> | 7 #include <gdk/gdkkeysyms.h> |
8 #include <X11/XF86keysym.h> | 8 #include <X11/XF86keysym.h> |
9 | 9 |
10 #include <string> | 10 #include <string> |
(...skipping 1301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1312 void BrowserWindowGtk::DestroyBrowser() { | 1312 void BrowserWindowGtk::DestroyBrowser() { |
1313 browser_.reset(); | 1313 browser_.reset(); |
1314 } | 1314 } |
1315 | 1315 |
1316 void BrowserWindowGtk::OnBoundsChanged(const gfx::Rect& bounds) { | 1316 void BrowserWindowGtk::OnBoundsChanged(const gfx::Rect& bounds) { |
1317 GetLocationBar()->location_entry()->ClosePopup(); | 1317 GetLocationBar()->location_entry()->ClosePopup(); |
1318 | 1318 |
1319 if (bounds_.size() != bounds.size()) | 1319 if (bounds_.size() != bounds.size()) |
1320 OnSizeChanged(bounds.width(), bounds.height()); | 1320 OnSizeChanged(bounds.width(), bounds.height()); |
1321 | 1321 |
| 1322 // We update |bounds_| but not |restored_bounds_| here. The latter needs |
| 1323 // to be updated conditionally when the window is non-maximized and non- |
| 1324 // fullscreen, but whether those state updates have been processed yet is |
| 1325 // window-manager specific. We update |restored_bounds_| in the debounced |
| 1326 // handler below, after the window state has been updated. |
1322 bounds_ = bounds; | 1327 bounds_ = bounds; |
1323 if (!IsFullscreen() && !IsMaximized()) | |
1324 restored_bounds_ = bounds; | |
1325 | 1328 |
1326 // When a window is moved or resized, GTK will call MainWindowConfigured() | 1329 // When a window is moved or resized, GTK will call MainWindowConfigured() |
1327 // above. The GdkEventConfigure* that it gets doesn't have quite the right | 1330 // above. The GdkEventConfigure* that it gets doesn't have quite the right |
1328 // coordinates though (they're relative to the drawable window area, rather | 1331 // coordinates though (they're relative to the drawable window area, rather |
1329 // than any window manager decorations, if enabled), so we need to call | 1332 // than any window manager decorations, if enabled), so we need to call |
1330 // gtk_window_get_position() to get the right values. (Otherwise session | 1333 // gtk_window_get_position() to get the right values. (Otherwise session |
1331 // restore, if enabled, will restore windows to incorrect positions.) That's | 1334 // restore, if enabled, will restore windows to incorrect positions.) That's |
1332 // a round trip to the X server though, so we set a debounce timer and only | 1335 // a round trip to the X server though, so we set a debounce timer and only |
1333 // call it (in OnDebouncedBoundsChanged() below) after we haven't seen a | 1336 // call it (in OnDebouncedBoundsChanged() below) after we haven't seen a |
1334 // reconfigure event in a short while. | 1337 // reconfigure event in a short while. |
1335 // We don't use Reset() because the timer may not yet be running. | 1338 // We don't use Reset() because the timer may not yet be running. |
1336 // (In that case Stop() is a no-op.) | 1339 // (In that case Stop() is a no-op.) |
1337 window_configure_debounce_timer_.Stop(); | 1340 window_configure_debounce_timer_.Stop(); |
1338 window_configure_debounce_timer_.Start(base::TimeDelta::FromMilliseconds( | 1341 window_configure_debounce_timer_.Start(base::TimeDelta::FromMilliseconds( |
1339 kDebounceTimeoutMilliseconds), this, | 1342 kDebounceTimeoutMilliseconds), this, |
1340 &BrowserWindowGtk::OnDebouncedBoundsChanged); | 1343 &BrowserWindowGtk::OnDebouncedBoundsChanged); |
1341 } | 1344 } |
1342 | 1345 |
1343 void BrowserWindowGtk::OnDebouncedBoundsChanged() { | 1346 void BrowserWindowGtk::OnDebouncedBoundsChanged() { |
1344 gint x, y; | 1347 gint x, y; |
1345 gtk_window_get_position(window_, &x, &y); | 1348 gtk_window_get_position(window_, &x, &y); |
1346 gfx::Point origin(x, y); | 1349 gfx::Point origin(x, y); |
1347 bounds_.set_origin(origin); | 1350 bounds_.set_origin(origin); |
1348 if (!IsFullscreen() && !IsMaximized()) | 1351 if (!IsFullscreen() && !IsMaximized()) |
1349 restored_bounds_.set_origin(origin); | 1352 restored_bounds_ = bounds_; |
1350 SaveWindowPosition(); | 1353 SaveWindowPosition(); |
1351 } | 1354 } |
1352 | 1355 |
1353 void BrowserWindowGtk::OnStateChanged(GdkWindowState state, | 1356 void BrowserWindowGtk::OnStateChanged(GdkWindowState state, |
1354 GdkWindowState changed_mask) { | 1357 GdkWindowState changed_mask) { |
1355 state_ = state; | 1358 state_ = state; |
1356 | 1359 |
1357 if (changed_mask & GDK_WINDOW_STATE_FULLSCREEN) { | 1360 if (changed_mask & GDK_WINDOW_STATE_FULLSCREEN) { |
1358 bool is_fullscreen = state & GDK_WINDOW_STATE_FULLSCREEN; | 1361 bool is_fullscreen = state & GDK_WINDOW_STATE_FULLSCREEN; |
1359 browser_->UpdateCommandsForFullscreenMode(is_fullscreen); | 1362 browser_->UpdateCommandsForFullscreenMode(is_fullscreen); |
(...skipping 832 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2192 // special-case the ones where the custom frame should be used. These names | 2195 // special-case the ones where the custom frame should be used. These names |
2193 // are taken from the WMs' source code. | 2196 // are taken from the WMs' source code. |
2194 return (wm_name == "Blackbox" || | 2197 return (wm_name == "Blackbox" || |
2195 wm_name == "compiz" || | 2198 wm_name == "compiz" || |
2196 wm_name == "e16" || // Enlightenment DR16 | 2199 wm_name == "e16" || // Enlightenment DR16 |
2197 wm_name == "KWin" || | 2200 wm_name == "KWin" || |
2198 wm_name == "Metacity" || | 2201 wm_name == "Metacity" || |
2199 wm_name == "Openbox" || | 2202 wm_name == "Openbox" || |
2200 wm_name == "Xfwm4"); | 2203 wm_name == "Xfwm4"); |
2201 } | 2204 } |
OLD | NEW |