Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include "ui/aura/client/default_capture_client.h" | 5 #include "ui/aura/client/default_capture_client.h" |
| 6 | 6 |
| 7 #include "ui/aura/client/capture_client_observer.h" | 7 #include "ui/aura/client/capture_client_observer.h" |
| 8 #include "ui/aura/window.h" | 8 #include "ui/aura/window.h" |
| 9 #include "ui/aura/window_event_dispatcher.h" | 9 #include "ui/aura/window_event_dispatcher.h" |
| 10 #include "ui/aura/window_tree_host.h" | 10 #include "ui/aura/window_tree_host.h" |
| 11 | 11 |
| 12 namespace aura { | 12 namespace aura { |
| 13 namespace client { | 13 namespace client { |
| 14 namespace { | 14 namespace { |
| 15 | 15 |
| 16 // Track the active capture window across root windows. | 16 // Track the active capture window across root windows. |
| 17 Window* global_capture_window_ = nullptr; | 17 Window* global_capture_window_ = nullptr; |
| 18 | 18 |
| 19 } // namespace | 19 } // namespace |
| 20 | 20 |
| 21 DefaultCaptureClient::DefaultCaptureClient(Window* root_window) | 21 DefaultCaptureClient::DefaultCaptureClient(Window* root_window) |
| 22 : root_window_(root_window), capture_window_(nullptr) { | 22 : root_window_(root_window), capture_window_(nullptr) { |
| 23 SetCaptureClient(root_window_, this); | 23 if (root_window_) |
| 24 SetCaptureClient(root_window_, this); | |
| 24 } | 25 } |
| 25 | 26 |
| 26 DefaultCaptureClient::~DefaultCaptureClient() { | 27 DefaultCaptureClient::~DefaultCaptureClient() { |
| 27 if (global_capture_window_ == capture_window_) | 28 if (global_capture_window_ == capture_window_) |
| 28 global_capture_window_ = nullptr; | 29 global_capture_window_ = nullptr; |
| 29 SetCaptureClient(root_window_, nullptr); | 30 if (root_window_) |
| 31 SetCaptureClient(root_window_, nullptr); | |
| 30 } | 32 } |
| 31 | 33 |
| 32 void DefaultCaptureClient::SetCapture(Window* window) { | 34 void DefaultCaptureClient::SetCapture(Window* window) { |
| 33 if (capture_window_ == window) | 35 if (capture_window_ == window) |
| 34 return; | 36 return; |
| 35 if (window) | 37 if (window) |
| 36 ui::GestureRecognizer::Get()->CancelActiveTouchesExcept(window); | 38 ui::GestureRecognizer::Get()->CancelActiveTouchesExcept(window); |
| 37 | 39 |
| 38 Window* old_capture_window = capture_window_; | 40 Window* old_capture_window = capture_window_; |
| 39 capture_window_ = window; | 41 capture_window_ = window; |
| 40 global_capture_window_ = window; | 42 global_capture_window_ = window; |
| 41 | 43 |
| 42 CaptureDelegate* capture_delegate = root_window_->GetHost()->dispatcher(); | 44 CaptureDelegate* capture_delegate = nullptr; |
| 43 if (capture_window_) | 45 if (capture_window_) { |
| 46 capture_delegate = capture_window_->GetHost()->dispatcher(); | |
|
msw
2016/10/25 17:57:58
q: just checking that the change from |root_window
| |
| 44 capture_delegate->SetNativeCapture(); | 47 capture_delegate->SetNativeCapture(); |
| 45 else | 48 } else { |
| 49 capture_delegate = old_capture_window->GetHost()->dispatcher(); | |
| 46 capture_delegate->ReleaseNativeCapture(); | 50 capture_delegate->ReleaseNativeCapture(); |
| 51 } | |
| 47 | 52 |
| 48 capture_delegate->UpdateCapture(old_capture_window, capture_window_); | 53 capture_delegate->UpdateCapture(old_capture_window, capture_window_); |
| 49 | 54 |
| 50 for (CaptureClientObserver& observer : observers_) | 55 for (CaptureClientObserver& observer : observers_) |
| 51 observer.OnCaptureChanged(old_capture_window, capture_window_); | 56 observer.OnCaptureChanged(old_capture_window, capture_window_); |
| 52 } | 57 } |
| 53 | 58 |
| 54 void DefaultCaptureClient::ReleaseCapture(Window* window) { | 59 void DefaultCaptureClient::ReleaseCapture(Window* window) { |
| 55 if (capture_window_ != window) | 60 if (capture_window_ != window) |
| 56 return; | 61 return; |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 68 void DefaultCaptureClient::AddObserver(CaptureClientObserver* observer) { | 73 void DefaultCaptureClient::AddObserver(CaptureClientObserver* observer) { |
| 69 observers_.AddObserver(observer); | 74 observers_.AddObserver(observer); |
| 70 } | 75 } |
| 71 | 76 |
| 72 void DefaultCaptureClient::RemoveObserver(CaptureClientObserver* observer) { | 77 void DefaultCaptureClient::RemoveObserver(CaptureClientObserver* observer) { |
| 73 observers_.RemoveObserver(observer); | 78 observers_.RemoveObserver(observer); |
| 74 } | 79 } |
| 75 | 80 |
| 76 } // namespace client | 81 } // namespace client |
| 77 } // namespace aura | 82 } // namespace aura |
| OLD | NEW |