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 20 matching lines...) Expand all Loading... | |
31 #include "base/strings/stringprintf.h" | 31 #include "base/strings/stringprintf.h" |
32 #include "base/strings/utf_string_conversions.h" | 32 #include "base/strings/utf_string_conversions.h" |
33 #include "ui/aura/client/capture_client.h" | 33 #include "ui/aura/client/capture_client.h" |
34 #include "ui/aura/client/focus_client.h" | 34 #include "ui/aura/client/focus_client.h" |
35 #include "ui/aura/client/screen_position_client.h" | 35 #include "ui/aura/client/screen_position_client.h" |
36 #include "ui/aura/window.h" | 36 #include "ui/aura/window.h" |
37 #include "ui/aura/window_event_dispatcher.h" | 37 #include "ui/aura/window_event_dispatcher.h" |
38 #include "ui/aura/window_property.h" | 38 #include "ui/aura/window_property.h" |
39 #include "ui/aura/window_tracker.h" | 39 #include "ui/aura/window_tracker.h" |
40 #include "ui/aura/window_tree_host.h" | 40 #include "ui/aura/window_tree_host.h" |
41 #include "ui/base/ime/input_method_factory.h" | |
41 #include "ui/compositor/compositor.h" | 42 #include "ui/compositor/compositor.h" |
42 #include "ui/gfx/display.h" | 43 #include "ui/gfx/display.h" |
43 #include "ui/gfx/screen.h" | 44 #include "ui/gfx/screen.h" |
44 #include "ui/wm/core/coordinate_conversion.h" | 45 #include "ui/wm/core/coordinate_conversion.h" |
45 #include "ui/wm/public/activation_client.h" | 46 #include "ui/wm/public/activation_client.h" |
46 | 47 |
47 #if defined(OS_CHROMEOS) | 48 #if defined(OS_CHROMEOS) |
48 #include "ash/display/display_configurator_animation.h" | 49 #include "ash/display/display_configurator_animation.h" |
49 #include "base/sys_info.h" | 50 #include "base/sys_info.h" |
50 #include "base/time/time.h" | 51 #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 | 861 // doesn't exist, or b) the primary_id has already been |
861 // set to the same and didn't update it. | 862 // set to the same and didn't update it. |
862 layout_store->UpdatePrimaryDisplayId( | 863 layout_store->UpdatePrimaryDisplayId( |
863 pair, Shell::GetScreen()->GetPrimaryDisplay().id()); | 864 pair, Shell::GetScreen()->GetPrimaryDisplay().id()); |
864 } | 865 } |
865 } | 866 } |
866 FOR_EACH_OBSERVER(Observer, observers_, OnDisplayConfigurationChanged()); | 867 FOR_EACH_OBSERVER(Observer, observers_, OnDisplayConfigurationChanged()); |
867 UpdateMouseLocationAfterDisplayChange(); | 868 UpdateMouseLocationAfterDisplayChange(); |
868 } | 869 } |
869 | 870 |
871 bool DisplayController::DispatchKeyEventPostIME(const ui::KeyEvent& event) { | |
872 return Shell::GetTargetRootWindow()->GetHost()->DispatchKeyEventPostIME( | |
James Cook
2015/06/02 16:29:11
Are you sure this is right? GetTargetRootWindow is
Shu Chen
2015/06/03 03:31:54
Done.
| |
873 event); | |
oshima
2015/06/02 17:35:55
James is correct. If you want to send key events t
Shu Chen
2015/06/03 03:31:54
Done.
| |
874 } | |
875 | |
870 AshWindowTreeHost* DisplayController::AddWindowTreeHostForDisplay( | 876 AshWindowTreeHost* DisplayController::AddWindowTreeHostForDisplay( |
871 const gfx::Display& display, | 877 const gfx::Display& display, |
872 const AshWindowTreeHostInitParams& init_params) { | 878 const AshWindowTreeHostInitParams& init_params) { |
873 static int host_count = 0; | 879 static int host_count = 0; |
874 const DisplayInfo& display_info = | 880 const DisplayInfo& display_info = |
875 GetDisplayManager()->GetDisplayInfo(display.id()); | 881 GetDisplayManager()->GetDisplayInfo(display.id()); |
876 AshWindowTreeHostInitParams params_with_bounds(init_params); | 882 AshWindowTreeHostInitParams params_with_bounds(init_params); |
877 params_with_bounds.initial_bounds = display_info.bounds_in_native(); | 883 params_with_bounds.initial_bounds = display_info.bounds_in_native(); |
878 params_with_bounds.offscreen = | 884 params_with_bounds.offscreen = |
879 display.id() == DisplayManager::kUnifiedDisplayId; | 885 display.id() == DisplayManager::kUnifiedDisplayId; |
880 AshWindowTreeHost* ash_host = AshWindowTreeHost::Create(params_with_bounds); | 886 AshWindowTreeHost* ash_host = AshWindowTreeHost::Create(params_with_bounds); |
881 aura::WindowTreeHost* host = ash_host->AsWindowTreeHost(); | 887 aura::WindowTreeHost* host = ash_host->AsWindowTreeHost(); |
888 if (!input_method_) { // Singleton input method instance for Ash. | |
889 input_method_ = ui::CreateInputMethod(this, host->GetAcceleratedWidget()); | |
890 input_method_->OnFocus(); | |
891 } | |
892 host->SetInputMethod(input_method_.get()); | |
882 | 893 |
883 host->window()->SetName(base::StringPrintf( | 894 host->window()->SetName(base::StringPrintf( |
884 "%sRootWindow-%d", params_with_bounds.offscreen ? "Offscreen" : "", | 895 "%sRootWindow-%d", params_with_bounds.offscreen ? "Offscreen" : "", |
885 host_count++)); | 896 host_count++)); |
886 host->window()->SetTitle(base::UTF8ToUTF16(display_info.name())); | 897 host->window()->SetTitle(base::UTF8ToUTF16(display_info.name())); |
887 host->compositor()->SetBackgroundColor(SK_ColorBLACK); | 898 host->compositor()->SetBackgroundColor(SK_ColorBLACK); |
888 // No need to remove our observer observer because the DisplayController | 899 // No need to remove our observer observer because the DisplayController |
889 // outlives the host. | 900 // outlives the host. |
890 host->AddObserver(this); | 901 host->AddObserver(this); |
891 InitRootWindowSettings(host->window())->display_id = display.id(); | 902 InitRootWindowSettings(host->window())->display_id = display.id(); |
(...skipping 15 matching lines...) Expand all Loading... | |
907 Shell::GetInstance()->display_configurator_animation() | 918 Shell::GetInstance()->display_configurator_animation() |
908 ->StartFadeInAnimation(); | 919 ->StartFadeInAnimation(); |
909 #endif | 920 #endif |
910 } | 921 } |
911 | 922 |
912 void DisplayController::SetMirrorModeAfterAnimation(bool mirror) { | 923 void DisplayController::SetMirrorModeAfterAnimation(bool mirror) { |
913 GetDisplayManager()->SetMirrorMode(mirror); | 924 GetDisplayManager()->SetMirrorMode(mirror); |
914 } | 925 } |
915 | 926 |
916 } // namespace ash | 927 } // namespace ash |
OLD | NEW |