diff options
-rw-r--r-- | chrome/browser/chromeos/browser_extenders.cc | 32 | ||||
-rw-r--r-- | chrome/browser/gtk/browser_window_gtk.cc | 12 | ||||
-rw-r--r-- | chrome/browser/views/frame/browser_extender.h | 3 | ||||
-rw-r--r-- | chrome/browser/views/frame/browser_frame_gtk.cc | 6 | ||||
-rw-r--r-- | chrome/browser/views/frame/browser_frame_gtk.h | 1 | ||||
-rw-r--r-- | chrome/browser/views/frame/standard_extender.cc | 1 | ||||
-rw-r--r-- | chrome/common/x11_util.cc | 16 | ||||
-rw-r--r-- | chrome/common/x11_util.h | 3 |
8 files changed, 58 insertions, 16 deletions
diff --git a/chrome/browser/chromeos/browser_extenders.cc b/chrome/browser/chromeos/browser_extenders.cc index 24ffd25..6fcc117 100644 --- a/chrome/browser/chromeos/browser_extenders.cc +++ b/chrome/browser/chromeos/browser_extenders.cc @@ -17,6 +17,7 @@ #include "chrome/browser/views/tabs/tab_overview_types.h" #include "chrome/browser/views/tabs/tab_strip.h" #include "chrome/browser/views/toolbar_view.h" +#include "chrome/common/x11_util.h" #include "grit/generated_resources.h" #include "grit/theme_resources.h" #include "views/controls/button/button.h" @@ -26,6 +27,8 @@ namespace { +const char* kChromeOsWindowManagerName = "chromeos-wm"; + // NormalExtender adds ChromeOS specific controls and menus to a BrowserView // created with Browser::TYPE_NORMAL. This extender adds controls to // the title bar as follows: @@ -46,7 +49,8 @@ class NormalExtender : public BrowserExtender, compact_navigation_bar_(NULL), // CompactNavigationBar is disabled by default. // TODO(oshima): Get this info from preference. - compact_navigation_bar_enabled_(false) { + compact_navigation_bar_enabled_(false), + force_maximized_window_(false) { } virtual ~NormalExtender() {} @@ -62,13 +66,14 @@ class NormalExtender : public BrowserExtender, main_menu_->SetImage(views::CustomButton::BS_PUSHED, image); browser_view()->AddChildView(main_menu_); - compact_location_bar_.reset(new chromeos::CompactLocationBar(browser_view())); - compact_navigation_bar_ = - new chromeos::CompactNavigationBar(browser_view()->browser()); + Browser* browser = browser_view()->browser(); + compact_location_bar_.reset( + new chromeos::CompactLocationBar(browser_view())); + compact_navigation_bar_ = new chromeos::CompactNavigationBar(browser); browser_view()->AddChildView(compact_navigation_bar_); compact_navigation_bar_->Init(); status_area_ = new chromeos::StatusAreaView( - browser_view()->browser(), + browser, browser_view()->GetWindow()->GetNativeWindow()); browser_view()->AddChildView(status_area_); status_area_->Init(); @@ -83,6 +88,12 @@ class NormalExtender : public BrowserExtender, BrowserFrameGtk* gtk_frame = static_cast<BrowserFrameGtk*>(browser_view()->frame()); gtk_frame->GetNonClientView()->SetContextMenuController(this); + + if (browser->type() == Browser::TYPE_NORMAL) { + std::string wm_name; + force_maximized_window_ = x11_util::GetWindowManagerName(&wm_name) && + wm_name == kChromeOsWindowManagerName; + } } virtual gfx::Rect Layout(const gfx::Rect& bounds) { @@ -196,6 +207,10 @@ class NormalExtender : public BrowserExtender, compact_location_bar_->StartPopupTimer(); } + virtual bool ShouldForceMaximizedWindow() { + return force_maximized_window_; + } + private: // Shows the compact location bar under the selected tab. void ShowCompactLocationBarUnderSelectedTab() { @@ -250,6 +265,9 @@ class NormalExtender : public BrowserExtender, // CompactLocationBar view. scoped_ptr<chromeos::CompactLocationBar> compact_location_bar_; + // A flag to specify if the browser window should be maximized. + bool force_maximized_window_; + DISALLOW_COPY_AND_ASSIGN(NormalExtender); }; @@ -329,6 +347,10 @@ class PopupExtender : public BrowserExtender { virtual void OnMouseExitedFromTab(Tab* tab) {} + virtual bool ShouldForceMaximizedWindow() { + return false; + } + // Controls interactions with the window manager for popup panels. scoped_ptr<chromeos::PanelController> panel_controller_; diff --git a/chrome/browser/gtk/browser_window_gtk.cc b/chrome/browser/gtk/browser_window_gtk.cc index 601bd20..3339ad8 100644 --- a/chrome/browser/gtk/browser_window_gtk.cc +++ b/chrome/browser/gtk/browser_window_gtk.cc @@ -2336,19 +2336,9 @@ void BrowserWindowGtk::PlaceBookmarkBar(bool is_floating) { // static bool BrowserWindowGtk::GetCustomFramePrefDefault() { - int wm_window = 0; - if (!x11_util::GetIntProperty(x11_util::GetX11RootWindow(), - "_NET_SUPPORTING_WM_CHECK", - &wm_window)) { - return false; - } - std::string wm_name; - if (!x11_util::GetStringProperty(static_cast<XID>(wm_window), - "_NET_WM_NAME", - &wm_name)) { + if (!x11_util::GetWindowManagerName(&wm_name)) return false; - } // Ideally, we'd use the custom frame by default and just fall back on using // system decorations for the few (?) tiling window managers where the custom diff --git a/chrome/browser/views/frame/browser_extender.h b/chrome/browser/views/frame/browser_extender.h index b27423c..1505eff 100644 --- a/chrome/browser/views/frame/browser_extender.h +++ b/chrome/browser/views/frame/browser_extender.h @@ -56,6 +56,9 @@ class BrowserExtender { // to use the regular logic to decide. virtual bool ShouldForceHideToolbar() = 0; + // Returns true if the window should be in the maximized state. + virtual bool ShouldForceMaximizedWindow() = 0; + // Returns true if the compact navigation bar is focusable and got // focus, false otherwise. virtual bool SetFocusToCompactNavigationBar() = 0; diff --git a/chrome/browser/views/frame/browser_frame_gtk.cc b/chrome/browser/views/frame/browser_frame_gtk.cc index 0068b81..76628f7 100644 --- a/chrome/browser/views/frame/browser_frame_gtk.cc +++ b/chrome/browser/views/frame/browser_frame_gtk.cc @@ -7,6 +7,7 @@ #include "base/logging.h" #include "chrome/browser/profile.h" #include "chrome/browser/status_bubble.h" +#include "chrome/browser/views/frame/browser_extender.h" #include "chrome/browser/views/frame/browser_root_view.h" #include "chrome/browser/views/frame/browser_view.h" #include "chrome/browser/views/frame/opaque_browser_frame_view.h" @@ -141,6 +142,11 @@ void BrowserFrameGtk::IsActiveChanged() { views::WidgetGtk::IsActiveChanged(); } +bool BrowserFrameGtk::IsMaximized() const { + return browser_view_->browser_extender()->ShouldForceMaximizedWindow() || + WindowGtk::IsMaximized(); +} + bool BrowserFrameGtk::GetAccelerator(int cmd_id, views::Accelerator* accelerator) { return browser_view_->GetAccelerator(cmd_id, accelerator); diff --git a/chrome/browser/views/frame/browser_frame_gtk.h b/chrome/browser/views/frame/browser_frame_gtk.h index f050dfe..ebcba31 100644 --- a/chrome/browser/views/frame/browser_frame_gtk.h +++ b/chrome/browser/views/frame/browser_frame_gtk.h @@ -49,6 +49,7 @@ class BrowserFrameGtk : public BrowserFrame, GdkEventWindowState* event); virtual gboolean OnConfigureEvent(GtkWidget* widget, GdkEventConfigure* event); + virtual bool IsMaximized() const; private: // The BrowserView is our ClientView. This is a pointer to it. diff --git a/chrome/browser/views/frame/standard_extender.cc b/chrome/browser/views/frame/standard_extender.cc index b03a572..1f2120e 100644 --- a/chrome/browser/views/frame/standard_extender.cc +++ b/chrome/browser/views/frame/standard_extender.cc @@ -27,6 +27,7 @@ class StandardExtender : public BrowserExtender { virtual void UpdateTitleBar() {} virtual void ActivationChanged() {} virtual bool ShouldForceHideToolbar() { return false; } + virtual bool ShouldForceMaximizedWindow() { return false; } virtual bool SetFocusToCompactNavigationBar() { return false; } virtual void ToggleCompactNavigationBar() {} virtual void OnMouseEnteredToTab(Tab* tab) {} diff --git a/chrome/common/x11_util.cc b/chrome/common/x11_util.cc index 1905d2c..556b804 100644 --- a/chrome/common/x11_util.cc +++ b/chrome/common/x11_util.cc @@ -548,4 +548,20 @@ bool GetWindowParent(XID* parent_window, bool* parent_is_root, XID window) { return true; } +bool GetWindowManagerName(std::string* wm_name) { + DCHECK(wm_name); + int wm_window = 0; + if (!x11_util::GetIntProperty(x11_util::GetX11RootWindow(), + "_NET_SUPPORTING_WM_CHECK", + &wm_window)) { + return false; + } + if (!x11_util::GetStringProperty(static_cast<XID>(wm_window), + "_NET_WM_NAME", + wm_name)) { + return false; + } + return true; +} + } // namespace x11_util diff --git a/chrome/common/x11_util.h b/chrome/common/x11_util.h index f11739c..aed7bad 100644 --- a/chrome/common/x11_util.h +++ b/chrome/common/x11_util.h @@ -133,6 +133,9 @@ bool GetWindowGeometry(int* x, int* y, unsigned* width, unsigned* height, // parent_is_root: (output) true iff the parent of |window| is the root window. bool GetWindowParent(XID* parent_window, bool* parent_is_root, XID window); +// Get the window manager name. +bool GetWindowManagerName(std::string* name); + } // namespace x11_util #endif // CHROME_COMMON_X11_UTIL_H_ |