OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 #include "ui/base/l10n/l10n_util.h" | 94 #include "ui/base/l10n/l10n_util.h" |
95 #include "ui/gfx/gtk_util.h" | 95 #include "ui/gfx/gtk_util.h" |
96 #include "ui/gfx/rect.h" | 96 #include "ui/gfx/rect.h" |
97 #include "ui/gfx/skia_utils_gtk.h" | 97 #include "ui/gfx/skia_utils_gtk.h" |
98 | 98 |
99 namespace { | 99 namespace { |
100 | 100 |
101 // The number of milliseconds between loading animation frames. | 101 // The number of milliseconds between loading animation frames. |
102 const int kLoadingAnimationFrameTimeMs = 30; | 102 const int kLoadingAnimationFrameTimeMs = 30; |
103 | 103 |
104 // Default height of dev tools pane when docked to the browser window. This | 104 // Minimal height of devotools pane or content pane when devtools are docked |
105 // matches the value in Views. | 105 // to the browser window. |
106 const int kDefaultDevToolsHeight = 200; | |
107 | |
108 const int kMinDevToolsHeight = 50; | 106 const int kMinDevToolsHeight = 50; |
| 107 const int kMinContentsHeight = 50; |
109 | 108 |
110 const char* kBrowserWindowKey = "__BROWSER_WINDOW_GTK__"; | 109 const char* kBrowserWindowKey = "__BROWSER_WINDOW_GTK__"; |
111 | 110 |
112 // The frame border is only visible in restored mode and is hardcoded to 4 px | 111 // The frame border is only visible in restored mode and is hardcoded to 4 px |
113 // on each side regardless of the system window border size. | 112 // on each side regardless of the system window border size. |
114 const int kFrameBorderThickness = 4; | 113 const int kFrameBorderThickness = 4; |
115 // While resize areas on Windows are normally the same size as the window | 114 // While resize areas on Windows are normally the same size as the window |
116 // borders, our top area is shrunk by 1 px to make it easier to move the window | 115 // borders, our top area is shrunk by 1 px to make it easier to move the window |
117 // around with our thinner top grabbable strip. (Incidentally, our side and | 116 // around with our thinner top grabbable strip. (Incidentally, our side and |
118 // bottom resize areas don't match the frame border thickness either -- they | 117 // bottom resize areas don't match the frame border thickness either -- they |
(...skipping 1173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1292 if (devtools_contents) { | 1291 if (devtools_contents) { |
1293 // TabContentsViewGtk::WasShown is not called when tab contents is shown by | 1292 // TabContentsViewGtk::WasShown is not called when tab contents is shown by |
1294 // anything other than user selecting a Tab. | 1293 // anything other than user selecting a Tab. |
1295 // See TabContentsViewViews::OnWindowPosChanged for reference on how it | 1294 // See TabContentsViewViews::OnWindowPosChanged for reference on how it |
1296 // should be implemented. | 1295 // should be implemented. |
1297 devtools_contents->tab_contents()->ShowContents(); | 1296 devtools_contents->tab_contents()->ShowContents(); |
1298 } | 1297 } |
1299 | 1298 |
1300 bool should_show = old_devtools == NULL && devtools_contents != NULL; | 1299 bool should_show = old_devtools == NULL && devtools_contents != NULL; |
1301 bool should_hide = old_devtools != NULL && devtools_contents == NULL; | 1300 bool should_hide = old_devtools != NULL && devtools_contents == NULL; |
| 1301 |
1302 if (should_show) { | 1302 if (should_show) { |
| 1303 // Restore split offset. |
| 1304 GtkAllocation contents_rect; |
| 1305 gtk_widget_get_allocation(contents_container_->widget(), &contents_rect); |
| 1306 |
| 1307 int split_offset = browser_->profile()->GetPrefs()-> |
| 1308 GetInteger(prefs::kDevToolsSplitLocation); |
| 1309 if (split_offset == -1) |
| 1310 split_offset = contents_rect.height * 2 / 3; |
| 1311 // Make sure user can see both panes. |
| 1312 split_offset = std::max(kMinContentsHeight, split_offset); |
| 1313 split_offset = std::min(contents_rect.height - kMinDevToolsHeight, |
| 1314 split_offset); |
| 1315 if (split_offset < 0) |
| 1316 split_offset = contents_rect.height * 2 / 3; |
| 1317 gtk_paned_set_position(GTK_PANED(contents_split_), split_offset); |
1303 gtk_widget_show(devtools_container_->widget()); | 1318 gtk_widget_show(devtools_container_->widget()); |
1304 } else if (should_hide) { | 1319 } else if (should_hide) { |
1305 // Store split offset when hiding devtools window only. | 1320 gint split_offset = gtk_paned_get_position(GTK_PANED(contents_split_)); |
1306 gint divider_offset = gtk_paned_get_position(GTK_PANED(contents_split_)); | |
1307 browser_->profile()->GetPrefs()-> | 1321 browser_->profile()->GetPrefs()-> |
1308 SetInteger(prefs::kDevToolsSplitLocation, divider_offset); | 1322 SetInteger(prefs::kDevToolsSplitLocation, split_offset); |
1309 gtk_widget_hide(devtools_container_->widget()); | 1323 gtk_widget_hide(devtools_container_->widget()); |
1310 } | 1324 } |
1311 } | 1325 } |
1312 | 1326 |
1313 void BrowserWindowGtk::DestroyBrowser() { | 1327 void BrowserWindowGtk::DestroyBrowser() { |
1314 browser_.reset(); | 1328 browser_.reset(); |
1315 } | 1329 } |
1316 | 1330 |
1317 gboolean BrowserWindowGtk::OnConfigure(GtkWidget* widget, | 1331 gboolean BrowserWindowGtk::OnConfigure(GtkWidget* widget, |
1318 GdkEventConfigure* event) { | 1332 GdkEventConfigure* event) { |
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1679 | 1693 |
1680 contents_container_.reset(new TabContentsContainerGtk(status_bubble_.get())); | 1694 contents_container_.reset(new TabContentsContainerGtk(status_bubble_.get())); |
1681 devtools_container_.reset(new TabContentsContainerGtk(NULL)); | 1695 devtools_container_.reset(new TabContentsContainerGtk(NULL)); |
1682 ViewIDUtil::SetID(devtools_container_->widget(), VIEW_ID_DEV_TOOLS_DOCKED); | 1696 ViewIDUtil::SetID(devtools_container_->widget(), VIEW_ID_DEV_TOOLS_DOCKED); |
1683 contents_split_ = gtk_vpaned_new(); | 1697 contents_split_ = gtk_vpaned_new(); |
1684 gtk_paned_pack1(GTK_PANED(contents_split_), contents_container_->widget(), | 1698 gtk_paned_pack1(GTK_PANED(contents_split_), contents_container_->widget(), |
1685 TRUE, TRUE); | 1699 TRUE, TRUE); |
1686 gtk_paned_pack2(GTK_PANED(contents_split_), devtools_container_->widget(), | 1700 gtk_paned_pack2(GTK_PANED(contents_split_), devtools_container_->widget(), |
1687 FALSE, TRUE); | 1701 FALSE, TRUE); |
1688 gtk_box_pack_end(GTK_BOX(render_area_vbox_), contents_split_, TRUE, TRUE, 0); | 1702 gtk_box_pack_end(GTK_BOX(render_area_vbox_), contents_split_, TRUE, TRUE, 0); |
1689 // Restore split offset. | 1703 |
1690 int split_offset = browser_->profile()->GetPrefs()-> | |
1691 GetInteger(prefs::kDevToolsSplitLocation); | |
1692 if (split_offset != -1) { | |
1693 if (split_offset < kMinDevToolsHeight) | |
1694 split_offset = kMinDevToolsHeight; | |
1695 gtk_paned_set_position(GTK_PANED(contents_split_), split_offset); | |
1696 } else { | |
1697 gtk_widget_set_size_request(devtools_container_->widget(), -1, | |
1698 kDefaultDevToolsHeight); | |
1699 } | |
1700 gtk_widget_show_all(render_area_floating_container_); | 1704 gtk_widget_show_all(render_area_floating_container_); |
1701 gtk_widget_hide(devtools_container_->widget()); | 1705 gtk_widget_hide(devtools_container_->widget()); |
1702 render_area_event_box_ = gtk_event_box_new(); | 1706 render_area_event_box_ = gtk_event_box_new(); |
1703 // Set a white background so during startup the user sees white in the | 1707 // Set a white background so during startup the user sees white in the |
1704 // content area before we get a TabContents in place. | 1708 // content area before we get a TabContents in place. |
1705 gtk_widget_modify_bg(render_area_event_box_, GTK_STATE_NORMAL, | 1709 gtk_widget_modify_bg(render_area_event_box_, GTK_STATE_NORMAL, |
1706 >k_util::kGdkWhite); | 1710 >k_util::kGdkWhite); |
1707 gtk_container_add(GTK_CONTAINER(render_area_event_box_), | 1711 gtk_container_add(GTK_CONTAINER(render_area_event_box_), |
1708 render_area_floating_container_); | 1712 render_area_floating_container_); |
1709 gtk_widget_show(render_area_event_box_); | 1713 gtk_widget_show(render_area_event_box_); |
(...skipping 662 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2372 // are taken from the WMs' source code. | 2376 // are taken from the WMs' source code. |
2373 return (wm_name == "Blackbox" || | 2377 return (wm_name == "Blackbox" || |
2374 wm_name == "compiz" || | 2378 wm_name == "compiz" || |
2375 wm_name == "Compiz" || | 2379 wm_name == "Compiz" || |
2376 wm_name == "e16" || // Enlightenment DR16 | 2380 wm_name == "e16" || // Enlightenment DR16 |
2377 wm_name == "Metacity" || | 2381 wm_name == "Metacity" || |
2378 wm_name == "Mutter" || | 2382 wm_name == "Mutter" || |
2379 wm_name == "Openbox" || | 2383 wm_name == "Openbox" || |
2380 wm_name == "Xfwm4"); | 2384 wm_name == "Xfwm4"); |
2381 } | 2385 } |
OLD | NEW |