| 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> |
| 11 #include <utility> | 11 #include <utility> |
| 12 | 12 |
| 13 #include "ash/common/ash_switches.h" | 13 #include "ash/common/ash_switches.h" |
| 14 #include "ash/common/system/tray/system_tray.h" | 14 #include "ash/common/system/tray/system_tray.h" |
| 15 #include "ash/display/cursor_window_controller.h" | 15 #include "ash/display/cursor_window_controller.h" |
| 16 #include "ash/display/display_manager.h" | |
| 17 #include "ash/display/mirror_window_controller.h" | 16 #include "ash/display/mirror_window_controller.h" |
| 18 #include "ash/display/root_window_transformers.h" | 17 #include "ash/display/root_window_transformers.h" |
| 19 #include "ash/host/ash_window_tree_host.h" | 18 #include "ash/host/ash_window_tree_host.h" |
| 20 #include "ash/host/ash_window_tree_host_init_params.h" | 19 #include "ash/host/ash_window_tree_host_init_params.h" |
| 21 #include "ash/host/root_window_transformer.h" | 20 #include "ash/host/root_window_transformer.h" |
| 22 #include "ash/ime/input_method_event_handler.h" | 21 #include "ash/ime/input_method_event_handler.h" |
| 23 #include "ash/magnifier/magnification_controller.h" | 22 #include "ash/magnifier/magnification_controller.h" |
| 24 #include "ash/magnifier/partial_magnification_controller.h" | 23 #include "ash/magnifier/partial_magnification_controller.h" |
| 25 #include "ash/root_window_controller.h" | 24 #include "ash/root_window_controller.h" |
| 26 #include "ash/root_window_settings.h" | 25 #include "ash/root_window_settings.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 38 #include "ui/aura/window_event_dispatcher.h" | 37 #include "ui/aura/window_event_dispatcher.h" |
| 39 #include "ui/aura/window_property.h" | 38 #include "ui/aura/window_property.h" |
| 40 #include "ui/aura/window_tracker.h" | 39 #include "ui/aura/window_tracker.h" |
| 41 #include "ui/aura/window_tree_host.h" | 40 #include "ui/aura/window_tree_host.h" |
| 42 #include "ui/base/ime/input_method_factory.h" | 41 #include "ui/base/ime/input_method_factory.h" |
| 43 #include "ui/base/l10n/l10n_util.h" | 42 #include "ui/base/l10n/l10n_util.h" |
| 44 #include "ui/compositor/compositor.h" | 43 #include "ui/compositor/compositor.h" |
| 45 #include "ui/display/display.h" | 44 #include "ui/display/display.h" |
| 46 #include "ui/display/manager/display_layout.h" | 45 #include "ui/display/manager/display_layout.h" |
| 47 #include "ui/display/manager/display_layout_store.h" | 46 #include "ui/display/manager/display_layout_store.h" |
| 47 #include "ui/display/manager/display_manager.h" |
| 48 #include "ui/display/screen.h" | 48 #include "ui/display/screen.h" |
| 49 #include "ui/wm/core/coordinate_conversion.h" | 49 #include "ui/wm/core/coordinate_conversion.h" |
| 50 #include "ui/wm/public/activation_client.h" | 50 #include "ui/wm/public/activation_client.h" |
| 51 | 51 |
| 52 #if defined(USE_X11) | 52 #if defined(USE_X11) |
| 53 #include "ui/base/x/x11_util.h" // nogncheck | 53 #include "ui/base/x/x11_util.h" // nogncheck |
| 54 #include "ui/gfx/x/x11_types.h" // nogncheck | 54 #include "ui/gfx/x/x11_types.h" // nogncheck |
| 55 | 55 |
| 56 // Including this at the bottom to avoid other | 56 // Including this at the bottom to avoid other |
| 57 // potential conflict with chrome headers. | 57 // potential conflict with chrome headers. |
| (...skipping 13 matching lines...) Expand all Loading... |
| 71 // during the shutdown instead of always keeping two display instances | 71 // during the shutdown instead of always keeping two display instances |
| 72 // (one here and another one in display_manager) in sync, which is error prone. | 72 // (one here and another one in display_manager) in sync, which is error prone. |
| 73 // This is initialized in the constructor, and then in CreatePrimaryHost(). | 73 // This is initialized in the constructor, and then in CreatePrimaryHost(). |
| 74 int64_t primary_display_id = -1; | 74 int64_t primary_display_id = -1; |
| 75 | 75 |
| 76 #if defined(USE_OZONE) && defined(OS_CHROMEOS) | 76 #if defined(USE_OZONE) && defined(OS_CHROMEOS) |
| 77 // Add 20% more cursor motion on non-integrated displays. | 77 // Add 20% more cursor motion on non-integrated displays. |
| 78 const float kCursorMultiplierForExternalDisplays = 1.2f; | 78 const float kCursorMultiplierForExternalDisplays = 1.2f; |
| 79 #endif | 79 #endif |
| 80 | 80 |
| 81 DisplayManager* GetDisplayManager() { | 81 display::DisplayManager* GetDisplayManager() { |
| 82 return Shell::GetInstance()->display_manager(); | 82 return Shell::GetInstance()->display_manager(); |
| 83 } | 83 } |
| 84 | 84 |
| 85 void SetDisplayPropertiesOnHost(AshWindowTreeHost* ash_host, | 85 void SetDisplayPropertiesOnHost(AshWindowTreeHost* ash_host, |
| 86 const display::Display& display) { | 86 const display::Display& display) { |
| 87 display::ManagedDisplayInfo info = | 87 display::ManagedDisplayInfo info = |
| 88 GetDisplayManager()->GetDisplayInfo(display.id()); | 88 GetDisplayManager()->GetDisplayInfo(display.id()); |
| 89 aura::WindowTreeHost* host = ash_host->AsWindowTreeHost(); | 89 aura::WindowTreeHost* host = ash_host->AsWindowTreeHost(); |
| 90 #if defined(OS_CHROMEOS) | 90 #if defined(OS_CHROMEOS) |
| 91 #if defined(USE_X11) | 91 #if defined(USE_X11) |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 293 const display::Display& primary_candidate = | 293 const display::Display& primary_candidate = |
| 294 GetDisplayManager()->GetPrimaryDisplayCandidate(); | 294 GetDisplayManager()->GetPrimaryDisplayCandidate(); |
| 295 primary_display_id = primary_candidate.id(); | 295 primary_display_id = primary_candidate.id(); |
| 296 CHECK_NE(display::Display::kInvalidDisplayID, primary_display_id); | 296 CHECK_NE(display::Display::kInvalidDisplayID, primary_display_id); |
| 297 AddWindowTreeHostForDisplay(primary_candidate, init_params); | 297 AddWindowTreeHostForDisplay(primary_candidate, init_params); |
| 298 } | 298 } |
| 299 | 299 |
| 300 void WindowTreeHostManager::InitHosts() { | 300 void WindowTreeHostManager::InitHosts() { |
| 301 RootWindowController::CreateForPrimaryDisplay( | 301 RootWindowController::CreateForPrimaryDisplay( |
| 302 window_tree_hosts_[primary_display_id]); | 302 window_tree_hosts_[primary_display_id]); |
| 303 DisplayManager* display_manager = GetDisplayManager(); | 303 display::DisplayManager* display_manager = GetDisplayManager(); |
| 304 for (size_t i = 0; i < display_manager->GetNumDisplays(); ++i) { | 304 for (size_t i = 0; i < display_manager->GetNumDisplays(); ++i) { |
| 305 const display::Display& display = display_manager->GetDisplayAt(i); | 305 const display::Display& display = display_manager->GetDisplayAt(i); |
| 306 if (primary_display_id != display.id()) { | 306 if (primary_display_id != display.id()) { |
| 307 AshWindowTreeHost* ash_host = | 307 AshWindowTreeHost* ash_host = |
| 308 AddWindowTreeHostForDisplay(display, AshWindowTreeHostInitParams()); | 308 AddWindowTreeHostForDisplay(display, AshWindowTreeHostInitParams()); |
| 309 RootWindowController::CreateForSecondaryDisplay(ash_host); | 309 RootWindowController::CreateForSecondaryDisplay(ash_host); |
| 310 } | 310 } |
| 311 } | 311 } |
| 312 | 312 |
| 313 for (auto& observer : observers_) | 313 for (auto& observer : observers_) |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 405 return; | 405 return; |
| 406 | 406 |
| 407 const display::Display& new_primary_display = | 407 const display::Display& new_primary_display = |
| 408 GetDisplayManager()->GetDisplayForId(id); | 408 GetDisplayManager()->GetDisplayForId(id); |
| 409 if (!new_primary_display.is_valid()) { | 409 if (!new_primary_display.is_valid()) { |
| 410 LOG(ERROR) << "Invalid or non-existent display is requested:" | 410 LOG(ERROR) << "Invalid or non-existent display is requested:" |
| 411 << new_primary_display.ToString(); | 411 << new_primary_display.ToString(); |
| 412 return; | 412 return; |
| 413 } | 413 } |
| 414 | 414 |
| 415 DisplayManager* display_manager = GetDisplayManager(); | 415 display::DisplayManager* display_manager = GetDisplayManager(); |
| 416 DCHECK(new_primary_display.is_valid()); | 416 DCHECK(new_primary_display.is_valid()); |
| 417 DCHECK(display_manager->GetDisplayForId(new_primary_display.id()).is_valid()); | 417 DCHECK(display_manager->GetDisplayForId(new_primary_display.id()).is_valid()); |
| 418 | 418 |
| 419 AshWindowTreeHost* non_primary_host = | 419 AshWindowTreeHost* non_primary_host = |
| 420 window_tree_hosts_[new_primary_display.id()]; | 420 window_tree_hosts_[new_primary_display.id()]; |
| 421 LOG_IF(ERROR, !non_primary_host) | 421 LOG_IF(ERROR, !non_primary_host) |
| 422 << "Unknown display is requested in SetPrimaryDisplay: id=" | 422 << "Unknown display is requested in SetPrimaryDisplay: id=" |
| 423 << new_primary_display.id(); | 423 << new_primary_display.id(); |
| 424 if (!non_primary_host) | 424 if (!non_primary_host) |
| 425 return; | 425 return; |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 470 | 470 |
| 471 void WindowTreeHostManager::UpdateMouseLocationAfterDisplayChange() { | 471 void WindowTreeHostManager::UpdateMouseLocationAfterDisplayChange() { |
| 472 // If the mouse is currently on a display in native location, | 472 // If the mouse is currently on a display in native location, |
| 473 // use the same native location. Otherwise find the display closest | 473 // use the same native location. Otherwise find the display closest |
| 474 // to the current cursor location in screen coordinates. | 474 // to the current cursor location in screen coordinates. |
| 475 | 475 |
| 476 gfx::Point point_in_screen = | 476 gfx::Point point_in_screen = |
| 477 display::Screen::GetScreen()->GetCursorScreenPoint(); | 477 display::Screen::GetScreen()->GetCursorScreenPoint(); |
| 478 gfx::Point target_location_in_native; | 478 gfx::Point target_location_in_native; |
| 479 int64_t closest_distance_squared = -1; | 479 int64_t closest_distance_squared = -1; |
| 480 DisplayManager* display_manager = GetDisplayManager(); | 480 display::DisplayManager* display_manager = GetDisplayManager(); |
| 481 | 481 |
| 482 aura::Window* dst_root_window = nullptr; | 482 aura::Window* dst_root_window = nullptr; |
| 483 for (size_t i = 0; i < display_manager->GetNumDisplays(); ++i) { | 483 for (size_t i = 0; i < display_manager->GetNumDisplays(); ++i) { |
| 484 const display::Display& display = display_manager->GetDisplayAt(i); | 484 const display::Display& display = display_manager->GetDisplayAt(i); |
| 485 const display::ManagedDisplayInfo display_info = | 485 const display::ManagedDisplayInfo display_info = |
| 486 display_manager->GetDisplayInfo(display.id()); | 486 display_manager->GetDisplayInfo(display.id()); |
| 487 aura::Window* root_window = GetRootWindowForDisplayId(display.id()); | 487 aura::Window* root_window = GetRootWindowForDisplayId(display.id()); |
| 488 if (display_info.bounds_in_native().Contains( | 488 if (display_info.bounds_in_native().Contains( |
| 489 cursor_location_in_native_coords_for_restore_)) { | 489 cursor_location_in_native_coords_for_restore_)) { |
| 490 dst_root_window = root_window; | 490 dst_root_window = root_window; |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 564 DCHECK(id != display::Display::kInvalidDisplayID); | 564 DCHECK(id != display::Display::kInvalidDisplayID); |
| 565 return GetDisplayManager()->UpdateWorkAreaOfDisplay(id, insets); | 565 return GetDisplayManager()->UpdateWorkAreaOfDisplay(id, insets); |
| 566 } | 566 } |
| 567 | 567 |
| 568 void WindowTreeHostManager::OnDisplayAdded(const display::Display& display) { | 568 void WindowTreeHostManager::OnDisplayAdded(const display::Display& display) { |
| 569 #if defined(OS_CHROMEOS) | 569 #if defined(OS_CHROMEOS) |
| 570 // If we're switching from/to offscreen WTH, we need to | 570 // If we're switching from/to offscreen WTH, we need to |
| 571 // create new WTH for primary display instead of reusing. | 571 // create new WTH for primary display instead of reusing. |
| 572 if (primary_tree_host_for_replace_ && | 572 if (primary_tree_host_for_replace_ && |
| 573 (GetRootWindowSettings(GetWindow(primary_tree_host_for_replace_)) | 573 (GetRootWindowSettings(GetWindow(primary_tree_host_for_replace_)) |
| 574 ->display_id == DisplayManager::kUnifiedDisplayId || | 574 ->display_id == display::DisplayManager::kUnifiedDisplayId || |
| 575 display.id() == DisplayManager::kUnifiedDisplayId)) { | 575 display.id() == display::DisplayManager::kUnifiedDisplayId)) { |
| 576 DCHECK_EQ(display::Display::kInvalidDisplayID, primary_display_id); | 576 DCHECK_EQ(display::Display::kInvalidDisplayID, primary_display_id); |
| 577 primary_display_id = display.id(); | 577 primary_display_id = display.id(); |
| 578 | 578 |
| 579 AshWindowTreeHost* ash_host = | 579 AshWindowTreeHost* ash_host = |
| 580 AddWindowTreeHostForDisplay(display, AshWindowTreeHostInitParams()); | 580 AddWindowTreeHostForDisplay(display, AshWindowTreeHostInitParams()); |
| 581 RootWindowController::CreateForSecondaryDisplay(ash_host); | 581 RootWindowController::CreateForSecondaryDisplay(ash_host); |
| 582 | 582 |
| 583 // Magnifier controllers keep pointers to the current root window. | 583 // Magnifier controllers keep pointers to the current root window. |
| 584 // Update them here to avoid accessing them later. | 584 // Update them here to avoid accessing them later. |
| 585 Shell::GetInstance()->magnification_controller()->SwitchTargetRootWindow( | 585 Shell::GetInstance()->magnification_controller()->SwitchTargetRootWindow( |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 713 AshWindowTreeHost* ash_host = window_tree_hosts_[display.id()]; | 713 AshWindowTreeHost* ash_host = window_tree_hosts_[display.id()]; |
| 714 ash_host->AsWindowTreeHost()->SetBounds(display_info.bounds_in_native()); | 714 ash_host->AsWindowTreeHost()->SetBounds(display_info.bounds_in_native()); |
| 715 SetDisplayPropertiesOnHost(ash_host, display); | 715 SetDisplayPropertiesOnHost(ash_host, display); |
| 716 } | 716 } |
| 717 | 717 |
| 718 void WindowTreeHostManager::OnHostResized(const aura::WindowTreeHost* host) { | 718 void WindowTreeHostManager::OnHostResized(const aura::WindowTreeHost* host) { |
| 719 display::Display display = | 719 display::Display display = |
| 720 display::Screen::GetScreen()->GetDisplayNearestWindow( | 720 display::Screen::GetScreen()->GetDisplayNearestWindow( |
| 721 const_cast<aura::Window*>(host->window())); | 721 const_cast<aura::Window*>(host->window())); |
| 722 | 722 |
| 723 DisplayManager* display_manager = GetDisplayManager(); | 723 display::DisplayManager* display_manager = GetDisplayManager(); |
| 724 if (display_manager->UpdateDisplayBounds(display.id(), host->GetBounds())) { | 724 if (display_manager->UpdateDisplayBounds(display.id(), host->GetBounds())) { |
| 725 mirror_window_controller_->UpdateWindow(); | 725 mirror_window_controller_->UpdateWindow(); |
| 726 cursor_window_controller_->UpdateContainer(); | 726 cursor_window_controller_->UpdateContainer(); |
| 727 } | 727 } |
| 728 } | 728 } |
| 729 | 729 |
| 730 void WindowTreeHostManager::CreateOrUpdateMirroringDisplay( | 730 void WindowTreeHostManager::CreateOrUpdateMirroringDisplay( |
| 731 const DisplayInfoList& info_list) { | 731 const display::DisplayInfoList& info_list) { |
| 732 if (GetDisplayManager()->IsInMirrorMode() || | 732 if (GetDisplayManager()->IsInMirrorMode() || |
| 733 GetDisplayManager()->IsInUnifiedMode()) { | 733 GetDisplayManager()->IsInUnifiedMode()) { |
| 734 mirror_window_controller_->UpdateWindow(info_list); | 734 mirror_window_controller_->UpdateWindow(info_list); |
| 735 cursor_window_controller_->UpdateContainer(); | 735 cursor_window_controller_->UpdateContainer(); |
| 736 } else { | 736 } else { |
| 737 NOTREACHED(); | 737 NOTREACHED(); |
| 738 } | 738 } |
| 739 } | 739 } |
| 740 | 740 |
| 741 void WindowTreeHostManager::CloseMirroringDisplayIfNotNecessary() { | 741 void WindowTreeHostManager::CloseMirroringDisplayIfNotNecessary() { |
| (...skipping 17 matching lines...) Expand all Loading... |
| 759 display::Display display = screen->GetDisplayNearestPoint(point_in_screen); | 759 display::Display display = screen->GetDisplayNearestPoint(point_in_screen); |
| 760 cursor_display_id_for_restore_ = display.id(); | 760 cursor_display_id_for_restore_ = display.id(); |
| 761 | 761 |
| 762 gfx::Point point_in_native = point_in_screen; | 762 gfx::Point point_in_native = point_in_screen; |
| 763 aura::Window* root_window = GetRootWindowForDisplayId(display.id()); | 763 aura::Window* root_window = GetRootWindowForDisplayId(display.id()); |
| 764 ::wm::ConvertPointFromScreen(root_window, &point_in_native); | 764 ::wm::ConvertPointFromScreen(root_window, &point_in_native); |
| 765 root_window->GetHost()->ConvertPointToNativeScreen(&point_in_native); | 765 root_window->GetHost()->ConvertPointToNativeScreen(&point_in_native); |
| 766 cursor_location_in_native_coords_for_restore_ = point_in_native; | 766 cursor_location_in_native_coords_for_restore_ = point_in_native; |
| 767 } | 767 } |
| 768 | 768 |
| 769 void WindowTreeHostManager::PostDisplayConfigurationChange() { | 769 void WindowTreeHostManager::PostDisplayConfigurationChange( |
| 770 bool must_clear_window) { |
| 770 focus_activation_store_->Restore(); | 771 focus_activation_store_->Restore(); |
| 771 | 772 |
| 772 DisplayManager* display_manager = GetDisplayManager(); | 773 display::DisplayManager* display_manager = GetDisplayManager(); |
| 773 display::DisplayLayoutStore* layout_store = display_manager->layout_store(); | 774 display::DisplayLayoutStore* layout_store = display_manager->layout_store(); |
| 774 if (display_manager->num_connected_displays() > 1) { | 775 if (display_manager->num_connected_displays() > 1) { |
| 775 display::DisplayIdList list = display_manager->GetCurrentDisplayIdList(); | 776 display::DisplayIdList list = display_manager->GetCurrentDisplayIdList(); |
| 776 const display::DisplayLayout& layout = | 777 const display::DisplayLayout& layout = |
| 777 layout_store->GetRegisteredDisplayLayout(list); | 778 layout_store->GetRegisteredDisplayLayout(list); |
| 778 layout_store->UpdateMultiDisplayState( | 779 layout_store->UpdateMultiDisplayState( |
| 779 list, display_manager->IsInMirrorMode(), layout.default_unified); | 780 list, display_manager->IsInMirrorMode(), layout.default_unified); |
| 780 if (display::Screen::GetScreen()->GetNumDisplays() > 1) { | 781 if (display::Screen::GetScreen()->GetNumDisplays() > 1) { |
| 781 SetPrimaryDisplayId(layout.primary_id == | 782 SetPrimaryDisplayId(layout.primary_id == |
| 782 display::Display::kInvalidDisplayID | 783 display::Display::kInvalidDisplayID |
| 783 ? list[0] | 784 ? list[0] |
| 784 : layout.primary_id); | 785 : layout.primary_id); |
| 785 } | 786 } |
| 786 } | 787 } |
| 787 | 788 |
| 788 for (const display::Display& display : | 789 for (const display::Display& display : |
| 789 display_manager->active_display_list()) { | 790 display_manager->active_display_list()) { |
| 790 bool output_is_secure = | 791 bool output_is_secure = |
| 791 !display_manager->IsInMirrorMode() && display.IsInternal(); | 792 !display_manager->IsInMirrorMode() && display.IsInternal(); |
| 792 GetAshWindowTreeHostForDisplayId(display.id()) | 793 GetAshWindowTreeHostForDisplayId(display.id()) |
| 793 ->AsWindowTreeHost() | 794 ->AsWindowTreeHost() |
| 794 ->compositor() | 795 ->compositor() |
| 795 ->SetOutputIsSecure(output_is_secure); | 796 ->SetOutputIsSecure(output_is_secure); |
| 796 } | 797 } |
| 797 | 798 |
| 798 for (auto& observer : observers_) | 799 for (auto& observer : observers_) |
| 799 observer.OnDisplayConfigurationChanged(); | 800 observer.OnDisplayConfigurationChanged(); |
| 800 UpdateMouseLocationAfterDisplayChange(); | 801 UpdateMouseLocationAfterDisplayChange(); |
| 802 |
| 803 #if defined(USE_X11) && defined(OS_CHROMEOS) |
| 804 if (must_clear_window) |
| 805 ui::ClearX11DefaultRootWindow(); |
| 806 #endif |
| 801 } | 807 } |
| 802 | 808 |
| 803 #if defined(OS_CHROMEOS) | 809 #if defined(OS_CHROMEOS) |
| 804 ui::DisplayConfigurator* WindowTreeHostManager::display_configurator() { | 810 ui::DisplayConfigurator* WindowTreeHostManager::display_configurator() { |
| 805 return Shell::GetInstance()->display_configurator(); | 811 return Shell::GetInstance()->display_configurator(); |
| 806 } | 812 } |
| 807 #endif | 813 #endif |
| 808 | 814 |
| 809 std::string WindowTreeHostManager::GetInternalDisplayNameString() { | 815 std::string WindowTreeHostManager::GetInternalDisplayNameString() { |
| 810 return l10n_util::GetStringUTF8(IDS_ASH_INTERNAL_DISPLAY_NAME); | 816 return l10n_util::GetStringUTF8(IDS_ASH_INTERNAL_DISPLAY_NAME); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 827 | 833 |
| 828 AshWindowTreeHost* WindowTreeHostManager::AddWindowTreeHostForDisplay( | 834 AshWindowTreeHost* WindowTreeHostManager::AddWindowTreeHostForDisplay( |
| 829 const display::Display& display, | 835 const display::Display& display, |
| 830 const AshWindowTreeHostInitParams& init_params) { | 836 const AshWindowTreeHostInitParams& init_params) { |
| 831 static int host_count = 0; | 837 static int host_count = 0; |
| 832 const display::ManagedDisplayInfo& display_info = | 838 const display::ManagedDisplayInfo& display_info = |
| 833 GetDisplayManager()->GetDisplayInfo(display.id()); | 839 GetDisplayManager()->GetDisplayInfo(display.id()); |
| 834 AshWindowTreeHostInitParams params_with_bounds(init_params); | 840 AshWindowTreeHostInitParams params_with_bounds(init_params); |
| 835 params_with_bounds.initial_bounds = display_info.bounds_in_native(); | 841 params_with_bounds.initial_bounds = display_info.bounds_in_native(); |
| 836 params_with_bounds.offscreen = | 842 params_with_bounds.offscreen = |
| 837 display.id() == DisplayManager::kUnifiedDisplayId; | 843 display.id() == display::DisplayManager::kUnifiedDisplayId; |
| 838 AshWindowTreeHost* ash_host = AshWindowTreeHost::Create(params_with_bounds); | 844 AshWindowTreeHost* ash_host = AshWindowTreeHost::Create(params_with_bounds); |
| 839 aura::WindowTreeHost* host = ash_host->AsWindowTreeHost(); | 845 aura::WindowTreeHost* host = ash_host->AsWindowTreeHost(); |
| 840 if (!input_method_) { // Singleton input method instance for Ash. | 846 if (!input_method_) { // Singleton input method instance for Ash. |
| 841 input_method_ = ui::CreateInputMethod(this, host->GetAcceleratedWidget()); | 847 input_method_ = ui::CreateInputMethod(this, host->GetAcceleratedWidget()); |
| 842 // Makes sure the input method is focused by default when created, because | 848 // Makes sure the input method is focused by default when created, because |
| 843 // Ash uses singleton InputMethod and it won't call OnFocus/OnBlur when the | 849 // Ash uses singleton InputMethod and it won't call OnFocus/OnBlur when the |
| 844 // active window changed. | 850 // active window changed. |
| 845 input_method_->OnFocus(); | 851 input_method_->OnFocus(); |
| 846 input_method_event_handler_.reset( | 852 input_method_event_handler_.reset( |
| 847 new InputMethodEventHandler(input_method_.get())); | 853 new InputMethodEventHandler(input_method_.get())); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 864 SetDisplayPropertiesOnHost(ash_host, display); | 870 SetDisplayPropertiesOnHost(ash_host, display); |
| 865 | 871 |
| 866 #if defined(OS_CHROMEOS) | 872 #if defined(OS_CHROMEOS) |
| 867 if (switches::ConstrainPointerToRoot()) | 873 if (switches::ConstrainPointerToRoot()) |
| 868 ash_host->ConfineCursorToRootWindow(); | 874 ash_host->ConfineCursorToRootWindow(); |
| 869 #endif | 875 #endif |
| 870 return ash_host; | 876 return ash_host; |
| 871 } | 877 } |
| 872 | 878 |
| 873 } // namespace ash | 879 } // namespace ash |
| OLD | NEW |