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

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

Issue 2468493002: Fix bug in keeping capture in sync during destruction (Closed)
Patch Set: sync 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
Index: ui/aura/mus/capture_synchronizer.h
diff --git a/ui/aura/mus/capture_synchronizer.h b/ui/aura/mus/capture_synchronizer.h
new file mode 100644
index 0000000000000000000000000000000000000000..e68a1648a8b187254fecf8624d68c24dbe3c75b2
--- /dev/null
+++ b/ui/aura/mus/capture_synchronizer.h
@@ -0,0 +1,74 @@
+// 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_CAPTURE_SYNCHRONIZER_H_
+#define UI_AURA_MUS_CAPTURE_SYNCHRONIZER_H_
+
+#include <stdint.h>
+
+#include "base/macros.h"
+#include "ui/aura/aura_export.h"
+#include "ui/aura/client/capture_client_observer.h"
+#include "ui/aura/window_observer.h"
+
+namespace ui {
+namespace mojom {
+class WindowTree;
+}
+}
+
+namespace aura {
+class CaptureSynchronizerDelegate;
+class WindowMus;
+
+namespace client {
+class CaptureClient;
+}
+
+// CaptureSynchronizer is resonsible for keeping capture in sync between aura
+// and the mus server.
+class CaptureSynchronizer : public WindowObserver,
+ public client::CaptureClientObserver {
+ public:
+ CaptureSynchronizer(CaptureSynchronizerDelegate* delegate,
+ ui::mojom::WindowTree* window_tree,
+ client::CaptureClient* capture_client);
+ ~CaptureSynchronizer() override;
+
+ WindowMus* capture_window() { return capture_window_; }
+
+ // Called when the server side wants to change capture to |window|.
+ void SetCaptureFromServer(WindowMus* window);
+
+ private:
+ // Internal implementation when capture changes. Adds/removes observer as
msw 2016/10/31 17:56:20 nit: s/when/for/?
sky 2016/10/31 18:00:31 Done.
+ // necessary and sets |capture_window_| to |window|.
+ void SetCaptureWindow(WindowMus* window);
+
+ // WindowObserver:
+ void OnWindowDestroying(Window* window) override;
+
+ // client::CaptureClientObserver:
+ void OnCaptureChanged(Window* lost_capture, Window* gained_capture) override;
+
+ CaptureSynchronizerDelegate* delegate_;
+ ui::mojom::WindowTree* window_tree_;
+ client::CaptureClient* capture_client_;
+
+ // Window that currently has capture.
+ WindowMus* capture_window_ = nullptr;
+
+ // Used when setting capture from the server to avoid setting capture back
+ // on the server. If |setting_capture_| is true SetCaptureFromServer() was
+ // called and |window_setting_capture_to_| is the window capture is being
+ // set on.
+ bool setting_capture_ = false;
+ WindowMus* window_setting_capture_to_ = nullptr;
+
+ DISALLOW_COPY_AND_ASSIGN(CaptureSynchronizer);
+};
+
+} // namespace aura
+
+#endif // UI_AURA_MUS_CAPTURE_SYNCHRONIZER_H_

Powered by Google App Engine
This is Rietveld 408576698