| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/gtk/browser_window_gtk.h" | 5 #include "chrome/browser/gtk/browser_window_gtk.h" |
| 6 | 6 |
| 7 #include <gdk/gdkkeysyms.h> | 7 #include <gdk/gdkkeysyms.h> |
| 8 #include <X11/XF86keysym.h> | 8 #include <X11/XF86keysym.h> |
| 9 | 9 |
| 10 #include <string> | 10 #include <string> |
| (...skipping 1467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1478 } | 1478 } |
| 1479 | 1479 |
| 1480 bool BrowserWindowGtk::ShouldShowWindowIcon() const { | 1480 bool BrowserWindowGtk::ShouldShowWindowIcon() const { |
| 1481 return browser_->SupportsWindowFeature(Browser::FEATURE_TITLEBAR); | 1481 return browser_->SupportsWindowFeature(Browser::FEATURE_TITLEBAR); |
| 1482 } | 1482 } |
| 1483 | 1483 |
| 1484 void BrowserWindowGtk::AddFindBar(FindBarGtk* findbar) { | 1484 void BrowserWindowGtk::AddFindBar(FindBarGtk* findbar) { |
| 1485 gtk_box_pack_start(GTK_BOX(render_area_vbox_), findbar->widget(), | 1485 gtk_box_pack_start(GTK_BOX(render_area_vbox_), findbar->widget(), |
| 1486 FALSE, FALSE, 0); | 1486 FALSE, FALSE, 0); |
| 1487 gtk_box_reorder_child(GTK_BOX(render_area_vbox_), findbar->widget(), 0); | 1487 gtk_box_reorder_child(GTK_BOX(render_area_vbox_), findbar->widget(), 0); |
| 1488 |
| 1489 gtk_widget_hide(toolbar_border_); |
| 1488 } | 1490 } |
| 1489 | 1491 |
| 1490 void BrowserWindowGtk::ResetCustomFrameCursor() { | 1492 void BrowserWindowGtk::ResetCustomFrameCursor() { |
| 1491 if (!frame_cursor_) | 1493 if (!frame_cursor_) |
| 1492 return; | 1494 return; |
| 1493 | 1495 |
| 1494 gdk_cursor_unref(frame_cursor_); | 1496 gdk_cursor_unref(frame_cursor_); |
| 1495 frame_cursor_ = NULL; | 1497 frame_cursor_ = NULL; |
| 1496 gdk_window_set_cursor(GTK_WIDGET(window_)->window, NULL); | 1498 gdk_window_set_cursor(GTK_WIDGET(window_)->window, NULL); |
| 1497 } | 1499 } |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1687 } | 1689 } |
| 1688 #endif | 1690 #endif |
| 1689 | 1691 |
| 1690 // This vbox surrounds the render area: find bar, info bars and render view. | 1692 // This vbox surrounds the render area: find bar, info bars and render view. |
| 1691 // The reason is that this area as a whole needs to be grouped in its own | 1693 // The reason is that this area as a whole needs to be grouped in its own |
| 1692 // GdkWindow hierarchy so that animations originating inside it (infobar, | 1694 // GdkWindow hierarchy so that animations originating inside it (infobar, |
| 1693 // download shelf, find bar) are all clipped to that area. This is why | 1695 // download shelf, find bar) are all clipped to that area. This is why |
| 1694 // |render_area_vbox_| is packed in |render_area_event_box_|. | 1696 // |render_area_vbox_| is packed in |render_area_event_box_|. |
| 1695 render_area_vbox_ = gtk_vbox_new(FALSE, 0); | 1697 render_area_vbox_ = gtk_vbox_new(FALSE, 0); |
| 1696 gtk_widget_set_name(render_area_vbox_, "chrome-render-area-vbox"); | 1698 gtk_widget_set_name(render_area_vbox_, "chrome-render-area-vbox"); |
| 1699 |
| 1700 toolbar_border_ = gtk_event_box_new(); |
| 1701 gtk_box_pack_start(GTK_BOX(render_area_vbox_), |
| 1702 toolbar_border_, FALSE, FALSE, 0); |
| 1703 gtk_widget_set_size_request(toolbar_border_, -1, 1); |
| 1704 gtk_widget_show(toolbar_border_); |
| 1705 |
| 1697 infobar_container_.reset(new InfoBarContainerGtk(browser_->profile())); | 1706 infobar_container_.reset(new InfoBarContainerGtk(browser_->profile())); |
| 1698 gtk_box_pack_start(GTK_BOX(render_area_vbox_), | 1707 gtk_box_pack_start(GTK_BOX(render_area_vbox_), |
| 1699 infobar_container_->widget(), | 1708 infobar_container_->widget(), |
| 1700 FALSE, FALSE, 0); | 1709 FALSE, FALSE, 0); |
| 1701 | 1710 |
| 1702 status_bubble_.reset(new StatusBubbleGtk(browser_->profile())); | 1711 status_bubble_.reset(new StatusBubbleGtk(browser_->profile())); |
| 1703 | 1712 |
| 1704 contents_container_.reset(new TabContentsContainerGtk(status_bubble_.get())); | 1713 contents_container_.reset(new TabContentsContainerGtk(status_bubble_.get())); |
| 1705 devtools_container_.reset(new TabContentsContainerGtk(NULL)); | 1714 devtools_container_.reset(new TabContentsContainerGtk(NULL)); |
| 1706 ViewIDUtil::SetID(devtools_container_->widget(), VIEW_ID_DEV_TOOLS_DOCKED); | 1715 ViewIDUtil::SetID(devtools_container_->widget(), VIEW_ID_DEV_TOOLS_DOCKED); |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1805 gtk_widget_set_size_request(status_widget->GetNativeView(), | 1814 gtk_widget_set_size_request(status_widget->GetNativeView(), |
| 1806 status_area_size.width(), | 1815 status_area_size.width(), |
| 1807 status_area_size.height()); | 1816 status_area_size.height()); |
| 1808 status_widget->Show(); | 1817 status_widget->Show(); |
| 1809 } | 1818 } |
| 1810 #endif // OS_CHROMEOS | 1819 #endif // OS_CHROMEOS |
| 1811 } | 1820 } |
| 1812 | 1821 |
| 1813 void BrowserWindowGtk::SetBackgroundColor() { | 1822 void BrowserWindowGtk::SetBackgroundColor() { |
| 1814 Profile* profile = browser()->profile(); | 1823 Profile* profile = browser()->profile(); |
| 1815 ThemeProvider* theme_provider = profile->GetThemeProvider(); | 1824 GtkThemeProvider* theme_provider = GtkThemeProvider::GetFrom(profile); |
| 1816 int frame_color_id; | 1825 int frame_color_id; |
| 1817 if (IsActive()) { | 1826 if (IsActive()) { |
| 1818 frame_color_id = browser()->profile()->IsOffTheRecord() | 1827 frame_color_id = browser()->profile()->IsOffTheRecord() |
| 1819 ? BrowserThemeProvider::COLOR_FRAME_INCOGNITO | 1828 ? BrowserThemeProvider::COLOR_FRAME_INCOGNITO |
| 1820 : BrowserThemeProvider::COLOR_FRAME; | 1829 : BrowserThemeProvider::COLOR_FRAME; |
| 1821 } else { | 1830 } else { |
| 1822 frame_color_id = browser()->profile()->IsOffTheRecord() | 1831 frame_color_id = browser()->profile()->IsOffTheRecord() |
| 1823 ? BrowserThemeProvider::COLOR_FRAME_INCOGNITO_INACTIVE | 1832 ? BrowserThemeProvider::COLOR_FRAME_INCOGNITO_INACTIVE |
| 1824 : BrowserThemeProvider::COLOR_FRAME_INACTIVE; | 1833 : BrowserThemeProvider::COLOR_FRAME_INACTIVE; |
| 1825 } | 1834 } |
| 1826 | 1835 |
| 1827 SkColor frame_color = theme_provider->GetColor(frame_color_id); | 1836 SkColor frame_color = theme_provider->GetColor(frame_color_id); |
| 1828 | 1837 |
| 1829 // Paint the frame color on the left, right and bottom. | 1838 // Paint the frame color on the left, right and bottom. |
| 1830 GdkColor frame_color_gdk = SkColorToGdkColor(frame_color); | 1839 GdkColor frame_color_gdk = SkColorToGdkColor(frame_color); |
| 1831 gtk_widget_modify_bg(GTK_WIDGET(window_), GTK_STATE_NORMAL, | 1840 gtk_widget_modify_bg(GTK_WIDGET(window_), GTK_STATE_NORMAL, |
| 1832 &frame_color_gdk); | 1841 &frame_color_gdk); |
| 1833 | 1842 |
| 1834 // Set the color of the dev tools divider. | 1843 // Set the color of the dev tools divider. |
| 1835 gtk_widget_modify_bg(contents_split_, GTK_STATE_NORMAL, &frame_color_gdk); | 1844 gtk_widget_modify_bg(contents_split_, GTK_STATE_NORMAL, &frame_color_gdk); |
| 1836 | 1845 |
| 1837 // When the cursor is over the divider, GTK+ normally lightens the background | 1846 // When the cursor is over the divider, GTK+ normally lightens the background |
| 1838 // color by 1.3 (see LIGHTNESS_MULT in gtkstyle.c). Since we're setting the | 1847 // color by 1.3 (see LIGHTNESS_MULT in gtkstyle.c). Since we're setting the |
| 1839 // color, override the prelight also. | 1848 // color, override the prelight also. |
| 1840 color_utils::HSL hsl = { -1, 0.5, 0.65 }; | 1849 color_utils::HSL hsl = { -1, 0.5, 0.65 }; |
| 1841 SkColor frame_prelight_color = color_utils::HSLShift(frame_color, hsl); | 1850 SkColor frame_prelight_color = color_utils::HSLShift(frame_color, hsl); |
| 1842 GdkColor frame_prelight_color_gdk = SkColorToGdkColor(frame_prelight_color); | 1851 GdkColor frame_prelight_color_gdk = SkColorToGdkColor(frame_prelight_color); |
| 1843 gtk_widget_modify_bg(contents_split_, GTK_STATE_PRELIGHT, | 1852 gtk_widget_modify_bg(contents_split_, GTK_STATE_PRELIGHT, |
| 1844 &frame_prelight_color_gdk); | 1853 &frame_prelight_color_gdk); |
| 1854 |
| 1855 GdkColor border_color = theme_provider->GetBorderColor(); |
| 1856 gtk_widget_modify_bg(toolbar_border_, GTK_STATE_NORMAL, &border_color); |
| 1845 } | 1857 } |
| 1846 | 1858 |
| 1847 void BrowserWindowGtk::OnSizeChanged(int width, int height) { | 1859 void BrowserWindowGtk::OnSizeChanged(int width, int height) { |
| 1848 UpdateWindowShape(width, height); | 1860 UpdateWindowShape(width, height); |
| 1849 } | 1861 } |
| 1850 | 1862 |
| 1851 void BrowserWindowGtk::UpdateWindowShape(int width, int height) { | 1863 void BrowserWindowGtk::UpdateWindowShape(int width, int height) { |
| 1852 if (UseCustomFrame() && !IsFullscreen() && !IsMaximized()) { | 1864 if (UseCustomFrame() && !IsFullscreen() && !IsMaximized()) { |
| 1853 // Make the top corners rounded. We set a mask that includes most of the | 1865 // Make the top corners rounded. We set a mask that includes most of the |
| 1854 // window except for a few pixels in the top two corners. | 1866 // window except for a few pixels in the top two corners. |
| (...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2302 // are taken from the WMs' source code. | 2314 // are taken from the WMs' source code. |
| 2303 return (wm_name == "Blackbox" || | 2315 return (wm_name == "Blackbox" || |
| 2304 wm_name == "compiz" || | 2316 wm_name == "compiz" || |
| 2305 wm_name == "e16" || // Enlightenment DR16 | 2317 wm_name == "e16" || // Enlightenment DR16 |
| 2306 wm_name == "KWin" || | 2318 wm_name == "KWin" || |
| 2307 wm_name == "Metacity" || | 2319 wm_name == "Metacity" || |
| 2308 wm_name == "Mutter" || | 2320 wm_name == "Mutter" || |
| 2309 wm_name == "Openbox" || | 2321 wm_name == "Openbox" || |
| 2310 wm_name == "Xfwm4"); | 2322 wm_name == "Xfwm4"); |
| 2311 } | 2323 } |
| OLD | NEW |