Separate Simple Backend creation from initialization.
[chromium-blink-merge.git] / ash / wm / capture_controller.cc
blob7a91d2f29c8f9b25297e8a634a1ad0781b6031aa
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"
7 #include "ash/shell.h"
8 #include "ui/aura/window.h"
9 #include "ui/aura/root_window.h"
11 namespace ash {
12 namespace internal {
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)
29 return;
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);
52 return;
55 void CaptureController::ReleaseCapture(aura::Window* window) {
56 if (capture_window_ != window)
57 return;
58 SetCapture(NULL);
61 aura::Window* CaptureController::GetCaptureWindow() {
62 return capture_window_;
65 } // namespace internal
66 } // namespace ash