| 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 LOG(ERROR) << "JAMES target_widget " << target_widget->GetName(); |
| 154 } else { |
| 155 LOG(ERROR) << "JAMES no target"; |
| 156 } |
| 157 |
| 148 // The mojo input events type converter uses the event root_location field | 158 // The mojo input events type converter uses the event root_location field |
| 149 // to store screen coordinates. Screen coordinates really should be returned | 159 // to store screen coordinates. Screen coordinates really should be returned |
| 150 // separately. See http://crbug.com/608547 | 160 // separately. See http://crbug.com/608547 |
| 151 gfx::Point location_in_screen = event.AsLocatedEvent()->root_location(); | 161 gfx::Point location_in_screen = event.AsLocatedEvent()->root_location(); |
| 152 if (event.type() == ui::ET_MOUSE_PRESSED) { | 162 if (event.type() == ui::ET_MOUSE_PRESSED) { |
| 153 FOR_EACH_OBSERVER( | 163 FOR_EACH_OBSERVER( |
| 154 PointerWatcher, pointer_watchers_, | 164 PointerWatcher, pointer_watchers_, |
| 155 OnMousePressed(*event.AsMouseEvent(), location_in_screen)); | 165 OnMousePressed(*event.AsMouseEvent(), location_in_screen, target_widget)
); |
| 156 } else if (event.type() == ui::ET_TOUCH_PRESSED) { | 166 } else if (event.type() == ui::ET_TOUCH_PRESSED) { |
| 157 FOR_EACH_OBSERVER( | 167 FOR_EACH_OBSERVER( |
| 158 PointerWatcher, pointer_watchers_, | 168 PointerWatcher, pointer_watchers_, |
| 159 OnTouchPressed(*event.AsTouchEvent(), location_in_screen)); | 169 OnTouchPressed(*event.AsTouchEvent(), location_in_screen, target_widget)
); |
| 160 } | 170 } |
| 161 } | 171 } |
| 162 | 172 |
| 163 void WindowManagerConnection::OnWindowManagerFrameValuesChanged() { | 173 void WindowManagerConnection::OnWindowManagerFrameValuesChanged() { |
| 164 if (window_tree_connection_) | 174 if (window_tree_connection_) |
| 165 NativeWidgetMus::NotifyFrameChanged(window_tree_connection_.get()); | 175 NativeWidgetMus::NotifyFrameChanged(window_tree_connection_.get()); |
| 166 } | 176 } |
| 167 | 177 |
| 168 gfx::Point WindowManagerConnection::GetCursorScreenPoint() { | 178 gfx::Point WindowManagerConnection::GetCursorScreenPoint() { |
| 169 return window_tree_connection_->GetCursorScreenPoint(); | 179 return window_tree_connection_->GetCursorScreenPoint(); |
| 170 } | 180 } |
| 171 | 181 |
| 172 } // namespace views | 182 } // namespace views |
| OLD | NEW |