summaryrefslogtreecommitdiffstats
path: root/ui/aura/window_tree_host.cc
diff options
context:
space:
mode:
Diffstat (limited to 'ui/aura/window_tree_host.cc')
-rw-r--r--ui/aura/window_tree_host.cc59
1 files changed, 28 insertions, 31 deletions
diff --git a/ui/aura/window_tree_host.cc b/ui/aura/window_tree_host.cc
index 93c624b..2f60c7c 100644
--- a/ui/aura/window_tree_host.cc
+++ b/ui/aura/window_tree_host.cc
@@ -5,13 +5,13 @@
#include "ui/aura/window_tree_host.h"
#include "base/debug/trace_event.h"
-#include "ui/aura/client/capture_client.h"
#include "ui/aura/client/cursor_client.h"
#include "ui/aura/env.h"
#include "ui/aura/root_window_transformer.h"
#include "ui/aura/window.h"
#include "ui/aura/window_event_dispatcher.h"
#include "ui/aura/window_targeter.h"
+#include "ui/aura/window_tree_host_delegate.h"
#include "ui/aura/window_tree_host_observer.h"
#include "ui/base/view_prop.h"
#include "ui/compositor/dip_util.h"
@@ -84,17 +84,6 @@ WindowTreeHost::~WindowTreeHost() {
DCHECK(!compositor_) << "compositor must be destroyed before root window";
}
-#if defined(OS_ANDROID)
-// static
-WindowTreeHost* WindowTreeHost::Create(const gfx::Rect& bounds) {
- // This is only hit for tests and ash, right now these aren't an issue so
- // adding the CHECK.
- // TODO(sky): decide if we want a factory.
- CHECK(false);
- return NULL;
-}
-#endif
-
// static
WindowTreeHost* WindowTreeHost::GetForAcceleratedWidget(
gfx::AcceleratedWidget widget) {
@@ -105,7 +94,7 @@ WindowTreeHost* WindowTreeHost::GetForAcceleratedWidget(
void WindowTreeHost::InitHost() {
InitCompositor();
UpdateRootWindowSize(GetBounds().size());
- Env::GetInstance()->NotifyRootWindowInitialized(dispatcher());
+ Env::GetInstance()->NotifyRootWindowInitialized(delegate_->AsDispatcher());
window()->Show();
}
@@ -198,8 +187,8 @@ void WindowTreeHost::OnCursorVisibilityChanged(bool show) {
// visible because that can only happen in response to a mouse event, which
// will trigger its own mouse enter.
if (!show) {
- dispatcher()->DispatchMouseExitAtPoint(
- dispatcher()->GetLastMouseLocationInRoot());
+ delegate_->AsDispatcher()->DispatchMouseExitAtPoint(
+ delegate_->AsDispatcher()->GetLastMouseLocationInRoot());
}
OnCursorVisibilityChangedNative(show);
@@ -217,11 +206,16 @@ void WindowTreeHost::MoveCursorToHostLocation(const gfx::Point& host_location) {
MoveCursorToInternal(root_location, host_location);
}
+WindowEventDispatcher* WindowTreeHost::GetDispatcher() {
+ return delegate_->AsDispatcher();
+}
+
////////////////////////////////////////////////////////////////////////////////
// WindowTreeHost, protected:
WindowTreeHost::WindowTreeHost()
- : window_(new Window(NULL)),
+ : delegate_(NULL),
+ window_(new Window(NULL)),
last_cursor_(ui::kCursorNull) {
}
@@ -231,6 +225,10 @@ void WindowTreeHost::DestroyCompositor() {
}
void WindowTreeHost::DestroyDispatcher() {
+ // An observer may have been added by an animation on the
+ // WindowEventDispatcher.
+ window()->layer()->GetAnimator()->RemoveObserver(dispatcher());
+
delete window_;
window_ = NULL;
dispatcher_.reset();
@@ -262,6 +260,7 @@ void WindowTreeHost::CreateCompositor(
this));
dispatcher_.reset(new WindowEventDispatcher(this));
}
+ delegate_ = dispatcher();
}
void WindowTreeHost::OnHostMoved(const gfx::Point& new_location) {
@@ -283,7 +282,7 @@ void WindowTreeHost::OnHostResized(const gfx::Size& new_size) {
// transformed size of the root window.
UpdateRootWindowSize(layer_size);
FOR_EACH_OBSERVER(WindowTreeHostObserver, observers_, OnHostResized(this));
- dispatcher()->OnHostResized(layer_size);
+ delegate_->OnHostResized(layer_size);
}
void WindowTreeHost::OnHostCloseRequested() {
@@ -291,19 +290,6 @@ void WindowTreeHost::OnHostCloseRequested() {
OnHostCloseRequested(this));
}
-void WindowTreeHost::OnHostActivated() {
- Env::GetInstance()->RootWindowActivated(dispatcher());
-}
-
-void WindowTreeHost::OnHostLostWindowCapture() {
- Window* capture_window = client::GetCaptureWindow(window());
- if (capture_window && capture_window->GetRootWindow() == window())
- capture_window->ReleaseCapture();
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// WindowTreeHost, private:
-
void WindowTreeHost::MoveCursorToInternal(const gfx::Point& root_location,
const gfx::Point& host_location) {
MoveCursorToNative(host_location);
@@ -313,7 +299,18 @@ void WindowTreeHost::MoveCursorToInternal(const gfx::Point& root_location,
gfx::Screen::GetScreenFor(window())->GetDisplayNearestWindow(window());
cursor_client->SetDisplay(display);
}
- dispatcher()->OnCursorMovedToRootLocation(root_location);
+ delegate_->OnCursorMovedToRootLocation(root_location);
}
+#if defined(OS_ANDROID)
+// static
+WindowTreeHost* WindowTreeHost::Create(const gfx::Rect& bounds) {
+ // This is only hit for tests and ash, right now these aren't an issue so
+ // adding the CHECK.
+ // TODO(sky): decide if we want a factory.
+ CHECK(false);
+ return NULL;
+}
+#endif
+
} // namespace aura