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