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/util/fill_layout_manager.h" | 7 #include "athena/util/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 // TODO(flackr:oshima): Remove this once athena switches to share |
| 41 // ash::DisplayManager. |
| 42 class ScreenForShutdown : public gfx::Screen { |
| 43 public: |
| 44 // Creates and sets the screen for shutdown. Deletes existing one if any. |
| 45 static void Create(const gfx::Screen* screen) { |
| 46 delete screen_for_shutdown; |
| 47 screen_for_shutdown = new ScreenForShutdown(screen->GetPrimaryDisplay()); |
| 48 gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, |
| 49 screen_for_shutdown); |
| 50 } |
| 51 |
| 52 private: |
| 53 explicit ScreenForShutdown(const gfx::Display& primary_display) |
| 54 : primary_display_(primary_display) {} |
| 55 |
| 56 // gfx::Screen overrides: |
| 57 virtual bool IsDIPEnabled() OVERRIDE { return true; } |
| 58 virtual gfx::Point GetCursorScreenPoint() OVERRIDE { return gfx::Point(); } |
| 59 virtual gfx::NativeWindow GetWindowUnderCursor() OVERRIDE { return NULL; } |
| 60 virtual gfx::NativeWindow GetWindowAtScreenPoint( |
| 61 const gfx::Point& point) OVERRIDE { |
| 62 return NULL; |
| 63 } |
| 64 virtual int GetNumDisplays() const OVERRIDE { return 1; } |
| 65 virtual std::vector<gfx::Display> GetAllDisplays() const OVERRIDE { |
| 66 std::vector<gfx::Display> displays(1, primary_display_); |
| 67 return displays; |
| 68 } |
| 69 virtual gfx::Display GetDisplayNearestWindow( |
| 70 gfx::NativeView view) const OVERRIDE { |
| 71 return primary_display_; |
| 72 } |
| 73 virtual gfx::Display GetDisplayNearestPoint( |
| 74 const gfx::Point& point) const OVERRIDE { |
| 75 return primary_display_; |
| 76 } |
| 77 virtual gfx::Display GetDisplayMatching( |
| 78 const gfx::Rect& match_rect) const OVERRIDE { |
| 79 return primary_display_; |
| 80 } |
| 81 virtual gfx::Display GetPrimaryDisplay() const OVERRIDE { |
| 82 return primary_display_; |
| 83 } |
| 84 virtual void AddObserver(gfx::DisplayObserver* observer) OVERRIDE { |
| 85 NOTREACHED() << "Observer should not be added during shutdown"; |
| 86 } |
| 87 virtual void RemoveObserver(gfx::DisplayObserver* observer) OVERRIDE {} |
| 88 |
| 89 const gfx::Display primary_display_; |
| 90 |
| 91 DISALLOW_COPY_AND_ASSIGN(ScreenForShutdown); |
| 92 }; |
| 93 |
37 // A class that bridges the gap between CursorManager and Aura. It borrows | 94 // A class that bridges the gap between CursorManager and Aura. It borrows |
38 // heavily from AshNativeCursorManager. | 95 // heavily from AshNativeCursorManager. |
39 class AthenaNativeCursorManager : public wm::NativeCursorManager { | 96 class AthenaNativeCursorManager : public wm::NativeCursorManager { |
40 public: | 97 public: |
41 explicit AthenaNativeCursorManager(aura::WindowTreeHost* host) | 98 explicit AthenaNativeCursorManager(aura::WindowTreeHost* host) |
42 : host_(host), image_cursors_(new ui::ImageCursors) {} | 99 : host_(host), image_cursors_(new ui::ImageCursors) {} |
43 virtual ~AthenaNativeCursorManager() {} | 100 virtual ~AthenaNativeCursorManager() {} |
44 | 101 |
45 // wm::NativeCursorManager overrides. | 102 // wm::NativeCursorManager overrides. |
46 virtual void SetDisplay(const gfx::Display& display, | 103 virtual void SetDisplay(const gfx::Display& display, |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 } | 232 } |
176 root_window_event_filter_.reset(); | 233 root_window_event_filter_.reset(); |
177 capture_client_.reset(); | 234 capture_client_.reset(); |
178 input_method_filter_.reset(); | 235 input_method_filter_.reset(); |
179 cursor_manager_.reset(); | 236 cursor_manager_.reset(); |
180 user_activity_notifier_.reset(); | 237 user_activity_notifier_.reset(); |
181 user_activity_detector_.reset(); | 238 user_activity_detector_.reset(); |
182 | 239 |
183 input_method_filter_.reset(); | 240 input_method_filter_.reset(); |
184 host_.reset(); | 241 host_.reset(); |
| 242 |
| 243 ScreenForShutdown::Create(screen_.get()); |
185 screen_.reset(); | 244 screen_.reset(); |
186 gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, NULL); | |
187 | |
188 aura::Env::DeleteInstance(); | 245 aura::Env::DeleteInstance(); |
189 | 246 |
190 display_configurator_->RemoveObserver(this); | 247 display_configurator_->RemoveObserver(this); |
191 display_configurator_.reset(); | 248 display_configurator_.reset(); |
192 } | 249 } |
193 | 250 |
194 private: | 251 private: |
195 virtual aura::WindowTreeHost* GetHost() OVERRIDE { return host_.get(); } | 252 virtual aura::WindowTreeHost* GetHost() OVERRIDE { return host_.get(); } |
196 | 253 |
197 // AthenaEnv: | 254 // AthenaEnv: |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 |