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

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

Issue 2576533003: Converts some services to use aura-mus (Closed)
Patch Set: remove log Created 4 years 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_router2.h" 5 #include "ui/views/mus/pointer_watcher_event_router2.h"
6 6
7 #include "ui/aura/client/capture_client.h" 7 #include "ui/aura/client/capture_client.h"
8 #include "ui/aura/mus/window_tree_client.h" 8 #include "ui/aura/mus/window_tree_client.h"
9 #include "ui/aura/window.h" 9 #include "ui/aura/window.h"
10 #include "ui/display/screen.h" 10 #include "ui/display/screen.h"
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 // events. This could only happen if there is a bug in the add logic. 83 // events. This could only happen if there is a bug in the add logic.
84 NOTREACHED(); 84 NOTREACHED();
85 break; 85 break;
86 } 86 }
87 } 87 }
88 88
89 void PointerWatcherEventRouter2::OnPointerEventObserved( 89 void PointerWatcherEventRouter2::OnPointerEventObserved(
90 const ui::PointerEvent& event, 90 const ui::PointerEvent& event,
91 aura::Window* target) { 91 aura::Window* target) {
92 Widget* target_widget = nullptr; 92 Widget* target_widget = nullptr;
93 ui::PointerEvent updated_event(event);
93 if (target) { 94 if (target) {
94 aura::Window* window = target; 95 aura::Window* window = target;
95 while (window && !target_widget) { 96 while (window && !target_widget) {
96 target_widget = Widget::GetWidgetForNativeView(window); 97 target_widget = Widget::GetWidgetForNativeView(window);
97 if (!target_widget) { 98 if (!target_widget) {
98 // Widget::GetWidgetForNativeView() uses NativeWidgetAura. Views with 99 // Widget::GetWidgetForNativeView() uses NativeWidgetAura. Views with
99 // aura-mus may also create DesktopNativeWidgetAura. 100 // aura-mus may also create DesktopNativeWidgetAura.
100 DesktopNativeWidgetAura* desktop_native_widget_aura = 101 DesktopNativeWidgetAura* desktop_native_widget_aura =
101 DesktopNativeWidgetAura::ForWindow(target); 102 DesktopNativeWidgetAura::ForWindow(target);
102 if (desktop_native_widget_aura) { 103 if (desktop_native_widget_aura) {
103 target_widget = static_cast<internal::NativeWidgetPrivate*>( 104 target_widget = static_cast<internal::NativeWidgetPrivate*>(
104 desktop_native_widget_aura) 105 desktop_native_widget_aura)
105 ->GetWidget(); 106 ->GetWidget();
106 } 107 }
107 } 108 }
108 window = window->parent(); 109 window = window->parent();
109 } 110 }
111 if (target_widget) {
112 gfx::Point widget_relative_location(event.location());
113 aura::Window::ConvertPointToTarget(target, target_widget->GetNativeView(),
114 &widget_relative_location);
115 updated_event.set_location(widget_relative_location);
116 }
110 } 117 }
111 118
112 // The mojo input events type converter uses the event root_location field 119 // The mojo input events type converter uses the event root_location field
113 // to store screen coordinates. Screen coordinates really should be returned 120 // to store screen coordinates. Screen coordinates really should be returned
114 // separately. See http://crbug.com/608547 121 // separately. See http://crbug.com/608547
115 gfx::Point location_in_screen = event.AsLocatedEvent()->root_location(); 122 gfx::Point location_in_screen = event.root_location();
116 for (PointerWatcher& observer : move_watchers_) 123 for (PointerWatcher& observer : move_watchers_) {
117 observer.OnPointerEventObserved(event, location_in_screen, target_widget); 124 observer.OnPointerEventObserved(updated_event, location_in_screen,
125 target_widget);
126 }
118 if (event.type() != ui::ET_POINTER_MOVED) { 127 if (event.type() != ui::ET_POINTER_MOVED) {
119 for (PointerWatcher& observer : non_move_watchers_) 128 for (PointerWatcher& observer : non_move_watchers_) {
120 observer.OnPointerEventObserved(event, location_in_screen, target_widget); 129 observer.OnPointerEventObserved(updated_event, location_in_screen,
130 target_widget);
131 }
121 } 132 }
122 } 133 }
123 134
124 PointerWatcherEventRouter2::EventTypes 135 PointerWatcherEventRouter2::EventTypes
125 PointerWatcherEventRouter2::DetermineEventTypes() { 136 PointerWatcherEventRouter2::DetermineEventTypes() {
126 if (HasPointerWatcher(&move_watchers_)) 137 if (HasPointerWatcher(&move_watchers_))
127 return EventTypes::MOVE_EVENTS; 138 return EventTypes::MOVE_EVENTS;
128 139
129 if (HasPointerWatcher(&non_move_watchers_)) 140 if (HasPointerWatcher(&non_move_watchers_))
130 return EventTypes::NON_MOVE_EVENTS; 141 return EventTypes::NON_MOVE_EVENTS;
(...skipping 19 matching lines...) Expand all
150 aura::WindowTreeClient* client) { 161 aura::WindowTreeClient* client) {
151 // We expect that all observers have been removed by this time. 162 // We expect that all observers have been removed by this time.
152 DCHECK_EQ(event_types_, EventTypes::NONE); 163 DCHECK_EQ(event_types_, EventTypes::NONE);
153 DCHECK_EQ(client, window_tree_client_); 164 DCHECK_EQ(client, window_tree_client_);
154 window_tree_client_->GetCaptureClient()->RemoveObserver(this); 165 window_tree_client_->GetCaptureClient()->RemoveObserver(this);
155 window_tree_client_->RemoveObserver(this); 166 window_tree_client_->RemoveObserver(this);
156 window_tree_client_ = nullptr; 167 window_tree_client_ = nullptr;
157 } 168 }
158 169
159 } // namespace views 170 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/mus/desktop_window_tree_host_mus.cc ('k') | ui/views/widget/desktop_aura/desktop_native_widget_aura.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698