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

Side by Side Diff: components/mus/ws/event_dispatcher.cc

Issue 1906623003: Convert //components/mus from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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
« no previous file with comments | « components/mus/ws/event_dispatcher.h ('k') | components/mus/ws/event_dispatcher_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "components/mus/ws/event_dispatcher.h" 5 #include "components/mus/ws/event_dispatcher.h"
6 6
7 #include <set> 7 #include <set>
8 8
9 #include "base/time/time.h" 9 #include "base/time/time.h"
10 #include "cc/surfaces/surface_hittest.h" 10 #include "cc/surfaces/surface_hittest.h"
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 void EventDispatcher::UpdateCursorProviderByLastKnownLocation() { 171 void EventDispatcher::UpdateCursorProviderByLastKnownLocation() {
172 if (!mouse_button_down_) { 172 if (!mouse_button_down_) {
173 gfx::Point location = mouse_pointer_last_location_; 173 gfx::Point location = mouse_pointer_last_location_;
174 mouse_cursor_source_window_ = 174 mouse_cursor_source_window_ =
175 FindDeepestVisibleWindowForEvents(root_, surface_id_, &location); 175 FindDeepestVisibleWindowForEvents(root_, surface_id_, &location);
176 } 176 }
177 } 177 }
178 178
179 bool EventDispatcher::AddAccelerator(uint32_t id, 179 bool EventDispatcher::AddAccelerator(uint32_t id,
180 mojom::EventMatcherPtr event_matcher) { 180 mojom::EventMatcherPtr event_matcher) {
181 scoped_ptr<Accelerator> accelerator(new Accelerator(id, *event_matcher)); 181 std::unique_ptr<Accelerator> accelerator(new Accelerator(id, *event_matcher));
182 // If an accelerator with the same id or matcher already exists, then abort. 182 // If an accelerator with the same id or matcher already exists, then abort.
183 for (const auto& pair : accelerators_) { 183 for (const auto& pair : accelerators_) {
184 if (pair.first == id || accelerator->EqualEventMatcher(pair.second.get())) 184 if (pair.first == id || accelerator->EqualEventMatcher(pair.second.get()))
185 return false; 185 return false;
186 } 186 }
187 accelerators_.insert(Entry(id, std::move(accelerator))); 187 accelerators_.insert(Entry(id, std::move(accelerator)));
188 return true; 188 return true;
189 } 189 }
190 190
191 void EventDispatcher::RemoveAccelerator(uint32_t id) { 191 void EventDispatcher::RemoveAccelerator(uint32_t id) {
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
379 } 379 }
380 380
381 void EventDispatcher::DispatchToPointerTarget(const PointerTarget& target, 381 void EventDispatcher::DispatchToPointerTarget(const PointerTarget& target,
382 const ui::LocatedEvent& event) { 382 const ui::LocatedEvent& event) {
383 if (!target.window) 383 if (!target.window)
384 return; 384 return;
385 385
386 gfx::Point location(event.location()); 386 gfx::Point location(event.location());
387 gfx::Transform transform(GetTransformToWindow(surface_id_, target.window)); 387 gfx::Transform transform(GetTransformToWindow(surface_id_, target.window));
388 transform.TransformPoint(&location); 388 transform.TransformPoint(&location);
389 scoped_ptr<ui::Event> clone = ui::Event::Clone(event); 389 std::unique_ptr<ui::Event> clone = ui::Event::Clone(event);
390 clone->AsLocatedEvent()->set_location(location); 390 clone->AsLocatedEvent()->set_location(location);
391 // TODO(jonross): add post-target accelerator support once accelerators 391 // TODO(jonross): add post-target accelerator support once accelerators
392 // support pointer events. 392 // support pointer events.
393 delegate_->DispatchInputEventToWindow(target.window, target.in_nonclient_area, 393 delegate_->DispatchInputEventToWindow(target.window, target.in_nonclient_area,
394 *clone, nullptr); 394 *clone, nullptr);
395 } 395 }
396 396
397 void EventDispatcher::CancelPointerEventsToTarget(ServerWindow* window) { 397 void EventDispatcher::CancelPointerEventsToTarget(ServerWindow* window) {
398 window->RemoveObserver(this); 398 window->RemoveObserver(this);
399 399
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
446 446
447 void EventDispatcher::OnWindowDestroyed(ServerWindow* window) { 447 void EventDispatcher::OnWindowDestroyed(ServerWindow* window) {
448 CancelPointerEventsToTarget(window); 448 CancelPointerEventsToTarget(window);
449 449
450 if (mouse_cursor_source_window_ == window) 450 if (mouse_cursor_source_window_ == window)
451 mouse_cursor_source_window_ = nullptr; 451 mouse_cursor_source_window_ = nullptr;
452 } 452 }
453 453
454 } // namespace ws 454 } // namespace ws
455 } // namespace mus 455 } // namespace mus
OLDNEW
« no previous file with comments | « components/mus/ws/event_dispatcher.h ('k') | components/mus/ws/event_dispatcher_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698