| 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/window.h" | 7 #include "ui/aura/window.h" |
| 8 #include "ui/aura/window_event_dispatcher.h" | 8 #include "ui/aura/window_event_dispatcher.h" |
| 9 #include "ui/aura/window_tree_host.h" | 9 #include "ui/aura/window_tree_host.h" |
| 10 | 10 |
| 11 namespace aura { | 11 namespace aura { |
| 12 namespace client { | 12 namespace client { |
| 13 | 13 |
| 14 // static |
| 15 // Track the active capture window across root windows. |
| 16 Window* global_capture_window_ = nullptr; |
| 17 |
| 14 DefaultCaptureClient::DefaultCaptureClient(Window* root_window) | 18 DefaultCaptureClient::DefaultCaptureClient(Window* root_window) |
| 15 : root_window_(root_window), | 19 : root_window_(root_window), |
| 16 capture_window_(NULL) { | 20 capture_window_(NULL) { |
| 17 SetCaptureClient(root_window_, this); | 21 SetCaptureClient(root_window_, this); |
| 18 } | 22 } |
| 19 | 23 |
| 20 DefaultCaptureClient::~DefaultCaptureClient() { | 24 DefaultCaptureClient::~DefaultCaptureClient() { |
| 25 if (global_capture_window_ == capture_window_) |
| 26 global_capture_window_ = nullptr; |
| 21 SetCaptureClient(root_window_, NULL); | 27 SetCaptureClient(root_window_, NULL); |
| 22 } | 28 } |
| 23 | 29 |
| 24 void DefaultCaptureClient::SetCapture(Window* window) { | 30 void DefaultCaptureClient::SetCapture(Window* window) { |
| 25 if (capture_window_ == window) | 31 if (capture_window_ == window) |
| 26 return; | 32 return; |
| 27 if (window) | 33 if (window) |
| 28 ui::GestureRecognizer::Get()->CancelActiveTouchesExcept(window); | 34 ui::GestureRecognizer::Get()->CancelActiveTouchesExcept(window); |
| 29 | 35 |
| 30 Window* old_capture_window = capture_window_; | 36 Window* old_capture_window = capture_window_; |
| 31 capture_window_ = window; | 37 capture_window_ = window; |
| 38 global_capture_window_ = window; |
| 32 | 39 |
| 33 CaptureDelegate* capture_delegate = root_window_->GetHost()->dispatcher(); | 40 CaptureDelegate* capture_delegate = root_window_->GetHost()->dispatcher(); |
| 34 if (capture_window_) | 41 if (capture_window_) |
| 35 capture_delegate->SetNativeCapture(); | 42 capture_delegate->SetNativeCapture(); |
| 36 else | 43 else |
| 37 capture_delegate->ReleaseNativeCapture(); | 44 capture_delegate->ReleaseNativeCapture(); |
| 38 | 45 |
| 39 capture_delegate->UpdateCapture(old_capture_window, capture_window_); | 46 capture_delegate->UpdateCapture(old_capture_window, capture_window_); |
| 40 } | 47 } |
| 41 | 48 |
| 42 void DefaultCaptureClient::ReleaseCapture(Window* window) { | 49 void DefaultCaptureClient::ReleaseCapture(Window* window) { |
| 43 if (capture_window_ != window) | 50 if (capture_window_ != window) |
| 44 return; | 51 return; |
| 45 SetCapture(NULL); | 52 SetCapture(NULL); |
| 46 } | 53 } |
| 47 | 54 |
| 48 Window* DefaultCaptureClient::GetCaptureWindow() { | 55 Window* DefaultCaptureClient::GetCaptureWindow() { |
| 49 return capture_window_; | 56 return capture_window_; |
| 50 } | 57 } |
| 51 | 58 |
| 52 Window* DefaultCaptureClient::GetGlobalCaptureWindow() { | 59 Window* DefaultCaptureClient::GetGlobalCaptureWindow() { |
| 53 return capture_window_; | 60 return global_capture_window_; |
| 54 } | 61 } |
| 55 | 62 |
| 56 } // namespace client | 63 } // namespace client |
| 57 } // namespace aura | 64 } // namespace aura |
| OLD | NEW |