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

Side by Side Diff: services/ui/ws/event_dispatcher.cc

Issue 2266603002: mus: Implement interwindow drag and drop (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Uploaded for a few comments. Created 4 years, 4 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "services/ui/ws/event_dispatcher.h" 5 #include "services/ui/ws/event_dispatcher.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/time/time.h" 9 #include "base/time/time.h"
10 #include "services/ui/ws/accelerator.h" 10 #include "services/ui/ws/accelerator.h"
11 #include "services/ui/ws/current_drag_operation.h"
12 #include "services/ui/ws/current_drag_operation_delegate.h"
11 #include "services/ui/ws/display.h" 13 #include "services/ui/ws/display.h"
12 #include "services/ui/ws/event_dispatcher_delegate.h" 14 #include "services/ui/ws/event_dispatcher_delegate.h"
13 #include "services/ui/ws/server_window.h" 15 #include "services/ui/ws/server_window.h"
14 #include "services/ui/ws/server_window_delegate.h" 16 #include "services/ui/ws/server_window_delegate.h"
15 #include "services/ui/ws/window_coordinate_conversions.h" 17 #include "services/ui/ws/window_coordinate_conversions.h"
16 #include "services/ui/ws/window_finder.h" 18 #include "services/ui/ws/window_finder.h"
17 #include "ui/events/event_utils.h" 19 #include "ui/events/event_utils.h"
18 #include "ui/gfx/geometry/point.h" 20 #include "ui/gfx/geometry/point.h"
19 #include "ui/gfx/geometry/point_conversions.h" 21 #include "ui/gfx/geometry/point_conversions.h"
20 22
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 delegate_->SetNativeCapture(window); 183 delegate_->SetNativeCapture(window);
182 } else { 184 } else {
183 delegate_->ReleaseNativeCapture(); 185 delegate_->ReleaseNativeCapture();
184 if (!mouse_button_down_) 186 if (!mouse_button_down_)
185 UpdateCursorProviderByLastKnownLocation(); 187 UpdateCursorProviderByLastKnownLocation();
186 } 188 }
187 189
188 return true; 190 return true;
189 } 191 }
190 192
193 void EventDispatcher::SetDragDropSourceWindow(
194 uint32_t change_id,
195 WindowTree* window_tree,
196 ServerWindow* capture_window,
197 mojo::Map<mojo::String, mojo::Array<uint8_t>> mime_data,
198 uint32_t drag_operations) {
199 current_drag_drop_operation_.reset(
200 new CurrentDragOperation(this, change_id, window_tree, capture_window,
201 std::move(mime_data), drag_operations));
202 }
203
191 void EventDispatcher::AddSystemModalWindow(ServerWindow* window) { 204 void EventDispatcher::AddSystemModalWindow(ServerWindow* window) {
192 modal_window_controller_.AddSystemModalWindow(window); 205 modal_window_controller_.AddSystemModalWindow(window);
193 } 206 }
194 207
195 void EventDispatcher::ReleaseCaptureBlockedByModalWindow( 208 void EventDispatcher::ReleaseCaptureBlockedByModalWindow(
196 const ServerWindow* modal_window) { 209 const ServerWindow* modal_window) {
197 if (!capture_window_) 210 if (!capture_window_)
198 return; 211 return;
199 212
200 if (modal_window_controller_.IsWindowBlockedBy(capture_window_, 213 if (modal_window_controller_.IsWindowBlockedBy(capture_window_,
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 (!is_mouse_event || IsOnlyOneMouseButtonDown(event.flags())); 347 (!is_mouse_event || IsOnlyOneMouseButtonDown(event.flags()));
335 348
336 // Update mouse down state upon events which change it. 349 // Update mouse down state upon events which change it.
337 if (is_mouse_event) { 350 if (is_mouse_event) {
338 if (event.type() == ui::ET_POINTER_DOWN) 351 if (event.type() == ui::ET_POINTER_DOWN)
339 mouse_button_down_ = true; 352 mouse_button_down_ = true;
340 else if (is_pointer_going_up) 353 else if (is_pointer_going_up)
341 mouse_button_down_ = false; 354 mouse_button_down_ = false;
342 } 355 }
343 356
357 if (current_drag_drop_operation_) {
358 const PointerTarget target = PointerTargetForEvent(event);
359 const ClientSpecificId client_id = delegate_->GetEventTargetClientId(
360 target.window, target.in_nonclient_area);
361 current_drag_drop_operation_->DispatchLocatedEvent(event, target.window,
362 client_id);
363 return;
364 }
365
344 if (capture_window_) { 366 if (capture_window_) {
345 mouse_cursor_source_window_ = capture_window_; 367 mouse_cursor_source_window_ = capture_window_;
346 DispatchToClient(capture_window_, capture_window_client_id_, event); 368 DispatchToClient(capture_window_, capture_window_client_id_, event);
347 return; 369 return;
348 } 370 }
349 371
350 const int32_t pointer_id = PointerId(event); 372 const int32_t pointer_id = PointerId(event);
351 if (!IsTrackingPointer(pointer_id) || 373 if (!IsTrackingPointer(pointer_id) ||
352 !pointer_targets_[pointer_id].is_pointer_down) { 374 !pointer_targets_[pointer_id].is_pointer_down) {
353 const bool any_pointers_down = AreAnyPointersDown(); 375 const bool any_pointers_down = AreAnyPointersDown();
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
568 CancelPointerEventsToTarget(window); 590 CancelPointerEventsToTarget(window);
569 } 591 }
570 592
571 void EventDispatcher::OnWindowDestroyed(ServerWindow* window) { 593 void EventDispatcher::OnWindowDestroyed(ServerWindow* window) {
572 CancelPointerEventsToTarget(window); 594 CancelPointerEventsToTarget(window);
573 595
574 if (mouse_cursor_source_window_ == window) 596 if (mouse_cursor_source_window_ == window)
575 mouse_cursor_source_window_ = nullptr; 597 mouse_cursor_source_window_ = nullptr;
576 } 598 }
577 599
600 void EventDispatcher::OnDragOver(bool success) {
601 current_drag_drop_operation_.reset();
602 }
603
578 } // namespace ws 604 } // namespace ws
579 } // namespace ui 605 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698