OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/aura/root_window.h" | 5 #include "ui/aura/root_window.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
281 } | 281 } |
282 | 282 |
283 void RootWindow::OnMouseEventsEnableStateChanged(bool enabled) { | 283 void RootWindow::OnMouseEventsEnableStateChanged(bool enabled) { |
284 // Send entered / exited so that visual state can be updated to match | 284 // Send entered / exited so that visual state can be updated to match |
285 // mouse events state. | 285 // mouse events state. |
286 PostMouseMoveEventAfterWindowChange(); | 286 PostMouseMoveEventAfterWindowChange(); |
287 // TODO(mazda): Add code to disable mouse events when |enabled| == false. | 287 // TODO(mazda): Add code to disable mouse events when |enabled| == false. |
288 } | 288 } |
289 | 289 |
290 void RootWindow::MoveCursorTo(const gfx::Point& location_in_dip) { | 290 void RootWindow::MoveCursorTo(const gfx::Point& location_in_dip) { |
291 gfx::Point location(location_in_dip); | 291 gfx::Point host_location(location_in_dip); |
292 ConvertPointToHost(&location); | 292 ConvertPointToHost(&host_location); |
293 host_->MoveCursorTo(location); | 293 MoveCursorToInternal(location_in_dip, host_location); |
294 SetLastMouseLocation(this, location_in_dip); | |
295 client::CursorClient* cursor_client = client::GetCursorClient(this); | |
296 if (cursor_client) { | |
297 const gfx::Display& display = | |
298 gfx::Screen::GetScreenFor(this)->GetDisplayNearestWindow(this); | |
299 cursor_client->SetDisplay(display); | |
300 } | |
301 } | 294 } |
302 | 295 |
303 void RootWindow::MoveCursorToHostLoation(const gfx::Point& host_location) { | 296 void RootWindow::MoveCursorToHostLocation(const gfx::Point& host_location) { |
304 host_->MoveCursorTo(host_location); | |
305 gfx::Point root_location(host_location); | 297 gfx::Point root_location(host_location); |
306 ConvertPointFromHost(&root_location); | 298 ConvertPointFromHost(&root_location); |
307 SetLastMouseLocation(this, root_location); | 299 MoveCursorToInternal(root_location, host_location); |
308 client::CursorClient* cursor_client = client::GetCursorClient(this); | |
309 if (cursor_client) { | |
310 const gfx::Display& display = | |
311 gfx::Screen::GetScreenFor(this)->GetDisplayNearestWindow(this); | |
312 cursor_client->SetDisplay(display); | |
313 } | |
314 | |
315 synthesize_mouse_move_ = false; | |
316 } | 300 } |
317 | 301 |
318 bool RootWindow::ConfineCursorToWindow() { | 302 bool RootWindow::ConfineCursorToWindow() { |
319 // We would like to be able to confine the cursor to that window. However, | 303 // We would like to be able to confine the cursor to that window. However, |
320 // currently, we do not have such functionality in X. So we just confine | 304 // currently, we do not have such functionality in X. So we just confine |
321 // to the root window. This is ok because this option is currently only | 305 // to the root window. This is ok because this option is currently only |
322 // being used in fullscreen mode, so root_window bounds = window bounds. | 306 // being used in fullscreen mode, so root_window bounds = window bounds. |
323 return host_->ConfineCursorToRootWindow(); | 307 return host_->ConfineCursorToRootWindow(); |
324 } | 308 } |
325 | 309 |
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
705 } | 689 } |
706 | 690 |
707 //////////////////////////////////////////////////////////////////////////////// | 691 //////////////////////////////////////////////////////////////////////////////// |
708 // RootWindow, private: | 692 // RootWindow, private: |
709 | 693 |
710 void RootWindow::TransformEventForDeviceScaleFactor(bool keep_inside_root, | 694 void RootWindow::TransformEventForDeviceScaleFactor(bool keep_inside_root, |
711 ui::LocatedEvent* event) { | 695 ui::LocatedEvent* event) { |
712 event->UpdateForRootTransform(GetInverseRootTransform()); | 696 event->UpdateForRootTransform(GetInverseRootTransform()); |
713 } | 697 } |
714 | 698 |
| 699 void RootWindow::MoveCursorToInternal(const gfx::Point& root_location, |
| 700 const gfx::Point& host_location) { |
| 701 host_->MoveCursorTo(host_location); |
| 702 SetLastMouseLocation(this, root_location); |
| 703 client::CursorClient* cursor_client = client::GetCursorClient(this); |
| 704 if (cursor_client) { |
| 705 const gfx::Display& display = |
| 706 gfx::Screen::GetScreenFor(this)->GetDisplayNearestWindow(this); |
| 707 cursor_client->SetDisplay(display); |
| 708 } |
| 709 synthesize_mouse_move_ = false; |
| 710 } |
| 711 |
715 void RootWindow::HandleMouseMoved(const ui::MouseEvent& event, Window* target) { | 712 void RootWindow::HandleMouseMoved(const ui::MouseEvent& event, Window* target) { |
716 if (target == mouse_moved_handler_) | 713 if (target == mouse_moved_handler_) |
717 return; | 714 return; |
718 | 715 |
719 DispatchMouseEnterOrExit(event, ui::ET_MOUSE_EXITED); | 716 DispatchMouseEnterOrExit(event, ui::ET_MOUSE_EXITED); |
720 | 717 |
721 if (mouse_event_dispatch_target_ != target) { | 718 if (mouse_event_dispatch_target_ != target) { |
722 mouse_moved_handler_ = NULL; | 719 mouse_moved_handler_ = NULL; |
723 return; | 720 return; |
724 } | 721 } |
(...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1179 } | 1176 } |
1180 | 1177 |
1181 gfx::Transform RootWindow::GetInverseRootTransform() const { | 1178 gfx::Transform RootWindow::GetInverseRootTransform() const { |
1182 float scale = ui::GetDeviceScaleFactor(layer()); | 1179 float scale = ui::GetDeviceScaleFactor(layer()); |
1183 gfx::Transform transform; | 1180 gfx::Transform transform; |
1184 transform.Scale(1.0f / scale, 1.0f / scale); | 1181 transform.Scale(1.0f / scale, 1.0f / scale); |
1185 return transformer_->GetInverseTransform() * transform; | 1182 return transformer_->GetInverseTransform() * transform; |
1186 } | 1183 } |
1187 | 1184 |
1188 } // namespace aura | 1185 } // namespace aura |
OLD | NEW |