OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/host/ash_window_tree_host.h" | 5 #include "ash/host/ash_window_tree_host.h" |
6 | 6 |
7 #include "ash/host/ash_window_tree_host_init_params.h" | 7 #include "ash/host/ash_window_tree_host_init_params.h" |
8 #include "ash/host/ash_window_tree_host_unified.h" | 8 #include "ash/host/ash_window_tree_host_unified.h" |
9 #include "base/lazy_instance.h" | |
10 #include "ui/aura/client/screen_position_client.h" | 9 #include "ui/aura/client/screen_position_client.h" |
11 #include "ui/aura/window_tree_host.h" | 10 #include "ui/aura/window_tree_host.h" |
12 #include "ui/events/event.h" | 11 #include "ui/events/event.h" |
13 #include "ui/gfx/geometry/rect.h" | 12 #include "ui/gfx/geometry/rect.h" |
14 | 13 |
15 #if defined(USE_OZONE) | 14 #if defined(USE_OZONE) |
16 #include "ash/host/ash_window_tree_host_platform.h" | 15 #include "ash/host/ash_window_tree_host_platform.h" |
17 #elif defined(USE_X11) | 16 #elif defined(USE_X11) |
18 #include "ash/host/ash_window_tree_host_x11.h" | 17 #include "ash/host/ash_window_tree_host_x11.h" |
19 #elif defined(OS_WIN) | |
20 #include "ash/host/ash_window_tree_host_win.h" | |
21 #endif | 18 #endif |
22 | 19 |
23 namespace ash { | 20 namespace ash { |
24 | 21 |
25 namespace { | |
26 | |
27 base::LazyInstance<AshWindowTreeHost::Factory> creation_factory = | |
28 LAZY_INSTANCE_INITIALIZER; | |
29 | |
30 } // namespace | |
31 | |
32 AshWindowTreeHost::AshWindowTreeHost() : input_method_handler_(nullptr) {} | 22 AshWindowTreeHost::AshWindowTreeHost() : input_method_handler_(nullptr) {} |
33 | 23 |
34 void AshWindowTreeHost::TranslateLocatedEvent(ui::LocatedEvent* event) { | 24 void AshWindowTreeHost::TranslateLocatedEvent(ui::LocatedEvent* event) { |
35 if (event->IsTouchEvent()) | 25 if (event->IsTouchEvent()) |
36 return; | 26 return; |
37 | 27 |
38 aura::WindowTreeHost* wth = AsWindowTreeHost(); | 28 aura::WindowTreeHost* wth = AsWindowTreeHost(); |
39 aura::Window* root_window = wth->window(); | 29 aura::Window* root_window = wth->window(); |
40 aura::client::ScreenPositionClient* screen_position_client = | 30 aura::client::ScreenPositionClient* screen_position_client = |
41 aura::client::GetScreenPositionClient(root_window); | 31 aura::client::GetScreenPositionClient(root_window); |
(...skipping 10 matching lines...) Expand all Loading... |
52 screen_position_client->ConvertPointFromScreen(root_window, &location); | 42 screen_position_client->ConvertPointFromScreen(root_window, &location); |
53 wth->ConvertDIPToPixels(&location); | 43 wth->ConvertDIPToPixels(&location); |
54 event->set_location(location); | 44 event->set_location(location); |
55 event->set_root_location(location); | 45 event->set_root_location(location); |
56 } | 46 } |
57 } | 47 } |
58 | 48 |
59 // static | 49 // static |
60 AshWindowTreeHost* AshWindowTreeHost::Create( | 50 AshWindowTreeHost* AshWindowTreeHost::Create( |
61 const AshWindowTreeHostInitParams& init_params) { | 51 const AshWindowTreeHostInitParams& init_params) { |
62 if (!creation_factory.Get().is_null()) | |
63 return creation_factory.Get().Run(init_params); | |
64 | |
65 if (init_params.offscreen) | 52 if (init_params.offscreen) |
66 return new AshWindowTreeHostUnified(init_params.initial_bounds); | 53 return new AshWindowTreeHostUnified(init_params.initial_bounds); |
67 #if defined(USE_OZONE) | 54 #if defined(USE_OZONE) |
68 return new AshWindowTreeHostPlatform(init_params.initial_bounds); | 55 return new AshWindowTreeHostPlatform(init_params.initial_bounds); |
69 #elif defined(USE_X11) | 56 #elif defined(USE_X11) |
70 return new AshWindowTreeHostX11(init_params.initial_bounds); | 57 return new AshWindowTreeHostX11(init_params.initial_bounds); |
71 #elif defined(OS_WIN) | |
72 return new AshWindowTreeHostWin(init_params.initial_bounds); | |
73 #else | 58 #else |
74 #error Unsupported platform. | 59 #error Unsupported platform. |
75 #endif | 60 #endif |
76 } | 61 } |
77 | 62 |
78 // static | |
79 void AshWindowTreeHost::SetFactory(const Factory& factory) { | |
80 creation_factory.Get() = factory; | |
81 } | |
82 | |
83 } // namespace ash | 63 } // namespace ash |
OLD | NEW |