| 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/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
| 10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 mouse_cursor_in_non_client_area_ = true; | 227 mouse_cursor_in_non_client_area_ = true; |
| 228 } | 228 } |
| 229 } | 229 } |
| 230 } | 230 } |
| 231 | 231 |
| 232 bool EventDispatcher::AddAccelerator(uint32_t id, | 232 bool EventDispatcher::AddAccelerator(uint32_t id, |
| 233 mojom::EventMatcherPtr event_matcher) { | 233 mojom::EventMatcherPtr event_matcher) { |
| 234 std::unique_ptr<Accelerator> accelerator(new Accelerator(id, *event_matcher)); | 234 std::unique_ptr<Accelerator> accelerator(new Accelerator(id, *event_matcher)); |
| 235 // If an accelerator with the same id or matcher already exists, then abort. | 235 // If an accelerator with the same id or matcher already exists, then abort. |
| 236 for (const auto& pair : accelerators_) { | 236 for (const auto& pair : accelerators_) { |
| 237 if (pair.first == id || accelerator->EqualEventMatcher(pair.second.get())) | 237 if (pair.first == id) { |
| 238 DVLOG(1) << "duplicate accelerator. Accelerator id=" << accelerator->id() |
| 239 << " type=" << event_matcher->type_matcher->type |
| 240 << " flags=" << event_matcher->flags_matcher->flags; |
| 238 return false; | 241 return false; |
| 242 } else if (accelerator->EqualEventMatcher(pair.second.get())) { |
| 243 DVLOG(1) << "duplicate matcher. Accelerator id=" << accelerator->id() |
| 244 << " type=" << event_matcher->type_matcher->type |
| 245 << " flags=" << event_matcher->flags_matcher->flags; |
| 246 return false; |
| 247 } |
| 239 } | 248 } |
| 240 accelerators_.insert(Entry(id, std::move(accelerator))); | 249 accelerators_.insert(Entry(id, std::move(accelerator))); |
| 241 return true; | 250 return true; |
| 242 } | 251 } |
| 243 | 252 |
| 244 void EventDispatcher::RemoveAccelerator(uint32_t id) { | 253 void EventDispatcher::RemoveAccelerator(uint32_t id) { |
| 245 auto it = accelerators_.find(id); | 254 auto it = accelerators_.find(id); |
| 246 // Clients may pass bogus ids. | 255 // Clients may pass bogus ids. |
| 247 if (it != accelerators_.end()) | 256 if (it != accelerators_.end()) |
| 248 accelerators_.erase(it); | 257 accelerators_.erase(it); |
| (...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 619 if (mouse_cursor_source_window_ == window) | 628 if (mouse_cursor_source_window_ == window) |
| 620 mouse_cursor_source_window_ = nullptr; | 629 mouse_cursor_source_window_ = nullptr; |
| 621 } | 630 } |
| 622 | 631 |
| 623 void EventDispatcher::OnDragCursorUpdated() { | 632 void EventDispatcher::OnDragCursorUpdated() { |
| 624 delegate_->UpdateNativeCursorFromDispatcher(); | 633 delegate_->UpdateNativeCursorFromDispatcher(); |
| 625 } | 634 } |
| 626 | 635 |
| 627 } // namespace ws | 636 } // namespace ws |
| 628 } // namespace ui | 637 } // namespace ui |
| OLD | NEW |