Commit 07aab203 authored by Scott Violet's avatar Scott Violet Committed by Commit Bot

Revert "wm/views: makes objects using Env take Env"

This reverts commit 9feb99aa.

Reason for revert: a patch earlier in the chain caused msan failures.

Original change's description:
> wm/views: makes objects using Env take Env
> 
> This allows for multiple Envs at the same time. Additionally:
> . NativeWidgetPrivate::CreateNativeWidget: now takes InitParams
> . NativeWidgetPrivate::IsMouseButtonDown() is now an member function.
> 
> BUG=847992
> TEST=covered by tests
> 
> Change-Id: Ic35b274c0a927a7c602809a7e611383b5d3dd3e2
> Reviewed-on: https://chromium-review.googlesource.com/1166148
> Commit-Queue: Scott Violet <sky@chromium.org>
> Reviewed-by: Michael Wasserman <msw@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#581621}

TBR=sky@chromium.org,msw@chromium.org

Change-Id: I9410bf471a71d07b32f49a139b7afa9ced0f3fea
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 847992
Reviewed-on: https://chromium-review.googlesource.com/1168403Reviewed-by: default avatarScott Violet <sky@chromium.org>
Commit-Queue: Scott Violet <sky@chromium.org>
Cr-Commit-Position: refs/heads/master@{#581716}
parent 93a3a4b3
......@@ -426,7 +426,6 @@ class AURA_EXPORT Window : public ui::LayerDelegate,
bool IsEmbeddingClient() const;
Env* env() { return env_; }
const Env* env() const { return env_; }
// ui::GestureConsumer:
bool RequiresDoubleTapGestureEvents() const override;
......
......@@ -69,24 +69,34 @@ class NativeViewHostAura::ClippingWindowDelegate : public aura::WindowDelegate {
aura::Window* native_view_;
};
NativeViewHostAura::NativeViewHostAura(NativeViewHost* host) : host_(host) {}
NativeViewHostAura::NativeViewHostAura(NativeViewHost* host)
: host_(host),
clipping_window_delegate_(new ClippingWindowDelegate()),
clipping_window_(clipping_window_delegate_.get()) {
// Set the type so descendant views (including popups) get positioned
// appropriately.
clipping_window_.SetType(aura::client::WINDOW_TYPE_CONTROL);
clipping_window_.Init(ui::LAYER_NOT_DRAWN);
clipping_window_.set_owned_by_parent(false);
clipping_window_.SetName("NativeViewHostAuraClip");
clipping_window_.layer()->SetMasksToBounds(true);
clipping_window_.SetProperty(views::kHostViewKey, static_cast<View*>(host_));
}
NativeViewHostAura::~NativeViewHostAura() {
if (host_->native_view()) {
host_->native_view()->RemoveObserver(this);
host_->native_view()->ClearProperty(views::kHostViewKey);
host_->native_view()->ClearProperty(aura::client::kHostWindowKey);
clipping_window_->ClearProperty(views::kHostViewKey);
if (host_->native_view()->parent() == clipping_window_.get())
clipping_window_->RemoveChild(host_->native_view());
clipping_window_.ClearProperty(views::kHostViewKey);
if (host_->native_view()->parent() == &clipping_window_)
clipping_window_.RemoveChild(host_->native_view());
}
}
////////////////////////////////////////////////////////////////////////////////
// NativeViewHostAura, NativeViewHostWrapper implementation:
void NativeViewHostAura::AttachNativeView() {
if (!clipping_window_)
CreateClippingWindow();
clipping_window_delegate_->set_native_view(host_->native_view());
host_->native_view()->AddObserver(this);
host_->native_view()->SetProperty(views::kHostViewKey,
......@@ -192,17 +202,18 @@ void NativeViewHostAura::ShowWidget(int x,
}
}
clipping_window_->SetBounds(clip_rect_ ? *clip_rect_ : gfx::Rect(x, y, w, h));
gfx::Point clip_offset = clipping_window_->bounds().origin();
clipping_window_.SetBounds(clip_rect_ ? *clip_rect_
: gfx::Rect(x, y, w, h));
gfx::Point clip_offset = clipping_window_.bounds().origin();
host_->native_view()->SetBounds(
gfx::Rect(x - clip_offset.x(), y - clip_offset.y(), native_w, native_h));
host_->native_view()->Show();
clipping_window_->Show();
clipping_window_.Show();
}
void NativeViewHostAura::HideWidget() {
host_->native_view()->Hide();
clipping_window_->Hide();
clipping_window_.Hide();
}
void NativeViewHostAura::SetFocus() {
......@@ -254,48 +265,35 @@ NativeViewHostWrapper* NativeViewHostWrapper::CreateWrapper(
return new NativeViewHostAura(host);
}
void NativeViewHostAura::CreateClippingWindow() {
clipping_window_delegate_ = std::make_unique<ClippingWindowDelegate>();
// Use WINDOW_TYPE_CONTROLLER type so descendant views (including popups) get
// positioned appropriately.
clipping_window_ = std::make_unique<aura::Window>(
clipping_window_delegate_.get(), aura::client::WINDOW_TYPE_CONTROL,
host_->native_view()->env());
clipping_window_->Init(ui::LAYER_NOT_DRAWN);
clipping_window_->set_owned_by_parent(false);
clipping_window_->SetName("NativeViewHostAuraClip");
clipping_window_->layer()->SetMasksToBounds(true);
clipping_window_->SetProperty(views::kHostViewKey, static_cast<View*>(host_));
}
void NativeViewHostAura::AddClippingWindow() {
RemoveClippingWindow();
host_->native_view()->SetProperty(aura::client::kHostWindowKey,
host_->GetWidget()->GetNativeView());
Widget::ReparentNativeView(host_->native_view(), clipping_window_.get());
Widget::ReparentNativeView(host_->native_view(),
&clipping_window_);
if (host_->GetWidget()->GetNativeView()) {
Widget::ReparentNativeView(clipping_window_.get(),
Widget::ReparentNativeView(&clipping_window_,
host_->GetWidget()->GetNativeView());
}
}
void NativeViewHostAura::RemoveClippingWindow() {
clipping_window_->Hide();
clipping_window_.Hide();
if (host_->native_view())
host_->native_view()->ClearProperty(aura::client::kHostWindowKey);
if (host_->native_view()->parent() == clipping_window_.get()) {
if (host_->native_view()->parent() == &clipping_window_) {
if (host_->GetWidget() && host_->GetWidget()->GetNativeView()) {
Widget::ReparentNativeView(host_->native_view(),
host_->GetWidget()->GetNativeView());
} else {
clipping_window_->RemoveChild(host_->native_view());
clipping_window_.RemoveChild(host_->native_view());
}
host_->native_view()->SetBounds(clipping_window_->bounds());
host_->native_view()->SetBounds(clipping_window_.bounds());
}
if (clipping_window_->parent())
clipping_window_->parent()->RemoveChild(clipping_window_.get());
if (clipping_window_.parent())
clipping_window_.parent()->RemoveChild(&clipping_window_);
}
void NativeViewHostAura::InstallMask() {
......
......@@ -7,16 +7,13 @@
#include "base/compiler_specific.h"
#include "base/macros.h"
#include "ui/aura/window.h"
#include "ui/aura/window_observer.h"
#include "ui/compositor/layer_owner.h"
#include "ui/gfx/transform.h"
#include "ui/views/controls/native/native_view_host_wrapper.h"
#include "ui/views/views_export.h"
namespace aura {
class Window;
}
namespace views {
class NativeViewHost;
......@@ -56,8 +53,6 @@ class NativeViewHostAura : public NativeViewHostWrapper,
const gfx::Rect& new_bounds,
ui::PropertyChangeReason reason) override;
void CreateClippingWindow();
// Reparents the native view with the clipping window existing between it and
// its old parent, so that the fast resize path works.
void AddClippingWindow();
......@@ -80,7 +75,7 @@ class NativeViewHostAura : public NativeViewHostWrapper,
// Window that exists between the native view and the parent that allows for
// clipping to occur. This is positioned in the coordinate space of
// host_->GetWidget().
std::unique_ptr<aura::Window> clipping_window_;
aura::Window clipping_window_;
std::unique_ptr<gfx::Rect> clip_rect_;
// This mask exists for the sake of SetCornerRadius().
......
......@@ -97,9 +97,7 @@ class NativeViewHostAuraTest : public test::NativeViewHostTestBase {
return child_.get();
}
aura::Window* clipping_window() {
return native_host()->clipping_window_.get();
}
aura::Window* clipping_window() { return &(native_host()->clipping_window_); }
void CreateHost() {
CreateTopLevel();
......
......@@ -14,7 +14,6 @@
#include "ui/aura/client/drag_drop_client.h"
#include "ui/aura/client/focus_client.h"
#include "ui/aura/client/window_parenting_client.h"
#include "ui/aura/env.h"
#include "ui/aura/window.h"
#include "ui/aura/window_observer.h"
#include "ui/aura/window_occlusion_tracker.h"
......@@ -913,11 +912,6 @@ bool DesktopNativeWidgetAura::IsMouseEventsEnabled() const {
return cursor_client ? cursor_client->IsMouseEventsEnabled() : true;
}
bool DesktopNativeWidgetAura::IsMouseButtonDown() const {
return content_window_ ? content_window_->env()->IsMouseButtonDown()
: aura::Env::GetInstance()->IsMouseButtonDown();
}
void DesktopNativeWidgetAura::ClearNativeFocus() {
desktop_window_tree_host_->ClearNativeFocus();
......
......@@ -174,7 +174,6 @@ class VIEWS_EXPORT DesktopNativeWidgetAura
void SchedulePaintInRect(const gfx::Rect& rect) override;
void SetCursor(gfx::NativeCursor cursor) override;
bool IsMouseEventsEnabled() const override;
bool IsMouseButtonDown() const override;
void ClearNativeFocus() override;
gfx::Rect GetWorkAreaBoundsInScreen() const override;
Widget::MoveLoopResult RunMoveLoop(
......
......@@ -5,12 +5,9 @@
#ifndef UI_VIEWS_WIDGET_NATIVE_WIDGET_H_
#define UI_VIEWS_WIDGET_NATIVE_WIDGET_H_
#include "ui/views/views_export.h"
#include "ui/views/widget/widget.h"
namespace views {
class Widget;
namespace internal {
class NativeWidgetPrivate;
}
......
......@@ -101,12 +101,11 @@ void SetIcon(aura::Window* window,
// NativeWidgetAura, public:
NativeWidgetAura::NativeWidgetAura(internal::NativeWidgetDelegate* delegate,
bool is_parallel_widget_in_window_manager,
aura::Env* env)
bool is_parallel_widget_in_window_manager)
: delegate_(delegate),
is_parallel_widget_in_window_manager_(
is_parallel_widget_in_window_manager),
window_(new aura::Window(this, aura::client::WINDOW_TYPE_UNKNOWN, env)),
window_(new aura::Window(this)),
ownership_(Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET),
destroying_(false),
cursor_(gfx::kNullCursor),
......@@ -708,11 +707,6 @@ bool NativeWidgetAura::IsMouseEventsEnabled() const {
return cursor_client ? cursor_client->IsMouseEventsEnabled() : true;
}
bool NativeWidgetAura::IsMouseButtonDown() const {
return window_ ? window_->env()->IsMouseButtonDown()
: aura::Env::GetInstance()->IsMouseButtonDown();
}
void NativeWidgetAura::ClearNativeFocus() {
aura::client::FocusClient* client = aura::client::GetFocusClient(window_);
if (window_ && client && window_->Contains(client->GetFocusedWindow()))
......@@ -1093,15 +1087,8 @@ namespace internal {
// static
NativeWidgetPrivate* NativeWidgetPrivate::CreateNativeWidget(
const Widget::InitParams& init_params,
internal::NativeWidgetDelegate* delegate) {
aura::Env* env = nullptr;
if (init_params.parent)
env = init_params.parent->env();
else if (init_params.context)
env = init_params.context->env();
return new NativeWidgetAura(
delegate, /*is_parallel_widget_in_window_manager*/ false, env);
return new NativeWidgetAura(delegate);
}
// static
......@@ -1210,6 +1197,11 @@ void NativeWidgetPrivate::ReparentNativeView(gfx::NativeView native_view,
}
}
// static
bool NativeWidgetPrivate::IsMouseButtonDown() {
return aura::Env::GetInstance()->IsMouseButtonDown();
}
// static
gfx::FontList NativeWidgetPrivate::GetWindowTitleFontList() {
#if defined(OS_WIN)
......
......@@ -21,7 +21,6 @@
#include "ui/wm/public/activation_delegate.h"
namespace aura {
class Env;
class Window;
}
......@@ -44,8 +43,7 @@ class VIEWS_EXPORT NativeWidgetAura : public internal::NativeWidgetPrivate,
// NativeWidgetAura is created in the window manager to represent a client
// window, in all other cases it's false.
explicit NativeWidgetAura(internal::NativeWidgetDelegate* delegate,
bool is_parallel_widget_in_window_manager = false,
aura::Env* env = nullptr);
bool is_parallel_widget_in_window_manager = false);
// Called internally by NativeWidgetAura and DesktopNativeWidgetAura to
// associate |native_widget| with |window|.
......@@ -135,7 +133,6 @@ class VIEWS_EXPORT NativeWidgetAura : public internal::NativeWidgetPrivate,
void SchedulePaintInRect(const gfx::Rect& rect) override;
void SetCursor(gfx::NativeCursor cursor) override;
bool IsMouseEventsEnabled() const override;
bool IsMouseButtonDown() const override;
void ClearNativeFocus() override;
gfx::Rect GetWorkAreaBoundsInScreen() const override;
Widget::MoveLoopResult RunMoveLoop(
......
......@@ -127,7 +127,6 @@ class VIEWS_EXPORT NativeWidgetMac : public internal::NativeWidgetPrivate {
void SchedulePaintInRect(const gfx::Rect& rect) override;
void SetCursor(gfx::NativeCursor cursor) override;
bool IsMouseEventsEnabled() const override;
bool IsMouseButtonDown() const override;
void ClearNativeFocus() override;
gfx::Rect GetWorkAreaBoundsInScreen() const override;
Widget::MoveLoopResult RunMoveLoop(
......
......@@ -597,10 +597,6 @@ bool NativeWidgetMac::IsMouseEventsEnabled() const {
return true;
}
bool NativeWidgetMac::IsMouseButtonDown() const {
return [NSEvent pressedMouseButtons] != 0;
}
void NativeWidgetMac::ClearNativeFocus() {
// To quote DesktopWindowTreeHostX11, "This method is weird and misnamed."
// The goal is to set focus to the content window, thereby removing focus from
......@@ -716,7 +712,6 @@ namespace internal {
// static
NativeWidgetPrivate* NativeWidgetPrivate::CreateNativeWidget(
const Widget::InitParams& init_params,
internal::NativeWidgetDelegate* delegate) {
return new NativeWidgetMac(delegate);
}
......@@ -849,6 +844,11 @@ void NativeWidgetPrivate::ReparentNativeView(gfx::NativeView native_view,
child->NotifyNativeViewHierarchyChanged();
}
// static
bool NativeWidgetPrivate::IsMouseButtonDown() {
return [NSEvent pressedMouseButtons] != 0;
}
// static
gfx::FontList NativeWidgetPrivate::GetWindowTitleFontList() {
NOTIMPLEMENTED();
......
......@@ -12,7 +12,6 @@
#include "ui/base/ui_base_types.h"
#include "ui/gfx/native_widget_types.h"
#include "ui/views/widget/native_widget.h"
#include "ui/views/widget/widget.h"
namespace gfx {
class FontList;
......@@ -50,7 +49,6 @@ class VIEWS_EXPORT NativeWidgetPrivate : public NativeWidget {
// Creates an appropriate default NativeWidgetPrivate implementation for the
// current OS/circumstance.
static NativeWidgetPrivate* CreateNativeWidget(
const Widget::InitParams& init_params,
internal::NativeWidgetDelegate* delegate);
static NativeWidgetPrivate* GetNativeWidgetForNativeView(
......@@ -70,6 +68,9 @@ class VIEWS_EXPORT NativeWidgetPrivate : public NativeWidget {
static void ReparentNativeView(gfx::NativeView native_view,
gfx::NativeView new_parent);
// Returns true if any mouse button is currently down.
static bool IsMouseButtonDown();
static gfx::FontList GetWindowTitleFontList();
// Returns the NativeView with capture, otherwise NULL if there is no current
......@@ -215,8 +216,6 @@ class VIEWS_EXPORT NativeWidgetPrivate : public NativeWidget {
virtual void SchedulePaintInRect(const gfx::Rect& rect) = 0;
virtual void SetCursor(gfx::NativeCursor cursor) = 0;
virtual bool IsMouseEventsEnabled() const = 0;
// Returns true if any mouse button is currently down.
virtual bool IsMouseButtonDown() const = 0;
virtual void ClearNativeFocus() = 0;
virtual gfx::Rect GetWorkAreaBoundsInScreen() const = 0;
virtual Widget::MoveLoopResult RunMoveLoop(
......
......@@ -70,7 +70,7 @@ NativeWidget* CreateNativeWidget(const Widget::InitParams& params,
if (native_widget)
return native_widget;
}
return internal::NativeWidgetPrivate::CreateNativeWidget(params, delegate);
return internal::NativeWidgetPrivate::CreateNativeWidget(delegate);
}
void NotifyCaretBoundsChanged(ui::InputMethod* input_method) {
......@@ -334,9 +334,11 @@ void Widget::Init(const InitParams& in_params) {
native_widget_ = CreateNativeWidget(params, this)->AsNativeWidgetPrivate();
root_view_.reset(CreateRootView());
default_theme_provider_.reset(new ui::DefaultThemeProvider);
if (params.type == InitParams::TYPE_MENU) {
is_mouse_button_pressed_ =
internal::NativeWidgetPrivate::IsMouseButtonDown();
}
native_widget_->InitNativeWidget(params);
if (params.type == InitParams::TYPE_MENU)
is_mouse_button_pressed_ = native_widget_->IsMouseButtonDown();
if (RequiresNonClientView(params.type)) {
non_client_view_ = new NonClientView;
non_client_view_->SetFrameView(CreateNonClientFrameView());
......@@ -947,7 +949,7 @@ void Widget::SetCapture(View* view) {
return;
}
if (native_widget_->IsMouseButtonDown())
if (internal::NativeWidgetPrivate::IsMouseButtonDown())
is_mouse_button_pressed_ = true;
root_view_->SetMouseHandler(view);
}
......@@ -1196,7 +1198,7 @@ void Widget::OnMouseEvent(ui::MouseEvent* event) {
// mouse-button is still down before attempting to do a capture.
if (root_view && root_view->OnMousePressed(*event) &&
widget_deletion_observer.IsWidgetAlive() && IsVisible() &&
native_widget_->IsMouseButtonDown() &&
internal::NativeWidgetPrivate::IsMouseButtonDown() &&
current_capture == internal::NativeWidgetPrivate::GetGlobalCapture(
native_widget_->GetNativeView())) {
is_mouse_button_pressed_ = true;
......
......@@ -238,11 +238,10 @@ void CompoundEventFilter::OnScrollEvent(ui::ScrollEvent* event) {
void CompoundEventFilter::OnTouchEvent(ui::TouchEvent* event) {
FilterTouchEvent(event);
if (!event->handled() && event->type() == ui::ET_TOUCH_PRESSED &&
ShouldHideCursorOnTouch(*event)) {
aura::Window* target = static_cast<aura::Window*>(event->target());
DCHECK(target);
if (!target->env()->IsMouseButtonDown())
SetMouseEventsEnableStateOnEvent(target, event, false);
ShouldHideCursorOnTouch(*event) &&
!aura::Env::GetInstance()->IsMouseButtonDown()) {
SetMouseEventsEnableStateOnEvent(
static_cast<aura::Window*>(event->target()), event, false);
}
}
......
......@@ -89,7 +89,7 @@ EasyResizeWindowTargeter::~EasyResizeWindowTargeter() {}
void EasyResizeWindowTargeter::OnSetInsets(
const gfx::Insets& last_mouse_extend,
const gfx::Insets& last_touch_extend) {
if (container_->env()->mode() != aura::Env::Mode::MUS)
if (aura::Env::GetInstance()->mode() != aura::Env::Mode::MUS)
return;
// Positive values equate to a hit test mask.
......
......@@ -7,10 +7,8 @@
#include <utility>
#include "base/command_line.h"
#include "base/containers/flat_set.h"
#include "base/logging.h"
#include "base/macros.h"
#include "base/no_destructor.h"
#include "base/scoped_observer.h"
#include "base/stl_util.h"
#include "ui/aura/client/aura_constants.h"
......@@ -98,8 +96,8 @@ class ShadowController::Impl :
public aura::WindowObserver,
public base::RefCounted<Impl> {
public:
// Returns the singleton instance for the specified Env.
static Impl* GetInstance(aura::Env* env);
// Returns the singleton instance, destroyed when there are no more refs.
static Impl* GetInstance();
void set_delegate(std::unique_ptr<ShadowControllerDelegate> delegate) {
delegate_ = std::move(delegate);
......@@ -125,11 +123,9 @@ class ShadowController::Impl :
friend class base::RefCounted<Impl>;
friend class ShadowController;
explicit Impl(aura::Env* env);
Impl();
~Impl() override;
static base::flat_set<Impl*>* GetInstances();
// Forwarded from ShadowController.
void OnWindowActivated(ActivationReason reason,
aura::Window* gained_active,
......@@ -151,22 +147,23 @@ class ShadowController::Impl :
// The shadow's bounds are initialized and it is added to the window's layer.
void CreateShadowForWindow(aura::Window* window);
aura::Env* const env_;
ScopedObserver<aura::Window, aura::WindowObserver> observer_manager_;
std::unique_ptr<ShadowControllerDelegate> delegate_;
static Impl* instance_;
DISALLOW_COPY_AND_ASSIGN(Impl);
};
// static
ShadowController::Impl* ShadowController::Impl::GetInstance(aura::Env* env) {
for (Impl* impl : *GetInstances()) {
if (impl->env_ == env)
return impl;
}
ShadowController::Impl* ShadowController::Impl::instance_ = NULL;
return new Impl(env);
// static
ShadowController::Impl* ShadowController::Impl::GetInstance() {
if (!instance_)
instance_ = new Impl();
return instance_;
}
bool ShadowController::Impl::IsShadowVisibleForWindow(aura::Window* window) {
......@@ -299,22 +296,15 @@ void ShadowController::Impl::CreateShadowForWindow(aura::Window* window) {
window->layer()->StackAtBottom(shadow->layer());
}
ShadowController::Impl::Impl(aura::Env* env)
: env_(env), observer_manager_(this) {
GetInstances()->insert(this);
env_->AddObserver(this);
ShadowController::Impl::Impl()
: observer_manager_(this) {
aura::Env::GetInstance()->AddObserver(this);
}
ShadowController::Impl::~Impl() {
env_->RemoveObserver(this);
GetInstances()->erase(this);
}
// static
base::flat_set<ShadowController::Impl*>*
ShadowController::Impl::GetInstances() {
static base::NoDestructor<base::flat_set<Impl*>> impls;
return impls.get();
DCHECK_EQ(instance_, this);
aura::Env::GetInstance()->RemoveObserver(this);
instance_ = NULL;
}
// ShadowController ------------------------------------------------------------
......@@ -325,10 +315,8 @@ ui::Shadow* ShadowController::GetShadowForWindow(aura::Window* window) {
ShadowController::ShadowController(
ActivationClient* activation_client,
std::unique_ptr<ShadowControllerDelegate> delegate,
aura::Env* env)
: activation_client_(activation_client),
impl_(Impl::GetInstance(env ? env : aura::Env::GetInstance())) {
std::unique_ptr<ShadowControllerDelegate> delegate)
: activation_client_(activation_client), impl_(Impl::GetInstance()) {
// Watch for window activation changes.
activation_client_->AddObserver(this);
if (delegate)
......
......@@ -14,7 +14,6 @@
#include "ui/wm/public/activation_change_observer.h"
namespace aura {
class Env;
class Window;
}
......@@ -37,8 +36,7 @@ class WM_CORE_EXPORT ShadowController : public ActivationChangeObserver {
static ui::Shadow* GetShadowForWindow(aura::Window* window);
ShadowController(ActivationClient* activation_client,
std::unique_ptr<ShadowControllerDelegate> delegate,
aura::Env* env = nullptr);
std::unique_ptr<ShadowControllerDelegate> delegate);
~ShadowController() override;
bool IsShadowVisibleForWindow(aura::Window* window);
......
......@@ -89,17 +89,16 @@ aura::Window* GetModalTransient(aura::Window* window) {
// WindowModalityController, public:
WindowModalityController::WindowModalityController(
ui::EventTarget* event_target,
aura::Env* env)
: env_(env ? env : aura::Env::GetInstance()), event_target_(event_target) {
env_->AddObserver(this);
ui::EventTarget* event_target)
: event_target_(event_target) {
aura::Env::GetInstance()->AddObserver(this);
DCHECK(event_target->IsPreTargetListEmpty());
event_target_->AddPreTargetHandler(this);
}
WindowModalityController::~WindowModalityController() {
event_target_->RemovePreTargetHandler(this);
env_->RemoveObserver(this);
aura::Env::GetInstance()->RemoveObserver(this);
for (size_t i = 0; i < windows_.size(); ++i)
windows_[i]->RemoveObserver(this);
}
......
......@@ -14,10 +14,6 @@
#include "ui/events/event_handler.h"
#include "ui/wm/core/wm_core_export.h"
namespace aura {
class Env;
}
namespace ui {
class EventTarget;
class LocatedEvent;
......@@ -39,8 +35,7 @@ class WM_CORE_EXPORT WindowModalityController : public ui::EventHandler,
public aura::EnvObserver,
public aura::WindowObserver {
public:
explicit WindowModalityController(ui::EventTarget* event_target,
aura::Env* env = nullptr);
explicit WindowModalityController(ui::EventTarget* event_target);
~WindowModalityController() override;
// Overridden from ui::EventHandler:
......@@ -64,8 +59,6 @@ class WM_CORE_EXPORT WindowModalityController : public ui::EventHandler,
bool ProcessLocatedEvent(aura::Window* target,
ui::LocatedEvent* event);
aura::Env* env_;
std::vector<aura::Window*> windows_;
ui::EventTarget* event_target_;
......
......@@ -22,10 +22,11 @@ class WM_CORE_EXPORT WMState {
WMState();
~WMState();
CaptureController* capture_controller() { return capture_controller_.get(); }
private:
std::unique_ptr<TransientWindowStackingClient> window_stacking_client_;
std::unique_ptr<TransientWindowController> transient_window_client_;
// NOTE: this is really only needed in ash
std::unique_ptr<CaptureController> capture_controller_;
DISALLOW_COPY_AND_ASSIGN(WMState);
......
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