diff options
author | mgiuca@chromium.org <mgiuca@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-01-23 09:27:02 +0000 |
---|---|---|
committer | mgiuca@chromium.org <mgiuca@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-01-23 09:27:02 +0000 |
commit | 02abfeea10fa049bf9cd10fd951dd4c840312d38 (patch) | |
tree | 754b988ac65faaa6025bcbff04a359c4fddd73c3 | |
parent | ddd8afa08a2cc983b0030c1c749808e7a0dc2c1c (diff) | |
download | chromium_src-02abfeea10fa049bf9cd10fd951dd4c840312d38.zip chromium_src-02abfeea10fa049bf9cd10fd951dd4c840312d38.tar.gz chromium_src-02abfeea10fa049bf9cd10fd951dd4c840312d38.tar.bz2 |
Linux Aura: Hide title bar when CustomFrameView maximized on Unity.
This avoids showing a double title bar on Task Manager and V2 app
windows.
BUG=330090
TEST=On Unity, maximize Task Manager and V2 app window. There should be
only the Unity title and caption buttons, no blue custom title bar.
Review URL: https://codereview.chromium.org/98793009
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@246544 0039d316-1c4b-4281-b951-d872f2087c98
12 files changed, 75 insertions, 53 deletions
diff --git a/chrome/browser/ui/views/chrome_views_delegate.cc b/chrome/browser/ui/views/chrome_views_delegate.cc index 8bb3526..213e3b2 100644 --- a/chrome/browser/ui/views/chrome_views_delegate.cc +++ b/chrome/browser/ui/views/chrome_views_delegate.cc @@ -39,6 +39,10 @@ #include "ui/views/widget/native_widget_aura.h" #endif +#if defined(OS_LINUX) && !defined(OS_CHROMEOS) +#include "ui/views/linux_ui/linux_ui.h" +#endif + #if defined(USE_ASH) #include "ash/shell.h" #include "ash/wm/window_state.h" @@ -302,6 +306,17 @@ ChromeViewsDelegate::GetDefaultTextfieldObscuredRevealDuration() { return base::TimeDelta(); } +bool ChromeViewsDelegate::WindowManagerProvidesTitleBar(bool maximized) { +#if defined(OS_LINUX) && !defined(OS_CHROMEOS) + // On Ubuntu Unity, the system always provides a title bar for maximized + // windows. + views::LinuxUI* ui = views::LinuxUI::instance(); + return maximized && ui && ui->UnityIsRunning(); +#endif + + return false; +} + #if !defined(USE_AURA) && !defined(USE_CHROMEOS) views::Widget::InitParams::WindowOpacity ChromeViewsDelegate::GetOpacityForInitParams( diff --git a/chrome/browser/ui/views/chrome_views_delegate.h b/chrome/browser/ui/views/chrome_views_delegate.h index e3e8f5b..95f827f 100644 --- a/chrome/browser/ui/views/chrome_views_delegate.h +++ b/chrome/browser/ui/views/chrome_views_delegate.h @@ -51,6 +51,7 @@ class ChromeViewsDelegate : public views::ViewsDelegate { views::Widget::InitParams* params, views::internal::NativeWidgetDelegate* delegate) OVERRIDE; virtual base::TimeDelta GetDefaultTextfieldObscuredRevealDuration() OVERRIDE; + virtual bool WindowManagerProvidesTitleBar(bool maximized) OVERRIDE; private: // Function to retrieve default opacity value mainly based on platform diff --git a/chrome/browser/ui/views/frame/opaque_browser_frame_view.cc b/chrome/browser/ui/views/frame/opaque_browser_frame_view.cc index 2b4f74a..1df6e50 100644 --- a/chrome/browser/ui/views/frame/opaque_browser_frame_view.cc +++ b/chrome/browser/ui/views/frame/opaque_browser_frame_view.cc @@ -48,6 +48,7 @@ #include "ui/views/controls/image_view.h" #include "ui/views/controls/label.h" #include "ui/views/layout/layout_constants.h" +#include "ui/views/views_delegate.h" #include "ui/views/widget/root_view.h" #include "ui/views/window/frame_background.h" #include "ui/views/window/window_shape.h" @@ -437,7 +438,7 @@ bool OpaqueBrowserFrameView::ShouldShowWindowIcon() const { #endif views::WidgetDelegate* delegate = frame()->widget_delegate(); - return platform_observer_->ShouldShowTitleBar() && delegate && + return ShouldShowWindowTitleBar() && delegate && delegate->ShouldShowWindowIcon(); } @@ -453,7 +454,7 @@ bool OpaqueBrowserFrameView::ShouldShowWindowTitle() const { // a window is being destroyed. // See more discussion at http://crosbug.com/8958 views::WidgetDelegate* delegate = frame()->widget_delegate(); - return platform_observer_->ShouldShowTitleBar() && delegate && + return ShouldShowWindowTitleBar() && delegate && delegate->ShouldShowWindowTitle(); } @@ -480,9 +481,15 @@ gfx::Size OpaqueBrowserFrameView::GetBrowserViewMinimumSize() const { } bool OpaqueBrowserFrameView::ShouldShowCaptionButtons() const { +#if defined(OS_LINUX) && !defined(OS_CHROMEOS) + // Do not show caption buttons if the system title bar is being used. + if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kUseSystemTitleBar)) + return false; +#endif + if (!OpaqueBrowserFrameViewLayout::ShouldAddDefaultCaptionButtons()) return false; - return platform_observer_->ShouldShowCaptionButtons(); + return ShouldShowWindowTitleBar(); } bool OpaqueBrowserFrameView::ShouldShowAvatar() const { @@ -604,6 +611,13 @@ gfx::Rect OpaqueBrowserFrameView::IconBounds() const { return layout_->IconBounds(); } +bool OpaqueBrowserFrameView::ShouldShowWindowTitleBar() const { + if (!views::ViewsDelegate::views_delegate) + return true; + return !views::ViewsDelegate::views_delegate->WindowManagerProvidesTitleBar( + IsMaximized()); +} + void OpaqueBrowserFrameView::PaintRestoredFrameBorder(gfx::Canvas* canvas) { frame_background_->set_frame_color(GetFrameColor()); frame_background_->set_theme_image(GetFrameImage()); diff --git a/chrome/browser/ui/views/frame/opaque_browser_frame_view.h b/chrome/browser/ui/views/frame/opaque_browser_frame_view.h index 029aec3..296504d 100644 --- a/chrome/browser/ui/views/frame/opaque_browser_frame_view.h +++ b/chrome/browser/ui/views/frame/opaque_browser_frame_view.h @@ -134,6 +134,9 @@ class OpaqueBrowserFrameView : public BrowserNonClientFrameView, // there was one). gfx::Rect IconBounds() const; + // Returns true if the view should draw its own custom title bar. + bool ShouldShowWindowTitleBar() const; + // Paint various sub-components of this view. The *FrameBorder() functions // also paint the background of the titlebar area, since the top frame border // and titlebar background are a contiguous component. diff --git a/chrome/browser/ui/views/frame/opaque_browser_frame_view_linux.cc b/chrome/browser/ui/views/frame/opaque_browser_frame_view_linux.cc index c6c9340..b911e6f 100644 --- a/chrome/browser/ui/views/frame/opaque_browser_frame_view_linux.cc +++ b/chrome/browser/ui/views/frame/opaque_browser_frame_view_linux.cc @@ -4,10 +4,8 @@ #include "chrome/browser/ui/views/frame/opaque_browser_frame_view_linux.h" -#include "base/command_line.h" #include "chrome/browser/ui/views/frame/opaque_browser_frame_view.h" #include "chrome/browser/ui/views/frame/opaque_browser_frame_view_layout.h" -#include "chrome/common/chrome_switches.h" #include "ui/views/linux_ui/linux_ui.h" /////////////////////////////////////////////////////////////////////////////// @@ -31,28 +29,6 @@ OpaqueBrowserFrameViewLinux::~OpaqueBrowserFrameViewLinux() { /////////////////////////////////////////////////////////////////////////////// // OpaqueBrowserFrameViewLinux, -// OpaqueBrowserFrameViewPlatformSpecific implementation: - -bool OpaqueBrowserFrameViewLinux::ShouldShowCaptionButtons() const { - // Do not show caption buttons if the system title bar is being used. - if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kUseSystemTitleBar)) - return false; - - // On Ubuntu Unity, if the window is maximized, the system will provide - // caption buttons, so Chrome should not add its own. - views::LinuxUI* ui = views::LinuxUI::instance(); - return !(view_->IsMaximized() && ui && ui->UnityIsRunning()); -} - -bool OpaqueBrowserFrameViewLinux::ShouldShowTitleBar() const { - // On Ubuntu Unity, if the window is maximized, the system will provide - // a title bar, so Chrome should not add its own. - views::LinuxUI* ui = views::LinuxUI::instance(); - return !(view_->IsMaximized() && ui && ui->UnityIsRunning()); -} - -/////////////////////////////////////////////////////////////////////////////// -// OpaqueBrowserFrameViewLinux, // views::WindowButtonOrderObserver implementation: void OpaqueBrowserFrameViewLinux::OnWindowButtonOrderingChange( diff --git a/chrome/browser/ui/views/frame/opaque_browser_frame_view_linux.h b/chrome/browser/ui/views/frame/opaque_browser_frame_view_linux.h index 1fb2005..c82425b 100644 --- a/chrome/browser/ui/views/frame/opaque_browser_frame_view_linux.h +++ b/chrome/browser/ui/views/frame/opaque_browser_frame_view_linux.h @@ -21,10 +21,6 @@ class OpaqueBrowserFrameViewLinux OpaqueBrowserFrameViewLayout* layout); virtual ~OpaqueBrowserFrameViewLinux(); - // Overridden from OpaqueBrowserFrameViewPlatformSpecific: - virtual bool ShouldShowCaptionButtons() const OVERRIDE; - virtual bool ShouldShowTitleBar() const OVERRIDE; - // Overridden from views::WindowButtonOrderObserver: virtual void OnWindowButtonOrderingChange( const std::vector<views::FrameButton>& leading_buttons, diff --git a/chrome/browser/ui/views/frame/opaque_browser_frame_view_platform_specific.cc b/chrome/browser/ui/views/frame/opaque_browser_frame_view_platform_specific.cc index 0e86182..2927953 100644 --- a/chrome/browser/ui/views/frame/opaque_browser_frame_view_platform_specific.cc +++ b/chrome/browser/ui/views/frame/opaque_browser_frame_view_platform_specific.cc @@ -17,11 +17,3 @@ OpaqueBrowserFrameViewPlatformSpecific::Create( } #endif - -bool OpaqueBrowserFrameViewPlatformSpecific::ShouldShowCaptionButtons() const { - return true; -} - -bool OpaqueBrowserFrameViewPlatformSpecific::ShouldShowTitleBar() const { - return true; -} diff --git a/chrome/browser/ui/views/frame/opaque_browser_frame_view_platform_specific.h b/chrome/browser/ui/views/frame/opaque_browser_frame_view_platform_specific.h index 765cf70..b457233 100644 --- a/chrome/browser/ui/views/frame/opaque_browser_frame_view_platform_specific.h +++ b/chrome/browser/ui/views/frame/opaque_browser_frame_view_platform_specific.h @@ -17,16 +17,6 @@ class OpaqueBrowserFrameViewPlatformSpecific { static OpaqueBrowserFrameViewPlatformSpecific* Create( OpaqueBrowserFrameView* view, OpaqueBrowserFrameViewLayout* layout); - - // Whether we should show the (minimize,maximize,close) buttons. This can - // depend on the current state of the window (e.g., whether it is maximized). - // The default implementation always returns true. - virtual bool ShouldShowCaptionButtons() const; - - // Whether we should show a title bar at all, for browser windows that do not - // have a tab strip (e.g., developer tools, popups). The default - // implementation always returns true. - virtual bool ShouldShowTitleBar() const; }; #endif // CHROME_BROWSER_UI_VIEWS_FRAME_OPAQUE_BROWSER_FRAME_VIEW_PLATFORM_SPECIFIC_H_ diff --git a/ui/views/views_delegate.cc b/ui/views/views_delegate.cc index 20cb88f..6552dd7 100644 --- a/ui/views/views_delegate.cc +++ b/ui/views/views_delegate.cc @@ -17,4 +17,8 @@ ViewsDelegate::~ViewsDelegate() { ui::TouchSelectionControllerFactory::SetInstance(NULL); } +bool ViewsDelegate::WindowManagerProvidesTitleBar(bool maximized) { + return false; +} + } // namespace views diff --git a/ui/views/views_delegate.h b/ui/views/views_delegate.h index 9ae48eec..a3d63bd 100644 --- a/ui/views/views_delegate.h +++ b/ui/views/views_delegate.h @@ -119,6 +119,12 @@ class VIEWS_EXPORT ViewsDelegate { // Returns the default obscured text reveal duration. virtual base::TimeDelta GetDefaultTextfieldObscuredRevealDuration() = 0; + // Returns true if the operating system's window manager will always provide a + // title bar with caption buttons (ignoring the setting to + // |remove_standard_frame| in InitParams). If |maximized|, this applies to + // maximized windows; otherwise to restored windows. + virtual bool WindowManagerProvidesTitleBar(bool maximized); + private: scoped_ptr<ViewsTouchSelectionControllerFactory> views_tsc_factory_; }; diff --git a/ui/views/window/custom_frame_view.cc b/ui/views/window/custom_frame_view.cc index bb27dc6..5ef022b 100644 --- a/ui/views/window/custom_frame_view.cc +++ b/ui/views/window/custom_frame_view.cc @@ -18,6 +18,7 @@ #include "ui/gfx/path.h" #include "ui/views/color_constants.h" #include "ui/views/controls/button/image_button.h" +#include "ui/views/views_delegate.h" #include "ui/views/widget/widget.h" #include "ui/views/widget/widget_delegate.h" #include "ui/views/window/client_view.h" @@ -186,7 +187,7 @@ int CustomFrameView::NonClientHitTest(const gfx::Point& point) { void CustomFrameView::GetWindowMask(const gfx::Size& size, gfx::Path* window_mask) { DCHECK(window_mask); - if (frame_->IsMaximized()) + if (frame_->IsMaximized() || !ShouldShowTitleBarAndBorder()) return; GetDefaultWindowMask(size, window_mask); @@ -212,6 +213,9 @@ void CustomFrameView::UpdateWindowTitle() { // CustomFrameView, View overrides: void CustomFrameView::OnPaint(gfx::Canvas* canvas) { + if (!ShouldShowTitleBarAndBorder()) + return; + if (frame_->IsMaximized()) PaintMaximizedFrameBorder(canvas); else @@ -222,8 +226,11 @@ void CustomFrameView::OnPaint(gfx::Canvas* canvas) { } void CustomFrameView::Layout() { - LayoutWindowControls(); - LayoutTitleBar(); + if (ShouldShowTitleBarAndBorder()) { + LayoutWindowControls(); + LayoutTitleBar(); + } + LayoutClientView(); } @@ -323,8 +330,17 @@ gfx::Rect CustomFrameView::IconBounds() const { return gfx::Rect(frame_thickness + kIconLeftSpacing, y, size, size); } +bool CustomFrameView::ShouldShowTitleBarAndBorder() const { + if (ViewsDelegate::views_delegate) { + return !ViewsDelegate::views_delegate->WindowManagerProvidesTitleBar( + frame_->IsMaximized()); + } + + return true; +} + bool CustomFrameView::ShouldShowClientEdge() const { - return !frame_->IsMaximized(); + return !frame_->IsMaximized() && ShouldShowTitleBarAndBorder(); } void CustomFrameView::PaintRestoredFrameBorder(gfx::Canvas* canvas) { @@ -549,6 +565,11 @@ void CustomFrameView::LayoutTitleBar() { } void CustomFrameView::LayoutClientView() { + if (!ShouldShowTitleBarAndBorder()) { + client_view_bounds_ = bounds(); + return; + } + int top_height = NonClientTopBorderHeight(); int border_thickness = NonClientBorderThickness(); client_view_bounds_.SetRect(border_thickness, top_height, diff --git a/ui/views/window/custom_frame_view.h b/ui/views/window/custom_frame_view.h index 8c96df7..96dbd22 100644 --- a/ui/views/window/custom_frame_view.h +++ b/ui/views/window/custom_frame_view.h @@ -86,6 +86,10 @@ class CustomFrameView : public NonClientFrameView, // there was one). gfx::Rect IconBounds() const; + // Returns true if the title bar, caption buttons, and frame border should be + // drawn. If false, the client view occupies the full area of this view. + bool ShouldShowTitleBarAndBorder() const; + // Returns true if the client edge should be drawn. This is true if // the window is not maximized. bool ShouldShowClientEdge() const; |