default_capture_client.cc revision 1e9bf3e0803691d0a228da41fc608347b6db4340
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 3// found in the LICENSE file. 4 5#include "ui/aura/client/default_capture_client.h" 6 7#include "ui/aura/root_window.h" 8 9namespace aura { 10namespace client { 11 12DefaultCaptureClient::DefaultCaptureClient(Window* root_window) 13 : root_window_(root_window), 14 capture_window_(NULL) { 15 client::SetCaptureClient(root_window_, this); 16} 17 18DefaultCaptureClient::~DefaultCaptureClient() { 19 client::SetCaptureClient(root_window_, NULL); 20} 21 22void DefaultCaptureClient::SetCapture(Window* window) { 23 if (capture_window_ == window) 24 return; 25 if (window) { 26 ui::GestureRecognizer::Get()->TransferEventsTo( 27 capture_window_, window); 28 } 29 30 Window* old_capture_window = capture_window_; 31 capture_window_ = window; 32 33 CaptureDelegate* capture_delegate = root_window_->GetDispatcher(); 34 if (capture_window_) 35 capture_delegate->SetNativeCapture(); 36 else 37 capture_delegate->ReleaseNativeCapture(); 38 39 capture_delegate->UpdateCapture(old_capture_window, capture_window_); 40} 41 42void DefaultCaptureClient::ReleaseCapture(Window* window) { 43 if (capture_window_ != window) 44 return; 45 SetCapture(NULL); 46} 47 48Window* DefaultCaptureClient::GetCaptureWindow() { 49 return capture_window_; 50} 51 52} // namespace client 53} // namespace aura 54