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

Unified Diff: components/mus/ws/event_dispatcher.cc

Issue 1465803003: mus: Let clients set the cursor of their window. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 3rd merge conflict today. Created 5 years 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 | « components/mus/ws/event_dispatcher.h ('k') | components/mus/ws/operation.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/mus/ws/event_dispatcher.cc
diff --git a/components/mus/ws/event_dispatcher.cc b/components/mus/ws/event_dispatcher.cc
index 384f9ba81f95b1c2d41d364a79a8a2653dabbe13..e55f6f94ec982e83a4f7cfb042a0cf3da9486275 100644
--- a/components/mus/ws/event_dispatcher.cc
+++ b/components/mus/ws/event_dispatcher.cc
@@ -139,7 +139,10 @@ class EventMatcher {
////////////////////////////////////////////////////////////////////////////////
EventDispatcher::EventDispatcher(EventDispatcherDelegate* delegate)
- : delegate_(delegate), root_(nullptr) {}
+ : delegate_(delegate),
+ root_(nullptr),
+ mouse_button_down_(false),
+ mouse_cursor_source_window_(nullptr) {}
EventDispatcher::~EventDispatcher() {
std::set<ServerWindow*> pointer_targets;
@@ -261,6 +264,28 @@ void EventDispatcher::DispatchToPointerTarget(const PointerTarget& target,
if (!target.window)
return;
+ if (event->pointer_data->kind == mojom::PointerKind::POINTER_KIND_MOUSE) {
+ if (event->action == mojom::EventType::EVENT_TYPE_POINTER_MOVE) {
+ // Only change the last targeted window when we are moving without
+ // dragging.
+ if (!mouse_button_down_)
+ mouse_cursor_source_window_ = target.window;
+ } else if (event->action == mojom::EventType::EVENT_TYPE_POINTER_UP ||
+ event->action == mojom::EventType::EVENT_TYPE_POINTER_CANCEL) {
+ mouse_button_down_ = false;
+
+ // When we release the mouse button, we want the cursor to be sourced
+ // from the window under the mouse pointer, even though we're sending the
+ // button up event to the window that had implicit capture.
+ gfx::Point location(EventLocationToPoint(*event));
+ mouse_cursor_source_window_ =
+ FindDeepestVisibleWindowForEvents(root_, surface_id_, &location);
+ } else if (event->action == mojom::EventType::EVENT_TYPE_POINTER_DOWN) {
+ mouse_button_down_ = true;
+ mouse_cursor_source_window_ = target.window;
+ }
+ }
+
gfx::Point location(EventLocationToPoint(*event));
gfx::Transform transform(GetTransformToWindow(surface_id_, target.window));
transform.TransformPoint(&location);
@@ -311,6 +336,9 @@ void EventDispatcher::OnWindowVisibilityChanged(ServerWindow* window) {
void EventDispatcher::OnWindowDestroyed(ServerWindow* window) {
CancelPointerEventsToTarget(window);
+
+ if (mouse_cursor_source_window_ == window)
+ mouse_cursor_source_window_ = nullptr;
}
} // namespace ws
« no previous file with comments | « components/mus/ws/event_dispatcher.h ('k') | components/mus/ws/operation.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698