Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(144)

Unified Diff: chromecast/graphics/cast_focus_client_aura.h

Issue 2636303002: [Chromecast] Add support for z-order and window focus. (Closed)
Patch Set: more tests, and bug fix found by test Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chromecast/graphics/cast_focus_client_aura.h
diff --git a/chromecast/graphics/cast_focus_client_aura.h b/chromecast/graphics/cast_focus_client_aura.h
new file mode 100644
index 0000000000000000000000000000000000000000..c628800f902853aa722b9d4abf0b3e27fec03ce1
--- /dev/null
+++ b/chromecast/graphics/cast_focus_client_aura.h
@@ -0,0 +1,63 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROMECAST_GRAPHICS_CAST_FOCUS_CLIENT_AURA_H_
+#define CHROMECAST_GRAPHICS_CAST_FOCUS_CLIENT_AURA_H_
+
+#include <vector>
+
+#include "base/macros.h"
+#include "base/observer_list.h"
+#include "ui/aura/client/focus_change_observer.h"
+#include "ui/aura/client/focus_client.h"
+#include "ui/aura/window_observer.h"
+
+namespace aura {
+class Window;
+}
+
+namespace chromecast {
+
+class CastFocusClientAura : public aura::WindowObserver,
+ public aura::client::FocusClient {
+ public:
+ CastFocusClientAura();
+ ~CastFocusClientAura() override;
+
+ // aura::client::FocusClient implementation:
+ void AddObserver(aura::client::FocusChangeObserver* observer) override;
+ void RemoveObserver(aura::client::FocusChangeObserver* observer) override;
+ void FocusWindow(aura::Window* window) override;
+ void ResetFocusWithinActiveWindow(aura::Window* window) override;
+ aura::Window* GetFocusedWindow() override;
+
+ private:
+ // aura::WindowObserver implementation:
+ void OnWindowVisibilityChanged(aura::Window* window, bool visible) override;
+ void OnWindowDestroying(aura::Window* window) override;
+ void OnWindowHierarchyChanging(const HierarchyChangeParams& params) override;
+
+ // Change the focused window and notify focus observers.
+ void UpdateWindowFocus();
+ // Get the window that should be focused.
+ aura::Window* GetWindowToFocus();
+ // Get the top-most window in a window's hierarchy.
+ aura::Window* GetTopLevelWindow(aura::Window* window);
+
+ base::ObserverList<aura::client::FocusChangeObserver> focus_observers_;
+
+ // Track the currently focused window, which isn't necessarily a top-level
+ // window.
+ aura::Window* focused_window_;
+ // Track the windows that we've focused in the past, so that we can restore
+ // focus to them. We assume that this is a small list so that we can perform
+ // linear ops on it.
+ std::vector<aura::Window*> focusable_windows_;
+
+ DISALLOW_COPY_AND_ASSIGN(CastFocusClientAura);
+};
+
+} // namespace chromecast
+
+#endif // CHROMECAST_GRAPHICS_CAST_FOCUS_CLIENT_AURA_H_

Powered by Google App Engine
This is Rietveld 408576698