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

Unified Diff: ui/aura/mus/focus_synchronizer.h

Issue 2488723002: Reland of Improves focus/activation for aura-mus and DesktopNativeWidgetAura (Closed)
Patch Set: Created 4 years, 1 month 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
« no previous file with comments | « ui/aura/env_observer.h ('k') | ui/aura/mus/focus_synchronizer.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/aura/mus/focus_synchronizer.h
diff --git a/ui/aura/mus/focus_synchronizer.h b/ui/aura/mus/focus_synchronizer.h
new file mode 100644
index 0000000000000000000000000000000000000000..db2556d76155f0e1cdb8000f5a0ab6af217f901a
--- /dev/null
+++ b/ui/aura/mus/focus_synchronizer.h
@@ -0,0 +1,72 @@
+// Copyright 2016 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 UI_AURA_MUS_FOCUS_SYNCHRONIZER_H_
+#define UI_AURA_MUS_FOCUS_SYNCHRONIZER_H_
+
+#include "base/macros.h"
+#include "ui/aura/client/focus_change_observer.h"
+#include "ui/aura/env_observer.h"
+
+namespace ui {
+namespace mojom {
+class WindowTree;
+}
+}
+
+namespace aura {
+
+class FocusSynchronizerDelegate;
+class WindowMus;
+
+namespace client {
+class FocusClient;
+}
+
+// FocusSynchronizer is resonsible for keeping focus in sync between aura
+// and the mus server.
+class FocusSynchronizer : public client::FocusChangeObserver,
+ public EnvObserver {
+ public:
+ FocusSynchronizer(FocusSynchronizerDelegate* delegate,
+ ui::mojom::WindowTree* window_tree);
+ ~FocusSynchronizer() override;
+
+ // Called when the server side wants to change focus to |window|.
+ void SetFocusFromServer(WindowMus* window);
+
+ // Called when the focused window is destroyed.
+ void OnFocusedWindowDestroyed();
+
+ WindowMus* focused_window() { return focused_window_; }
+
+ private:
+ void SetActiveFocusClient(client::FocusClient* focus_client);
+
+ // Called internally to set |focused_window_| and update the server.
+ void SetFocusedWindow(WindowMus* window);
+
+ // Overriden from client::FocusChangeObserver:
+ void OnWindowFocused(Window* gained_focus, Window* lost_focus) override;
+
+ // Overrided from EnvObserver:
+ void OnWindowInitialized(Window* window) override;
+ void OnActiveFocusClientChanged(client::FocusClient* focus_client,
+ Window* window) override;
+
+ FocusSynchronizerDelegate* delegate_;
+ ui::mojom::WindowTree* window_tree_;
+
+ client::FocusClient* active_focus_client_ = nullptr;
+
+ bool setting_focus_ = false;
+ WindowMus* window_setting_focus_to_ = nullptr;
+ WindowMus* focused_window_ = nullptr;
+
+ DISALLOW_COPY_AND_ASSIGN(FocusSynchronizer);
+};
+
+} // namespace aura
+
+#endif // UI_AURA_MUS_FOCUS_SYNCHRONIZER_H_
« no previous file with comments | « ui/aura/env_observer.h ('k') | ui/aura/mus/focus_synchronizer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698