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; |
109 | 107 |
110 const char* kBrowserWindowKey = "__BROWSER_WINDOW_GTK__"; | 108 const char* kBrowserWindowKey = "__BROWSER_WINDOW_GTK__"; |
111 | 109 |
112 // The frame border is only visible in restored mode and is hardcoded to 4 px | 110 // 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. | 111 // on each side regardless of the system window border size. |
114 const int kFrameBorderThickness = 4; | 112 const int kFrameBorderThickness = 4; |
115 // While resize areas on Windows are normally the same size as the window | 113 // 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 | 114 // 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 | 115 // around with our thinner top grabbable strip. (Incidentally, our side and |
(...skipping 1174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1292 if (devtools_contents) { | 1290 if (devtools_contents) { |
1293 // TabContentsViewGtk::WasShown is not called when tab contents is shown by | 1291 // TabContentsViewGtk::WasShown is not called when tab contents is shown by |
1294 // anything other than user selecting a Tab. | 1292 // anything other than user selecting a Tab. |
1295 // See TabContentsViewViews::OnWindowPosChanged for reference on how it | 1293 // See TabContentsViewViews::OnWindowPosChanged for reference on how it |
1296 // should be implemented. | 1294 // should be implemented. |
1297 devtools_contents->tab_contents()->ShowContents(); | 1295 devtools_contents->tab_contents()->ShowContents(); |
1298 } | 1296 } |
1299 | 1297 |
1300 bool should_show = old_devtools == NULL && devtools_contents != NULL; | 1298 bool should_show = old_devtools == NULL && devtools_contents != NULL; |
1301 bool should_hide = old_devtools != NULL && devtools_contents == NULL; | 1299 bool should_hide = old_devtools != NULL && devtools_contents == NULL; |
1300 | |
1302 if (should_show) { | 1301 if (should_show) { |
1302 // Restore split offset. | |
1303 GtkAllocation contents_rect; | |
1304 gtk_widget_get_allocation(contents_container_->widget(), &contents_rect); | |
1305 | |
1306 int split_offset = browser_->profile()->GetPrefs()-> | |
1307 GetInteger(prefs::kDevToolsSplitLocation); | |
1308 if (split_offset == -1) | |
1309 split_offset = contents_rect.height * 2 / 3; | |
1310 | |
1311 // Make sure user can see both panes. | |
1312 split_offset = std::min(contents_rect.height - kMinDevToolsHeight, | |
yurys
2011/06/08 08:14:27
Can we handle the case of negative offset explicit
| |
1313 std::max(kMinDevToolsHeight, split_offset)); | |
1314 gtk_paned_set_position(GTK_PANED(contents_split_), split_offset); | |
1303 gtk_widget_show(devtools_container_->widget()); | 1315 gtk_widget_show(devtools_container_->widget()); |
1304 } else if (should_hide) { | 1316 } else if (should_hide) { |
1305 // Store split offset when hiding devtools window only. | 1317 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()-> | 1318 browser_->profile()->GetPrefs()-> |
1308 SetInteger(prefs::kDevToolsSplitLocation, divider_offset); | 1319 SetInteger(prefs::kDevToolsSplitLocation, split_offset); |
1309 gtk_widget_hide(devtools_container_->widget()); | 1320 gtk_widget_hide(devtools_container_->widget()); |
1310 } | 1321 } |
1311 } | 1322 } |
1312 | 1323 |
1313 void BrowserWindowGtk::DestroyBrowser() { | 1324 void BrowserWindowGtk::DestroyBrowser() { |
1314 browser_.reset(); | 1325 browser_.reset(); |
1315 } | 1326 } |
1316 | 1327 |
1317 gboolean BrowserWindowGtk::OnConfigure(GtkWidget* widget, | 1328 gboolean BrowserWindowGtk::OnConfigure(GtkWidget* widget, |
1318 GdkEventConfigure* event) { | 1329 GdkEventConfigure* event) { |
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1679 | 1690 |
1680 contents_container_.reset(new TabContentsContainerGtk(status_bubble_.get())); | 1691 contents_container_.reset(new TabContentsContainerGtk(status_bubble_.get())); |
1681 devtools_container_.reset(new TabContentsContainerGtk(NULL)); | 1692 devtools_container_.reset(new TabContentsContainerGtk(NULL)); |
1682 ViewIDUtil::SetID(devtools_container_->widget(), VIEW_ID_DEV_TOOLS_DOCKED); | 1693 ViewIDUtil::SetID(devtools_container_->widget(), VIEW_ID_DEV_TOOLS_DOCKED); |
1683 contents_split_ = gtk_vpaned_new(); | 1694 contents_split_ = gtk_vpaned_new(); |
1684 gtk_paned_pack1(GTK_PANED(contents_split_), contents_container_->widget(), | 1695 gtk_paned_pack1(GTK_PANED(contents_split_), contents_container_->widget(), |
1685 TRUE, TRUE); | 1696 TRUE, TRUE); |
1686 gtk_paned_pack2(GTK_PANED(contents_split_), devtools_container_->widget(), | 1697 gtk_paned_pack2(GTK_PANED(contents_split_), devtools_container_->widget(), |
1687 FALSE, TRUE); | 1698 FALSE, TRUE); |
1688 gtk_box_pack_end(GTK_BOX(render_area_vbox_), contents_split_, TRUE, TRUE, 0); | 1699 gtk_box_pack_end(GTK_BOX(render_area_vbox_), contents_split_, TRUE, TRUE, 0); |
1689 // Restore split offset. | 1700 |
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_); | 1701 gtk_widget_show_all(render_area_floating_container_); |
1701 gtk_widget_hide(devtools_container_->widget()); | 1702 gtk_widget_hide(devtools_container_->widget()); |
1702 render_area_event_box_ = gtk_event_box_new(); | 1703 render_area_event_box_ = gtk_event_box_new(); |
1703 // Set a white background so during startup the user sees white in the | 1704 // Set a white background so during startup the user sees white in the |
1704 // content area before we get a TabContents in place. | 1705 // content area before we get a TabContents in place. |
1705 gtk_widget_modify_bg(render_area_event_box_, GTK_STATE_NORMAL, | 1706 gtk_widget_modify_bg(render_area_event_box_, GTK_STATE_NORMAL, |
1706 >k_util::kGdkWhite); | 1707 >k_util::kGdkWhite); |
1707 gtk_container_add(GTK_CONTAINER(render_area_event_box_), | 1708 gtk_container_add(GTK_CONTAINER(render_area_event_box_), |
1708 render_area_floating_container_); | 1709 render_area_floating_container_); |
1709 gtk_widget_show(render_area_event_box_); | 1710 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. | 2373 // are taken from the WMs' source code. |
2373 return (wm_name == "Blackbox" || | 2374 return (wm_name == "Blackbox" || |
2374 wm_name == "compiz" || | 2375 wm_name == "compiz" || |
2375 wm_name == "Compiz" || | 2376 wm_name == "Compiz" || |
2376 wm_name == "e16" || // Enlightenment DR16 | 2377 wm_name == "e16" || // Enlightenment DR16 |
2377 wm_name == "Metacity" || | 2378 wm_name == "Metacity" || |
2378 wm_name == "Mutter" || | 2379 wm_name == "Mutter" || |
2379 wm_name == "Openbox" || | 2380 wm_name == "Openbox" || |
2380 wm_name == "Xfwm4"); | 2381 wm_name == "Xfwm4"); |
2381 } | 2382 } |
OLD | NEW |