| 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 |
| 11 #include "ash/ash_switches.h" | 11 #include "ash/ash_switches.h" |
| 12 #include "ash/display/cursor_window_controller.h" | 12 #include "ash/display/cursor_window_controller.h" |
| 13 #include "ash/display/display_layout_store.h" | 13 #include "ash/display/display_layout_store.h" |
| 14 #include "ash/display/display_manager.h" | 14 #include "ash/display/display_manager.h" |
| 15 #include "ash/display/mirror_window_controller.h" | 15 #include "ash/display/mirror_window_controller.h" |
| 16 #include "ash/display/root_window_transformers.h" | 16 #include "ash/display/root_window_transformers.h" |
| 17 #include "ash/host/ash_window_tree_host.h" | 17 #include "ash/host/ash_window_tree_host.h" |
| 18 #include "ash/host/ash_window_tree_host_init_params.h" | 18 #include "ash/host/ash_window_tree_host_init_params.h" |
| 19 #include "ash/host/root_window_transformer.h" | 19 #include "ash/host/root_window_transformer.h" |
| 20 #include "ash/magnifier/magnification_controller.h" | 20 #include "ash/magnifier/magnification_controller.h" |
| 21 #include "ash/magnifier/partial_magnification_controller.h" | 21 #include "ash/magnifier/partial_magnification_controller.h" |
| 22 #include "ash/root_window_controller.h" | 22 #include "ash/root_window_controller.h" |
| 23 #include "ash/root_window_settings.h" | 23 #include "ash/root_window_settings.h" |
| 24 #include "ash/screen_util.h" | 24 #include "ash/screen_util.h" |
| 25 #include "ash/shell.h" | 25 #include "ash/shell.h" |
| 26 #include "ash/shell_delegate.h" | 26 #include "ash/shell_delegate.h" |
| 27 #include "ash/system/tray/system_tray.h" | 27 #include "ash/system/tray/system_tray.h" |
| 28 #include "ash/wm/coordinate_conversion.h" | 28 #include "ash/wm/coordinate_conversion.h" |
| 29 #include "ash/wm/window_util.h" |
| 29 #include "base/command_line.h" | 30 #include "base/command_line.h" |
| 30 #include "base/stl_util.h" | 31 #include "base/stl_util.h" |
| 31 #include "base/strings/stringprintf.h" | 32 #include "base/strings/stringprintf.h" |
| 32 #include "base/strings/utf_string_conversions.h" | 33 #include "base/strings/utf_string_conversions.h" |
| 33 #include "ui/aura/client/capture_client.h" | 34 #include "ui/aura/client/capture_client.h" |
| 34 #include "ui/aura/client/focus_client.h" | 35 #include "ui/aura/client/focus_client.h" |
| 35 #include "ui/aura/client/screen_position_client.h" | 36 #include "ui/aura/client/screen_position_client.h" |
| 36 #include "ui/aura/window.h" | 37 #include "ui/aura/window.h" |
| 37 #include "ui/aura/window_event_dispatcher.h" | 38 #include "ui/aura/window_event_dispatcher.h" |
| 38 #include "ui/aura/window_property.h" | 39 #include "ui/aura/window_property.h" |
| 39 #include "ui/aura/window_tracker.h" | 40 #include "ui/aura/window_tracker.h" |
| 40 #include "ui/aura/window_tree_host.h" | 41 #include "ui/aura/window_tree_host.h" |
| 42 #include "ui/base/ime/input_method_factory.h" |
| 41 #include "ui/compositor/compositor.h" | 43 #include "ui/compositor/compositor.h" |
| 42 #include "ui/gfx/display.h" | 44 #include "ui/gfx/display.h" |
| 43 #include "ui/gfx/screen.h" | 45 #include "ui/gfx/screen.h" |
| 44 #include "ui/wm/core/coordinate_conversion.h" | 46 #include "ui/wm/core/coordinate_conversion.h" |
| 45 #include "ui/wm/public/activation_client.h" | 47 #include "ui/wm/public/activation_client.h" |
| 46 | 48 |
| 47 #if defined(OS_CHROMEOS) | 49 #if defined(OS_CHROMEOS) |
| 48 #include "ash/display/display_configurator_animation.h" | 50 #include "ash/display/display_configurator_animation.h" |
| 49 #include "base/sys_info.h" | 51 #include "base/sys_info.h" |
| 50 #include "base/time/time.h" | 52 #include "base/time/time.h" |
| (...skipping 809 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 860 // doesn't exist, or b) the primary_id has already been | 862 // doesn't exist, or b) the primary_id has already been |
| 861 // set to the same and didn't update it. | 863 // set to the same and didn't update it. |
| 862 layout_store->UpdatePrimaryDisplayId( | 864 layout_store->UpdatePrimaryDisplayId( |
| 863 pair, Shell::GetScreen()->GetPrimaryDisplay().id()); | 865 pair, Shell::GetScreen()->GetPrimaryDisplay().id()); |
| 864 } | 866 } |
| 865 } | 867 } |
| 866 FOR_EACH_OBSERVER(Observer, observers_, OnDisplayConfigurationChanged()); | 868 FOR_EACH_OBSERVER(Observer, observers_, OnDisplayConfigurationChanged()); |
| 867 UpdateMouseLocationAfterDisplayChange(); | 869 UpdateMouseLocationAfterDisplayChange(); |
| 868 } | 870 } |
| 869 | 871 |
| 872 bool DisplayController::DispatchKeyEventPostIME(const ui::KeyEvent& event) { |
| 873 aura::Window* root_window = wm::GetActiveWindow(); |
| 874 if (root_window) |
| 875 root_window = root_window->GetRootWindow(); |
| 876 if (!root_window) |
| 877 root_window = Shell::GetTargetRootWindow(); |
| 878 return root_window->GetHost()->DispatchKeyEventPostIME(event); |
| 879 } |
| 880 |
| 870 AshWindowTreeHost* DisplayController::AddWindowTreeHostForDisplay( | 881 AshWindowTreeHost* DisplayController::AddWindowTreeHostForDisplay( |
| 871 const gfx::Display& display, | 882 const gfx::Display& display, |
| 872 const AshWindowTreeHostInitParams& init_params) { | 883 const AshWindowTreeHostInitParams& init_params) { |
| 873 static int host_count = 0; | 884 static int host_count = 0; |
| 874 const DisplayInfo& display_info = | 885 const DisplayInfo& display_info = |
| 875 GetDisplayManager()->GetDisplayInfo(display.id()); | 886 GetDisplayManager()->GetDisplayInfo(display.id()); |
| 876 AshWindowTreeHostInitParams params_with_bounds(init_params); | 887 AshWindowTreeHostInitParams params_with_bounds(init_params); |
| 877 params_with_bounds.initial_bounds = display_info.bounds_in_native(); | 888 params_with_bounds.initial_bounds = display_info.bounds_in_native(); |
| 878 params_with_bounds.offscreen = | 889 params_with_bounds.offscreen = |
| 879 display.id() == DisplayManager::kUnifiedDisplayId; | 890 display.id() == DisplayManager::kUnifiedDisplayId; |
| 880 AshWindowTreeHost* ash_host = AshWindowTreeHost::Create(params_with_bounds); | 891 AshWindowTreeHost* ash_host = AshWindowTreeHost::Create(params_with_bounds); |
| 881 aura::WindowTreeHost* host = ash_host->AsWindowTreeHost(); | 892 aura::WindowTreeHost* host = ash_host->AsWindowTreeHost(); |
| 893 if (!input_method_) { // Singleton input method instance for Ash. |
| 894 input_method_ = ui::CreateInputMethod(this, host->GetAcceleratedWidget()); |
| 895 input_method_->OnFocus(); |
| 896 } |
| 897 host->SetInputMethod(input_method_.get()); |
| 882 | 898 |
| 883 host->window()->SetName(base::StringPrintf( | 899 host->window()->SetName(base::StringPrintf( |
| 884 "%sRootWindow-%d", params_with_bounds.offscreen ? "Offscreen" : "", | 900 "%sRootWindow-%d", params_with_bounds.offscreen ? "Offscreen" : "", |
| 885 host_count++)); | 901 host_count++)); |
| 886 host->window()->SetTitle(base::UTF8ToUTF16(display_info.name())); | 902 host->window()->SetTitle(base::UTF8ToUTF16(display_info.name())); |
| 887 host->compositor()->SetBackgroundColor(SK_ColorBLACK); | 903 host->compositor()->SetBackgroundColor(SK_ColorBLACK); |
| 888 // No need to remove our observer observer because the DisplayController | 904 // No need to remove our observer observer because the DisplayController |
| 889 // outlives the host. | 905 // outlives the host. |
| 890 host->AddObserver(this); | 906 host->AddObserver(this); |
| 891 InitRootWindowSettings(host->window())->display_id = display.id(); | 907 InitRootWindowSettings(host->window())->display_id = display.id(); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 907 Shell::GetInstance()->display_configurator_animation() | 923 Shell::GetInstance()->display_configurator_animation() |
| 908 ->StartFadeInAnimation(); | 924 ->StartFadeInAnimation(); |
| 909 #endif | 925 #endif |
| 910 } | 926 } |
| 911 | 927 |
| 912 void DisplayController::SetMirrorModeAfterAnimation(bool mirror) { | 928 void DisplayController::SetMirrorModeAfterAnimation(bool mirror) { |
| 913 GetDisplayManager()->SetMirrorMode(mirror); | 929 GetDisplayManager()->SetMirrorMode(mirror); |
| 914 } | 930 } |
| 915 | 931 |
| 916 } // namespace ash | 932 } // namespace ash |
| OLD | NEW |