blob: a728b9e1ac1fa3cf33507f77ec564a90454fcc97 (
plain)
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
67
68
69
70
71
72
|
// 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/overlay_event_filter.h"
#include "ui/aura/window.h"
#include "ui/aura/window_delegate.h"
#include "ui/events/event.h"
#include "ui/views/widget/widget.h"
namespace ash {
OverlayEventFilter::OverlayEventFilter()
: delegate_(NULL) {
}
OverlayEventFilter::~OverlayEventFilter() {
delegate_ = NULL;
}
void OverlayEventFilter::OnKeyEvent(ui::KeyEvent* event) {
if (!delegate_)
return;
if (delegate_ && delegate_->IsCancelingKeyEvent(event))
Cancel();
// Pass key events only when they are sent to a child of the delegate's
// window.
aura::Window* target = static_cast<aura::Window*>(event->target());
if (!delegate_ || !delegate_->GetWindow() ||
!delegate_->GetWindow()->Contains(target))
event->StopPropagation();
}
void OverlayEventFilter::OnLoginStateChanged(
user::LoginStatus status) {
Cancel();
}
void OverlayEventFilter::OnAppTerminating() {
Cancel();
}
void OverlayEventFilter::OnLockStateChanged(bool locked) {
Cancel();
}
void OverlayEventFilter::Activate(Delegate* delegate) {
if (delegate_)
delegate_->Cancel();
delegate_ = delegate;
}
void OverlayEventFilter::Deactivate(Delegate* delegate) {
if (delegate_ == delegate)
delegate_ = nullptr;
}
void OverlayEventFilter::Cancel() {
if (delegate_) {
delegate_->Cancel();
delegate_ = nullptr;
}
}
bool OverlayEventFilter::IsActive() {
return delegate_ != nullptr;
}
} // namespace ash
|