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

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: initial idea was reverted. The new version fix gtk problem, make identical logic for all platforms. 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
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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 devtools pane or content pane when devtools are docked
105 // matches the value in Views. 105 // to the browser window.
106 const int kDefaultDevToolsHeight = 200; 106 const int kMinDevToolsHeight = 100;
pfeldman 2011/06/07 19:59:12 Leave it 50
107
108 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
118 // bottom resize areas don't match the frame border thickness either -- they 116 // 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) { 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 int split_offset = browser_->profile()->GetPrefs()->
1304 GetInteger(prefs::kDevToolsSplitLocation);
pfeldman 2011/06/07 19:59:12 Is default window height 600? Otherwise how do you
1305
1306 GtkAllocation contents_rect;
1307 gtk_widget_get_allocation(contents_container_->widget(), &contents_rect);
1308
1309 // Make sure user can see both panes.
1310 split_offset = std::min(contents_rect.height - kMinDevToolsHeight,
1311 std::max(kMinDevToolsHeight, split_offset));
1312 gtk_paned_set_position(GTK_PANED(contents_split_), split_offset);
1303 gtk_widget_show(devtools_container_->widget()); 1313 gtk_widget_show(devtools_container_->widget());
1304 } else if (should_hide) { 1314 } else if (should_hide) {
1305 // Store split offset when hiding devtools window only. 1315 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()-> 1316 browser_->profile()->GetPrefs()->
1308 SetInteger(prefs::kDevToolsSplitLocation, divider_offset); 1317 SetInteger(prefs::kDevToolsSplitLocation, split_offset);
1309 gtk_widget_hide(devtools_container_->widget()); 1318 gtk_widget_hide(devtools_container_->widget());
1310 } 1319 }
1311 } 1320 }
1312 1321
1313 void BrowserWindowGtk::DestroyBrowser() { 1322 void BrowserWindowGtk::DestroyBrowser() {
1314 browser_.reset(); 1323 browser_.reset();
1315 } 1324 }
1316 1325
1317 gboolean BrowserWindowGtk::OnConfigure(GtkWidget* widget, 1326 gboolean BrowserWindowGtk::OnConfigure(GtkWidget* widget,
1318 GdkEventConfigure* event) { 1327 GdkEventConfigure* event) {
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after
1679 1688
1680 contents_container_.reset(new TabContentsContainerGtk(status_bubble_.get())); 1689 contents_container_.reset(new TabContentsContainerGtk(status_bubble_.get()));
1681 devtools_container_.reset(new TabContentsContainerGtk(NULL)); 1690 devtools_container_.reset(new TabContentsContainerGtk(NULL));
1682 ViewIDUtil::SetID(devtools_container_->widget(), VIEW_ID_DEV_TOOLS_DOCKED); 1691 ViewIDUtil::SetID(devtools_container_->widget(), VIEW_ID_DEV_TOOLS_DOCKED);
1683 contents_split_ = gtk_vpaned_new(); 1692 contents_split_ = gtk_vpaned_new();
1684 gtk_paned_pack1(GTK_PANED(contents_split_), contents_container_->widget(), 1693 gtk_paned_pack1(GTK_PANED(contents_split_), contents_container_->widget(),
1685 TRUE, TRUE); 1694 TRUE, TRUE);
1686 gtk_paned_pack2(GTK_PANED(contents_split_), devtools_container_->widget(), 1695 gtk_paned_pack2(GTK_PANED(contents_split_), devtools_container_->widget(),
1687 FALSE, TRUE); 1696 FALSE, TRUE);
1688 gtk_box_pack_end(GTK_BOX(render_area_vbox_), contents_split_, TRUE, TRUE, 0); 1697 gtk_box_pack_end(GTK_BOX(render_area_vbox_), contents_split_, TRUE, TRUE, 0);
1689 // Restore split offset. 1698
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_); 1699 gtk_widget_show_all(render_area_floating_container_);
1701 gtk_widget_hide(devtools_container_->widget()); 1700 gtk_widget_hide(devtools_container_->widget());
1702 render_area_event_box_ = gtk_event_box_new(); 1701 render_area_event_box_ = gtk_event_box_new();
1703 // Set a white background so during startup the user sees white in the 1702 // Set a white background so during startup the user sees white in the
1704 // content area before we get a TabContents in place. 1703 // content area before we get a TabContents in place.
1705 gtk_widget_modify_bg(render_area_event_box_, GTK_STATE_NORMAL, 1704 gtk_widget_modify_bg(render_area_event_box_, GTK_STATE_NORMAL,
1706 &gtk_util::kGdkWhite); 1705 &gtk_util::kGdkWhite);
1707 gtk_container_add(GTK_CONTAINER(render_area_event_box_), 1706 gtk_container_add(GTK_CONTAINER(render_area_event_box_),
1708 render_area_floating_container_); 1707 render_area_floating_container_);
1709 gtk_widget_show(render_area_event_box_); 1708 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. 2371 // are taken from the WMs' source code.
2373 return (wm_name == "Blackbox" || 2372 return (wm_name == "Blackbox" ||
2374 wm_name == "compiz" || 2373 wm_name == "compiz" ||
2375 wm_name == "Compiz" || 2374 wm_name == "Compiz" ||
2376 wm_name == "e16" || // Enlightenment DR16 2375 wm_name == "e16" || // Enlightenment DR16
2377 wm_name == "Metacity" || 2376 wm_name == "Metacity" ||
2378 wm_name == "Mutter" || 2377 wm_name == "Mutter" ||
2379 wm_name == "Openbox" || 2378 wm_name == "Openbox" ||
2380 wm_name == "Xfwm4"); 2379 wm_name == "Xfwm4");
2381 } 2380 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698