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 "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 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
308 for (const auto& pair : accelerators_) { | 308 for (const auto& pair : accelerators_) { |
309 if (pair.first == id || matcher.Equals(pair.second)) | 309 if (pair.first == id || matcher.Equals(pair.second)) |
310 return false; | 310 return false; |
311 } | 311 } |
312 accelerators_.insert(Entry(id, matcher)); | 312 accelerators_.insert(Entry(id, matcher)); |
313 return true; | 313 return true; |
314 } | 314 } |
315 | 315 |
316 void EventDispatcher::RemoveAccelerator(uint32_t id) { | 316 void EventDispatcher::RemoveAccelerator(uint32_t id) { |
317 auto it = accelerators_.find(id); | 317 auto it = accelerators_.find(id); |
318 DCHECK(it != accelerators_.end()); | 318 // Clients may pass bogus ids. |
319 accelerators_.erase(it); | 319 if (it != accelerators_.end()) |
| 320 accelerators_.erase(it); |
320 } | 321 } |
321 | 322 |
322 void EventDispatcher::ProcessEvent(const ui::Event& event) { | 323 void EventDispatcher::ProcessEvent(const ui::Event& event) { |
323 if (!root_) | 324 if (!root_) |
324 return; | 325 return; |
325 | 326 |
326 if (event.IsKeyEvent()) { | 327 if (event.IsKeyEvent()) { |
327 const ui::KeyEvent* key_event = event.AsKeyEvent(); | 328 const ui::KeyEvent* key_event = event.AsKeyEvent(); |
328 if (event.type() == ui::ET_KEY_PRESSED && !key_event->is_char()) { | 329 if (event.type() == ui::ET_KEY_PRESSED && !key_event->is_char()) { |
329 uint32_t accelerator = 0u; | 330 uint32_t accelerator = 0u; |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
561 | 562 |
562 void EventDispatcher::OnWindowDestroyed(ServerWindow* window) { | 563 void EventDispatcher::OnWindowDestroyed(ServerWindow* window) { |
563 CancelPointerEventsToTarget(window); | 564 CancelPointerEventsToTarget(window); |
564 | 565 |
565 if (mouse_cursor_source_window_ == window) | 566 if (mouse_cursor_source_window_ == window) |
566 mouse_cursor_source_window_ = nullptr; | 567 mouse_cursor_source_window_ = nullptr; |
567 } | 568 } |
568 | 569 |
569 } // namespace ws | 570 } // namespace ws |
570 } // namespace mus | 571 } // namespace mus |
OLD | NEW |