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