| 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 520 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 531 std::vector<DisplayInfo> display_info_list; | 531 std::vector<DisplayInfo> display_info_list; |
| 532 display_info_list.push_back(display_manager->GetDisplayInfo( | 532 display_info_list.push_back(display_manager->GetDisplayInfo( |
| 533 primary_display_id)); | 533 primary_display_id)); |
| 534 display_info_list.push_back(display_manager->GetDisplayInfo( | 534 display_info_list.push_back(display_manager->GetDisplayInfo( |
| 535 ScreenUtil::GetSecondaryDisplay().id())); | 535 ScreenUtil::GetSecondaryDisplay().id())); |
| 536 GetDisplayManager()->set_force_bounds_changed(true); | 536 GetDisplayManager()->set_force_bounds_changed(true); |
| 537 GetDisplayManager()->UpdateDisplays(display_info_list); | 537 GetDisplayManager()->UpdateDisplays(display_info_list); |
| 538 GetDisplayManager()->set_force_bounds_changed(false); | 538 GetDisplayManager()->set_force_bounds_changed(false); |
| 539 } | 539 } |
| 540 | 540 |
| 541 void DisplayController::EnsurePointerInDisplays() { | 541 void DisplayController::UpdateMouseLocationAfterDisplayChange() { |
| 542 // If the mouse is currently on a display in native location, | 542 // If the mouse is currently on a display in native location, |
| 543 // use the same native location. Otherwise find the display closest | 543 // use the same native location. Otherwise find the display closest |
| 544 // to the current cursor location in screen coordinates. | 544 // to the current cursor location in screen coordinates. |
| 545 | 545 |
| 546 gfx::Point point_in_screen = Shell::GetScreen()->GetCursorScreenPoint(); | 546 gfx::Point point_in_screen = Shell::GetScreen()->GetCursorScreenPoint(); |
| 547 gfx::Point target_location_in_native; | 547 gfx::Point target_location_in_native; |
| 548 int64 closest_distance_squared = -1; | 548 int64 closest_distance_squared = -1; |
| 549 DisplayManager* display_manager = GetDisplayManager(); | 549 DisplayManager* display_manager = GetDisplayManager(); |
| 550 | 550 |
| 551 aura::Window* dst_root_window = NULL; | 551 aura::Window* dst_root_window = NULL; |
| (...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 774 // Update the primary_id in case the above call is | 774 // Update the primary_id in case the above call is |
| 775 // ignored. Happens when a) default layout's primary id | 775 // ignored. Happens when a) default layout's primary id |
| 776 // doesn't exist, or b) the primary_id has already been | 776 // doesn't exist, or b) the primary_id has already been |
| 777 // set to the same and didn't update it. | 777 // set to the same and didn't update it. |
| 778 layout_store->UpdatePrimaryDisplayId( | 778 layout_store->UpdatePrimaryDisplayId( |
| 779 pair, Shell::GetScreen()->GetPrimaryDisplay().id()); | 779 pair, Shell::GetScreen()->GetPrimaryDisplay().id()); |
| 780 } | 780 } |
| 781 } | 781 } |
| 782 FOR_EACH_OBSERVER(Observer, observers_, OnDisplayConfigurationChanged()); | 782 FOR_EACH_OBSERVER(Observer, observers_, OnDisplayConfigurationChanged()); |
| 783 UpdateHostWindowNames(); | 783 UpdateHostWindowNames(); |
| 784 EnsurePointerInDisplays(); | 784 UpdateMouseLocationAfterDisplayChange(); |
| 785 } | 785 } |
| 786 | 786 |
| 787 AshWindowTreeHost* DisplayController::AddWindowTreeHostForDisplay( | 787 AshWindowTreeHost* DisplayController::AddWindowTreeHostForDisplay( |
| 788 const gfx::Display& display, | 788 const gfx::Display& display, |
| 789 const AshWindowTreeHostInitParams& init_params) { | 789 const AshWindowTreeHostInitParams& init_params) { |
| 790 static int host_count = 0; | 790 static int host_count = 0; |
| 791 const DisplayInfo& display_info = | 791 const DisplayInfo& display_info = |
| 792 GetDisplayManager()->GetDisplayInfo(display.id()); | 792 GetDisplayManager()->GetDisplayInfo(display.id()); |
| 793 AshWindowTreeHostInitParams params_with_bounds(init_params); | 793 AshWindowTreeHostInitParams params_with_bounds(init_params); |
| 794 params_with_bounds.initial_bounds = display_info.bounds_in_native(); | 794 params_with_bounds.initial_bounds = display_info.bounds_in_native(); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 840 std::string name = | 840 std::string name = |
| 841 root_windows[i] == primary ? "aura_root_0" : "aura_root_x"; | 841 root_windows[i] == primary ? "aura_root_0" : "aura_root_x"; |
| 842 gfx::AcceleratedWidget xwindow = | 842 gfx::AcceleratedWidget xwindow = |
| 843 root_windows[i]->GetHost()->GetAcceleratedWidget(); | 843 root_windows[i]->GetHost()->GetAcceleratedWidget(); |
| 844 XStoreName(gfx::GetXDisplay(), xwindow, name.c_str()); | 844 XStoreName(gfx::GetXDisplay(), xwindow, name.c_str()); |
| 845 } | 845 } |
| 846 #endif | 846 #endif |
| 847 } | 847 } |
| 848 | 848 |
| 849 } // namespace ash | 849 } // namespace ash |
| OLD | NEW |