Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(502)

Side by Side Diff: ash/wm/overlay_event_filter.cc

Issue 11570012: events: Update key-event handlers to not return EventResult. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: tot-merge-for-landing Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ash/wm/overlay_event_filter.h ('k') | ash/wm/system_modal_container_event_filter.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ash/wm/overlay_event_filter.h" 5 #include "ash/wm/overlay_event_filter.h"
6 6
7 #include "ash/wm/partial_screenshot_view.h" 7 #include "ash/wm/partial_screenshot_view.h"
8 #include "ui/aura/window.h" 8 #include "ui/aura/window.h"
9 #include "ui/aura/window_delegate.h" 9 #include "ui/aura/window_delegate.h"
10 #include "ui/base/events/event.h" 10 #include "ui/base/events/event.h"
11 #include "ui/views/widget/widget.h" 11 #include "ui/views/widget/widget.h"
12 12
13 namespace ash { 13 namespace ash {
14 namespace internal { 14 namespace internal {
15 15
16 OverlayEventFilter::OverlayEventFilter() 16 OverlayEventFilter::OverlayEventFilter()
17 : delegate_(NULL) { 17 : delegate_(NULL) {
18 } 18 }
19 19
20 OverlayEventFilter::~OverlayEventFilter() { 20 OverlayEventFilter::~OverlayEventFilter() {
21 delegate_ = NULL; 21 delegate_ = NULL;
22 } 22 }
23 23
24 ui::EventResult OverlayEventFilter::OnKeyEvent(ui::KeyEvent* event) { 24 void OverlayEventFilter::OnKeyEvent(ui::KeyEvent* event) {
25 if (!delegate_) 25 if (!delegate_)
26 return ui::ER_UNHANDLED; 26 return;
27 27
28 // Do not consume a translated key event which is generated by an IME (e.g., 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 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 30 // press or release before showing the ovelay. This is important not to
31 // confuse key event handling JavaScript code in a page. 31 // confuse key event handling JavaScript code in a page.
32 if (event->type() == ui::ET_TRANSLATED_KEY_PRESS || 32 if (event->type() == ui::ET_TRANSLATED_KEY_PRESS ||
33 event->type() == ui::ET_TRANSLATED_KEY_RELEASE) { 33 event->type() == ui::ET_TRANSLATED_KEY_RELEASE) {
34 return ui::ER_UNHANDLED; 34 return;
35 } 35 }
36 36
37 if (delegate_ && delegate_->IsCancelingKeyEvent(event)) 37 if (delegate_ && delegate_->IsCancelingKeyEvent(event))
38 Cancel(); 38 Cancel();
39 39
40 // Handle key events only when they are sent to a child of the delegate's 40 // Handle key events only when they are sent to a child of the delegate's
41 // window. 41 // window.
42 aura::Window* target = static_cast<aura::Window*>(event->target()); 42 aura::Window* target = static_cast<aura::Window*>(event->target());
43 if (delegate_ && delegate_->GetWindow() && 43 if (delegate_ && delegate_->GetWindow() &&
44 delegate_->GetWindow()->Contains(target)) 44 delegate_->GetWindow()->Contains(target))
45 target->delegate()->OnKeyEvent(event); 45 target->delegate()->OnKeyEvent(event);
46 46
47 // Always handled: other windows shouldn't receive input while we're 47 // Always handled: other windows shouldn't receive input while we're
48 // displaying an overlay. 48 // displaying an overlay.
49 return ui::ER_CONSUMED; 49 event->StopPropagation();
50 } 50 }
51 51
52 void OverlayEventFilter::OnLoginStateChanged( 52 void OverlayEventFilter::OnLoginStateChanged(
53 user::LoginStatus status) { 53 user::LoginStatus status) {
54 Cancel(); 54 Cancel();
55 } 55 }
56 56
57 void OverlayEventFilter::OnAppTerminating() { 57 void OverlayEventFilter::OnAppTerminating() {
58 Cancel(); 58 Cancel();
59 } 59 }
60 60
61 void OverlayEventFilter::OnLockStateChanged(bool locked) { 61 void OverlayEventFilter::OnLockStateChanged(bool locked) {
62 Cancel(); 62 Cancel();
63 } 63 }
64 64
65 void OverlayEventFilter::Activate(Delegate* delegate) { 65 void OverlayEventFilter::Activate(Delegate* delegate) {
66 delegate_ = delegate; 66 delegate_ = delegate;
67 } 67 }
68 68
69 void OverlayEventFilter::Deactivate() { 69 void OverlayEventFilter::Deactivate() {
70 delegate_ = NULL; 70 delegate_ = NULL;
71 } 71 }
72 72
73 void OverlayEventFilter::Cancel() { 73 void OverlayEventFilter::Cancel() {
74 if (delegate_) 74 if (delegate_)
75 delegate_->Cancel(); 75 delegate_->Cancel();
76 } 76 }
77 } // namespace internal 77 } // namespace internal
78 } // namespace ash 78 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/overlay_event_filter.h ('k') | ash/wm/system_modal_container_event_filter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698