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 "athena/env/public/athena_env.h" | 5 #include "athena/env/public/athena_env.h" |
6 | 6 |
7 #include "athena/common/fill_layout_manager.h" | 7 #include "athena/common/fill_layout_manager.h" |
8 #include "base/sys_info.h" | 8 #include "base/sys_info.h" |
9 #include "ui/aura/client/aura_constants.h" | 9 #include "ui/aura/client/aura_constants.h" |
10 #include "ui/aura/client/cursor_client.h" | 10 #include "ui/aura/client/cursor_client.h" |
(...skipping 16 matching lines...) Expand all Loading... | |
27 #include "ui/wm/core/native_cursor_manager.h" | 27 #include "ui/wm/core/native_cursor_manager.h" |
28 #include "ui/wm/core/native_cursor_manager_delegate.h" | 28 #include "ui/wm/core/native_cursor_manager_delegate.h" |
29 #include "ui/wm/core/user_activity_detector.h" | 29 #include "ui/wm/core/user_activity_detector.h" |
30 | 30 |
31 namespace athena { | 31 namespace athena { |
32 | 32 |
33 namespace { | 33 namespace { |
34 | 34 |
35 AthenaEnv* instance = NULL; | 35 AthenaEnv* instance = NULL; |
36 | 36 |
37 // Screen object used during shutdown. | |
38 gfx::Screen* screen_for_shutdown = NULL; | |
39 | |
40 class ScreenForShutdown : public gfx::Screen { | |
sadrul
2014/09/09 23:27:44
Any chance this could be consolidated with the ash
oshima
2014/09/09 23:52:46
That'll be done when we switch the display code to
| |
41 public: | |
42 // Creates and sets the screen for shutdown. Deletes existing one if any. | |
43 static void Create(const gfx::Screen* screen) { | |
44 delete screen_for_shutdown; | |
45 screen_for_shutdown = new ScreenForShutdown(screen->GetPrimaryDisplay()); | |
46 gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, | |
47 screen_for_shutdown); | |
48 } | |
49 | |
50 private: | |
51 explicit ScreenForShutdown(const gfx::Display& primary_display) | |
52 : primary_display_(primary_display) {} | |
53 | |
54 // gfx::Screen overrides: | |
55 virtual bool IsDIPEnabled() OVERRIDE { return true; } | |
56 virtual gfx::Point GetCursorScreenPoint() OVERRIDE { return gfx::Point(); } | |
57 virtual gfx::NativeWindow GetWindowUnderCursor() OVERRIDE { return NULL; } | |
58 virtual gfx::NativeWindow GetWindowAtScreenPoint( | |
59 const gfx::Point& point) OVERRIDE { | |
60 return NULL; | |
61 } | |
62 virtual int GetNumDisplays() const OVERRIDE { return 1; } | |
63 virtual std::vector<gfx::Display> GetAllDisplays() const OVERRIDE { | |
64 std::vector<gfx::Display> displays(1, primary_display_); | |
65 return displays; | |
66 } | |
67 virtual gfx::Display GetDisplayNearestWindow( | |
68 gfx::NativeView view) const OVERRIDE { | |
69 return primary_display_; | |
70 } | |
71 virtual gfx::Display GetDisplayNearestPoint( | |
72 const gfx::Point& point) const OVERRIDE { | |
73 return primary_display_; | |
74 } | |
75 virtual gfx::Display GetDisplayMatching( | |
76 const gfx::Rect& match_rect) const OVERRIDE { | |
77 return primary_display_; | |
78 } | |
79 virtual gfx::Display GetPrimaryDisplay() const OVERRIDE { | |
80 return primary_display_; | |
81 } | |
82 virtual void AddObserver(gfx::DisplayObserver* observer) OVERRIDE { | |
83 NOTREACHED() << "Observer should not be added during shutdown"; | |
84 } | |
85 virtual void RemoveObserver(gfx::DisplayObserver* observer) OVERRIDE {} | |
86 | |
87 const gfx::Display primary_display_; | |
88 | |
89 DISALLOW_COPY_AND_ASSIGN(ScreenForShutdown); | |
90 }; | |
91 | |
37 // A class that bridges the gap between CursorManager and Aura. It borrows | 92 // A class that bridges the gap between CursorManager and Aura. It borrows |
38 // heavily from AshNativeCursorManager. | 93 // heavily from AshNativeCursorManager. |
39 class AthenaNativeCursorManager : public wm::NativeCursorManager { | 94 class AthenaNativeCursorManager : public wm::NativeCursorManager { |
40 public: | 95 public: |
41 explicit AthenaNativeCursorManager(aura::WindowTreeHost* host) | 96 explicit AthenaNativeCursorManager(aura::WindowTreeHost* host) |
42 : host_(host), image_cursors_(new ui::ImageCursors) {} | 97 : host_(host), image_cursors_(new ui::ImageCursors) {} |
43 virtual ~AthenaNativeCursorManager() {} | 98 virtual ~AthenaNativeCursorManager() {} |
44 | 99 |
45 // wm::NativeCursorManager overrides. | 100 // wm::NativeCursorManager overrides. |
46 virtual void SetDisplay(const gfx::Display& display, | 101 virtual void SetDisplay(const gfx::Display& display, |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
175 } | 230 } |
176 root_window_event_filter_.reset(); | 231 root_window_event_filter_.reset(); |
177 capture_client_.reset(); | 232 capture_client_.reset(); |
178 input_method_filter_.reset(); | 233 input_method_filter_.reset(); |
179 cursor_manager_.reset(); | 234 cursor_manager_.reset(); |
180 user_activity_notifier_.reset(); | 235 user_activity_notifier_.reset(); |
181 user_activity_detector_.reset(); | 236 user_activity_detector_.reset(); |
182 | 237 |
183 input_method_filter_.reset(); | 238 input_method_filter_.reset(); |
184 host_.reset(); | 239 host_.reset(); |
240 | |
241 ScreenForShutdown::Create(screen_.get()); | |
185 screen_.reset(); | 242 screen_.reset(); |
186 gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, NULL); | |
187 | |
188 aura::Env::DeleteInstance(); | 243 aura::Env::DeleteInstance(); |
189 | 244 |
190 display_configurator_->RemoveObserver(this); | 245 display_configurator_->RemoveObserver(this); |
191 display_configurator_.reset(); | 246 display_configurator_.reset(); |
192 } | 247 } |
193 | 248 |
194 private: | 249 private: |
195 virtual aura::WindowTreeHost* GetHost() OVERRIDE { return host_.get(); } | 250 virtual aura::WindowTreeHost* GetHost() OVERRIDE { return host_.get(); } |
196 | 251 |
197 // AthenaEnv: | 252 // AthenaEnv: |
(...skipping 28 matching lines...) Expand all Loading... | |
226 scoped_ptr<aura::WindowTreeHost> host_; | 281 scoped_ptr<aura::WindowTreeHost> host_; |
227 | 282 |
228 scoped_ptr<wm::InputMethodEventFilter> input_method_filter_; | 283 scoped_ptr<wm::InputMethodEventFilter> input_method_filter_; |
229 scoped_ptr<wm::CompoundEventFilter> root_window_event_filter_; | 284 scoped_ptr<wm::CompoundEventFilter> root_window_event_filter_; |
230 scoped_ptr<aura::client::DefaultCaptureClient> capture_client_; | 285 scoped_ptr<aura::client::DefaultCaptureClient> capture_client_; |
231 scoped_ptr<wm::CursorManager> cursor_manager_; | 286 scoped_ptr<wm::CursorManager> cursor_manager_; |
232 scoped_ptr<wm::UserActivityDetector> user_activity_detector_; | 287 scoped_ptr<wm::UserActivityDetector> user_activity_detector_; |
233 scoped_ptr<ui::DisplayConfigurator> display_configurator_; | 288 scoped_ptr<ui::DisplayConfigurator> display_configurator_; |
234 scoped_ptr<ui::UserActivityPowerManagerNotifier> user_activity_notifier_; | 289 scoped_ptr<ui::UserActivityPowerManagerNotifier> user_activity_notifier_; |
235 | 290 |
291 std::vector<base::Closure> terminating_callbacks_; | |
292 | |
sadrul
2014/09/09 23:27:44
This doesn't seem to be used?
oshima
2014/09/09 23:52:46
Oops, forgot to cleanup. Removed.
| |
236 DISALLOW_COPY_AND_ASSIGN(AthenaEnvImpl); | 293 DISALLOW_COPY_AND_ASSIGN(AthenaEnvImpl); |
237 }; | 294 }; |
238 | 295 |
239 } // namespace | 296 } // namespace |
240 | 297 |
241 // static | 298 // static |
242 void AthenaEnv::Create() { | 299 void AthenaEnv::Create() { |
243 DCHECK(!instance); | 300 DCHECK(!instance); |
244 new AthenaEnvImpl(); | 301 new AthenaEnvImpl(); |
245 } | 302 } |
246 | 303 |
247 AthenaEnv* AthenaEnv::Get() { | 304 AthenaEnv* AthenaEnv::Get() { |
248 DCHECK(instance); | 305 DCHECK(instance); |
249 return instance; | 306 return instance; |
250 } | 307 } |
251 | 308 |
252 // static | 309 // static |
253 | 310 |
254 // static | 311 // static |
255 void AthenaEnv::Shutdown() { | 312 void AthenaEnv::Shutdown() { |
256 DCHECK(instance); | 313 DCHECK(instance); |
257 delete instance; | 314 delete instance; |
258 } | 315 } |
259 | 316 |
260 } // namespace athena | 317 } // namespace athena |
OLD | NEW |