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 522 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
533 #endif | 533 #endif |
534 | 534 |
535 BrowserWindowGtk::BrowserWindowGtk(Browser* browser) | 535 BrowserWindowGtk::BrowserWindowGtk(Browser* browser) |
536 : browser_(browser), | 536 : browser_(browser), |
537 state_(GDK_WINDOW_STATE_WITHDRAWN), | 537 state_(GDK_WINDOW_STATE_WITHDRAWN), |
538 #if defined(OS_CHROMEOS) | 538 #if defined(OS_CHROMEOS) |
539 drag_active_(false), | 539 drag_active_(false), |
540 panel_controller_(NULL), | 540 panel_controller_(NULL), |
541 compact_navigation_bar_(NULL), | 541 compact_navigation_bar_(NULL), |
542 status_area_(NULL), | 542 status_area_(NULL), |
| 543 main_menu_button_(NULL), |
| 544 compact_navbar_hbox_(NULL), |
543 #endif | 545 #endif |
544 frame_cursor_(NULL), | 546 frame_cursor_(NULL), |
545 is_active_(true), | 547 is_active_(true), |
546 last_click_time_(0), | 548 last_click_time_(0), |
547 maximize_after_show_(false), | 549 maximize_after_show_(false), |
548 accel_group_(NULL) { | 550 accel_group_(NULL) { |
549 use_custom_frame_pref_.Init(prefs::kUseCustomChromeFrame, | 551 use_custom_frame_pref_.Init(prefs::kUseCustomChromeFrame, |
550 browser_->profile()->GetPrefs(), this); | 552 browser_->profile()->GetPrefs(), this); |
551 | 553 |
552 window_ = GTK_WINDOW(gtk_window_new(GTK_WINDOW_TOPLEVEL)); | 554 window_ = GTK_WINDOW(gtk_window_new(GTK_WINDOW_TOPLEVEL)); |
(...skipping 853 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1406 | 1408 |
1407 if (changed_mask & GDK_WINDOW_STATE_FULLSCREEN) { | 1409 if (changed_mask & GDK_WINDOW_STATE_FULLSCREEN) { |
1408 bool is_fullscreen = state & GDK_WINDOW_STATE_FULLSCREEN; | 1410 bool is_fullscreen = state & GDK_WINDOW_STATE_FULLSCREEN; |
1409 browser_->UpdateCommandsForFullscreenMode(is_fullscreen); | 1411 browser_->UpdateCommandsForFullscreenMode(is_fullscreen); |
1410 if (is_fullscreen) { | 1412 if (is_fullscreen) { |
1411 UpdateCustomFrame(); | 1413 UpdateCustomFrame(); |
1412 toolbar_->Hide(); | 1414 toolbar_->Hide(); |
1413 tabstrip_->Hide(); | 1415 tabstrip_->Hide(); |
1414 if (IsBookmarkBarSupported()) | 1416 if (IsBookmarkBarSupported()) |
1415 bookmark_bar_->EnterFullscreen(); | 1417 bookmark_bar_->EnterFullscreen(); |
| 1418 #if defined(OS_CHROMEOS) |
| 1419 if (main_menu_button_) |
| 1420 gtk_widget_hide(main_menu_button_->widget()); |
| 1421 if (compact_navbar_hbox_) |
| 1422 gtk_widget_hide(compact_navbar_hbox_); |
| 1423 if (status_area_) |
| 1424 status_area_->GetWidget()->Hide(); |
| 1425 #endif |
1416 } else { | 1426 } else { |
1417 UpdateCustomFrame(); | 1427 UpdateCustomFrame(); |
1418 ShowSupportedWindowFeatures(); | 1428 ShowSupportedWindowFeatures(); |
1419 } | 1429 } |
1420 } | 1430 } |
1421 | 1431 |
1422 UpdateWindowShape(bounds_.width(), bounds_.height()); | 1432 UpdateWindowShape(bounds_.width(), bounds_.height()); |
1423 SaveWindowPosition(); | 1433 SaveWindowPosition(); |
1424 } | 1434 } |
1425 | 1435 |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1604 gtk_container_add(GTK_CONTAINER(window_container_), window_vbox_); | 1614 gtk_container_add(GTK_CONTAINER(window_container_), window_vbox_); |
1605 | 1615 |
1606 tabstrip_.reset(new TabStripGtk(browser_->tabstrip_model(), this)); | 1616 tabstrip_.reset(new TabStripGtk(browser_->tabstrip_model(), this)); |
1607 tabstrip_->Init(); | 1617 tabstrip_->Init(); |
1608 | 1618 |
1609 // Build the titlebar (tabstrip + header space + min/max/close buttons). | 1619 // Build the titlebar (tabstrip + header space + min/max/close buttons). |
1610 titlebar_.reset(new BrowserTitlebar(this, window_)); | 1620 titlebar_.reset(new BrowserTitlebar(this, window_)); |
1611 | 1621 |
1612 #if defined(OS_CHROMEOS) | 1622 #if defined(OS_CHROMEOS) |
1613 GtkWidget* titlebar_hbox = NULL; | 1623 GtkWidget* titlebar_hbox = NULL; |
1614 GtkWidget* navbar_hbox = NULL; | |
1615 GtkWidget* status_container = NULL; | 1624 GtkWidget* status_container = NULL; |
1616 bool has_compact_nav_bar = next_window_should_use_compact_nav_; | 1625 bool has_compact_nav_bar = next_window_should_use_compact_nav_; |
1617 if (browser_->type() == Browser::TYPE_NORMAL) { | 1626 if (browser_->type() == Browser::TYPE_NORMAL) { |
1618 // Make a box that we'll later insert the compact navigation bar into. The | 1627 // Make a box that we'll later insert the compact navigation bar into. The |
1619 // tabstrip must go into an hbox with our box so that they can get arranged | 1628 // tabstrip must go into an hbox with our box so that they can get arranged |
1620 // horizontally. | 1629 // horizontally. |
1621 titlebar_hbox = gtk_hbox_new(FALSE, 0); | 1630 titlebar_hbox = gtk_hbox_new(FALSE, 0); |
1622 gtk_widget_show(titlebar_hbox); | 1631 gtk_widget_show(titlebar_hbox); |
1623 | 1632 |
1624 // Main menu button. | 1633 // Main menu button. |
1625 CustomDrawButton* main_menu_button = | 1634 main_menu_button_ = |
1626 new CustomDrawButton(IDR_MAIN_MENU_BUTTON, IDR_MAIN_MENU_BUTTON, | 1635 new CustomDrawButton(IDR_MAIN_MENU_BUTTON, IDR_MAIN_MENU_BUTTON, |
1627 IDR_MAIN_MENU_BUTTON, 0); | 1636 IDR_MAIN_MENU_BUTTON, 0); |
1628 gtk_widget_show(main_menu_button->widget()); | 1637 gtk_widget_show(main_menu_button_->widget()); |
1629 g_signal_connect(G_OBJECT(main_menu_button->widget()), "clicked", | 1638 g_signal_connect(G_OBJECT(main_menu_button_->widget()), "clicked", |
1630 G_CALLBACK(OnMainMenuButtonClicked), this); | 1639 G_CALLBACK(OnMainMenuButtonClicked), this); |
1631 GTK_WIDGET_UNSET_FLAGS(main_menu_button->widget(), GTK_CAN_FOCUS); | 1640 GTK_WIDGET_UNSET_FLAGS(main_menu_button_->widget(), GTK_CAN_FOCUS); |
1632 gtk_box_pack_start(GTK_BOX(titlebar_hbox), main_menu_button->widget(), | 1641 gtk_box_pack_start(GTK_BOX(titlebar_hbox), main_menu_button_->widget(), |
1633 FALSE, FALSE, 0); | 1642 FALSE, FALSE, 0); |
1634 | 1643 |
1635 MainMenu::ScheduleCreation(); | 1644 MainMenu::ScheduleCreation(); |
1636 | 1645 |
1637 if (has_compact_nav_bar) { | 1646 if (has_compact_nav_bar) { |
1638 navbar_hbox = gtk_hbox_new(FALSE, 0); | 1647 compact_navbar_hbox_ = gtk_hbox_new(FALSE, 0); |
1639 gtk_widget_show(navbar_hbox); | 1648 gtk_widget_show(compact_navbar_hbox_); |
1640 gtk_box_pack_start(GTK_BOX(titlebar_hbox), navbar_hbox, FALSE, FALSE, 0); | 1649 gtk_box_pack_start(GTK_BOX(titlebar_hbox), compact_navbar_hbox_, |
| 1650 FALSE, FALSE, 0); |
1641 | 1651 |
1642 // Reset the compact nav bit now that we're creating the next toplevel | 1652 // Reset the compact nav bit now that we're creating the next toplevel |
1643 // window. Code below will use our local has_compact_nav_bar variable. | 1653 // window. Code below will use our local has_compact_nav_bar variable. |
1644 next_window_should_use_compact_nav_ = false; | 1654 next_window_should_use_compact_nav_ = false; |
1645 } | 1655 } |
1646 status_container = gtk_fixed_new(); | 1656 status_container = gtk_fixed_new(); |
1647 gtk_widget_show(status_container); | 1657 gtk_widget_show(status_container); |
1648 gtk_box_pack_start(GTK_BOX(titlebar_hbox), titlebar_->widget(), TRUE, TRUE, | 1658 gtk_box_pack_start(GTK_BOX(titlebar_hbox), titlebar_->widget(), TRUE, TRUE, |
1649 0); | 1659 0); |
1650 gtk_box_pack_start(GTK_BOX(titlebar_hbox), status_container, FALSE, FALSE, | 1660 gtk_box_pack_start(GTK_BOX(titlebar_hbox), status_container, FALSE, FALSE, |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1754 // Create the compact navigation bar. This must be done after adding | 1764 // Create the compact navigation bar. This must be done after adding |
1755 // everything to the window since it's done in Views, which expects to | 1765 // everything to the window since it's done in Views, which expects to |
1756 // call realize (requiring a window) in the Init function. | 1766 // call realize (requiring a window) in the Init function. |
1757 views::WidgetGtk* clb_widget = | 1767 views::WidgetGtk* clb_widget = |
1758 new views::WidgetGtk(views::WidgetGtk::TYPE_CHILD); | 1768 new views::WidgetGtk(views::WidgetGtk::TYPE_CHILD); |
1759 clb_widget->set_delete_on_destroy(true); | 1769 clb_widget->set_delete_on_destroy(true); |
1760 // Must initialize with a NULL parent since the widget will assume the | 1770 // Must initialize with a NULL parent since the widget will assume the |
1761 // parent is also a WidgetGtk. Then we can parent the native widget | 1771 // parent is also a WidgetGtk. Then we can parent the native widget |
1762 // afterwards. | 1772 // afterwards. |
1763 clb_widget->Init(NULL, gfx::Rect(0, 0, 100, 30)); | 1773 clb_widget->Init(NULL, gfx::Rect(0, 0, 100, 30)); |
1764 gtk_widget_reparent(clb_widget->GetNativeView(), navbar_hbox); | 1774 gtk_widget_reparent(clb_widget->GetNativeView(), compact_navbar_hbox_); |
1765 | 1775 |
1766 compact_navigation_bar_ = new CompactNavigationBar(browser_.get()); | 1776 compact_navigation_bar_ = new CompactNavigationBar(browser_.get()); |
1767 | 1777 |
1768 clb_widget->SetContentsView(compact_navigation_bar_); | 1778 clb_widget->SetContentsView(compact_navigation_bar_); |
1769 compact_navigation_bar_->Init(); | 1779 compact_navigation_bar_->Init(); |
1770 | 1780 |
1771 // Must be after Init. | 1781 // Must be after Init. |
1772 gtk_widget_set_size_request(clb_widget->GetNativeView(), | 1782 gtk_widget_set_size_request(clb_widget->GetNativeView(), |
1773 compact_navigation_bar_->GetPreferredSize().width(), 20); | 1783 compact_navigation_bar_->GetPreferredSize().width(), 20); |
1774 clb_widget->Show(); | 1784 clb_widget->Show(); |
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2137 | 2147 |
2138 void BrowserWindowGtk::ShowSupportedWindowFeatures() { | 2148 void BrowserWindowGtk::ShowSupportedWindowFeatures() { |
2139 if (IsTabStripSupported()) | 2149 if (IsTabStripSupported()) |
2140 tabstrip_->Show(); | 2150 tabstrip_->Show(); |
2141 | 2151 |
2142 if (IsToolbarSupported()) | 2152 if (IsToolbarSupported()) |
2143 toolbar_->Show(); | 2153 toolbar_->Show(); |
2144 | 2154 |
2145 if (IsBookmarkBarSupported()) | 2155 if (IsBookmarkBarSupported()) |
2146 MaybeShowBookmarkBar(browser_->GetSelectedTabContents(), false); | 2156 MaybeShowBookmarkBar(browser_->GetSelectedTabContents(), false); |
| 2157 |
| 2158 #if defined(OS_CHROMEOS) |
| 2159 if (main_menu_button_) |
| 2160 gtk_widget_show(main_menu_button_->widget()); |
| 2161 |
| 2162 if (compact_navbar_hbox_) |
| 2163 gtk_widget_show(compact_navbar_hbox_); |
| 2164 |
| 2165 if (status_area_) |
| 2166 status_area_->GetWidget()->Show(); |
| 2167 #endif |
2147 } | 2168 } |
2148 | 2169 |
2149 void BrowserWindowGtk::HideUnsupportedWindowFeatures() { | 2170 void BrowserWindowGtk::HideUnsupportedWindowFeatures() { |
2150 if (!IsTabStripSupported()) | 2171 if (!IsTabStripSupported()) |
2151 tabstrip_->Hide(); | 2172 tabstrip_->Hide(); |
2152 | 2173 |
2153 if (!IsToolbarSupported()) | 2174 if (!IsToolbarSupported()) |
2154 toolbar_->Hide(); | 2175 toolbar_->Hide(); |
2155 | 2176 |
2156 // If the bookmark bar shelf is unsupported, then we never create it. | 2177 // If the bookmark bar shelf is unsupported, then we never create it. |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2277 // are taken from the WMs' source code. | 2298 // are taken from the WMs' source code. |
2278 return (wm_name == "Blackbox" || | 2299 return (wm_name == "Blackbox" || |
2279 wm_name == "compiz" || | 2300 wm_name == "compiz" || |
2280 wm_name == "e16" || // Enlightenment DR16 | 2301 wm_name == "e16" || // Enlightenment DR16 |
2281 wm_name == "KWin" || | 2302 wm_name == "KWin" || |
2282 wm_name == "Metacity" || | 2303 wm_name == "Metacity" || |
2283 wm_name == "Mutter" || | 2304 wm_name == "Mutter" || |
2284 wm_name == "Openbox" || | 2305 wm_name == "Openbox" || |
2285 wm_name == "Xfwm4"); | 2306 wm_name == "Xfwm4"); |
2286 } | 2307 } |
OLD | NEW |