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.
5 #include "ash/wm/capture_controller.h"
8 #include "ui/aura/window.h"
9 #include "ui/aura/root_window.h"
14 ////////////////////////////////////////////////////////////////////////////////
15 // CaptureController, public:
17 CaptureController::CaptureController()
18 : capture_window_(NULL
) {
21 CaptureController::~CaptureController() {
24 ////////////////////////////////////////////////////////////////////////////////
25 // CaptureController, client::CaptureClient implementation:
27 void CaptureController::SetCapture(aura::Window
* new_capture_window
) {
28 if (capture_window_
== new_capture_window
)
30 // Make sure window has a root window.
31 DCHECK(!new_capture_window
|| new_capture_window
->GetRootWindow());
32 DCHECK(!capture_window_
|| capture_window_
->GetRootWindow());
34 aura::Window
* old_capture_window
= capture_window_
;
36 Shell::RootWindowList root_windows
= Shell::GetAllRootWindows();
37 for (Shell::RootWindowList::iterator iter
= root_windows
.begin();
38 iter
!= root_windows
.end(); ++iter
) {
39 aura::RootWindow
* root_window
= *iter
;
40 root_window
->gesture_recognizer()->
41 TransferEventsTo(old_capture_window
, new_capture_window
);
44 capture_window_
= new_capture_window
;
46 for (Shell::RootWindowList::iterator iter
= root_windows
.begin();
47 iter
!= root_windows
.end(); ++iter
) {
48 aura::RootWindow
* root_window
= *iter
;
49 root_window
->UpdateCapture(old_capture_window
, new_capture_window
);
55 void CaptureController::ReleaseCapture(aura::Window
* window
) {
56 if (capture_window_
!= window
)
61 aura::Window
* CaptureController::GetCaptureWindow() {
62 return capture_window_
;
65 } // namespace internal