OLD | NEW |
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 Loading... |
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 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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(contents_container_->widget(), -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 } |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 Loading... |
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 851 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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)); |
1684 ViewIDUtil::SetID(devtools_container_->widget(), VIEW_ID_DEV_TOOLS_DOCKED); | 1678 ViewIDUtil::SetID(devtools_container_->widget(), VIEW_ID_DEV_TOOLS_DOCKED); |
1685 | 1679 |
1686 contents_hsplit_ = gtk_hpaned_new(); | 1680 devtools_floating_container_ = gtk_floating_container_new(); |
1687 gtk_paned_pack1(GTK_PANED(contents_hsplit_), contents_container_->widget(), | 1681 gtk_floating_container_add_floating( |
1688 TRUE, TRUE); | 1682 GTK_FLOATING_CONTAINER(devtools_floating_container_), |
1689 contents_vsplit_ = gtk_vpaned_new(); | 1683 contents_container_->widget()); |
1690 gtk_paned_pack1(GTK_PANED(contents_vsplit_), contents_hsplit_, TRUE, TRUE); | 1684 gtk_container_add(GTK_CONTAINER(devtools_floating_container_), |
1691 | 1685 devtools_container_->widget()); |
| 1686 g_signal_connect(devtools_floating_container_, "set-floating-position", |
| 1687 G_CALLBACK(OnDevToolsContainerSetFloatingPosition), this); |
1692 gtk_box_pack_end(GTK_BOX(render_area_vbox_), | 1688 gtk_box_pack_end(GTK_BOX(render_area_vbox_), |
1693 contents_vsplit_, TRUE, TRUE, 0); | 1689 devtools_floating_container_, TRUE, TRUE, 0); |
1694 | 1690 |
1695 gtk_widget_show_all(render_area_floating_container_); | 1691 gtk_widget_show_all(render_area_floating_container_); |
| 1692 |
1696 render_area_event_box_ = gtk_event_box_new(); | 1693 render_area_event_box_ = gtk_event_box_new(); |
1697 // Set a white background so during startup the user sees white in the | 1694 // Set a white background so during startup the user sees white in the |
1698 // content area before we get a WebContents in place. | 1695 // content area before we get a WebContents in place. |
1699 gtk_widget_modify_bg(render_area_event_box_, GTK_STATE_NORMAL, | 1696 gtk_widget_modify_bg(render_area_event_box_, GTK_STATE_NORMAL, |
1700 &ui::kGdkWhite); | 1697 &ui::kGdkWhite); |
1701 gtk_container_add(GTK_CONTAINER(render_area_event_box_), | 1698 gtk_container_add(GTK_CONTAINER(render_area_event_box_), |
1702 render_area_floating_container_); | 1699 render_area_floating_container_); |
1703 gtk_widget_show(render_area_event_box_); | 1700 gtk_widget_show(render_area_event_box_); |
1704 gtk_box_pack_end(GTK_BOX(window_vbox_), render_area_event_box_, | 1701 gtk_box_pack_end(GTK_BOX(window_vbox_), render_area_event_box_, |
1705 TRUE, TRUE, 0); | 1702 TRUE, TRUE, 0); |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1764 : ThemeProperties::COLOR_FRAME_INACTIVE; | 1761 : ThemeProperties::COLOR_FRAME_INACTIVE; |
1765 } | 1762 } |
1766 | 1763 |
1767 SkColor frame_color = theme_provider->GetColor(frame_color_id); | 1764 SkColor frame_color = theme_provider->GetColor(frame_color_id); |
1768 | 1765 |
1769 // Paint the frame color on the left, right and bottom. | 1766 // Paint the frame color on the left, right and bottom. |
1770 GdkColor frame_color_gdk = gfx::SkColorToGdkColor(frame_color); | 1767 GdkColor frame_color_gdk = gfx::SkColorToGdkColor(frame_color); |
1771 gtk_widget_modify_bg(GTK_WIDGET(window_), GTK_STATE_NORMAL, | 1768 gtk_widget_modify_bg(GTK_WIDGET(window_), GTK_STATE_NORMAL, |
1772 &frame_color_gdk); | 1769 &frame_color_gdk); |
1773 | 1770 |
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(); | 1771 GdkColor border_color = theme_provider->GetBorderColor(); |
1791 gtk_widget_modify_bg(toolbar_border_, GTK_STATE_NORMAL, &border_color); | 1772 gtk_widget_modify_bg(toolbar_border_, GTK_STATE_NORMAL, &border_color); |
1792 } | 1773 } |
1793 | 1774 |
1794 void BrowserWindowGtk::UpdateWindowShape(int width, int height) { | 1775 void BrowserWindowGtk::UpdateWindowShape(int width, int height) { |
1795 using gtk_window_util::kFrameBorderThickness; | 1776 using gtk_window_util::kFrameBorderThickness; |
1796 GdkRegion* mask = GetWindowShape(width, height); | 1777 GdkRegion* mask = GetWindowShape(width, height); |
1797 gdk_window_shape_combine_region( | 1778 gdk_window_shape_combine_region( |
1798 gtk_widget_get_window(GTK_WIDGET(window_)), mask, 0, 0); | 1779 gtk_widget_get_window(GTK_WIDGET(window_)), mask, 0, 0); |
1799 if (mask) | 1780 if (mask) |
(...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2267 // changes, we can't consistently repaint the frame at the right time. Instead | 2248 // changes, we can't consistently repaint the frame at the right time. Instead |
2268 // we always draw the frame as active. | 2249 // we always draw the frame as active. |
2269 return true; | 2250 return true; |
2270 } | 2251 } |
2271 | 2252 |
2272 void BrowserWindowGtk::UpdateDevToolsForContents(WebContents* contents) { | 2253 void BrowserWindowGtk::UpdateDevToolsForContents(WebContents* contents) { |
2273 TRACE_EVENT0("ui::gtk", "BrowserWindowGtk::UpdateDevToolsForContents"); | 2254 TRACE_EVENT0("ui::gtk", "BrowserWindowGtk::UpdateDevToolsForContents"); |
2274 DevToolsWindow* new_devtools_window = contents ? | 2255 DevToolsWindow* new_devtools_window = contents ? |
2275 DevToolsWindow::GetDockedInstanceForInspectedTab(contents) : NULL; | 2256 DevToolsWindow::GetDockedInstanceForInspectedTab(contents) : NULL; |
2276 | 2257 |
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. | 2258 // Replace tab contents. |
2284 if (devtools_window_ != new_devtools_window) { | 2259 if (devtools_window_ != new_devtools_window) { |
2285 if (devtools_window_) | 2260 if (devtools_window_) |
2286 devtools_container_->DetachTab(devtools_window_->web_contents()); | 2261 devtools_container_->DetachTab(devtools_window_->web_contents()); |
2287 devtools_container_->SetTab( | 2262 devtools_container_->SetTab( |
2288 new_devtools_window ? new_devtools_window->web_contents() : NULL); | 2263 new_devtools_window ? new_devtools_window->web_contents() : NULL); |
2289 if (new_devtools_window) { | 2264 if (new_devtools_window) { |
2290 // WebContentsViewGtk::WasShown is not called when a web contents is shown | 2265 // WebContentsViewGtk::WasShown is not called when a web contents is shown |
2291 // by anything other than user selecting a Tab. | 2266 // by anything other than user selecting a Tab. |
2292 // See TabContentsViewViews::OnWindowPosChanged for reference on how it | 2267 // See TabContentsViewViews::OnWindowPosChanged for reference on how it |
2293 // should be implemented. | 2268 // should be implemented. |
2294 new_devtools_window->web_contents()->WasShown(); | 2269 new_devtools_window->web_contents()->WasShown(); |
2295 } | 2270 } |
2296 } | 2271 } |
2297 | 2272 |
2298 // Store last used position. | 2273 // Show / hide container if necessary. |
2299 if (devtools_window_) { | 2274 bool should_hide = devtools_window_ && !new_devtools_window; |
2300 GtkAllocation contents_rect; | 2275 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 | 2276 |
2322 if (should_hide) | 2277 if (should_hide) |
2323 HideDevToolsContainer(); | 2278 HideDevToolsContainer(); |
2324 | 2279 |
2325 devtools_window_ = new_devtools_window; | 2280 devtools_window_ = new_devtools_window; |
| 2281 if (devtools_window_) { |
| 2282 top_left_contents_offset_ = devtools_window_->GetTopLeftContentsOffset(); |
| 2283 bottom_right_contents_offset_ = |
| 2284 devtools_window_->GetBottomRightContentsOffset(); |
| 2285 } else { |
| 2286 top_left_contents_offset_ = gfx::Size(); |
| 2287 bottom_right_contents_offset_ = gfx::Size(); |
| 2288 } |
2326 | 2289 |
2327 if (should_show) { | 2290 if (should_show) |
2328 devtools_dock_side_ = new_devtools_window->dock_side(); | |
2329 ShowDevToolsContainer(); | 2291 ShowDevToolsContainer(); |
2330 } else if (new_devtools_window) { | 2292 |
2331 UpdateDevToolsSplitPosition(); | 2293 gtk_widget_queue_resize(devtools_floating_container_); |
2332 } | 2294 gtk_widget_queue_draw(devtools_floating_container_); |
2333 } | 2295 } |
2334 | 2296 |
2335 void BrowserWindowGtk::ShowDevToolsContainer() { | 2297 void BrowserWindowGtk::ShowDevToolsContainer() { |
2336 if (devtools_dock_side_ == DEVTOOLS_DOCK_SIDE_MINIMIZED) { | 2298 // Move devtools below contents. |
2337 gtk_box_pack_end(GTK_BOX(render_area_vbox_), | 2299 GdkWindow* const devtools_gdk_window = |
2338 devtools_container_->widget(), FALSE, FALSE, 0); | 2300 gtk_widget_get_window(devtools_container_->widget()); |
2339 gtk_box_reorder_child(GTK_BOX(render_area_vbox_), | 2301 if (devtools_gdk_window) |
2340 devtools_container_->widget(), 0); | 2302 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 } | 2303 } |
2354 | 2304 |
2355 void BrowserWindowGtk::HideDevToolsContainer() { | 2305 void BrowserWindowGtk::HideDevToolsContainer() { |
2356 gtk_container_remove(GTK_CONTAINER( | 2306 // 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 } | 2307 } |
2363 | 2308 |
2364 void BrowserWindowGtk::UpdateDevToolsSplitPosition() { | 2309 // static |
2365 if (!window_has_shown_) | 2310 void BrowserWindowGtk::OnDevToolsContainerSetFloatingPosition( |
2366 return; | 2311 GtkFloatingContainer* container, GtkAllocation* allocation, |
| 2312 BrowserWindowGtk* browser_window) { |
| 2313 gfx::Size top_left = browser_window->top_left_contents_offset_; |
| 2314 gfx::Size bottom_right = browser_window->bottom_right_contents_offset_; |
2367 | 2315 |
2368 // This is required if infobar appears/disappears, or devtools container is | 2316 int contents_width = std::max(0, |
2369 // moved between |render_area_vbox_| and |contents_{v,h}split_|. | 2317 allocation->width - top_left.width() - bottom_right.width()); |
2370 gtk_container_check_resize(GTK_CONTAINER(render_area_vbox_)); | 2318 int contents_height = std::max(0, |
| 2319 allocation->height - top_left.height() - bottom_right.height()); |
| 2320 int contents_x = std::min(top_left.width(), allocation->width); |
| 2321 int contents_y = std::min(top_left.height(), allocation->height); |
2371 | 2322 |
2372 GtkAllocation contents_rect; | 2323 gtk_widget_set_size_request(browser_window->contents_container_->widget(), |
2373 gtk_widget_get_allocation(contents_vsplit_, &contents_rect); | 2324 contents_width, contents_height); |
2374 int split_size; | |
2375 | 2325 |
2376 if (devtools_window_->dock_side() == DEVTOOLS_DOCK_SIDE_RIGHT) { | 2326 GValue value = { 0, }; |
2377 gtk_widget_style_get(contents_hsplit_, "handle-size", &split_size, NULL); | 2327 g_value_init(&value, G_TYPE_INT); |
2378 int split_offset = contents_rect.width - | 2328 g_value_set_int(&value, contents_x); |
2379 devtools_window_->GetWidth(contents_rect.width) - split_size; | 2329 gtk_container_child_set_property(GTK_CONTAINER(container), |
2380 gtk_paned_set_position(GTK_PANED(contents_hsplit_), split_offset); | 2330 browser_window->contents_container_->widget(), "x", &value); |
2381 } else if (devtools_window_->dock_side() == DEVTOOLS_DOCK_SIDE_BOTTOM) { | 2331 g_value_set_int(&value, contents_y); |
2382 gtk_widget_style_get(contents_vsplit_, "handle-size", &split_size, NULL); | 2332 gtk_container_child_set_property(GTK_CONTAINER(container), |
2383 int split_offset = contents_rect.height - | 2333 browser_window->contents_container_->widget(), "y", &value); |
2384 devtools_window_->GetHeight(contents_rect.height) - split_size; | 2334 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 } | 2335 } |
2391 | 2336 |
2392 void BrowserWindowGtk::OnUseCustomChromeFrameChanged() { | 2337 void BrowserWindowGtk::OnUseCustomChromeFrameChanged() { |
2393 UpdateCustomFrame(); | 2338 UpdateCustomFrame(); |
2394 ui::SetHideTitlebarWhenMaximizedProperty( | 2339 ui::SetHideTitlebarWhenMaximizedProperty( |
2395 ui::GetX11WindowFromGtkWidget(GTK_WIDGET(window_)), | 2340 ui::GetX11WindowFromGtkWidget(GTK_WIDGET(window_)), |
2396 UseCustomFrame() ? ui::HIDE_TITLEBAR_WHEN_MAXIMIZED : | 2341 UseCustomFrame() ? ui::HIDE_TITLEBAR_WHEN_MAXIMIZED : |
2397 ui::SHOW_TITLEBAR_WHEN_MAXIMIZED); | 2342 ui::SHOW_TITLEBAR_WHEN_MAXIMIZED); |
2398 } | 2343 } |
2399 | 2344 |
(...skipping 23 matching lines...) Expand all Loading... |
2423 BrowserWindowGtk* browser_window_gtk = new BrowserWindowGtk(browser); | 2368 BrowserWindowGtk* browser_window_gtk = new BrowserWindowGtk(browser); |
2424 browser_window_gtk->Init(); | 2369 browser_window_gtk->Init(); |
2425 return browser_window_gtk; | 2370 return browser_window_gtk; |
2426 } | 2371 } |
2427 | 2372 |
2428 // static | 2373 // static |
2429 chrome::HostDesktopType BrowserWindow::AdjustHostDesktopType( | 2374 chrome::HostDesktopType BrowserWindow::AdjustHostDesktopType( |
2430 chrome::HostDesktopType desktop_type) { | 2375 chrome::HostDesktopType desktop_type) { |
2431 return desktop_type; | 2376 return desktop_type; |
2432 } | 2377 } |
OLD | NEW |