OLD | NEW |
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/events/event.h" | 10 #include "ui/events/event.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 } | 21 } |
22 | 22 |
23 void OverlayEventFilter::OnKeyEvent(ui::KeyEvent* event) { | 23 void OverlayEventFilter::OnKeyEvent(ui::KeyEvent* event) { |
24 if (!delegate_) | 24 if (!delegate_) |
25 return; | 25 return; |
26 | 26 |
27 // Do not consume a translated key event which is generated by an IME (e.g., | 27 // Do not consume a translated key event which is generated by an IME (e.g., |
28 // ui::VKEY_PROCESSKEY) since the key event is generated in response to a key | 28 // ui::VKEY_PROCESSKEY) since the key event is generated in response to a key |
29 // press or release before showing the ovelay. This is important not to | 29 // press or release before showing the ovelay. This is important not to |
30 // confuse key event handling JavaScript code in a page. | 30 // confuse key event handling JavaScript code in a page. |
31 if (event->type() == ui::ET_TRANSLATED_KEY_PRESS || | 31 if (event->IsTranslated()) |
32 event->type() == ui::ET_TRANSLATED_KEY_RELEASE) { | |
33 return; | 32 return; |
34 } | |
35 | 33 |
36 if (delegate_ && delegate_->IsCancelingKeyEvent(event)) | 34 if (delegate_ && delegate_->IsCancelingKeyEvent(event)) |
37 Cancel(); | 35 Cancel(); |
38 | 36 |
39 // Pass key events only when they are sent to a child of the delegate's | 37 // Pass key events only when they are sent to a child of the delegate's |
40 // window. | 38 // window. |
41 aura::Window* target = static_cast<aura::Window*>(event->target()); | 39 aura::Window* target = static_cast<aura::Window*>(event->target()); |
42 if (!delegate_ || !delegate_->GetWindow() || | 40 if (!delegate_ || !delegate_->GetWindow() || |
43 !delegate_->GetWindow()->Contains(target)) | 41 !delegate_->GetWindow()->Contains(target)) |
44 event->StopPropagation(); | 42 event->StopPropagation(); |
(...skipping 19 matching lines...) Expand all Loading... |
64 void OverlayEventFilter::Deactivate() { | 62 void OverlayEventFilter::Deactivate() { |
65 delegate_ = NULL; | 63 delegate_ = NULL; |
66 } | 64 } |
67 | 65 |
68 void OverlayEventFilter::Cancel() { | 66 void OverlayEventFilter::Cancel() { |
69 if (delegate_) | 67 if (delegate_) |
70 delegate_->Cancel(); | 68 delegate_->Cancel(); |
71 } | 69 } |
72 | 70 |
73 } // namespace ash | 71 } // namespace ash |
OLD | NEW |