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

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

Issue 63173016: DevTools: place DevTools WebContents underneath inspected WebContents. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 7 years 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
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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 <algorithm> 9 #include <algorithm>
10 #include <string> 10 #include <string>
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 : window_(NULL), 218 : window_(NULL),
219 window_has_shown_(false), 219 window_has_shown_(false),
220 window_container_(NULL), 220 window_container_(NULL),
221 window_vbox_(NULL), 221 window_vbox_(NULL),
222 render_area_vbox_(NULL), 222 render_area_vbox_(NULL),
223 render_area_floating_container_(NULL), 223 render_area_floating_container_(NULL),
224 render_area_event_box_(NULL), 224 render_area_event_box_(NULL),
225 toolbar_border_(NULL), 225 toolbar_border_(NULL),
226 browser_(browser), 226 browser_(browser),
227 state_(GDK_WINDOW_STATE_WITHDRAWN), 227 state_(GDK_WINDOW_STATE_WITHDRAWN),
228 devtools_dock_side_(DEVTOOLS_DOCK_SIDE_BOTTOM),
229 devtools_window_(NULL), 228 devtools_window_(NULL),
230 contents_hsplit_(NULL), 229 devtools_floating_container_(NULL),
231 contents_vsplit_(NULL),
232 frame_cursor_(NULL), 230 frame_cursor_(NULL),
233 is_active_(false), 231 is_active_(false),
234 show_state_after_show_(ui::SHOW_STATE_DEFAULT), 232 show_state_after_show_(ui::SHOW_STATE_DEFAULT),
235 suppress_window_raise_(false), 233 suppress_window_raise_(false),
236 accel_group_(NULL), 234 accel_group_(NULL),
237 is_fullscreen_(false) { 235 is_fullscreen_(false) {
238 } 236 }
239 237
240 BrowserWindowGtk::~BrowserWindowGtk() { 238 BrowserWindowGtk::~BrowserWindowGtk() {
241 ui::ActiveWindowWatcherX::RemoveObserver(this); 239 ui::ActiveWindowWatcherX::RemoveObserver(this);
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
584 gtk_window_maximize(window_); 582 gtk_window_maximize(window_);
585 show_state_after_show_ = ui::SHOW_STATE_NORMAL; 583 show_state_after_show_ = ui::SHOW_STATE_NORMAL;
586 } else if (show_state_after_show_ == ui::SHOW_STATE_MINIMIZED) { 584 } else if (show_state_after_show_ == ui::SHOW_STATE_MINIMIZED) {
587 gtk_window_iconify(window_); 585 gtk_window_iconify(window_);
588 show_state_after_show_ = ui::SHOW_STATE_NORMAL; 586 show_state_after_show_ = ui::SHOW_STATE_NORMAL;
589 } 587 }
590 588
591 // If we have sized the window by setting a size request for the render 589 // If we have sized the window by setting a size request for the render
592 // area, then undo it so that the render view can later adjust its own 590 // area, then undo it so that the render view can later adjust its own
593 // size. 591 // size.
594 gtk_widget_set_size_request(contents_container_->widget(), -1, -1); 592 gtk_widget_set_size_request(devtools_floating_container_, -1, -1);
595 593
596 bool update_devtools = !window_has_shown_ && devtools_window_;
597 window_has_shown_ = true; 594 window_has_shown_ = true;
598 browser()->OnWindowDidShow(); 595 browser()->OnWindowDidShow();
599 if (update_devtools)
600 UpdateDevToolsSplitPosition();
601 } 596 }
602 597
603 void BrowserWindowGtk::ShowInactive() { 598 void BrowserWindowGtk::ShowInactive() {
604 gtk_window_set_focus_on_map(window_, false); 599 gtk_window_set_focus_on_map(window_, false);
605 gtk_widget_show(GTK_WIDGET(window_)); 600 gtk_widget_show(GTK_WIDGET(window_));
606 } 601 }
607 602
608 void BrowserWindowGtk::Hide() { 603 void BrowserWindowGtk::Hide() {
609 // Not implemented. 604 // Not implemented.
610 } 605 }
611 606
612 void BrowserWindowGtk::SetBoundsImpl(const gfx::Rect& bounds, 607 void BrowserWindowGtk::SetBoundsImpl(const gfx::Rect& bounds,
613 bool exterior, 608 bool exterior,
614 bool move) { 609 bool move) {
615 gint x = static_cast<gint>(bounds.x()); 610 gint x = static_cast<gint>(bounds.x());
616 gint y = static_cast<gint>(bounds.y()); 611 gint y = static_cast<gint>(bounds.y());
617 gint width = static_cast<gint>(bounds.width()); 612 gint width = static_cast<gint>(bounds.width());
618 gint height = static_cast<gint>(bounds.height()); 613 gint height = static_cast<gint>(bounds.height());
619 614
620 if (move) 615 if (move)
621 gtk_window_move(window_, x, y); 616 gtk_window_move(window_, x, y);
622 617
623 if (exterior) { 618 if (exterior) {
624 gtk_window_util::SetWindowSize(window_, gfx::Size(width, height)); 619 gtk_window_util::SetWindowSize(window_, gfx::Size(width, height));
625 } else { 620 } else {
626 gtk_widget_set_size_request(contents_container_->widget(), 621 gtk_widget_set_size_request(devtools_floating_container_,
627 width, height); 622 width, height);
628 } 623 }
629 } 624 }
630 625
631 void BrowserWindowGtk::SetBounds(const gfx::Rect& bounds) { 626 void BrowserWindowGtk::SetBounds(const gfx::Rect& bounds) {
632 if (IsFullscreen()) 627 if (IsFullscreen())
633 ExitFullscreen(); 628 ExitFullscreen();
634 SetBoundsImpl(bounds, true, true); 629 SetBoundsImpl(bounds, true, true);
635 } 630 }
636 631
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
674 // destruction, set window_ to NULL before any handlers will run. 669 // destruction, set window_ to NULL before any handlers will run.
675 window_ = NULL; 670 window_ = NULL;
676 // Avoid use-after-free in any code that runs after Close() and forgets to 671 // Avoid use-after-free in any code that runs after Close() and forgets to
677 // check window_. 672 // check window_.
678 window_container_ = NULL; 673 window_container_ = NULL;
679 window_vbox_ = NULL; 674 window_vbox_ = NULL;
680 render_area_vbox_ = NULL; 675 render_area_vbox_ = NULL;
681 render_area_floating_container_ = NULL; 676 render_area_floating_container_ = NULL;
682 render_area_event_box_ = NULL; 677 render_area_event_box_ = NULL;
683 toolbar_border_ = NULL; 678 toolbar_border_ = NULL;
684 contents_vsplit_ = NULL; 679 devtools_floating_container_ = NULL;
685 contents_hsplit_ = NULL;
686 680
687 window_has_shown_ = false; 681 window_has_shown_ = false;
688 titlebar_->set_window(NULL); 682 titlebar_->set_window(NULL);
689 683
690 // We don't want GlobalMenuBar handling any notifications or commands after 684 // We don't want GlobalMenuBar handling any notifications or commands after
691 // the window is destroyed. 685 // the window is destroyed.
692 global_menu_bar_->Disable(); 686 global_menu_bar_->Disable();
693 gtk_widget_destroy(window); 687 gtk_widget_destroy(window);
694 } 688 }
695 689
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
801 void BrowserWindowGtk::OnActiveTabChanged(WebContents* old_contents, 795 void BrowserWindowGtk::OnActiveTabChanged(WebContents* old_contents,
802 WebContents* new_contents, 796 WebContents* new_contents,
803 int index, 797 int index,
804 int reason) { 798 int reason) {
805 TRACE_EVENT0("ui::gtk", "BrowserWindowGtk::ActiveTabChanged"); 799 TRACE_EVENT0("ui::gtk", "BrowserWindowGtk::ActiveTabChanged");
806 if (old_contents && !old_contents->IsBeingDestroyed()) 800 if (old_contents && !old_contents->IsBeingDestroyed())
807 old_contents->GetView()->StoreFocus(); 801 old_contents->GetView()->StoreFocus();
808 802
809 // Update various elements that are interested in knowing the current 803 // Update various elements that are interested in knowing the current
810 // WebContents. 804 // WebContents.
811 UpdateDevToolsForContents(new_contents);
812 infobar_container_->ChangeInfoBarService( 805 infobar_container_->ChangeInfoBarService(
813 InfoBarService::FromWebContents(new_contents)); 806 InfoBarService::FromWebContents(new_contents));
814 contents_container_->SetTab(new_contents); 807 contents_container_->SetTab(new_contents);
808 UpdateDevToolsForContents(new_contents);
815 809
816 // TODO(estade): after we manage browser activation, add a check to make sure 810 // TODO(estade): after we manage browser activation, add a check to make sure
817 // we are the active browser before calling RestoreFocus(). 811 // we are the active browser before calling RestoreFocus().
818 if (!browser_->tab_strip_model()->closing_all()) { 812 if (!browser_->tab_strip_model()->closing_all()) {
819 new_contents->GetView()->RestoreFocus(); 813 new_contents->GetView()->RestoreFocus();
820 FindTabHelper* find_tab_helper = 814 FindTabHelper* find_tab_helper =
821 FindTabHelper::FromWebContents(new_contents); 815 FindTabHelper::FromWebContents(new_contents);
822 if (find_tab_helper->find_ui_active()) 816 if (find_tab_helper->find_ui_active())
823 browser_->GetFindBarController()->find_bar()->SetFocusAndSelection(); 817 browser_->GetFindBarController()->find_bar()->SetFocusAndSelection();
824 } 818 }
(...skipping 849 matching lines...) Expand 10 before | Expand all | Expand 10 after
1674 infobar_container_->widget(), 1668 infobar_container_->widget(),
1675 FALSE, FALSE, 0); 1669 FALSE, FALSE, 0);
1676 1670
1677 status_bubble_.reset(new StatusBubbleGtk(browser_->profile())); 1671 status_bubble_.reset(new StatusBubbleGtk(browser_->profile()));
1678 1672
1679 contents_container_.reset(new TabContentsContainerGtk( 1673 contents_container_.reset(new TabContentsContainerGtk(
1680 status_bubble_.get(), 1674 status_bubble_.get(),
1681 implicit_cast<content::WebContentsDelegate*>(browser_.get())-> 1675 implicit_cast<content::WebContentsDelegate*>(browser_.get())->
1682 EmbedsFullscreenWidget())); 1676 EmbedsFullscreenWidget()));
1683 devtools_container_.reset(new TabContentsContainerGtk(NULL, false)); 1677 devtools_container_.reset(new TabContentsContainerGtk(NULL, false));
1678 // DevTools container should only have DevTools-specific view ID.
1679 ViewIDUtil::SetDelegateForWidget(devtools_container_->widget(), NULL);
1684 ViewIDUtil::SetID(devtools_container_->widget(), VIEW_ID_DEV_TOOLS_DOCKED); 1680 ViewIDUtil::SetID(devtools_container_->widget(), VIEW_ID_DEV_TOOLS_DOCKED);
1685 1681
1686 contents_hsplit_ = gtk_hpaned_new(); 1682 devtools_floating_container_ = gtk_floating_container_new();
1687 gtk_paned_pack1(GTK_PANED(contents_hsplit_), contents_container_->widget(), 1683 gtk_container_add(GTK_CONTAINER(devtools_floating_container_),
1688 TRUE, TRUE); 1684 devtools_container_->widget());
1689 contents_vsplit_ = gtk_vpaned_new(); 1685 gtk_floating_container_add_floating(
1690 gtk_paned_pack1(GTK_PANED(contents_vsplit_), contents_hsplit_, TRUE, TRUE); 1686 GTK_FLOATING_CONTAINER(devtools_floating_container_),
1691 1687 contents_container_->widget());
1688 g_signal_connect(devtools_floating_container_, "set-floating-position",
1689 G_CALLBACK(OnDevToolsContainerSetFloatingPosition), this);
1692 gtk_box_pack_end(GTK_BOX(render_area_vbox_), 1690 gtk_box_pack_end(GTK_BOX(render_area_vbox_),
1693 contents_vsplit_, TRUE, TRUE, 0); 1691 devtools_floating_container_, TRUE, TRUE, 0);
1694 1692
1695 gtk_widget_show_all(render_area_floating_container_); 1693 gtk_widget_show_all(render_area_floating_container_);
1694
1696 render_area_event_box_ = gtk_event_box_new(); 1695 render_area_event_box_ = gtk_event_box_new();
1697 // Set a white background so during startup the user sees white in the 1696 // Set a white background so during startup the user sees white in the
1698 // content area before we get a WebContents in place. 1697 // content area before we get a WebContents in place.
1699 gtk_widget_modify_bg(render_area_event_box_, GTK_STATE_NORMAL, 1698 gtk_widget_modify_bg(render_area_event_box_, GTK_STATE_NORMAL,
1700 &ui::kGdkWhite); 1699 &ui::kGdkWhite);
1701 gtk_container_add(GTK_CONTAINER(render_area_event_box_), 1700 gtk_container_add(GTK_CONTAINER(render_area_event_box_),
1702 render_area_floating_container_); 1701 render_area_floating_container_);
1703 gtk_widget_show(render_area_event_box_); 1702 gtk_widget_show(render_area_event_box_);
1704 gtk_box_pack_end(GTK_BOX(window_vbox_), render_area_event_box_, 1703 gtk_box_pack_end(GTK_BOX(window_vbox_), render_area_event_box_,
1705 TRUE, TRUE, 0); 1704 TRUE, TRUE, 0);
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
1764 : ThemeProperties::COLOR_FRAME_INACTIVE; 1763 : ThemeProperties::COLOR_FRAME_INACTIVE;
1765 } 1764 }
1766 1765
1767 SkColor frame_color = theme_provider->GetColor(frame_color_id); 1766 SkColor frame_color = theme_provider->GetColor(frame_color_id);
1768 1767
1769 // Paint the frame color on the left, right and bottom. 1768 // Paint the frame color on the left, right and bottom.
1770 GdkColor frame_color_gdk = gfx::SkColorToGdkColor(frame_color); 1769 GdkColor frame_color_gdk = gfx::SkColorToGdkColor(frame_color);
1771 gtk_widget_modify_bg(GTK_WIDGET(window_), GTK_STATE_NORMAL, 1770 gtk_widget_modify_bg(GTK_WIDGET(window_), GTK_STATE_NORMAL,
1772 &frame_color_gdk); 1771 &frame_color_gdk);
1773 1772
1774 // Set the color of the dev tools divider.
1775 gtk_widget_modify_bg(contents_vsplit_, GTK_STATE_NORMAL, &frame_color_gdk);
1776 gtk_widget_modify_bg(contents_hsplit_, GTK_STATE_NORMAL, &frame_color_gdk);
1777
1778 // When the cursor is over the divider, GTK+ normally lightens the background
1779 // color by 1.3 (see LIGHTNESS_MULT in gtkstyle.c). Since we're setting the
1780 // color, override the prelight also.
1781 color_utils::HSL hsl = { -1, 0.5, 0.65 };
1782 SkColor frame_prelight_color = color_utils::HSLShift(frame_color, hsl);
1783 GdkColor frame_prelight_color_gdk =
1784 gfx::SkColorToGdkColor(frame_prelight_color);
1785 gtk_widget_modify_bg(contents_hsplit_, GTK_STATE_PRELIGHT,
1786 &frame_prelight_color_gdk);
1787 gtk_widget_modify_bg(contents_vsplit_, GTK_STATE_PRELIGHT,
1788 &frame_prelight_color_gdk);
1789
1790 GdkColor border_color = theme_provider->GetBorderColor(); 1773 GdkColor border_color = theme_provider->GetBorderColor();
1791 gtk_widget_modify_bg(toolbar_border_, GTK_STATE_NORMAL, &border_color); 1774 gtk_widget_modify_bg(toolbar_border_, GTK_STATE_NORMAL, &border_color);
1792 } 1775 }
1793 1776
1794 void BrowserWindowGtk::UpdateWindowShape(int width, int height) { 1777 void BrowserWindowGtk::UpdateWindowShape(int width, int height) {
1795 using gtk_window_util::kFrameBorderThickness; 1778 using gtk_window_util::kFrameBorderThickness;
1796 GdkRegion* mask = GetWindowShape(width, height); 1779 GdkRegion* mask = GetWindowShape(width, height);
1797 gdk_window_shape_combine_region( 1780 gdk_window_shape_combine_region(
1798 gtk_widget_get_window(GTK_WIDGET(window_)), mask, 0, 0); 1781 gtk_widget_get_window(GTK_WIDGET(window_)), mask, 0, 0);
1799 if (mask) 1782 if (mask)
(...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after
2267 // changes, we can't consistently repaint the frame at the right time. Instead 2250 // changes, we can't consistently repaint the frame at the right time. Instead
2268 // we always draw the frame as active. 2251 // we always draw the frame as active.
2269 return true; 2252 return true;
2270 } 2253 }
2271 2254
2272 void BrowserWindowGtk::UpdateDevToolsForContents(WebContents* contents) { 2255 void BrowserWindowGtk::UpdateDevToolsForContents(WebContents* contents) {
2273 TRACE_EVENT0("ui::gtk", "BrowserWindowGtk::UpdateDevToolsForContents"); 2256 TRACE_EVENT0("ui::gtk", "BrowserWindowGtk::UpdateDevToolsForContents");
2274 DevToolsWindow* new_devtools_window = contents ? 2257 DevToolsWindow* new_devtools_window = contents ?
2275 DevToolsWindow::GetDockedInstanceForInspectedTab(contents) : NULL; 2258 DevToolsWindow::GetDockedInstanceForInspectedTab(contents) : NULL;
2276 2259
2277 // Fast return in case of the same window having same orientation.
2278 if (devtools_window_ == new_devtools_window && (!new_devtools_window ||
2279 new_devtools_window->dock_side() == devtools_dock_side_)) {
2280 return;
2281 }
2282
2283 // Replace tab contents. 2260 // Replace tab contents.
2284 if (devtools_window_ != new_devtools_window) { 2261 if (devtools_window_ != new_devtools_window) {
2285 if (devtools_window_) 2262 if (devtools_window_)
2286 devtools_container_->DetachTab(devtools_window_->web_contents()); 2263 devtools_container_->DetachTab(devtools_window_->web_contents());
2287 devtools_container_->SetTab( 2264 devtools_container_->SetTab(
2288 new_devtools_window ? new_devtools_window->web_contents() : NULL); 2265 new_devtools_window ? new_devtools_window->web_contents() : NULL);
2289 if (new_devtools_window) { 2266 if (new_devtools_window) {
2290 // WebContentsViewGtk::WasShown is not called when a web contents is shown 2267 // WebContentsViewGtk::WasShown is not called when a web contents is shown
2291 // by anything other than user selecting a Tab. 2268 // by anything other than user selecting a Tab.
2292 // See TabContentsViewViews::OnWindowPosChanged for reference on how it 2269 // See TabContentsViewViews::OnWindowPosChanged for reference on how it
2293 // should be implemented. 2270 // should be implemented.
2294 new_devtools_window->web_contents()->WasShown(); 2271 new_devtools_window->web_contents()->WasShown();
2295 } 2272 }
2296 } 2273 }
2297 2274
2298 // Store last used position. 2275 // Show / hide container if necessary.
2299 if (devtools_window_) { 2276 bool should_hide = devtools_window_ && !new_devtools_window;
2300 GtkAllocation contents_rect; 2277 bool should_show = new_devtools_window && !devtools_window_;
2301 gtk_widget_get_allocation(contents_vsplit_, &contents_rect);
2302 int split_size;
2303 if (devtools_dock_side_ == DEVTOOLS_DOCK_SIDE_RIGHT) {
2304 gtk_widget_style_get(contents_hsplit_, "handle-size", &split_size, NULL);
2305 devtools_window_->SetWidth(
2306 contents_rect.width - split_size -
2307 gtk_paned_get_position(GTK_PANED(contents_hsplit_)));
2308 } else if (devtools_dock_side_ == DEVTOOLS_DOCK_SIDE_BOTTOM) {
2309 gtk_widget_style_get(contents_vsplit_, "handle-size", &split_size, NULL);
2310 devtools_window_->SetHeight(
2311 contents_rect.height - split_size -
2312 gtk_paned_get_position(GTK_PANED(contents_vsplit_)));
2313 }
2314 }
2315
2316 // Show / hide container if necessary. Changing dock orientation is
2317 // hide + show.
2318 bool should_hide = devtools_window_ && (!new_devtools_window ||
2319 devtools_dock_side_ != new_devtools_window->dock_side());
2320 bool should_show = new_devtools_window && (!devtools_window_ || should_hide);
2321 2278
2322 if (should_hide) 2279 if (should_hide)
2323 HideDevToolsContainer(); 2280 HideDevToolsContainer();
2324 2281
2325 devtools_window_ = new_devtools_window; 2282 devtools_window_ = new_devtools_window;
2283 contents_insets_ = devtools_window_ ? devtools_window_->GetContentsInsets() :
2284 gfx::Insets();
2326 2285
2327 if (should_show) { 2286 if (should_show)
2328 devtools_dock_side_ = new_devtools_window->dock_side();
2329 ShowDevToolsContainer(); 2287 ShowDevToolsContainer();
2330 } else if (new_devtools_window) { 2288
2331 UpdateDevToolsSplitPosition(); 2289 gtk_widget_queue_resize(devtools_floating_container_);
2332 } 2290 gtk_widget_queue_draw(devtools_floating_container_);
2333 } 2291 }
2334 2292
2335 void BrowserWindowGtk::ShowDevToolsContainer() { 2293 void BrowserWindowGtk::ShowDevToolsContainer() {
2336 if (devtools_dock_side_ == DEVTOOLS_DOCK_SIDE_MINIMIZED) { 2294 // Move devtools below contents.
2337 gtk_box_pack_end(GTK_BOX(render_area_vbox_), 2295 GdkWindow* const devtools_gdk_window =
2338 devtools_container_->widget(), FALSE, FALSE, 0); 2296 gtk_widget_get_window(devtools_container_->widget());
2339 gtk_box_reorder_child(GTK_BOX(render_area_vbox_), 2297 if (devtools_gdk_window)
2340 devtools_container_->widget(), 0); 2298 gdk_window_lower(devtools_gdk_window);
2341 } else {
2342 gtk_widget_set_size_request(devtools_container_->widget(),
2343 devtools_window_->GetMinimumWidth(),
2344 devtools_window_->GetMinimumHeight());
2345 bool to_right = devtools_dock_side_ == DEVTOOLS_DOCK_SIDE_RIGHT;
2346 gtk_paned_pack2(GTK_PANED(to_right ? contents_hsplit_ : contents_vsplit_),
2347 devtools_container_->widget(),
2348 FALSE,
2349 FALSE);
2350 }
2351 UpdateDevToolsSplitPosition();
2352 gtk_widget_show(devtools_container_->widget());
2353 } 2299 }
2354 2300
2355 void BrowserWindowGtk::HideDevToolsContainer() { 2301 void BrowserWindowGtk::HideDevToolsContainer() {
2356 gtk_container_remove(GTK_CONTAINER( 2302 // This method is left intentionally blank.
2357 devtools_dock_side_ == DEVTOOLS_DOCK_SIDE_RIGHT ? contents_hsplit_ :
2358 devtools_dock_side_ == DEVTOOLS_DOCK_SIDE_BOTTOM ? contents_vsplit_ :
2359 render_area_vbox_),
2360 devtools_container_->widget());
2361 gtk_widget_hide(devtools_container_->widget());
2362 } 2303 }
2363 2304
2364 void BrowserWindowGtk::UpdateDevToolsSplitPosition() { 2305 // static
2365 if (!window_has_shown_) 2306 void BrowserWindowGtk::OnDevToolsContainerSetFloatingPosition(
2366 return; 2307 GtkFloatingContainer* container, GtkAllocation* allocation,
2308 BrowserWindowGtk* browser_window) {
2309 gfx::Insets insets = browser_window->contents_insets_;
2367 2310
2368 // This is required if infobar appears/disappears, or devtools container is 2311 int contents_width = std::max(0, allocation->width - insets.width());
2369 // moved between |render_area_vbox_| and |contents_{v,h}split_|. 2312 int contents_height = std::max(0, allocation->height - insets.height());
2370 gtk_container_check_resize(GTK_CONTAINER(render_area_vbox_)); 2313 int contents_x = std::min(insets.left(), allocation->width);
2314 int contents_y = std::min(insets.top(), allocation->height);
2371 2315
2372 GtkAllocation contents_rect; 2316 gtk_widget_set_size_request(browser_window->contents_container_->widget(),
2373 gtk_widget_get_allocation(contents_vsplit_, &contents_rect); 2317 contents_width, contents_height);
2374 int split_size;
2375 2318
2376 if (devtools_window_->dock_side() == DEVTOOLS_DOCK_SIDE_RIGHT) { 2319 GValue value = { 0, };
2377 gtk_widget_style_get(contents_hsplit_, "handle-size", &split_size, NULL); 2320 g_value_init(&value, G_TYPE_INT);
2378 int split_offset = contents_rect.width - 2321 g_value_set_int(&value, contents_x);
2379 devtools_window_->GetWidth(contents_rect.width) - split_size; 2322 gtk_container_child_set_property(GTK_CONTAINER(container),
2380 gtk_paned_set_position(GTK_PANED(contents_hsplit_), split_offset); 2323 browser_window->contents_container_->widget(), "x", &value);
2381 } else if (devtools_window_->dock_side() == DEVTOOLS_DOCK_SIDE_BOTTOM) { 2324 g_value_set_int(&value, contents_y);
2382 gtk_widget_style_get(contents_vsplit_, "handle-size", &split_size, NULL); 2325 gtk_container_child_set_property(GTK_CONTAINER(container),
2383 int split_offset = contents_rect.height - 2326 browser_window->contents_container_->widget(), "y", &value);
2384 devtools_window_->GetHeight(contents_rect.height) - split_size; 2327 g_value_unset(&value);
2385 gtk_paned_set_position(GTK_PANED(contents_vsplit_), split_offset);
2386 } else {
2387 gtk_widget_set_size_request(devtools_container_->widget(),
2388 0, devtools_window_->GetMinimizedHeight());
2389 }
2390 } 2328 }
2391 2329
2392 void BrowserWindowGtk::OnUseCustomChromeFrameChanged() { 2330 void BrowserWindowGtk::OnUseCustomChromeFrameChanged() {
2393 UpdateCustomFrame(); 2331 UpdateCustomFrame();
2394 ui::SetHideTitlebarWhenMaximizedProperty( 2332 ui::SetHideTitlebarWhenMaximizedProperty(
2395 ui::GetX11WindowFromGtkWidget(GTK_WIDGET(window_)), 2333 ui::GetX11WindowFromGtkWidget(GTK_WIDGET(window_)),
2396 UseCustomFrame() ? ui::HIDE_TITLEBAR_WHEN_MAXIMIZED : 2334 UseCustomFrame() ? ui::HIDE_TITLEBAR_WHEN_MAXIMIZED :
2397 ui::SHOW_TITLEBAR_WHEN_MAXIMIZED); 2335 ui::SHOW_TITLEBAR_WHEN_MAXIMIZED);
2398 } 2336 }
2399 2337
(...skipping 23 matching lines...) Expand all
2423 BrowserWindowGtk* browser_window_gtk = new BrowserWindowGtk(browser); 2361 BrowserWindowGtk* browser_window_gtk = new BrowserWindowGtk(browser);
2424 browser_window_gtk->Init(); 2362 browser_window_gtk->Init();
2425 return browser_window_gtk; 2363 return browser_window_gtk;
2426 } 2364 }
2427 2365
2428 // static 2366 // static
2429 chrome::HostDesktopType BrowserWindow::AdjustHostDesktopType( 2367 chrome::HostDesktopType BrowserWindow::AdjustHostDesktopType(
2430 chrome::HostDesktopType desktop_type) { 2368 chrome::HostDesktopType desktop_type) {
2431 return desktop_type; 2369 return desktop_type;
2432 } 2370 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/gtk/browser_window_gtk.h ('k') | chrome/browser/ui/views/frame/browser_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698