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

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: Remove stray mark Created 4 years, 3 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_source.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 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 delegate_->SetNativeCapture(window); 174 delegate_->SetNativeCapture(window);
173 } else { 175 } else {
174 delegate_->ReleaseNativeCapture(); 176 delegate_->ReleaseNativeCapture();
175 if (!mouse_button_down_) 177 if (!mouse_button_down_)
176 UpdateCursorProviderByLastKnownLocation(); 178 UpdateCursorProviderByLastKnownLocation();
177 } 179 }
178 180
179 return true; 181 return true;
180 } 182 }
181 183
184 void EventDispatcher::SetDragDropSourceWindow(
185 CurrentDragOperationSource* drag_source,
186 ServerWindow* window,
187 mojo::Map<mojo::String, mojo::Array<uint8_t>> mime_data,
188 uint32_t drag_operations) {
189 current_drag_drop_operation_.reset(new CurrentDragOperation(
sky 2016/09/06 21:11:27 MakeUnique is the new hotness. Should this implic
Elliot Glaysher 2016/09/07 21:42:23 The normal ash drag controller implicitly takes ca
sky 2016/09/07 23:25:29 Relying on ash to have done before calling this is
190 drag_source, window, std::move(mime_data), drag_operations));
191 }
192
193 void EventDispatcher::EndDragDrop() {
194 current_drag_drop_operation_.reset();
195 }
196
182 void EventDispatcher::AddSystemModalWindow(ServerWindow* window) { 197 void EventDispatcher::AddSystemModalWindow(ServerWindow* window) {
183 modal_window_controller_.AddSystemModalWindow(window); 198 modal_window_controller_.AddSystemModalWindow(window);
184 } 199 }
185 200
186 void EventDispatcher::ReleaseCaptureBlockedByModalWindow( 201 void EventDispatcher::ReleaseCaptureBlockedByModalWindow(
187 const ServerWindow* modal_window) { 202 const ServerWindow* modal_window) {
188 if (!capture_window_) 203 if (!capture_window_)
189 return; 204 return;
190 205
191 if (modal_window_controller_.IsWindowBlockedBy(capture_window_, 206 if (modal_window_controller_.IsWindowBlockedBy(capture_window_,
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 295
281 DCHECK(event.IsPointerEvent()); 296 DCHECK(event.IsPointerEvent());
282 ProcessPointerEvent(*event.AsPointerEvent()); 297 ProcessPointerEvent(*event.AsPointerEvent());
283 return; 298 return;
284 } 299 }
285 300
286 void EventDispatcher::ProcessKeyEvent(const ui::KeyEvent& event, 301 void EventDispatcher::ProcessKeyEvent(const ui::KeyEvent& event,
287 AcceleratorMatchPhase match_phase) { 302 AcceleratorMatchPhase match_phase) {
288 Accelerator* post_target = 303 Accelerator* post_target =
289 FindAccelerator(event, ui::mojom::AcceleratorPhase::POST_TARGET); 304 FindAccelerator(event, ui::mojom::AcceleratorPhase::POST_TARGET);
305 if (current_drag_drop_operation_ && event.type() == ui::ET_KEY_PRESSED &&
306 event.key_code() == ui::VKEY_ESCAPE) {
307 current_drag_drop_operation_->DispatchCancel();
308 return;
309 }
290 ServerWindow* focused_window = 310 ServerWindow* focused_window =
291 delegate_->GetFocusedWindowForEventDispatcher(); 311 delegate_->GetFocusedWindowForEventDispatcher();
292 if (focused_window) { 312 if (focused_window) {
293 // Assume key events are for the client area. 313 // Assume key events are for the client area.
294 const bool in_nonclient_area = false; 314 const bool in_nonclient_area = false;
295 const ClientSpecificId client_id = 315 const ClientSpecificId client_id =
296 delegate_->GetEventTargetClientId(focused_window, in_nonclient_area); 316 delegate_->GetEventTargetClientId(focused_window, in_nonclient_area);
297 delegate_->DispatchInputEventToWindow(focused_window, client_id, event, 317 delegate_->DispatchInputEventToWindow(focused_window, client_id, event,
298 post_target); 318 post_target);
299 return; 319 return;
(...skipping 21 matching lines...) Expand all
321 (!is_mouse_event || IsOnlyOneMouseButtonDown(event.flags())); 341 (!is_mouse_event || IsOnlyOneMouseButtonDown(event.flags()));
322 342
323 // Update mouse down state upon events which change it. 343 // Update mouse down state upon events which change it.
324 if (is_mouse_event) { 344 if (is_mouse_event) {
325 if (event.type() == ui::ET_POINTER_DOWN) 345 if (event.type() == ui::ET_POINTER_DOWN)
326 mouse_button_down_ = true; 346 mouse_button_down_ = true;
327 else if (is_pointer_going_up) 347 else if (is_pointer_going_up)
328 mouse_button_down_ = false; 348 mouse_button_down_ = false;
329 } 349 }
330 350
351 if (current_drag_drop_operation_) {
352 const PointerTarget target = PointerTargetForEvent(event);
sky 2016/09/06 21:11:27 Won't an early return potentially leave pointer_ta
Elliot Glaysher 2016/09/07 21:42:23 Maybe I'm misunderstanding this, but why is this a
sky 2016/09/07 23:25:29 As long as you ensure capture is present, then I a
353 current_drag_drop_operation_->DispatchLocatedEvent(event, target.window);
354 return;
355 }
356
331 if (capture_window_) { 357 if (capture_window_) {
332 mouse_cursor_source_window_ = capture_window_; 358 mouse_cursor_source_window_ = capture_window_;
333 DispatchToClient(capture_window_, capture_window_client_id_, event); 359 DispatchToClient(capture_window_, capture_window_client_id_, event);
334 return; 360 return;
335 } 361 }
336 362
337 const int32_t pointer_id = event.pointer_id(); 363 const int32_t pointer_id = event.pointer_id();
338 if (!IsTrackingPointer(pointer_id) || 364 if (!IsTrackingPointer(pointer_id) ||
339 !pointer_targets_[pointer_id].is_pointer_down) { 365 !pointer_targets_[pointer_id].is_pointer_down) {
340 const bool any_pointers_down = AreAnyPointersDown(); 366 const bool any_pointers_down = AreAnyPointersDown();
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
558 584
559 void EventDispatcher::OnWindowDestroyed(ServerWindow* window) { 585 void EventDispatcher::OnWindowDestroyed(ServerWindow* window) {
560 CancelPointerEventsToTarget(window); 586 CancelPointerEventsToTarget(window);
561 587
562 if (mouse_cursor_source_window_ == window) 588 if (mouse_cursor_source_window_ == window)
563 mouse_cursor_source_window_ = nullptr; 589 mouse_cursor_source_window_ = nullptr;
564 } 590 }
565 591
566 } // namespace ws 592 } // namespace ws
567 } // namespace ui 593 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698