| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 #ifndef CHROMECAST_GRAPHICS_CAST_WINDOW_MANAGER_AURA_H_ | 5 #ifndef CHROMECAST_GRAPHICS_CAST_WINDOW_MANAGER_AURA_H_ |
| 6 #define CHROMECAST_GRAPHICS_CAST_WINDOW_MANAGER_AURA_H_ | 6 #define CHROMECAST_GRAPHICS_CAST_WINDOW_MANAGER_AURA_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <vector> |
| 9 | 10 |
| 10 #include "base/macros.h" | 11 #include "base/macros.h" |
| 11 #include "base/observer_list.h" | 12 #include "base/observer_list.h" |
| 12 #include "chromecast/graphics/cast_vsync_settings.h" | 13 #include "chromecast/graphics/cast_vsync_settings.h" |
| 13 #include "chromecast/graphics/cast_window_manager.h" | 14 #include "chromecast/graphics/cast_window_manager.h" |
| 15 #include "ui/aura/client/focus_client.h" |
| 16 #include "ui/aura/window_observer.h" |
| 14 | 17 |
| 15 namespace aura { | 18 namespace aura { |
| 16 class Window; | 19 class Window; |
| 17 namespace client { | 20 namespace client { |
| 18 class DefaultCaptureClient; | 21 class DefaultCaptureClient; |
| 19 } // namespace client | 22 } // namespace client |
| 20 } // namespace aura | 23 } // namespace aura |
| 21 | 24 |
| 22 namespace chromecast { | 25 namespace chromecast { |
| 23 | 26 |
| 24 class CastWindowTreeHost; | 27 class CastWindowTreeHost; |
| 25 | 28 |
| 26 class CastWindowManagerAura : public CastWindowManager, | 29 class CastWindowManagerAura : public CastWindowManager, |
| 27 private CastVSyncSettings::Observer { | 30 private CastVSyncSettings::Observer, |
| 31 private aura::WindowObserver, |
| 32 private aura::client::FocusClient { |
| 28 public: | 33 public: |
| 29 ~CastWindowManagerAura() override; | 34 ~CastWindowManagerAura() override; |
| 30 | 35 |
| 31 // CastWindowManager implementation: | 36 // CastWindowManager implementation: |
| 32 void TearDown() override; | 37 void TearDown() override; |
| 33 void AddWindow(gfx::NativeView window) override; | 38 void AddWindow(gfx::NativeView window) override; |
| 34 | 39 |
| 40 // aura::client::FocusClient implementation: |
| 41 void AddObserver(aura::client::FocusChangeObserver* observer) override; |
| 42 void RemoveObserver(aura::client::FocusChangeObserver* observer) override; |
| 43 void FocusWindow(aura::Window* window) override; |
| 44 void ResetFocusWithinActiveWindow(aura::Window* window) override; |
| 45 aura::Window* GetFocusedWindow() override; |
| 46 |
| 35 private: | 47 private: |
| 36 friend class CastWindowManager; | 48 friend class CastWindowManager; |
| 37 | 49 |
| 38 // This class should only be instantiated by CastWindowManager::Create. | 50 // This class should only be instantiated by CastWindowManager::Create. |
| 39 explicit CastWindowManagerAura(bool enable_input); | 51 explicit CastWindowManagerAura(bool enable_input); |
| 40 | 52 |
| 41 // CastVSyncSettings::Observer implementation: | 53 // CastVSyncSettings::Observer implementation: |
| 42 void OnVSyncIntervalChanged(base::TimeDelta interval) override; | 54 void OnVSyncIntervalChanged(base::TimeDelta interval) override; |
| 43 | 55 |
| 56 // aura::WindowObserver implementation: |
| 57 void OnWindowVisibilityChanged(aura::Window* window, bool visible) override; |
| 58 void OnWindowDestroying(aura::Window* window) override; |
| 59 void OnWindowHierarchyChanging(const HierarchyChangeParams& params) override; |
| 60 |
| 44 void Setup(); | 61 void Setup(); |
| 45 | 62 |
| 46 const bool enable_input_; | 63 const bool enable_input_; |
| 47 std::unique_ptr<CastWindowTreeHost> window_tree_host_; | 64 std::unique_ptr<CastWindowTreeHost> window_tree_host_; |
| 65 base::ObserverList<aura::client::FocusChangeObserver> focus_observers_; |
| 48 std::unique_ptr<aura::client::DefaultCaptureClient> capture_client_; | 66 std::unique_ptr<aura::client::DefaultCaptureClient> capture_client_; |
| 49 | 67 |
| 68 // Track the currently focused window, which isn't necessarily a top-level |
| 69 // window. |
| 70 aura::Window* focused_window_; |
| 71 // Track the windows that we've focused in the past, so that we can restore |
| 72 // focus to them. We assume that this is a small list so that we can perform |
| 73 // linear ops on it. |
| 74 std::vector<aura::Window*> focusable_windows_; |
| 75 |
| 76 // Change the focused window and notify focus observers. |
| 77 void UpdateWindowFocus(aura::Window* skip); |
| 78 // Get the window that should be focused. |
| 79 aura::Window* GetWindowToFocus(aura::Window* skip); |
| 80 |
| 81 // Return the top-level window for |window|. |
| 82 aura::Window* GetTopLevelWindow(aura::Window* window); |
| 83 |
| 50 DISALLOW_COPY_AND_ASSIGN(CastWindowManagerAura); | 84 DISALLOW_COPY_AND_ASSIGN(CastWindowManagerAura); |
| 51 }; | 85 }; |
| 52 | 86 |
| 53 } // namespace chromecast | 87 } // namespace chromecast |
| 54 | 88 |
| 55 #endif // CHROMECAST_GRAPHICS_CAST_WINDOW_MANAGER_AURA_H_ | 89 #endif // CHROMECAST_GRAPHICS_CAST_WINDOW_MANAGER_AURA_H_ |
| OLD | NEW |