| 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 "ui/views/mus/window_manager_connection.h" | 5 #include "ui/views/mus/window_manager_connection.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
| 10 #include "base/threading/thread_local.h" | 10 #include "base/threading/thread_local.h" |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 // during iteration over the list even when the last observer is removed. | 135 // during iteration over the list even when the last observer is removed. |
| 136 base::ObserverList<PointerWatcher>::Iterator iterator(&pointer_watchers_); | 136 base::ObserverList<PointerWatcher>::Iterator iterator(&pointer_watchers_); |
| 137 return !!iterator.GetNext(); | 137 return !!iterator.GetNext(); |
| 138 } | 138 } |
| 139 | 139 |
| 140 void WindowManagerConnection::OnEmbed(mus::Window* root) {} | 140 void WindowManagerConnection::OnEmbed(mus::Window* root) {} |
| 141 | 141 |
| 142 void WindowManagerConnection::OnConnectionLost( | 142 void WindowManagerConnection::OnConnectionLost( |
| 143 mus::WindowTreeConnection* connection) {} | 143 mus::WindowTreeConnection* connection) {} |
| 144 | 144 |
| 145 void WindowManagerConnection::OnEventObserved(const ui::Event& event) { | 145 void WindowManagerConnection::OnEventObserved(const ui::Event& event, |
| 146 mus::Window* target) { |
| 146 if (!event.IsLocatedEvent()) | 147 if (!event.IsLocatedEvent()) |
| 147 return; | 148 return; |
| 149 Widget* target_widget = nullptr; |
| 150 if (target) { |
| 151 mus::Window* root = target->GetRoot(); |
| 152 target_widget = NativeWidgetMus::GetWidgetForWindow(root); |
| 153 } |
| 154 |
| 148 // The mojo input events type converter uses the event root_location field | 155 // The mojo input events type converter uses the event root_location field |
| 149 // to store screen coordinates. Screen coordinates really should be returned | 156 // to store screen coordinates. Screen coordinates really should be returned |
| 150 // separately. See http://crbug.com/608547 | 157 // separately. See http://crbug.com/608547 |
| 151 gfx::Point location_in_screen = event.AsLocatedEvent()->root_location(); | 158 gfx::Point location_in_screen = event.AsLocatedEvent()->root_location(); |
| 152 if (event.type() == ui::ET_MOUSE_PRESSED) { | 159 if (event.type() == ui::ET_MOUSE_PRESSED) { |
| 153 FOR_EACH_OBSERVER( | 160 FOR_EACH_OBSERVER(PointerWatcher, pointer_watchers_, |
| 154 PointerWatcher, pointer_watchers_, | 161 OnMousePressed(*event.AsMouseEvent(), location_in_screen, |
| 155 OnMousePressed(*event.AsMouseEvent(), location_in_screen)); | 162 target_widget)); |
| 156 } else if (event.type() == ui::ET_TOUCH_PRESSED) { | 163 } else if (event.type() == ui::ET_TOUCH_PRESSED) { |
| 157 FOR_EACH_OBSERVER( | 164 FOR_EACH_OBSERVER(PointerWatcher, pointer_watchers_, |
| 158 PointerWatcher, pointer_watchers_, | 165 OnTouchPressed(*event.AsTouchEvent(), location_in_screen, |
| 159 OnTouchPressed(*event.AsTouchEvent(), location_in_screen)); | 166 target_widget)); |
| 160 } | 167 } |
| 161 } | 168 } |
| 162 | 169 |
| 163 void WindowManagerConnection::OnWindowManagerFrameValuesChanged() { | 170 void WindowManagerConnection::OnWindowManagerFrameValuesChanged() { |
| 164 if (window_tree_connection_) | 171 if (window_tree_connection_) |
| 165 NativeWidgetMus::NotifyFrameChanged(window_tree_connection_.get()); | 172 NativeWidgetMus::NotifyFrameChanged(window_tree_connection_.get()); |
| 166 } | 173 } |
| 167 | 174 |
| 168 gfx::Point WindowManagerConnection::GetCursorScreenPoint() { | 175 gfx::Point WindowManagerConnection::GetCursorScreenPoint() { |
| 169 return window_tree_connection_->GetCursorScreenPoint(); | 176 return window_tree_connection_->GetCursorScreenPoint(); |
| 170 } | 177 } |
| 171 | 178 |
| 172 } // namespace views | 179 } // namespace views |
| OLD | NEW |