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 "ash/display/display_controller.h" | 5 #include "ash/display/display_controller.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cmath> | 8 #include <cmath> |
9 #include <map> | 9 #include <map> |
10 | 10 |
(...skipping 568 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
579 } | 579 } |
580 } | 580 } |
581 | 581 |
582 gfx::Point target_location_in_root = target_location_in_native; | 582 gfx::Point target_location_in_root = target_location_in_native; |
583 dst_root_window->GetHost()->ConvertPointFromNativeScreen( | 583 dst_root_window->GetHost()->ConvertPointFromNativeScreen( |
584 &target_location_in_root); | 584 &target_location_in_root); |
585 | 585 |
586 #if defined(USE_OZONE) | 586 #if defined(USE_OZONE) |
587 gfx::Point target_location_in_screen = target_location_in_root; | 587 gfx::Point target_location_in_screen = target_location_in_root; |
588 ::wm::ConvertPointToScreen(dst_root_window, &target_location_in_screen); | 588 ::wm::ConvertPointToScreen(dst_root_window, &target_location_in_screen); |
589 int64 target_display_id = | 589 const gfx::Display& target_display = |
590 display_manager->FindDisplayContainingPoint(target_location_in_screen) | 590 display_manager->FindDisplayContainingPoint(target_location_in_screen); |
591 .id(); | 591 int64 target_display_id = target_display.id(); |
592 | 592 |
593 // Do not move the cursor if the cursor's location did not change. This avoids | 593 // Do not move the cursor if the cursor's location did not change. This avoids |
594 // moving (and showing) the cursor on startup. | 594 // moving (and showing) the cursor: |
595 // - |cursor_location_in_screen_coords_for_restore_| is checked to ensure that | 595 // - At startup. |
596 // the cursor is moved when the cursor's native position does not change but | 596 // - When the device is rotated in maximized mode. |
597 // the scale factor or rotation of the display it is on have changed. | 597 // |cursor_display_id_for_restore_| is checked to ensure that the cursor is |
598 // - |cursor_display_id_for_restore_| is checked to ensure that the cursor is | 598 // moved when the cursor's native position does not change but the display |
599 // moved when the cursor's native position and screen position do not change | 599 // that it is on has changed. This occurs when swapping the primary display. |
600 // but the display that it is on has changed. This occurs when swapping the | |
601 // primary display. | |
602 if (target_location_in_native != | 600 if (target_location_in_native != |
603 cursor_location_in_native_coords_for_restore_ || | 601 cursor_location_in_native_coords_for_restore_ || |
604 target_location_in_screen != | |
605 cursor_location_in_screen_coords_for_restore_ || | |
606 target_display_id != cursor_display_id_for_restore_) { | 602 target_display_id != cursor_display_id_for_restore_) { |
607 dst_root_window->MoveCursorTo(target_location_in_root); | 603 dst_root_window->MoveCursorTo(target_location_in_root); |
| 604 } else if (target_location_in_screen != |
| 605 cursor_location_in_screen_coords_for_restore_) { |
| 606 // The cursor's native position did not change but its screen position did |
| 607 // change. This occurs when the scale factor or the rotation of the display |
| 608 // that the cursor is on changes. |
| 609 Shell::GetInstance()->cursor_manager()->SetDisplay(target_display); |
| 610 |
| 611 // Update the cursor's root location. This ends up dispatching a synthetic |
| 612 // mouse move. The synthetic mouse move updates the composited cursor's |
| 613 // location and hover effects. Synthetic mouse moves do not affect the |
| 614 // cursor's visibility. |
| 615 dst_root_window->GetHost()->dispatcher()->OnCursorMovedToRootLocation( |
| 616 target_location_in_root); |
608 } | 617 } |
609 #else | 618 #else |
610 dst_root_window->MoveCursorTo(target_location_in_root); | 619 dst_root_window->MoveCursorTo(target_location_in_root); |
611 #endif | 620 #endif |
612 } | 621 } |
613 | 622 |
614 bool DisplayController::UpdateWorkAreaOfDisplayNearestWindow( | 623 bool DisplayController::UpdateWorkAreaOfDisplayNearestWindow( |
615 const aura::Window* window, | 624 const aura::Window* window, |
616 const gfx::Insets& insets) { | 625 const gfx::Insets& insets) { |
617 const aura::Window* root_window = window->GetRootWindow(); | 626 const aura::Window* root_window = window->GetRootWindow(); |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
849 std::string name = | 858 std::string name = |
850 root_windows[i] == primary ? "aura_root_0" : "aura_root_x"; | 859 root_windows[i] == primary ? "aura_root_0" : "aura_root_x"; |
851 gfx::AcceleratedWidget xwindow = | 860 gfx::AcceleratedWidget xwindow = |
852 root_windows[i]->GetHost()->GetAcceleratedWidget(); | 861 root_windows[i]->GetHost()->GetAcceleratedWidget(); |
853 XStoreName(gfx::GetXDisplay(), xwindow, name.c_str()); | 862 XStoreName(gfx::GetXDisplay(), xwindow, name.c_str()); |
854 } | 863 } |
855 #endif | 864 #endif |
856 } | 865 } |
857 | 866 |
858 } // namespace ash | 867 } // namespace ash |
OLD | NEW |