Commit 3f93e51c authored by Mitsuru Oshima's avatar Mitsuru Oshima Committed by Commit Bot

Set opaque region in ash frame

Bug: None
Change-Id: I8c19dce72cc631336002c5c979748ed78772046e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1948512Reviewed-by: default avatarAlexander Alekseev <alemate@chromium.org>
Commit-Queue: Mitsuru Oshima <oshima@chromium.org>
Cr-Commit-Position: refs/heads/master@{#721248}
parent 6a9dd6d2
...@@ -231,9 +231,14 @@ NonClientFrameViewAsh::NonClientFrameViewAsh(views::Widget* frame) ...@@ -231,9 +231,14 @@ NonClientFrameViewAsh::NonClientFrameViewAsh(views::Widget* frame)
} }
frame_window->SetProperty(kNonClientFrameViewAshKey, this); frame_window->SetProperty(kNonClientFrameViewAshKey, this);
frame_window->AddObserver(this);
} }
NonClientFrameViewAsh::~NonClientFrameViewAsh() = default; NonClientFrameViewAsh::~NonClientFrameViewAsh() {
aura::Window* frame_window = frame_->GetNativeWindow();
if (frame_window && frame_window->HasObserver(this))
frame_window->RemoveObserver(this);
}
// static // static
NonClientFrameViewAsh* NonClientFrameViewAsh::Get(aura::Window* window) { NonClientFrameViewAsh* NonClientFrameViewAsh::Get(aura::Window* window) {
...@@ -362,6 +367,20 @@ void NonClientFrameViewAsh::SetVisible(bool visible) { ...@@ -362,6 +367,20 @@ void NonClientFrameViewAsh::SetVisible(bool visible) {
InvalidateLayout(); InvalidateLayout();
} }
void NonClientFrameViewAsh::OnWindowBoundsChanged(
aura::Window* window,
const gfx::Rect& old_bounds,
const gfx::Rect& new_bounds,
ui::PropertyChangeReason reason) {
if (window->transparent())
window->SetOpaqueRegionsForOcclusion({gfx::Rect(new_bounds.size())});
}
void NonClientFrameViewAsh::OnWindowDestroying(aura::Window* window) {
DCHECK_EQ(window, frame_->GetNativeWindow());
window->RemoveObserver(this);
}
void NonClientFrameViewAsh::SetShouldPaintHeader(bool paint) { void NonClientFrameViewAsh::SetShouldPaintHeader(bool paint) {
header_view_->SetShouldPaintHeader(paint); header_view_->SetShouldPaintHeader(paint);
} }
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include "base/memory/weak_ptr.h" #include "base/memory/weak_ptr.h"
#include "base/optional.h" #include "base/optional.h"
#include "third_party/skia/include/core/SkColor.h" #include "third_party/skia/include/core/SkColor.h"
#include "ui/aura/window_observer.h"
#include "ui/views/window/non_client_view.h" #include "ui/views/window/non_client_view.h"
namespace views { namespace views {
...@@ -32,7 +33,8 @@ class NonClientFrameViewAshImmersiveHelper; ...@@ -32,7 +33,8 @@ class NonClientFrameViewAshImmersiveHelper;
// The window header overlay slides onscreen when the user hovers the mouse at // The window header overlay slides onscreen when the user hovers the mouse at
// the top of the screen. See also views::CustomFrameView and // the top of the screen. See also views::CustomFrameView and
// BrowserNonClientFrameViewAsh. // BrowserNonClientFrameViewAsh.
class ASH_EXPORT NonClientFrameViewAsh : public views::NonClientFrameView { class ASH_EXPORT NonClientFrameViewAsh : public views::NonClientFrameView,
public aura::WindowObserver {
public: public:
// Internal class name. // Internal class name.
static const char kViewClassName[]; static const char kViewClassName[];
...@@ -87,6 +89,13 @@ class ASH_EXPORT NonClientFrameViewAsh : public views::NonClientFrameView { ...@@ -87,6 +89,13 @@ class ASH_EXPORT NonClientFrameViewAsh : public views::NonClientFrameView {
gfx::Size GetMaximumSize() const override; gfx::Size GetMaximumSize() const override;
void SetVisible(bool visible) override; void SetVisible(bool visible) override;
// aura::WindowObserver:
void OnWindowBoundsChanged(aura::Window* window,
const gfx::Rect& old_bounds,
const gfx::Rect& new_bounds,
ui::PropertyChangeReason reason) override;
void OnWindowDestroying(aura::Window* window) override;
// If |paint| is false, we should not paint the header. Used for overview mode // If |paint| is false, we should not paint the header. Used for overview mode
// with OnOverviewModeStarting() and OnOverviewModeEnded() to hide/show the // with OnOverviewModeStarting() and OnOverviewModeEnded() to hide/show the
// header of v2 and ARC apps. // header of v2 and ARC apps.
......
...@@ -83,8 +83,7 @@ class ShellSurfaceWidget : public views::Widget { ...@@ -83,8 +83,7 @@ class ShellSurfaceWidget : public views::Widget {
DISALLOW_COPY_AND_ASSIGN(ShellSurfaceWidget); DISALLOW_COPY_AND_ASSIGN(ShellSurfaceWidget);
}; };
class CustomFrameView : public ash::NonClientFrameViewAsh, class CustomFrameView : public ash::NonClientFrameViewAsh {
public aura::WindowObserver {
public: public:
using ShapeRects = std::vector<gfx::Rect>; using ShapeRects = std::vector<gfx::Rect>;
...@@ -99,16 +98,9 @@ class CustomFrameView : public ash::NonClientFrameViewAsh, ...@@ -99,16 +98,9 @@ class CustomFrameView : public ash::NonClientFrameViewAsh,
SetVisible(enabled); SetVisible(enabled);
if (!enabled) if (!enabled)
NonClientFrameViewAsh::SetShouldPaintHeader(false); NonClientFrameViewAsh::SetShouldPaintHeader(false);
frame()->GetNativeWindow()->AddObserver(this);
} }
~CustomFrameView() override { ~CustomFrameView() override = default;
if (frame() && frame()->GetNativeWindow() &&
frame()->GetNativeWindow()->HasObserver(this)) {
frame()->GetNativeWindow()->RemoveObserver(this);
}
}
// Overridden from ash::NonClientFrameViewAsh: // Overridden from ash::NonClientFrameViewAsh:
void SetShouldPaintHeader(bool paint) override { void SetShouldPaintHeader(bool paint) override {
...@@ -118,11 +110,6 @@ class CustomFrameView : public ash::NonClientFrameViewAsh, ...@@ -118,11 +110,6 @@ class CustomFrameView : public ash::NonClientFrameViewAsh,
} }
} }
void OnWindowDestroying(aura::Window* window) override {
DCHECK_EQ(frame()->GetNativeWindow(), window);
window->RemoveObserver(this);
}
// Overridden from views::NonClientFrameView: // Overridden from views::NonClientFrameView:
gfx::Rect GetBoundsForClientView() const override { gfx::Rect GetBoundsForClientView() const override {
if (GetVisible()) if (GetVisible())
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment