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

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

Issue 10827145: Convert Aura to use ui::Event. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 4 months 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/panel_layout_manager.cc » ('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/event.h"
10 #include "ui/views/widget/widget.h" 11 #include "ui/views/widget/widget.h"
11 12
12 namespace ash { 13 namespace ash {
13 namespace internal { 14 namespace internal {
14 15
15 OverlayEventFilter::OverlayEventFilter() 16 OverlayEventFilter::OverlayEventFilter()
16 : delegate_(NULL) { 17 : delegate_(NULL) {
17 } 18 }
18 19
19 OverlayEventFilter::~OverlayEventFilter() { 20 OverlayEventFilter::~OverlayEventFilter() {
20 delegate_ = NULL; 21 delegate_ = NULL;
21 } 22 }
22 23
23 bool OverlayEventFilter::PreHandleKeyEvent( 24 bool OverlayEventFilter::PreHandleKeyEvent(
24 aura::Window* target, aura::KeyEvent* event) { 25 aura::Window* target, ui::KeyEvent* event) {
25 if (!delegate_) 26 if (!delegate_)
26 return false; 27 return false;
27 28
28 // Do not consume a translated key event which is generated by an IME (e.g., 29 // 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 // 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 // press or release before showing the ovelay. This is important not to
31 // confuse key event handling JavaScript code in a page. 32 // confuse key event handling JavaScript code in a page.
32 if (event->type() == ui::ET_TRANSLATED_KEY_PRESS || 33 if (event->type() == ui::ET_TRANSLATED_KEY_PRESS ||
33 event->type() == ui::ET_TRANSLATED_KEY_RELEASE) { 34 event->type() == ui::ET_TRANSLATED_KEY_RELEASE) {
34 return false; 35 return false;
35 } 36 }
36 37
37 if (delegate_ && delegate_->IsCancelingKeyEvent(event)) 38 if (delegate_ && delegate_->IsCancelingKeyEvent(event))
38 Cancel(); 39 Cancel();
39 40
40 // Handle key events only when they are sent to a child of the delegate's 41 // Handle key events only when they are sent to a child of the delegate's
41 // window. 42 // window.
42 if (delegate_ && delegate_->GetWindow()->Contains(target)) 43 if (delegate_ && delegate_->GetWindow()->Contains(target))
43 target->delegate()->OnKeyEvent(event); 44 target->delegate()->OnKeyEvent(event);
44 45
45 // Always handled: other windows shouldn't receive input while we're 46 // Always handled: other windows shouldn't receive input while we're
46 // displaying an overlay. 47 // displaying an overlay.
47 return true; 48 return true;
48 } 49 }
49 50
50 bool OverlayEventFilter::PreHandleMouseEvent( 51 bool OverlayEventFilter::PreHandleMouseEvent(
51 aura::Window* target, aura::MouseEvent* event) { 52 aura::Window* target, ui::MouseEvent* event) {
52 if (delegate_) { 53 if (delegate_) {
53 DCHECK_EQ(target, delegate_->GetWindow()); 54 DCHECK_EQ(target, delegate_->GetWindow());
54 target->delegate()->OnMouseEvent(event); 55 target->delegate()->OnMouseEvent(event);
55 return true; 56 return true;
56 } 57 }
57 return false; // Not handled. 58 return false; // Not handled.
58 } 59 }
59 60
60 ui::TouchStatus OverlayEventFilter::PreHandleTouchEvent( 61 ui::TouchStatus OverlayEventFilter::PreHandleTouchEvent(
61 aura::Window* target, aura::TouchEvent* event) { 62 aura::Window* target, ui::TouchEventImpl* event) {
62 return ui::TOUCH_STATUS_UNKNOWN; // Not handled. 63 return ui::TOUCH_STATUS_UNKNOWN; // Not handled.
63 } 64 }
64 65
65 ui::GestureStatus OverlayEventFilter::PreHandleGestureEvent( 66 ui::GestureStatus OverlayEventFilter::PreHandleGestureEvent(
66 aura::Window* target, aura::GestureEvent* event) { 67 aura::Window* target, ui::GestureEventImpl* event) {
67 return ui::GESTURE_STATUS_UNKNOWN; // Not handled. 68 return ui::GESTURE_STATUS_UNKNOWN; // Not handled.
68 } 69 }
69 70
70 void OverlayEventFilter::OnLoginStateChanged( 71 void OverlayEventFilter::OnLoginStateChanged(
71 user::LoginStatus status) { 72 user::LoginStatus status) {
72 Cancel(); 73 Cancel();
73 } 74 }
74 75
75 void OverlayEventFilter::OnAppTerminating() { 76 void OverlayEventFilter::OnAppTerminating() {
76 Cancel(); 77 Cancel();
(...skipping 10 matching lines...) Expand all
87 void OverlayEventFilter::Deactivate() { 88 void OverlayEventFilter::Deactivate() {
88 delegate_ = NULL; 89 delegate_ = NULL;
89 } 90 }
90 91
91 void OverlayEventFilter::Cancel() { 92 void OverlayEventFilter::Cancel() {
92 if (delegate_) 93 if (delegate_)
93 delegate_->Cancel(); 94 delegate_->Cancel();
94 } 95 }
95 } // namespace internal 96 } // namespace internal
96 } // namespace ash 97 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/overlay_event_filter.h ('k') | ash/wm/panel_layout_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698