| OLD | NEW |
| 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" |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 242 ? IsLocationInNonclientArea(mouse_cursor_source_window_, location) | 242 ? IsLocationInNonclientArea(mouse_cursor_source_window_, location) |
| 243 : false; | 243 : false; |
| 244 } | 244 } |
| 245 } | 245 } |
| 246 | 246 |
| 247 bool EventDispatcher::AddAccelerator(uint32_t id, | 247 bool EventDispatcher::AddAccelerator(uint32_t id, |
| 248 mojom::EventMatcherPtr event_matcher) { | 248 mojom::EventMatcherPtr event_matcher) { |
| 249 std::unique_ptr<Accelerator> accelerator(new Accelerator(id, *event_matcher)); | 249 std::unique_ptr<Accelerator> accelerator(new Accelerator(id, *event_matcher)); |
| 250 // If an accelerator with the same id or matcher already exists, then abort. | 250 // If an accelerator with the same id or matcher already exists, then abort. |
| 251 for (const auto& pair : accelerators_) { | 251 for (const auto& pair : accelerators_) { |
| 252 if (pair.first == id || accelerator->EqualEventMatcher(pair.second.get())) | 252 if (pair.first == id) { |
| 253 DVLOG(1) << "duplicate accelerator. Accelerator id=" << accelerator->id() |
| 254 << " type=" << event_matcher->type_matcher->type |
| 255 << " flags=" << event_matcher->flags_matcher->flags; |
| 253 return false; | 256 return false; |
| 257 } else if (accelerator->EqualEventMatcher(pair.second.get())) { |
| 258 DVLOG(1) << "duplicate matcher. Accelerator id=" << accelerator->id() |
| 259 << " type=" << event_matcher->type_matcher->type |
| 260 << " flags=" << event_matcher->flags_matcher->flags; |
| 261 return false; |
| 262 } |
| 254 } | 263 } |
| 255 accelerators_.insert(Entry(id, std::move(accelerator))); | 264 accelerators_.insert(Entry(id, std::move(accelerator))); |
| 256 return true; | 265 return true; |
| 257 } | 266 } |
| 258 | 267 |
| 259 void EventDispatcher::RemoveAccelerator(uint32_t id) { | 268 void EventDispatcher::RemoveAccelerator(uint32_t id) { |
| 260 auto it = accelerators_.find(id); | 269 auto it = accelerators_.find(id); |
| 261 // Clients may pass bogus ids. | 270 // Clients may pass bogus ids. |
| 262 if (it != accelerators_.end()) | 271 if (it != accelerators_.end()) |
| 263 accelerators_.erase(it); | 272 accelerators_.erase(it); |
| (...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 616 if (mouse_cursor_source_window_ == window) | 625 if (mouse_cursor_source_window_ == window) |
| 617 mouse_cursor_source_window_ = nullptr; | 626 mouse_cursor_source_window_ = nullptr; |
| 618 } | 627 } |
| 619 | 628 |
| 620 void EventDispatcher::OnDragCursorUpdated() { | 629 void EventDispatcher::OnDragCursorUpdated() { |
| 621 delegate_->UpdateNativeCursorFromDispatcher(); | 630 delegate_->UpdateNativeCursorFromDispatcher(); |
| 622 } | 631 } |
| 623 | 632 |
| 624 } // namespace ws | 633 } // namespace ws |
| 625 } // namespace ui | 634 } // namespace ui |
| OLD | NEW |