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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
45 return false; | 45 return false; |
46 | 46 |
47 for (const auto& rect : target->additional_client_areas()) { | 47 for (const auto& rect : target->additional_client_areas()) { |
48 if (rect.Contains(location)) | 48 if (rect.Contains(location)) |
49 return false; | 49 return false; |
50 } | 50 } |
51 | 51 |
52 return true; | 52 return true; |
53 } | 53 } |
54 | 54 |
55 ServerWindow* GetModalTargetForWindow(ServerWindow* target) { | |
56 for (ServerWindow* window = target; window; window = window->parent()) { | |
57 for (const auto& transient_child : window->transient_children()) { | |
58 if (transient_child->is_modal()) | |
59 return GetModalTargetForWindow(transient_child); | |
60 } | |
61 } | |
62 return target; | |
63 } | |
64 | |
55 } // namespace | 65 } // namespace |
56 | 66 |
57 class EventMatcher { | 67 class EventMatcher { |
58 public: | 68 public: |
59 explicit EventMatcher(const mojom::EventMatcher& matcher) | 69 explicit EventMatcher(const mojom::EventMatcher& matcher) |
60 : fields_to_match_(NONE), | 70 : fields_to_match_(NONE), |
61 event_type_(ui::ET_UNKNOWN), | 71 event_type_(ui::ET_UNKNOWN), |
62 event_flags_(ui::EF_NONE), | 72 event_flags_(ui::EF_NONE), |
63 ignore_event_flags_(ui::EF_NONE), | 73 ignore_event_flags_(ui::EF_NONE), |
64 keyboard_code_(ui::VKEY_UNKNOWN), | 74 keyboard_code_(ui::VKEY_UNKNOWN), |
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
436 // Technically we're updating in place, but calling start then stop makes for | 446 // Technically we're updating in place, but calling start then stop makes for |
437 // simpler code. | 447 // simpler code. |
438 StopTrackingPointer(pointer_id); | 448 StopTrackingPointer(pointer_id); |
439 StartTrackingPointer(pointer_id, pointer_target); | 449 StartTrackingPointer(pointer_id, pointer_target); |
440 } | 450 } |
441 | 451 |
442 EventDispatcher::PointerTarget EventDispatcher::PointerTargetForEvent( | 452 EventDispatcher::PointerTarget EventDispatcher::PointerTargetForEvent( |
443 const ui::PointerEvent& event) const { | 453 const ui::PointerEvent& event) const { |
444 PointerTarget pointer_target; | 454 PointerTarget pointer_target; |
445 gfx::Point location(event.location()); | 455 gfx::Point location(event.location()); |
446 pointer_target.window = | 456 ServerWindow* target_window = |
447 FindDeepestVisibleWindowForEvents(root_, surface_id_, &location); | 457 FindDeepestVisibleWindowForEvents(root_, surface_id_, &location); |
458 pointer_target.window = GetModalTargetForWindow(target_window); | |
448 pointer_target.is_mouse_event = event.IsMousePointerEvent(); | 459 pointer_target.is_mouse_event = event.IsMousePointerEvent(); |
449 pointer_target.in_nonclient_area = | 460 pointer_target.in_nonclient_area = |
sky
2016/03/02 18:28:33
Aren't you going to use an enum to indicate modal?
mohsen
2016/03/03 22:54:59
Not at the moment. That enum would be useful if we
sky
2016/03/03 23:50:39
If you don't send a flag indicating this, I'm not
mohsen
2016/03/04 16:24:17
I've tested this code (using window_type_launcher)
| |
461 target_window != pointer_target.window || | |
450 IsLocationInNonclientArea(pointer_target.window, location); | 462 IsLocationInNonclientArea(pointer_target.window, location); |
451 pointer_target.is_pointer_down = event.type() == ui::ET_POINTER_DOWN; | 463 pointer_target.is_pointer_down = event.type() == ui::ET_POINTER_DOWN; |
452 return pointer_target; | 464 return pointer_target; |
453 } | 465 } |
454 | 466 |
455 bool EventDispatcher::AreAnyPointersDown() const { | 467 bool EventDispatcher::AreAnyPointersDown() const { |
456 for (const auto& pair : pointer_targets_) { | 468 for (const auto& pair : pointer_targets_) { |
457 if (pair.second.is_pointer_down) | 469 if (pair.second.is_pointer_down) |
458 return true; | 470 return true; |
459 } | 471 } |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
526 | 538 |
527 void EventDispatcher::OnWindowDestroyed(ServerWindow* window) { | 539 void EventDispatcher::OnWindowDestroyed(ServerWindow* window) { |
528 CancelPointerEventsToTarget(window); | 540 CancelPointerEventsToTarget(window); |
529 | 541 |
530 if (mouse_cursor_source_window_ == window) | 542 if (mouse_cursor_source_window_ == window) |
531 mouse_cursor_source_window_ = nullptr; | 543 mouse_cursor_source_window_ = nullptr; |
532 } | 544 } |
533 | 545 |
534 } // namespace ws | 546 } // namespace ws |
535 } // namespace mus | 547 } // namespace mus |
OLD | NEW |