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/ash_switches.h" | 13 #include "ash/ash_switches.h" |
14 #include "ash/display/cursor_window_controller.h" | 14 #include "ash/display/cursor_window_controller.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/ime/input_method_event_handler.h" | |
21 #include "ash/magnifier/magnification_controller.h" | 20 #include "ash/magnifier/magnification_controller.h" |
22 #include "ash/magnifier/partial_magnification_controller.h" | 21 #include "ash/magnifier/partial_magnification_controller.h" |
23 #include "ash/public/cpp/config.h" | 22 #include "ash/public/cpp/config.h" |
24 #include "ash/root_window_controller.h" | 23 #include "ash/root_window_controller.h" |
25 #include "ash/root_window_settings.h" | 24 #include "ash/root_window_settings.h" |
26 #include "ash/shell.h" | 25 #include "ash/shell.h" |
27 #include "ash/system/tray/system_tray.h" | 26 #include "ash/system/tray/system_tray.h" |
28 #include "ash/wm/window_util.h" | 27 #include "ash/wm/window_util.h" |
29 #include "base/command_line.h" | 28 #include "base/command_line.h" |
30 #include "base/strings/stringprintf.h" | 29 #include "base/strings/stringprintf.h" |
(...skipping 802 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
833 // When using IME service, input method is hosted by the browser process, so | 832 // When using IME service, input method is hosted by the browser process, so |
834 // we don't need to create and set it here. | 833 // we don't need to create and set it here. |
835 if (!Shell::ShouldUseIMEService()) { | 834 if (!Shell::ShouldUseIMEService()) { |
836 DCHECK(!host->has_input_method()); | 835 DCHECK(!host->has_input_method()); |
837 if (!input_method_) { // Singleton input method instance for Ash. | 836 if (!input_method_) { // Singleton input method instance for Ash. |
838 input_method_ = ui::CreateInputMethod(this, host->GetAcceleratedWidget()); | 837 input_method_ = ui::CreateInputMethod(this, host->GetAcceleratedWidget()); |
839 // Makes sure the input method is focused by default when created, because | 838 // Makes sure the input method is focused by default when created, because |
840 // Ash uses singleton InputMethod and it won't call OnFocus/OnBlur when | 839 // Ash uses singleton InputMethod and it won't call OnFocus/OnBlur when |
841 // the active window changed. | 840 // the active window changed. |
842 input_method_->OnFocus(); | 841 input_method_->OnFocus(); |
843 input_method_event_handler_.reset( | |
844 new InputMethodEventHandler(input_method_.get())); | |
845 } | 842 } |
846 host->SetSharedInputMethod(input_method_.get()); | 843 host->SetSharedInputMethod(input_method_.get()); |
847 ash_host->set_input_method_handler(input_method_event_handler_.get()); | |
848 } | 844 } |
849 | 845 |
850 host->window()->SetName(base::StringPrintf( | 846 host->window()->SetName(base::StringPrintf( |
851 "%sRootWindow-%d", params_with_bounds.offscreen ? "Offscreen" : "", | 847 "%sRootWindow-%d", params_with_bounds.offscreen ? "Offscreen" : "", |
852 host_count++)); | 848 host_count++)); |
853 host->window()->SetTitle(base::UTF8ToUTF16(display_info.name())); | 849 host->window()->SetTitle(base::UTF8ToUTF16(display_info.name())); |
854 host->compositor()->SetBackgroundColor(SK_ColorBLACK); | 850 host->compositor()->SetBackgroundColor(SK_ColorBLACK); |
855 // No need to remove our observer observer because the WindowTreeHostManager | 851 // No need to remove our observer observer because the WindowTreeHostManager |
856 // outlives the host. | 852 // outlives the host. |
857 host->AddObserver(this); | 853 host->AddObserver(this); |
858 InitRootWindowSettings(host->window())->display_id = display.id(); | 854 InitRootWindowSettings(host->window())->display_id = display.id(); |
859 host->InitHost(); | 855 host->InitHost(); |
860 host->window()->Show(); | 856 host->window()->Show(); |
861 | 857 |
862 window_tree_hosts_[display.id()] = ash_host; | 858 window_tree_hosts_[display.id()] = ash_host; |
863 SetDisplayPropertiesOnHost(ash_host, display); | 859 SetDisplayPropertiesOnHost(ash_host, display); |
864 | 860 |
865 if (switches::ConstrainPointerToRoot()) | 861 if (switches::ConstrainPointerToRoot()) |
866 ash_host->ConfineCursorToRootWindow(); | 862 ash_host->ConfineCursorToRootWindow(); |
867 return ash_host; | 863 return ash_host; |
868 } | 864 } |
869 | 865 |
870 } // namespace ash | 866 } // namespace ash |
OLD | NEW |