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/window_tree_host_manager.h" | 5 #include "ash/display/window_tree_host_manager.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cmath> | 8 #include <cmath> |
9 #include <map> | 9 #include <map> |
10 #include <memory> | 10 #include <memory> |
(...skipping 506 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
517 // that it is on has changed. This occurs when swapping the primary display. | 517 // that it is on has changed. This occurs when swapping the primary display. |
518 if (target_location_in_native != | 518 if (target_location_in_native != |
519 cursor_location_in_native_coords_for_restore_ || | 519 cursor_location_in_native_coords_for_restore_ || |
520 target_display_id != cursor_display_id_for_restore_) { | 520 target_display_id != cursor_display_id_for_restore_) { |
521 dst_root_window->MoveCursorTo(target_location_in_root); | 521 dst_root_window->MoveCursorTo(target_location_in_root); |
522 } else if (target_location_in_screen != | 522 } else if (target_location_in_screen != |
523 cursor_location_in_screen_coords_for_restore_) { | 523 cursor_location_in_screen_coords_for_restore_) { |
524 // The cursor's native position did not change but its screen position did | 524 // The cursor's native position did not change but its screen position did |
525 // change. This occurs when the scale factor or the rotation of the display | 525 // change. This occurs when the scale factor or the rotation of the display |
526 // that the cursor is on changes. | 526 // that the cursor is on changes. |
527 Shell::Get()->cursor_manager()->SetDisplay(target_display); | 527 // TODO: conditional should not be necessary. http://crbug.com/631103. |
| 528 if (Shell::Get()->cursor_manager()) |
| 529 Shell::Get()->cursor_manager()->SetDisplay(target_display); |
528 | 530 |
529 // Update the cursor's root location. This ends up dispatching a synthetic | 531 // Update the cursor's root location. This ends up dispatching a synthetic |
530 // mouse move. The synthetic mouse move updates the composited cursor's | 532 // mouse move. The synthetic mouse move updates the composited cursor's |
531 // location and hover effects. Synthetic mouse moves do not affect the | 533 // location and hover effects. Synthetic mouse moves do not affect the |
532 // cursor's visibility. | 534 // cursor's visibility. |
533 dst_root_window->GetHost()->dispatcher()->OnCursorMovedToRootLocation( | 535 dst_root_window->GetHost()->dispatcher()->OnCursorMovedToRootLocation( |
534 target_location_in_root); | 536 target_location_in_root); |
535 } | 537 } |
536 #else | 538 #else |
537 dst_root_window->MoveCursorTo(target_location_in_root); | 539 dst_root_window->MoveCursorTo(target_location_in_root); |
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
806 AshWindowTreeHost* WindowTreeHostManager::AddWindowTreeHostForDisplay( | 808 AshWindowTreeHost* WindowTreeHostManager::AddWindowTreeHostForDisplay( |
807 const display::Display& display, | 809 const display::Display& display, |
808 const AshWindowTreeHostInitParams& init_params) { | 810 const AshWindowTreeHostInitParams& init_params) { |
809 static int host_count = 0; | 811 static int host_count = 0; |
810 const display::ManagedDisplayInfo& display_info = | 812 const display::ManagedDisplayInfo& display_info = |
811 GetDisplayManager()->GetDisplayInfo(display.id()); | 813 GetDisplayManager()->GetDisplayInfo(display.id()); |
812 AshWindowTreeHostInitParams params_with_bounds(init_params); | 814 AshWindowTreeHostInitParams params_with_bounds(init_params); |
813 params_with_bounds.initial_bounds = display_info.bounds_in_native(); | 815 params_with_bounds.initial_bounds = display_info.bounds_in_native(); |
814 params_with_bounds.offscreen = | 816 params_with_bounds.offscreen = |
815 display.id() == display::DisplayManager::kUnifiedDisplayId; | 817 display.id() == display::DisplayManager::kUnifiedDisplayId; |
| 818 params_with_bounds.display_id = display.id(); |
| 819 params_with_bounds.device_scale_factor = display.device_scale_factor(); |
| 820 params_with_bounds.ui_scale_factor = display_info.configured_ui_scale(); |
816 // The AshWindowTreeHost ends up owned by the RootWindowControllers created | 821 // The AshWindowTreeHost ends up owned by the RootWindowControllers created |
817 // by this class. | 822 // by this class. |
818 AshWindowTreeHost* ash_host = | 823 AshWindowTreeHost* ash_host = |
819 AshWindowTreeHost::Create(params_with_bounds).release(); | 824 AshWindowTreeHost::Create(params_with_bounds).release(); |
820 aura::WindowTreeHost* host = ash_host->AsWindowTreeHost(); | 825 aura::WindowTreeHost* host = ash_host->AsWindowTreeHost(); |
821 if (!input_method_) { // Singleton input method instance for Ash. | 826 if (!host->has_input_method()) { |
822 input_method_ = ui::CreateInputMethod(this, host->GetAcceleratedWidget()); | 827 if (!input_method_) { // Singleton input method instance for Ash. |
823 // Makes sure the input method is focused by default when created, because | 828 input_method_ = ui::CreateInputMethod(this, host->GetAcceleratedWidget()); |
824 // Ash uses singleton InputMethod and it won't call OnFocus/OnBlur when the | 829 // Makes sure the input method is focused by default when created, because |
825 // active window changed. | 830 // Ash uses singleton InputMethod and it won't call OnFocus/OnBlur when |
826 input_method_->OnFocus(); | 831 // the active window changed. |
827 input_method_event_handler_.reset( | 832 input_method_->OnFocus(); |
828 new InputMethodEventHandler(input_method_.get())); | 833 input_method_event_handler_.reset( |
| 834 new InputMethodEventHandler(input_method_.get())); |
| 835 } |
| 836 host->SetSharedInputMethod(input_method_.get()); |
| 837 // XXX figure this out! |
| 838 ash_host->set_input_method_handler(input_method_event_handler_.get()); |
829 } | 839 } |
830 host->SetSharedInputMethod(input_method_.get()); | |
831 ash_host->set_input_method_handler(input_method_event_handler_.get()); | |
832 | 840 |
833 host->window()->SetName(base::StringPrintf( | 841 host->window()->SetName(base::StringPrintf( |
834 "%sRootWindow-%d", params_with_bounds.offscreen ? "Offscreen" : "", | 842 "%sRootWindow-%d", params_with_bounds.offscreen ? "Offscreen" : "", |
835 host_count++)); | 843 host_count++)); |
836 host->window()->SetTitle(base::UTF8ToUTF16(display_info.name())); | 844 host->window()->SetTitle(base::UTF8ToUTF16(display_info.name())); |
837 host->compositor()->SetBackgroundColor(SK_ColorBLACK); | 845 host->compositor()->SetBackgroundColor(SK_ColorBLACK); |
838 // No need to remove our observer observer because the WindowTreeHostManager | 846 // No need to remove our observer observer because the WindowTreeHostManager |
839 // outlives the host. | 847 // outlives the host. |
840 host->AddObserver(this); | 848 host->AddObserver(this); |
841 InitRootWindowSettings(host->window())->display_id = display.id(); | 849 InitRootWindowSettings(host->window())->display_id = display.id(); |
842 host->InitHost(); | 850 host->InitHost(); |
843 host->window()->Show(); | 851 host->window()->Show(); |
844 | 852 |
845 window_tree_hosts_[display.id()] = ash_host; | 853 window_tree_hosts_[display.id()] = ash_host; |
846 SetDisplayPropertiesOnHost(ash_host, display); | 854 SetDisplayPropertiesOnHost(ash_host, display); |
847 | 855 |
848 if (switches::ConstrainPointerToRoot()) | 856 if (switches::ConstrainPointerToRoot()) |
849 ash_host->ConfineCursorToRootWindow(); | 857 ash_host->ConfineCursorToRootWindow(); |
850 return ash_host; | 858 return ash_host; |
851 } | 859 } |
852 | 860 |
853 } // namespace ash | 861 } // namespace ash |
OLD | NEW |