forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcapture_controller.cc
66 lines (50 loc) · 1.9 KB
/
capture_controller.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ash/wm/capture_controller.h"
#include "ash/shell.h"
#include "ui/aura/window.h"
#include "ui/aura/root_window.h"
namespace ash {
namespace internal {
////////////////////////////////////////////////////////////////////////////////
// CaptureController, public:
CaptureController::CaptureController()
: capture_window_(NULL) {
}
CaptureController::~CaptureController() {
}
////////////////////////////////////////////////////////////////////////////////
// CaptureController, client::CaptureClient implementation:
void CaptureController::SetCapture(aura::Window* new_capture_window) {
if (capture_window_ == new_capture_window)
return;
// Make sure window has a root window.
DCHECK(!new_capture_window || new_capture_window->GetRootWindow());
DCHECK(!capture_window_ || capture_window_->GetRootWindow());
aura::Window* old_capture_window = capture_window_;
Shell::RootWindowList root_windows = Shell::GetAllRootWindows();
for (Shell::RootWindowList::iterator iter = root_windows.begin();
iter != root_windows.end(); ++iter) {
aura::RootWindow* root_window = *iter;
root_window->gesture_recognizer()->
TransferEventsTo(old_capture_window, new_capture_window);
}
capture_window_ = new_capture_window;
for (Shell::RootWindowList::iterator iter = root_windows.begin();
iter != root_windows.end(); ++iter) {
aura::RootWindow* root_window = *iter;
root_window->UpdateCapture(old_capture_window, new_capture_window);
}
return;
}
void CaptureController::ReleaseCapture(aura::Window* window) {
if (capture_window_ != window)
return;
SetCapture(NULL);
}
aura::Window* CaptureController::GetCaptureWindow() {
return capture_window_;
}
} // namespace internal
} // namespace ash