| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "ui/views/mus/pointer_watcher_event_router.h" | 5 #include "ui/views/mus/pointer_watcher_event_router.h" |
| 6 | 6 |
| 7 #include "services/ui/public/cpp/window.h" | 7 #include "services/ui/public/cpp/window.h" |
| 8 #include "services/ui/public/cpp/window_tree_client.h" | 8 #include "services/ui/public/cpp/window_tree_client.h" |
| 9 #include "ui/display/screen.h" |
| 9 #include "ui/events/base_event_utils.h" | 10 #include "ui/events/base_event_utils.h" |
| 10 #include "ui/events/event.h" | 11 #include "ui/events/event.h" |
| 11 #include "ui/views/mus/native_widget_mus.h" | 12 #include "ui/views/mus/native_widget_mus.h" |
| 12 #include "ui/views/pointer_watcher.h" | 13 #include "ui/views/pointer_watcher.h" |
| 13 | 14 |
| 14 namespace views { | 15 namespace views { |
| 15 | 16 |
| 16 PointerWatcherEventRouter::PointerWatcherEventRouter( | 17 PointerWatcherEventRouter::PointerWatcherEventRouter( |
| 17 ui::WindowTreeClient* client) | 18 ui::WindowTreeClient* client) |
| 18 : window_tree_client_(client) { | 19 : window_tree_client_(client) { |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 // Check to see if we really have any observers left. This doesn't use | 79 // Check to see if we really have any observers left. This doesn't use |
| 79 // base::ObserverList<>::might_have_observers() because that returns true | 80 // base::ObserverList<>::might_have_observers() because that returns true |
| 80 // during iteration over the list even when the last observer is removed. | 81 // during iteration over the list even when the last observer is removed. |
| 81 base::ObserverList<PointerWatcher>::Iterator iterator(&pointer_watchers_); | 82 base::ObserverList<PointerWatcher>::Iterator iterator(&pointer_watchers_); |
| 82 return !!iterator.GetNext(); | 83 return !!iterator.GetNext(); |
| 83 } | 84 } |
| 84 | 85 |
| 85 void PointerWatcherEventRouter::OnWindowTreeCaptureChanged( | 86 void PointerWatcherEventRouter::OnWindowTreeCaptureChanged( |
| 86 ui::Window* gained_capture, | 87 ui::Window* gained_capture, |
| 87 ui::Window* lost_capture) { | 88 ui::Window* lost_capture) { |
| 88 FOR_EACH_OBSERVER(PointerWatcher, pointer_watchers_, OnMouseCaptureChanged()); | 89 const ui::MouseEvent mouse_event(ui::ET_MOUSE_CAPTURE_CHANGED, gfx::Point(), |
| 90 gfx::Point(), ui::EventTimeForNow(), 0, 0); |
| 91 const ui::PointerEvent event(mouse_event); |
| 92 FOR_EACH_OBSERVER(PointerWatcher, pointer_watchers_, |
| 93 OnPointerEventObserved(event, gfx::Point(), nullptr)); |
| 89 } | 94 } |
| 90 | 95 |
| 91 void PointerWatcherEventRouter::OnDidDestroyClient( | 96 void PointerWatcherEventRouter::OnDidDestroyClient( |
| 92 ui::WindowTreeClient* client) { | 97 ui::WindowTreeClient* client) { |
| 93 DCHECK(!pointer_watchers_.might_have_observers()); | 98 DCHECK(!pointer_watchers_.might_have_observers()); |
| 94 DCHECK_EQ(client, window_tree_client_); | 99 DCHECK_EQ(client, window_tree_client_); |
| 95 window_tree_client_->RemoveObserver(this); | 100 window_tree_client_->RemoveObserver(this); |
| 96 window_tree_client_ = nullptr; | 101 window_tree_client_ = nullptr; |
| 97 } | 102 } |
| 98 | 103 |
| 99 } // namespace views | 104 } // namespace views |
| OLD | NEW |