OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/ui/gtk/browser_window_gtk.h" | 5 #include "chrome/browser/ui/gtk/browser_window_gtk.h" |
6 | 6 |
7 #include <gdk/gdkkeysyms.h> | 7 #include <gdk/gdkkeysyms.h> |
8 | 8 |
9 #include <dlfcn.h> | 9 #include <dlfcn.h> |
10 #include <string> | 10 #include <string> |
(...skipping 1454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1465 browser_.reset(); | 1465 browser_.reset(); |
1466 } | 1466 } |
1467 | 1467 |
1468 gboolean BrowserWindowGtk::OnConfigure(GtkWidget* widget, | 1468 gboolean BrowserWindowGtk::OnConfigure(GtkWidget* widget, |
1469 GdkEventConfigure* event) { | 1469 GdkEventConfigure* event) { |
1470 gfx::Rect bounds(event->x, event->y, event->width, event->height); | 1470 gfx::Rect bounds(event->x, event->y, event->width, event->height); |
1471 | 1471 |
1472 // When the window moves, we'll get multiple configure-event signals. We can | 1472 // When the window moves, we'll get multiple configure-event signals. We can |
1473 // also get events when the bounds haven't changed, but the window's stacking | 1473 // also get events when the bounds haven't changed, but the window's stacking |
1474 // has, which we aren't interested in. http://crbug.com/70125 | 1474 // has, which we aren't interested in. http://crbug.com/70125 |
1475 if (bounds == bounds_) | 1475 if (bounds == configure_bounds_) |
1476 return FALSE; | 1476 return FALSE; |
1477 | 1477 |
1478 GetLocationBar()->location_entry()->ClosePopup(); | 1478 GetLocationBar()->location_entry()->ClosePopup(); |
1479 | 1479 |
1480 TabContentsWrapper* tab = GetDisplayedTab(); | 1480 TabContentsWrapper* tab = GetDisplayedTab(); |
1481 if (tab) { | 1481 if (tab) { |
1482 tab->web_contents()->GetRenderViewHost()->NotifyMoveOrResizeStarted(); | 1482 tab->web_contents()->GetRenderViewHost()->NotifyMoveOrResizeStarted(); |
1483 } | 1483 } |
1484 | 1484 |
1485 if (bounds_.size() != bounds.size()) | 1485 if (bounds_.size() != bounds.size()) |
1486 OnSizeChanged(bounds.width(), bounds.height()); | 1486 OnSizeChanged(bounds.width(), bounds.height()); |
1487 | 1487 |
1488 // We update |bounds_| but not |restored_bounds_| here. The latter needs | 1488 // We update |bounds_| but not |restored_bounds_| here. The latter needs |
1489 // to be updated conditionally when the window is non-maximized and non- | 1489 // to be updated conditionally when the window is non-maximized and non- |
1490 // fullscreen, but whether those state updates have been processed yet is | 1490 // fullscreen, but whether those state updates have been processed yet is |
1491 // window-manager specific. We update |restored_bounds_| in the debounced | 1491 // window-manager specific. We update |restored_bounds_| in the debounced |
1492 // handler below, after the window state has been updated. | 1492 // handler below, after the window state has been updated. |
1493 bounds_ = bounds; | 1493 bounds_ = bounds; |
| 1494 configure_bounds_ = bounds; |
1494 | 1495 |
1495 // The GdkEventConfigure* we get here doesn't have quite the right | 1496 // The GdkEventConfigure* we get here doesn't have quite the right |
1496 // coordinates though (they're relative to the drawable window area, rather | 1497 // coordinates though (they're relative to the drawable window area, rather |
1497 // than any window manager decorations, if enabled), so we need to call | 1498 // than any window manager decorations, if enabled), so we need to call |
1498 // gtk_window_get_position() to get the right values. (Otherwise session | 1499 // gtk_window_get_position() to get the right values. (Otherwise session |
1499 // restore, if enabled, will restore windows to incorrect positions.) That's | 1500 // restore, if enabled, will restore windows to incorrect positions.) That's |
1500 // a round trip to the X server though, so we set a debounce timer and only | 1501 // a round trip to the X server though, so we set a debounce timer and only |
1501 // call it (in OnDebouncedBoundsChanged() below) after we haven't seen a | 1502 // call it (in OnDebouncedBoundsChanged() below) after we haven't seen a |
1502 // reconfigure event in a short while. | 1503 // reconfigure event in a short while. |
1503 // We don't use Reset() because the timer may not yet be running. | 1504 // We don't use Reset() because the timer may not yet be running. |
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1741 g_signal_connect(window_, "button-press-event", | 1742 g_signal_connect(window_, "button-press-event", |
1742 G_CALLBACK(OnButtonPressEventThunk), this); | 1743 G_CALLBACK(OnButtonPressEventThunk), this); |
1743 g_signal_connect(window_, "focus-in-event", | 1744 g_signal_connect(window_, "focus-in-event", |
1744 G_CALLBACK(OnFocusInThunk), this); | 1745 G_CALLBACK(OnFocusInThunk), this); |
1745 g_signal_connect(window_, "focus-out-event", | 1746 g_signal_connect(window_, "focus-out-event", |
1746 G_CALLBACK(OnFocusOutThunk), this); | 1747 G_CALLBACK(OnFocusOutThunk), this); |
1747 } | 1748 } |
1748 | 1749 |
1749 void BrowserWindowGtk::InitWidgets() { | 1750 void BrowserWindowGtk::InitWidgets() { |
1750 ConnectHandlersToSignals(); | 1751 ConnectHandlersToSignals(); |
1751 bounds_ = restored_bounds_ = GetInitialWindowBounds(window_); | 1752 |
| 1753 bounds_ = configure_bounds_ = restored_bounds_ = |
| 1754 GetInitialWindowBounds(window_); |
1752 | 1755 |
1753 // This vbox encompasses all of the widgets within the browser. This is | 1756 // This vbox encompasses all of the widgets within the browser. This is |
1754 // everything except the custom frame border. | 1757 // everything except the custom frame border. |
1755 window_vbox_ = gtk_vbox_new(FALSE, 0); | 1758 window_vbox_ = gtk_vbox_new(FALSE, 0); |
1756 gtk_widget_show(window_vbox_); | 1759 gtk_widget_show(window_vbox_); |
1757 | 1760 |
1758 // We hold an always hidden GtkMenuBar inside our browser window simply to | 1761 // We hold an always hidden GtkMenuBar inside our browser window simply to |
1759 // fool the Unity desktop, which will mirror the contents of the first | 1762 // fool the Unity desktop, which will mirror the contents of the first |
1760 // GtkMenuBar it sees into the global menu bar. (It doesn't seem to check the | 1763 // GtkMenuBar it sees into the global menu bar. (It doesn't seem to check the |
1761 // visibility of the GtkMenuBar, so we can just permanently hide it.) | 1764 // visibility of the GtkMenuBar, so we can just permanently hide it.) |
(...skipping 758 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2520 wm_type == ui::WM_OPENBOX || | 2523 wm_type == ui::WM_OPENBOX || |
2521 wm_type == ui::WM_XFWM4); | 2524 wm_type == ui::WM_XFWM4); |
2522 } | 2525 } |
2523 | 2526 |
2524 // static | 2527 // static |
2525 BrowserWindow* BrowserWindow::CreateBrowserWindow(Browser* browser) { | 2528 BrowserWindow* BrowserWindow::CreateBrowserWindow(Browser* browser) { |
2526 BrowserWindowGtk* browser_window_gtk = new BrowserWindowGtk(browser); | 2529 BrowserWindowGtk* browser_window_gtk = new BrowserWindowGtk(browser); |
2527 browser_window_gtk->Init(); | 2530 browser_window_gtk->Init(); |
2528 return browser_window_gtk; | 2531 return browser_window_gtk; |
2529 } | 2532 } |
OLD | NEW |