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

Side by Side Diff: chrome/browser/ui/gtk/browser_window_gtk.cc

Issue 7121012: DevTools window doesn't restore its minimal size if it's shrinked to zero. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 6 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/ui/browser.cc ('k') | chrome/common/pref_names.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 // Default height of dev tools pane when docked to the browser window. This
105 // matches the value in Views. 105 // matches the value in Views.
106 const int kDefaultDevToolsHeight = 200; 106 const int kDefaultDevToolsHeight = 200;
107 107
108 const int kMinDevToolsHeight = 50; 108 const int kMinDevToolsHeight = 100;
109 109
110 const char* kBrowserWindowKey = "__BROWSER_WINDOW_GTK__"; 110 const char* kBrowserWindowKey = "__BROWSER_WINDOW_GTK__";
111 111
112 // The frame border is only visible in restored mode and is hardcoded to 4 px 112 // 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. 113 // on each side regardless of the system window border size.
114 const int kFrameBorderThickness = 4; 114 const int kFrameBorderThickness = 4;
115 // While resize areas on Windows are normally the same size as the window 115 // 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 116 // 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 117 // around with our thinner top grabbable strip. (Incidentally, our side and
118 // bottom resize areas don't match the frame border thickness either -- they 118 // bottom resize areas don't match the frame border thickness either -- they
(...skipping 1173 matching lines...) Expand 10 before | Expand all | Expand 10 after
1292 if (devtools_contents) { 1292 if (devtools_contents) {
1293 // TabContentsViewGtk::WasShown is not called when tab contents is shown by 1293 // TabContentsViewGtk::WasShown is not called when tab contents is shown by
1294 // anything other than user selecting a Tab. 1294 // anything other than user selecting a Tab.
1295 // See TabContentsViewViews::OnWindowPosChanged for reference on how it 1295 // See TabContentsViewViews::OnWindowPosChanged for reference on how it
1296 // should be implemented. 1296 // should be implemented.
1297 devtools_contents->tab_contents()->ShowContents(); 1297 devtools_contents->tab_contents()->ShowContents();
1298 } 1298 }
1299 1299
1300 bool should_show = old_devtools == NULL && devtools_contents != NULL; 1300 bool should_show = old_devtools == NULL && devtools_contents != NULL;
1301 bool should_hide = old_devtools != NULL && devtools_contents == NULL; 1301 bool should_hide = old_devtools != NULL && devtools_contents == NULL;
1302 GtkAllocation devtools_rect;
1303 gtk_widget_get_allocation(devtools_container_->widget(), &devtools_rect);
1302 if (should_show) { 1304 if (should_show) {
1305 if (devtools_rect.height < kMinDevToolsHeight) {
1306 gint split_offset = gtk_paned_get_position(GTK_PANED(contents_split_));
1307 split_offset -= kMinDevToolsHeight - devtools_rect.height;
1308 gtk_paned_set_position(GTK_PANED(contents_split_), split_offset);
1309 }
1303 gtk_widget_show(devtools_container_->widget()); 1310 gtk_widget_show(devtools_container_->widget());
1304 } else if (should_hide) { 1311 } else if (should_hide) {
1305 // Store split offset when hiding devtools window only.
1306 gint divider_offset = gtk_paned_get_position(GTK_PANED(contents_split_));
1307 browser_->profile()->GetPrefs()-> 1312 browser_->profile()->GetPrefs()->
1308 SetInteger(prefs::kDevToolsSplitLocation, divider_offset); 1313 SetInteger(prefs::kDevToolsWidgetHeight, devtools_rect.height);
1309 gtk_widget_hide(devtools_container_->widget()); 1314 gtk_widget_hide(devtools_container_->widget());
1310 } 1315 }
1311 } 1316 }
1312 1317
1313 void BrowserWindowGtk::DestroyBrowser() { 1318 void BrowserWindowGtk::DestroyBrowser() {
1314 browser_.reset(); 1319 browser_.reset();
1315 } 1320 }
1316 1321
1317 gboolean BrowserWindowGtk::OnConfigure(GtkWidget* widget, 1322 gboolean BrowserWindowGtk::OnConfigure(GtkWidget* widget,
1318 GdkEventConfigure* event) { 1323 GdkEventConfigure* event) {
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after
1679 1684
1680 contents_container_.reset(new TabContentsContainerGtk(status_bubble_.get())); 1685 contents_container_.reset(new TabContentsContainerGtk(status_bubble_.get()));
1681 devtools_container_.reset(new TabContentsContainerGtk(NULL)); 1686 devtools_container_.reset(new TabContentsContainerGtk(NULL));
1682 ViewIDUtil::SetID(devtools_container_->widget(), VIEW_ID_DEV_TOOLS_DOCKED); 1687 ViewIDUtil::SetID(devtools_container_->widget(), VIEW_ID_DEV_TOOLS_DOCKED);
1683 contents_split_ = gtk_vpaned_new(); 1688 contents_split_ = gtk_vpaned_new();
1684 gtk_paned_pack1(GTK_PANED(contents_split_), contents_container_->widget(), 1689 gtk_paned_pack1(GTK_PANED(contents_split_), contents_container_->widget(),
1685 TRUE, TRUE); 1690 TRUE, TRUE);
1686 gtk_paned_pack2(GTK_PANED(contents_split_), devtools_container_->widget(), 1691 gtk_paned_pack2(GTK_PANED(contents_split_), devtools_container_->widget(),
1687 FALSE, TRUE); 1692 FALSE, TRUE);
1688 gtk_box_pack_end(GTK_BOX(render_area_vbox_), contents_split_, TRUE, TRUE, 0); 1693 gtk_box_pack_end(GTK_BOX(render_area_vbox_), contents_split_, TRUE, TRUE, 0);
1689 // Restore split offset. 1694
1695 // split_location is obsolete property. It will never be updated.
1696 // We just check it for backward compatibility.
1690 int split_offset = browser_->profile()->GetPrefs()-> 1697 int split_offset = browser_->profile()->GetPrefs()->
1691 GetInteger(prefs::kDevToolsSplitLocation); 1698 GetInteger(prefs::kDevToolsSplitLocation);
pfeldman 2011/06/07 14:54:06 I'd suggest nuking the property and fixing all por
1692 if (split_offset != -1) { 1699
1693 if (split_offset < kMinDevToolsHeight) 1700 int devtools_height = browser_->profile()->GetPrefs()->
1694 split_offset = kMinDevToolsHeight; 1701 GetInteger(prefs::kDevToolsWidgetHeight);
1695 gtk_paned_set_position(GTK_PANED(contents_split_), split_offset); 1702
1696 } else { 1703 if (devtools_height == -1 && split_offset == -1)
1697 gtk_widget_set_size_request(devtools_container_->widget(), -1, 1704 devtools_height = kDefaultDevToolsHeight;
1698 kDefaultDevToolsHeight); 1705
1699 } 1706 if (devtools_height == -1)
1707 devtools_height = bounds_.height() - split_offset;
1708
1709 devtools_height = std::max(devtools_height, kMinDevToolsHeight);
1710 devtools_height = std::min(devtools_height, bounds_.height() * 2 / 3);
1711 gtk_widget_set_size_request(devtools_container_->widget(), -1,
1712 devtools_height);
1713
1700 gtk_widget_show_all(render_area_floating_container_); 1714 gtk_widget_show_all(render_area_floating_container_);
1701 gtk_widget_hide(devtools_container_->widget()); 1715 gtk_widget_hide(devtools_container_->widget());
1702 render_area_event_box_ = gtk_event_box_new(); 1716 render_area_event_box_ = gtk_event_box_new();
1703 // Set a white background so during startup the user sees white in the 1717 // Set a white background so during startup the user sees white in the
1704 // content area before we get a TabContents in place. 1718 // content area before we get a TabContents in place.
1705 gtk_widget_modify_bg(render_area_event_box_, GTK_STATE_NORMAL, 1719 gtk_widget_modify_bg(render_area_event_box_, GTK_STATE_NORMAL,
1706 &gtk_util::kGdkWhite); 1720 &gtk_util::kGdkWhite);
1707 gtk_container_add(GTK_CONTAINER(render_area_event_box_), 1721 gtk_container_add(GTK_CONTAINER(render_area_event_box_),
1708 render_area_floating_container_); 1722 render_area_floating_container_);
1709 gtk_widget_show(render_area_event_box_); 1723 gtk_widget_show(render_area_event_box_);
(...skipping 662 matching lines...) Expand 10 before | Expand all | Expand 10 after
2372 // are taken from the WMs' source code. 2386 // are taken from the WMs' source code.
2373 return (wm_name == "Blackbox" || 2387 return (wm_name == "Blackbox" ||
2374 wm_name == "compiz" || 2388 wm_name == "compiz" ||
2375 wm_name == "Compiz" || 2389 wm_name == "Compiz" ||
2376 wm_name == "e16" || // Enlightenment DR16 2390 wm_name == "e16" || // Enlightenment DR16
2377 wm_name == "Metacity" || 2391 wm_name == "Metacity" ||
2378 wm_name == "Mutter" || 2392 wm_name == "Mutter" ||
2379 wm_name == "Openbox" || 2393 wm_name == "Openbox" ||
2380 wm_name == "Xfwm4"); 2394 wm_name == "Xfwm4");
2381 } 2395 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/browser.cc ('k') | chrome/common/pref_names.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698