summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-10-18 22:24:19 +0000
committerben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-10-18 22:24:19 +0000
commitefdb40cc616faff68ecdef6bc4877b978cf9b37e (patch)
treecd051c085e43df5b19bdaf9f58e436916e3f74d3
parent4340c35762403cf76443ba074a2de7c75b5b47f0 (diff)
downloadchromium_src-efdb40cc616faff68ecdef6bc4877b978cf9b37e.zip
chromium_src-efdb40cc616faff68ecdef6bc4877b978cf9b37e.tar.gz
chromium_src-efdb40cc616faff68ecdef6bc4877b978cf9b37e.tar.bz2
Resort RootWindow methods
TBR=sky@chromium.org BUG= Review URL: https://codereview.chromium.org/28333002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@229484 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--ui/aura/client/default_capture_client.cc10
-rw-r--r--ui/aura/root_window.cc272
-rw-r--r--ui/aura/root_window.h46
-rw-r--r--ui/views/corewm/capture_controller.cc17
-rw-r--r--ui/views/widget/desktop_aura/desktop_capture_client.cc7
5 files changed, 178 insertions, 174 deletions
diff --git a/ui/aura/client/default_capture_client.cc b/ui/aura/client/default_capture_client.cc
index 94f5f81..9b5fff5 100644
--- a/ui/aura/client/default_capture_client.cc
+++ b/ui/aura/client/default_capture_client.cc
@@ -22,19 +22,21 @@ DefaultCaptureClient::~DefaultCaptureClient() {
void DefaultCaptureClient::SetCapture(Window* window) {
if (capture_window_ == window)
return;
- if (window)
+ if (window) {
root_window_->gesture_recognizer()->
TransferEventsTo(capture_window_, window);
+ }
Window* old_capture_window = capture_window_;
capture_window_ = window;
+ CaptureDelegate* capture_delegate = root_window_;
if (capture_window_)
- root_window_->SetNativeCapture();
+ capture_delegate->SetNativeCapture();
else
- root_window_->ReleaseNativeCapture();
+ capture_delegate->ReleaseNativeCapture();
- root_window_->UpdateCapture(old_capture_window, capture_window_);
+ capture_delegate->UpdateCapture(old_capture_window, capture_window_);
}
void DefaultCaptureClient::ReleaseCapture(Window* window) {
diff --git a/ui/aura/root_window.cc b/ui/aura/root_window.cc
index bfd6b35..2b45684 100644
--- a/ui/aura/root_window.cc
+++ b/ui/aura/root_window.cc
@@ -490,21 +490,8 @@ gfx::Point RootWindow::GetLastMouseLocationInRoot() const {
return location;
}
-////////////////////////////////////////////////////////////////////////////////
-// RootWindow, Window overrides:
-
-RootWindow* RootWindow::GetRootWindow() {
- return this;
-}
-
-const RootWindow* RootWindow::GetRootWindow() const {
- return this;
-}
-
-void RootWindow::SetTransform(const gfx::Transform& transform) {
- scoped_ptr<RootWindowTransformer> transformer(
- new SimpleRootWindowTransformer(this, transform));
- SetRootWindowTransformer(transformer.Pass());
+bool RootWindow::QueryMouseLocationForTest(gfx::Point* point) const {
+ return host_->QueryMouseLocation(point);
}
void RootWindow::SetRootWindowTransformer(
@@ -527,45 +514,21 @@ gfx::Transform RootWindow::GetRootTransform() const {
}
////////////////////////////////////////////////////////////////////////////////
-// RootWindow, ui::EventTarget implementation:
+// RootWindow, Window overrides:
-ui::EventTarget* RootWindow::GetParentTarget() {
- return client::GetEventClient(this) ?
- client::GetEventClient(this)->GetToplevelEventTarget() :
- Env::GetInstance();
+RootWindow* RootWindow::GetRootWindow() {
+ return this;
}
-////////////////////////////////////////////////////////////////////////////////
-// RootWindow, ui::LayerDelegate implementation:
-
-void RootWindow::OnDeviceScaleFactorChanged(
- float device_scale_factor) {
- const bool cursor_is_in_bounds =
- GetBoundsInScreen().Contains(Env::GetInstance()->last_mouse_location());
- bool cursor_visible = false;
- client::CursorClient* cursor_client = client::GetCursorClient(this);
- if (cursor_is_in_bounds && cursor_client) {
- cursor_visible = cursor_client->IsCursorVisible();
- if (cursor_visible)
- cursor_client->HideCursor();
- }
- host_->OnDeviceScaleFactorChanged(device_scale_factor);
- Window::OnDeviceScaleFactorChanged(device_scale_factor);
- // Update the device scale factor of the cursor client only when the last
- // mouse location is on this root window.
- if (cursor_is_in_bounds) {
- if (cursor_client) {
- const gfx::Display& display =
- gfx::Screen::GetScreenFor(this)->GetDisplayNearestWindow(this);
- cursor_client->SetDisplay(display);
- }
- }
- if (cursor_is_in_bounds && cursor_client && cursor_visible)
- cursor_client->ShowCursor();
+const RootWindow* RootWindow::GetRootWindow() const {
+ return this;
}
-////////////////////////////////////////////////////////////////////////////////
-// RootWindow, overridden from aura::Window:
+void RootWindow::SetTransform(const gfx::Transform& transform) {
+ scoped_ptr<RootWindowTransformer> transformer(
+ new SimpleRootWindowTransformer(this, transform));
+ SetRootWindowTransformer(transformer.Pass());
+}
bool RootWindow::CanFocus() const {
return IsVisible();
@@ -576,59 +539,6 @@ bool RootWindow::CanReceiveEvents() const {
}
////////////////////////////////////////////////////////////////////////////////
-// RootWindow, overridden from aura::client::CaptureDelegate:
-
-void RootWindow::UpdateCapture(Window* old_capture, Window* new_capture) {
- if (!new_capture && old_capture && old_capture->GetRootWindow() != this) {
- // If we no longer contain the window that had capture make sure we clean
- // state in the GestureRecognizer. Since we don't contain the window we'll
- // never get notification of its destruction and clean up state.
- // We do this early on as OnCaptureLost() may delete |old_capture|.
- gesture_recognizer_->CleanupStateForConsumer(old_capture);
- }
-
- // |mouse_moved_handler_| may have been set to a Window in a different root
- // (see below). Clear it here to ensure we don't end up referencing a stale
- // Window.
- if (mouse_moved_handler_ && !Contains(mouse_moved_handler_))
- mouse_moved_handler_ = NULL;
-
- if (old_capture && old_capture->GetRootWindow() == this &&
- old_capture->delegate()) {
- // Send a capture changed event with bogus location data.
- ui::MouseEvent event(ui::ET_MOUSE_CAPTURE_CHANGED, gfx::Point(),
- gfx::Point(), 0);
-
- ProcessEvent(old_capture, &event);
-
- old_capture->delegate()->OnCaptureLost();
- }
-
- if (new_capture) {
- // Make all subsequent mouse events go to the capture window. We shouldn't
- // need to send an event here as OnCaptureLost() should take care of that.
- if (mouse_moved_handler_ || Env::GetInstance()->IsMouseButtonDown())
- mouse_moved_handler_ = new_capture;
- } else {
- // Make sure mouse_moved_handler gets updated.
- SynthesizeMouseMoveEvent();
- }
- mouse_pressed_handler_ = NULL;
-}
-
-void RootWindow::SetNativeCapture() {
- host_->SetCapture();
-}
-
-void RootWindow::ReleaseNativeCapture() {
- host_->ReleaseCapture();
-}
-
-bool RootWindow::QueryMouseLocationForTest(gfx::Point* point) const {
- return host_->QueryMouseLocation(point);
-}
-
-////////////////////////////////////////////////////////////////////////////////
// RootWindow, private:
void RootWindow::TransformEventForDeviceScaleFactor(ui::LocatedEvent* event) {
@@ -691,6 +601,13 @@ bool RootWindow::ProcessGestures(ui::GestureRecognizer::Gestures* gestures) {
return handled;
}
+void RootWindow::OnWindowAddedToRootWindow(Window* attached) {
+ if (attached->IsVisible() &&
+ attached->ContainsPointInRoot(GetLastMouseLocationInRoot())) {
+ PostMouseMoveEventAfterWindowChange();
+ }
+}
+
void RootWindow::OnWindowRemovedFromRootWindow(Window* detached,
RootWindow* new_root) {
DCHECK(aura::client::GetCaptureWindow(this) != this);
@@ -745,16 +662,104 @@ void RootWindow::UpdateRootWindowSize(const gfx::Size& host_size) {
SetBounds(transformer_->GetRootWindowBounds(host_size));
}
-void RootWindow::OnWindowAddedToRootWindow(Window* attached) {
- if (attached->IsVisible() &&
- attached->ContainsPointInRoot(GetLastMouseLocationInRoot()))
- PostMouseMoveEventAfterWindowChange();
+////////////////////////////////////////////////////////////////////////////////
+// RootWindow, ui::EventTarget implementation:
+
+ui::EventTarget* RootWindow::GetParentTarget() {
+ return client::GetEventClient(this) ?
+ client::GetEventClient(this)->GetToplevelEventTarget() :
+ Env::GetInstance();
}
+////////////////////////////////////////////////////////////////////////////////
+// RootWindow, ui::LayerDelegate implementation:
+
+void RootWindow::OnDeviceScaleFactorChanged(
+ float device_scale_factor) {
+ const bool cursor_is_in_bounds =
+ GetBoundsInScreen().Contains(Env::GetInstance()->last_mouse_location());
+ bool cursor_visible = false;
+ client::CursorClient* cursor_client = client::GetCursorClient(this);
+ if (cursor_is_in_bounds && cursor_client) {
+ cursor_visible = cursor_client->IsCursorVisible();
+ if (cursor_visible)
+ cursor_client->HideCursor();
+ }
+ host_->OnDeviceScaleFactorChanged(device_scale_factor);
+ Window::OnDeviceScaleFactorChanged(device_scale_factor);
+ // Update the device scale factor of the cursor client only when the last
+ // mouse location is on this root window.
+ if (cursor_is_in_bounds) {
+ if (cursor_client) {
+ const gfx::Display& display =
+ gfx::Screen::GetScreenFor(this)->GetDisplayNearestWindow(this);
+ cursor_client->SetDisplay(display);
+ }
+ }
+ if (cursor_is_in_bounds && cursor_client && cursor_visible)
+ cursor_client->ShowCursor();
+}
+
+////////////////////////////////////////////////////////////////////////////////
+// RootWindow, aura::client::CaptureDelegate implementation:
+
+void RootWindow::UpdateCapture(Window* old_capture,
+ Window* new_capture) {
+ if (!new_capture && old_capture && old_capture->GetRootWindow() != this) {
+ // If we no longer contain the window that had capture make sure we clean
+ // state in the GestureRecognizer. Since we don't contain the window we'll
+ // never get notification of its destruction and clean up state.
+ // We do this early on as OnCaptureLost() may delete |old_capture|.
+ gesture_recognizer_->CleanupStateForConsumer(old_capture);
+ }
+
+ // |mouse_moved_handler_| may have been set to a Window in a different root
+ // (see below). Clear it here to ensure we don't end up referencing a stale
+ // Window.
+ if (mouse_moved_handler_ && !Contains(mouse_moved_handler_))
+ mouse_moved_handler_ = NULL;
+
+ if (old_capture && old_capture->GetRootWindow() == this &&
+ old_capture->delegate()) {
+ // Send a capture changed event with bogus location data.
+ ui::MouseEvent event(ui::ET_MOUSE_CAPTURE_CHANGED, gfx::Point(),
+ gfx::Point(), 0);
+
+ ProcessEvent(old_capture, &event);
+
+ old_capture->delegate()->OnCaptureLost();
+ }
+
+ if (new_capture) {
+ // Make all subsequent mouse events go to the capture window. We shouldn't
+ // need to send an event here as OnCaptureLost() should take care of that.
+ if (mouse_moved_handler_ || Env::GetInstance()->IsMouseButtonDown())
+ mouse_moved_handler_ = new_capture;
+ } else {
+ // Make sure mouse_moved_handler gets updated.
+ SynthesizeMouseMoveEvent();
+ }
+ mouse_pressed_handler_ = NULL;
+}
+
+void RootWindow::SetNativeCapture() {
+ host_->SetCapture();
+}
+
+void RootWindow::ReleaseNativeCapture() {
+ host_->ReleaseCapture();
+}
+
+////////////////////////////////////////////////////////////////////////////////
+// RootWindow, ui::EventDispatcherDelegate implementation:
+
bool RootWindow::CanDispatchToTarget(ui::EventTarget* target) {
return event_dispatch_target_ == target;
}
+////////////////////////////////////////////////////////////////////////////////
+// RootWindow, ui::GestureEventHelper implementation:
+
bool RootWindow::DispatchLongPressGestureEvent(ui::GestureEvent* event) {
return DispatchGestureEvent(event);
}
@@ -763,6 +768,9 @@ bool RootWindow::DispatchCancelTouchEvent(ui::TouchEvent* event) {
return OnHostTouchEvent(event);
}
+////////////////////////////////////////////////////////////////////////////////
+// RootWindow, ui::LayerAnimationObserver implementation:
+
void RootWindow::OnLayerAnimationEnded(
ui::LayerAnimationSequence* animation) {
UpdateRootWindowSize(GetHostSize());
@@ -934,32 +942,6 @@ void RootWindow::DispatchMouseEventRepost(ui::MouseEvent* event) {
root->DispatchMouseEventToTarget(event, target);
}
-bool RootWindow::DispatchGestureEventRepost(ui::GestureEvent* event) {
- if (event->type() != ui::ET_GESTURE_TAP_DOWN)
- return false;
-
- // Cleanup stale gesture events for the old gesture target.
- GestureConsumer* old_consumer = GetGestureTarget(event);
- if (old_consumer)
- CleanupGestureRecognizerState(static_cast<aura::Window*>(old_consumer));
-
- Window* new_consumer = GetEventHandlerForPoint(event->root_location());
- if (new_consumer) {
- ui::GestureEvent begin_gesture(
- ui::ET_GESTURE_BEGIN,
- event->x(),
- event->y(),
- event->flags(),
- event->time_stamp(),
- ui::GestureEventDetails(ui::ET_GESTURE_BEGIN, 0, 0),
- event->touch_ids_bitfield());
- ProcessEvent(new_consumer, &begin_gesture);
- ProcessEvent(new_consumer, event);
- return event->handled();
- }
- return false;
-}
-
bool RootWindow::DispatchMouseEventToTarget(ui::MouseEvent* event,
Window* target) {
client::CursorClient* cursor_client = client::GetCursorClient(this);
@@ -1113,6 +1095,32 @@ bool RootWindow::DispatchTouchEventImpl(ui::TouchEvent* event) {
return ProcessGestures(gestures.get()) ? true : handled;
}
+bool RootWindow::DispatchGestureEventRepost(ui::GestureEvent* event) {
+ if (event->type() != ui::ET_GESTURE_TAP_DOWN)
+ return false;
+
+ // Cleanup stale gesture events for the old gesture target.
+ GestureConsumer* old_consumer = GetGestureTarget(event);
+ if (old_consumer)
+ CleanupGestureRecognizerState(static_cast<aura::Window*>(old_consumer));
+
+ Window* new_consumer = GetEventHandlerForPoint(event->root_location());
+ if (new_consumer) {
+ ui::GestureEvent begin_gesture(
+ ui::ET_GESTURE_BEGIN,
+ event->x(),
+ event->y(),
+ event->flags(),
+ event->time_stamp(),
+ ui::GestureEventDetails(ui::ET_GESTURE_BEGIN, 0, 0),
+ event->touch_ids_bitfield());
+ ProcessEvent(new_consumer, &begin_gesture);
+ ProcessEvent(new_consumer, event);
+ return event->handled();
+ }
+ return false;
+}
+
void RootWindow::DispatchHeldEvents() {
if (held_repostable_event_) {
if (held_repostable_event_->type() == ui::ET_MOUSE_PRESSED) {
diff --git a/ui/aura/root_window.h b/ui/aura/root_window.h
index b6d73b4..b8c4455 100644
--- a/ui/aura/root_window.h
+++ b/ui/aura/root_window.h
@@ -133,12 +133,6 @@ class AURA_EXPORT RootWindow : public Window,
// Clips the cursor movement to the root_window.
bool ConfineCursorToWindow();
- // Draws the necessary set of windows.
- void Draw();
-
- // Draw the whole screen.
- void ScheduleFullRedraw();
-
// Draw the damage_rect.
void ScheduleRedrawRect(const gfx::Rect& damage_rect);
@@ -244,32 +238,19 @@ class AURA_EXPORT RootWindow : public Window,
// coordinates. This may return a point outside the root window's bounds.
gfx::Point GetLastMouseLocationInRoot() const;
+ // Exposes RootWindowHost::QueryMouseLocation() for test purposes.
+ bool QueryMouseLocationForTest(gfx::Point* point) const;
+
+ void SetRootWindowTransformer(scoped_ptr<RootWindowTransformer> transformer);
+ gfx::Transform GetRootTransform() const;
+
// Overridden from Window:
virtual RootWindow* GetRootWindow() OVERRIDE;
virtual const RootWindow* GetRootWindow() const OVERRIDE;
virtual void SetTransform(const gfx::Transform& transform) OVERRIDE;
-
- // Overridden from ui::EventTarget:
- virtual ui::EventTarget* GetParentTarget() OVERRIDE;
-
- // Overridden from ui::LayerDelegate:
- virtual void OnDeviceScaleFactorChanged(float device_scale_factor) OVERRIDE;
-
- // Overridden from Window:
virtual bool CanFocus() const OVERRIDE;
virtual bool CanReceiveEvents() const OVERRIDE;
- // Overridden from aura::client::CaptureDelegate:
- virtual void UpdateCapture(Window* old_capture, Window* new_capture) OVERRIDE;
- virtual void SetNativeCapture() OVERRIDE;
- virtual void ReleaseNativeCapture() OVERRIDE;
-
- // Exposes RootWindowHost::QueryMouseLocation() for test purposes.
- bool QueryMouseLocationForTest(gfx::Point* point) const;
-
- void SetRootWindowTransformer(scoped_ptr<RootWindowTransformer> transformer);
- gfx::Transform GetRootTransform() const;
-
private:
FRIEND_TEST_ALL_PREFIXES(RootWindowTest, KeepTranslatedEventInRoot);
@@ -322,6 +303,17 @@ class AURA_EXPORT RootWindow : public Window,
// transform and insets.
void UpdateRootWindowSize(const gfx::Size& host_size);
+ // Overridden from ui::EventTarget:
+ virtual ui::EventTarget* GetParentTarget() OVERRIDE;
+
+ // Overridden from ui::LayerDelegate:
+ virtual void OnDeviceScaleFactorChanged(float device_scale_factor) OVERRIDE;
+
+ // Overridden from aura::client::CaptureDelegate:
+ virtual void UpdateCapture(Window* old_capture, Window* new_capture) OVERRIDE;
+ virtual void SetNativeCapture() OVERRIDE;
+ virtual void ReleaseNativeCapture() OVERRIDE;
+
// Overridden from ui::EventDispatcherDelegate.
virtual bool CanDispatchToTarget(EventTarget* target) OVERRIDE;
@@ -368,10 +360,6 @@ class AURA_EXPORT RootWindow : public Window,
bool DispatchGestureEventRepost(ui::GestureEvent* event);
void DispatchHeldEvents();
- // Parses the switch describing the initial size for the host window and
- // returns bounds for the window.
- gfx::Rect GetInitialHostWindowBounds() const;
-
// Posts a task to send synthesized mouse move event if there
// is no a pending task.
void PostMouseMoveEventAfterWindowChange();
diff --git a/ui/views/corewm/capture_controller.cc b/ui/views/corewm/capture_controller.cc
index faf0caf..c39a9ab 100644
--- a/ui/views/corewm/capture_controller.cc
+++ b/ui/views/corewm/capture_controller.cc
@@ -25,7 +25,7 @@ void CaptureController::Detach(aura::RootWindow* root) {
}
////////////////////////////////////////////////////////////////////////////////
-// CaptureController, client::CaptureClient implementation:
+// CaptureController, aura::client::CaptureClient implementation:
void CaptureController::SetCapture(aura::Window* new_capture_window) {
if (capture_window_ == new_capture_window)
@@ -60,16 +60,21 @@ void CaptureController::SetCapture(aura::Window* new_capture_window) {
for (RootWindows::const_iterator i = root_windows.begin();
i != root_windows.end(); ++i) {
- (*i)->UpdateCapture(old_capture_window, new_capture_window);
+ aura::client::CaptureDelegate* delegate = *i;
+ delegate->UpdateCapture(old_capture_window, new_capture_window);
}
aura::RootWindow* capture_root =
capture_window_ ? capture_window_->GetRootWindow() : NULL;
if (capture_root != old_capture_root) {
- if (old_capture_root)
- old_capture_root->ReleaseNativeCapture();
- if (capture_root)
- capture_root->SetNativeCapture();
+ if (old_capture_root) {
+ aura::client::CaptureDelegate* delegate = old_capture_root;
+ delegate->ReleaseNativeCapture();
+ }
+ if (capture_root) {
+ aura::client::CaptureDelegate* delegate = capture_root;
+ delegate->SetNativeCapture();
+ }
}
}
diff --git a/ui/views/widget/desktop_aura/desktop_capture_client.cc b/ui/views/widget/desktop_aura/desktop_capture_client.cc
index 0c1beb1..118b5f2 100644
--- a/ui/views/widget/desktop_aura/desktop_capture_client.cc
+++ b/ui/views/widget/desktop_aura/desktop_capture_client.cc
@@ -56,13 +56,14 @@ void DesktopCaptureClient::SetCapture(aura::Window* new_capture_window) {
capture_window_ = new_capture_window;
- root_->UpdateCapture(old_capture_window, new_capture_window);
+ aura::client::CaptureDelegate* delegate = root_;
+ delegate->UpdateCapture(old_capture_window, new_capture_window);
// Initiate native capture updating.
if (!capture_window_) {
- root_->ReleaseNativeCapture();
+ delegate->ReleaseNativeCapture();
} else if (!old_capture_window) {
- root_->SetNativeCapture();
+ delegate->SetNativeCapture();
} // else case is capture is remaining in our root, nothing to do.
}