Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6)

Side by Side Diff: ui/views/mus/pointer_watcher_event_router.cc

Issue 2256343003: Update ui::PointerEvent to support mouse wheel and capture change events. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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(
93 PointerWatcher, pointer_watchers_,
94 OnPointerEventObserved(
95 event, display::Screen::GetScreen()->GetCursorScreenPoint(),
sadrul 2016/08/19 16:38:59 Why not gfx::Point()?
riajiang 2016/08/19 17:23:42 (same as the first reply)
sadrul 2016/08/22 14:55:19 OK. Get the location first, before calling the obs
riajiang 2016/08/22 16:03:05 Done.
96 nullptr));
89 } 97 }
90 98
91 void PointerWatcherEventRouter::OnDidDestroyClient( 99 void PointerWatcherEventRouter::OnDidDestroyClient(
92 ui::WindowTreeClient* client) { 100 ui::WindowTreeClient* client) {
93 DCHECK(!pointer_watchers_.might_have_observers()); 101 DCHECK(!pointer_watchers_.might_have_observers());
94 DCHECK_EQ(client, window_tree_client_); 102 DCHECK_EQ(client, window_tree_client_);
95 window_tree_client_->RemoveObserver(this); 103 window_tree_client_->RemoveObserver(this);
96 window_tree_client_ = nullptr; 104 window_tree_client_ = nullptr;
97 } 105 }
98 106
99 } // namespace views 107 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698