Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(277)

Unified Diff: ui/aura/window_tree_host.cc

Issue 188223002: Clean up WindowEventDispatcher some more. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/aura/window_tree_host.h ('k') | ui/aura/window_tree_host_delegate.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/aura/window_tree_host.cc
diff --git a/ui/aura/window_tree_host.cc b/ui/aura/window_tree_host.cc
index 2f60c7c3a732431dd9074f2487e899d934474005..93c624b174b9a6a0b97ddd574095c8df6cf7c66e 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,6 +84,17 @@ 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) {
@@ -94,7 +105,7 @@ WindowTreeHost* WindowTreeHost::GetForAcceleratedWidget(
void WindowTreeHost::InitHost() {
InitCompositor();
UpdateRootWindowSize(GetBounds().size());
- Env::GetInstance()->NotifyRootWindowInitialized(delegate_->AsDispatcher());
+ Env::GetInstance()->NotifyRootWindowInitialized(dispatcher());
window()->Show();
}
@@ -187,8 +198,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) {
- delegate_->AsDispatcher()->DispatchMouseExitAtPoint(
- delegate_->AsDispatcher()->GetLastMouseLocationInRoot());
+ dispatcher()->DispatchMouseExitAtPoint(
+ dispatcher()->GetLastMouseLocationInRoot());
}
OnCursorVisibilityChangedNative(show);
@@ -206,16 +217,11 @@ void WindowTreeHost::MoveCursorToHostLocation(const gfx::Point& host_location) {
MoveCursorToInternal(root_location, host_location);
}
-WindowEventDispatcher* WindowTreeHost::GetDispatcher() {
- return delegate_->AsDispatcher();
-}
-
////////////////////////////////////////////////////////////////////////////////
// WindowTreeHost, protected:
WindowTreeHost::WindowTreeHost()
- : delegate_(NULL),
- window_(new Window(NULL)),
+ : window_(new Window(NULL)),
last_cursor_(ui::kCursorNull) {
}
@@ -225,10 +231,6 @@ 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();
@@ -260,7 +262,6 @@ void WindowTreeHost::CreateCompositor(
this));
dispatcher_.reset(new WindowEventDispatcher(this));
}
- delegate_ = dispatcher();
}
void WindowTreeHost::OnHostMoved(const gfx::Point& new_location) {
@@ -282,7 +283,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));
- delegate_->OnHostResized(layer_size);
+ dispatcher()->OnHostResized(layer_size);
}
void WindowTreeHost::OnHostCloseRequested() {
@@ -290,6 +291,19 @@ 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);
@@ -299,18 +313,7 @@ void WindowTreeHost::MoveCursorToInternal(const gfx::Point& root_location,
gfx::Screen::GetScreenFor(window())->GetDisplayNearestWindow(window());
cursor_client->SetDisplay(display);
}
- delegate_->OnCursorMovedToRootLocation(root_location);
+ dispatcher()->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
« no previous file with comments | « ui/aura/window_tree_host.h ('k') | ui/aura/window_tree_host_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698