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/overlay_event_filter.h"
7 #include "ash/wm/partial_screenshot_view.h"
8 #include "ui/aura/window.h"
9 #include "ui/aura/window_delegate.h"
10 #include "ui/base/events/event.h"
11 #include "ui/views/widget/widget.h"
16 OverlayEventFilter::OverlayEventFilter()
20 OverlayEventFilter::~OverlayEventFilter() {
24 void OverlayEventFilter::OnKeyEvent(ui::KeyEvent
* event
) {
28 // Do not consume a translated key event which is generated by an IME (e.g.,
29 // ui::VKEY_PROCESSKEY) since the key event is generated in response to a key
30 // press or release before showing the ovelay. This is important not to
31 // confuse key event handling JavaScript code in a page.
32 if (event
->type() == ui::ET_TRANSLATED_KEY_PRESS
||
33 event
->type() == ui::ET_TRANSLATED_KEY_RELEASE
) {
37 if (delegate_
&& delegate_
->IsCancelingKeyEvent(event
))
40 // Handle key events only when they are sent to a child of the delegate's
42 aura::Window
* target
= static_cast<aura::Window
*>(event
->target());
43 if (delegate_
&& delegate_
->GetWindow() &&
44 delegate_
->GetWindow()->Contains(target
))
45 target
->delegate()->OnKeyEvent(event
);
47 // Always handled: other windows shouldn't receive input while we're
48 // displaying an overlay.
49 event
->StopPropagation();
52 void OverlayEventFilter::OnLoginStateChanged(
53 user::LoginStatus status
) {
57 void OverlayEventFilter::OnAppTerminating() {
61 void OverlayEventFilter::OnLockStateChanged(bool locked
) {
65 void OverlayEventFilter::Activate(Delegate
* delegate
) {
69 void OverlayEventFilter::Deactivate() {
73 void OverlayEventFilter::Cancel() {
77 } // namespace internal