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

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

Issue 2626013005: Change CaptureSynchronizer and PointerWatcherEventRouter to support multiple CaptureClients. (Closed)
Patch Set: comments; sequence; 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: ui/aura/mus/capture_synchronizer.cc
diff --git a/ui/aura/mus/capture_synchronizer.cc b/ui/aura/mus/capture_synchronizer.cc
index 67dacb4e9d5672b55204f2980242e71c5ca52f0f..62190e94cca65c83dae74847dc931d3cf39d48e0 100644
--- a/ui/aura/mus/capture_synchronizer.cc
+++ b/ui/aura/mus/capture_synchronizer.cc
@@ -14,30 +14,37 @@
namespace aura {
CaptureSynchronizer::CaptureSynchronizer(CaptureSynchronizerDelegate* delegate,
- ui::mojom::WindowTree* window_tree,
- client::CaptureClient* capture_client)
- : delegate_(delegate),
- window_tree_(window_tree),
- capture_client_(capture_client) {
- capture_client_->AddObserver(this);
-}
+ ui::mojom::WindowTree* window_tree)
+ : delegate_(delegate), window_tree_(window_tree) {}
-CaptureSynchronizer::~CaptureSynchronizer() {
- SetCaptureWindow(nullptr);
- capture_client_->RemoveObserver(this);
-}
+CaptureSynchronizer::~CaptureSynchronizer() {}
void CaptureSynchronizer::SetCaptureFromServer(WindowMus* window) {
if (window == capture_window_)
return;
DCHECK(!setting_capture_);
- // Don't immediately set |capture_client_|. It's possible the change will be
+ // Don't immediately set capture client. It's possible the change will be
sadrul 2017/01/30 19:37:58 We do not set the capture client anymore (since we
riajiang 2017/01/30 20:24:09 Done.
// rejected.
base::AutoReset<bool> capture_reset(&setting_capture_, true);
base::AutoReset<WindowMus*> window_setting_capture_to_reset(
&window_setting_capture_to_, window);
- capture_client_->SetCapture(window ? window->GetWindow() : nullptr);
+ client::CaptureClient* capture_client =
+ window ? client::GetCaptureClient(window->GetWindow()->GetRootWindow())
+ : client::GetCaptureClient(
+ capture_window_->GetWindow()->GetRootWindow());
+ capture_client->SetCapture(window ? window->GetWindow() : nullptr);
+}
+
+void CaptureSynchronizer::AttachToCaptureClient(
+ client::CaptureClient* capture_client) {
+ capture_client->AddObserver(this);
+}
+
+void CaptureSynchronizer::DetachFromCaptureClient(
+ client::CaptureClient* capture_client) {
+ SetCaptureWindow(nullptr);
+ capture_client->RemoveObserver(this);
}
void CaptureSynchronizer::SetCaptureWindow(WindowMus* window) {
@@ -62,6 +69,12 @@ void CaptureSynchronizer::OnCaptureChanged(Window* lost_capture,
if (!gained_capture && !capture_window_)
return; // Happens if the window is deleted during notification.
+ // Happens if the window that just lost capture is not the most updated window
+ // that has capture to avoid setting the current capture_window_ to null by
+ // accident.
sadrul 2017/01/30 19:37:58 This probably needs some farther explanation, e.g.
riajiang 2017/01/30 20:24:09 Updated the comment. WDYT?
+ if (!gained_capture && lost_capture != capture_window_->GetWindow())
+ return;
+
WindowMus* gained_capture_mus = WindowMus::Get(gained_capture);
if (setting_capture_ && gained_capture_mus == window_setting_capture_to_) {
SetCaptureWindow(gained_capture_mus);

Powered by Google App Engine
This is Rietveld 408576698