Chromium Code Reviews| 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/events/base_event_utils.h" | 9 #include "ui/events/base_event_utils.h" |
| 10 #include "ui/events/event.h" | 10 #include "ui/events/event.h" |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 37 | 37 |
| 38 bool had_watcher = HasPointerWatcher(); | 38 bool had_watcher = HasPointerWatcher(); |
| 39 pointer_watchers_.AddObserver(watcher); | 39 pointer_watchers_.AddObserver(watcher); |
| 40 if (!had_watcher) { | 40 if (!had_watcher) { |
| 41 // First PointerWatcher added, start the watcher on the window server. | 41 // First PointerWatcher added, start the watcher on the window server. |
| 42 window_tree_client_->StartPointerWatcher(want_moves); | 42 window_tree_client_->StartPointerWatcher(want_moves); |
| 43 } | 43 } |
| 44 } | 44 } |
| 45 | 45 |
| 46 void PointerWatcherEventRouter::RemovePointerWatcher(PointerWatcher* watcher) { | 46 void PointerWatcherEventRouter::RemovePointerWatcher(PointerWatcher* watcher) { |
| 47 DCHECK(pointer_watchers_.HasObserver(watcher)); | |
|
James Cook
2016/08/17 18:31:50
FYI - We'll have to see how this goes. I vaguely r
msw
2016/08/17 18:55:17
Acknowledged.
| |
| 47 pointer_watchers_.RemoveObserver(watcher); | 48 pointer_watchers_.RemoveObserver(watcher); |
| 48 if (!HasPointerWatcher()) { | 49 if (!HasPointerWatcher()) { |
| 49 // Last PointerWatcher removed, stop the watcher on the window server. | 50 // Last PointerWatcher removed, stop the watcher on the window server. |
| 50 window_tree_client_->StopPointerWatcher(); | 51 window_tree_client_->StopPointerWatcher(); |
| 51 pointer_watcher_want_moves_ = false; | 52 pointer_watcher_want_moves_ = false; |
| 52 } | 53 } |
| 53 } | 54 } |
| 54 | 55 |
| 55 void PointerWatcherEventRouter::OnPointerEventObserved( | 56 void PointerWatcherEventRouter::OnPointerEventObserved( |
| 56 const ui::PointerEvent& event, | 57 const ui::PointerEvent& event, |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 80 base::ObserverList<PointerWatcher>::Iterator iterator(&pointer_watchers_); | 81 base::ObserverList<PointerWatcher>::Iterator iterator(&pointer_watchers_); |
| 81 return !!iterator.GetNext(); | 82 return !!iterator.GetNext(); |
| 82 } | 83 } |
| 83 | 84 |
| 84 void PointerWatcherEventRouter::OnWindowTreeCaptureChanged( | 85 void PointerWatcherEventRouter::OnWindowTreeCaptureChanged( |
| 85 ui::Window* gained_capture, | 86 ui::Window* gained_capture, |
| 86 ui::Window* lost_capture) { | 87 ui::Window* lost_capture) { |
| 87 FOR_EACH_OBSERVER(PointerWatcher, pointer_watchers_, OnMouseCaptureChanged()); | 88 FOR_EACH_OBSERVER(PointerWatcher, pointer_watchers_, OnMouseCaptureChanged()); |
| 88 } | 89 } |
| 89 | 90 |
| 90 void PointerWatcherEventRouter::OnWillDestroyClient( | 91 void PointerWatcherEventRouter::OnDidDestroyClient( |
| 91 ui::WindowTreeClient* client) { | 92 ui::WindowTreeClient* client) { |
| 93 DCHECK(!pointer_watchers_.might_have_observers()); | |
|
sky
2016/08/17 19:50:36
I suspect we'll have to remove this, but we can tr
| |
| 92 DCHECK_EQ(client, window_tree_client_); | 94 DCHECK_EQ(client, window_tree_client_); |
| 93 window_tree_client_->RemoveObserver(this); | 95 window_tree_client_->RemoveObserver(this); |
| 94 window_tree_client_ = nullptr; | 96 window_tree_client_ = nullptr; |
| 95 } | 97 } |
| 96 | 98 |
| 97 } // namespace views | 99 } // namespace views |
| OLD | NEW |