Chromium Code Reviews| Index: ash/wm/overlay_event_filter.cc |
| diff --git a/ash/wm/partial_screenshot_event_filter.cc b/ash/wm/overlay_event_filter.cc |
| similarity index 58% |
| rename from ash/wm/partial_screenshot_event_filter.cc |
| rename to ash/wm/overlay_event_filter.cc |
| index f70ae05b8bc26d146adb1a215b5005047bba820a..9ec654df5d097c866dca129af128246bf8188de5 100644 |
| --- a/ash/wm/partial_screenshot_event_filter.cc |
| +++ b/ash/wm/overlay_event_filter.cc |
| @@ -2,7 +2,7 @@ |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| -#include "ash/wm/partial_screenshot_event_filter.h" |
| +#include "ash/wm/overlay_event_filter.h" |
| #include "ash/wm/partial_screenshot_view.h" |
| #include "ui/aura/window.h" |
| @@ -12,17 +12,17 @@ |
| namespace ash { |
| namespace internal { |
| -PartialScreenshotEventFilter::PartialScreenshotEventFilter() |
| - : view_(NULL) { |
| +OverlayEventFilter::OverlayEventFilter() |
| + : delegate_(NULL) { |
| } |
| -PartialScreenshotEventFilter::~PartialScreenshotEventFilter() { |
| - view_ = NULL; |
| +OverlayEventFilter::~OverlayEventFilter() { |
| + delegate_ = NULL; |
| } |
| -bool PartialScreenshotEventFilter::PreHandleKeyEvent( |
| +bool OverlayEventFilter::PreHandleKeyEvent( |
| aura::Window* target, aura::KeyEvent* event) { |
| - if (!view_) |
| + if (!delegate_) |
| return false; |
| // Do not consume a translated key event which is generated by an IME (e.g., |
| @@ -34,58 +34,63 @@ bool PartialScreenshotEventFilter::PreHandleKeyEvent( |
| return false; |
| } |
| - if (event->key_code() == ui::VKEY_ESCAPE) |
| + if (delegate_ && delegate_->IsCancelingKeyEvent(event)) |
| Cancel(); |
| + // Handle key events only when they are sent to a child of the delegate's |
| + // window. |
| + if (delegate_ && delegate_->GetWindow()->Contains(target)) |
| + target->delegate()->OnKeyEvent(event); |
| + |
| // Always handled: other windows shouldn't receive input while we're |
| // taking a screenshot. |
|
Daniel Erat
2012/07/26 01:52:51
nit: s/taking a screenshot/displaying an overlay/
mazda
2012/07/26 02:09:08
Done.
|
| return true; |
| } |
| -bool PartialScreenshotEventFilter::PreHandleMouseEvent( |
| +bool OverlayEventFilter::PreHandleMouseEvent( |
| aura::Window* target, aura::MouseEvent* event) { |
| - if (view_) { |
| - DCHECK_EQ(target, view_->GetWidget()->GetNativeWindow()); |
| + if (delegate_) { |
| + DCHECK_EQ(target, delegate_->GetWindow()); |
| target->delegate()->OnMouseEvent(event); |
| return true; |
| } |
| return false; // Not handled. |
| } |
| -ui::TouchStatus PartialScreenshotEventFilter::PreHandleTouchEvent( |
| +ui::TouchStatus OverlayEventFilter::PreHandleTouchEvent( |
| aura::Window* target, aura::TouchEvent* event) { |
| return ui::TOUCH_STATUS_UNKNOWN; // Not handled. |
| } |
| -ui::GestureStatus PartialScreenshotEventFilter::PreHandleGestureEvent( |
| +ui::GestureStatus OverlayEventFilter::PreHandleGestureEvent( |
| aura::Window* target, aura::GestureEvent* event) { |
| return ui::GESTURE_STATUS_UNKNOWN; // Not handled. |
| } |
| -void PartialScreenshotEventFilter::OnLoginStateChanged( |
| +void OverlayEventFilter::OnLoginStateChanged( |
| user::LoginStatus status) { |
| Cancel(); |
| } |
| -void PartialScreenshotEventFilter::OnAppTerminating() { |
| +void OverlayEventFilter::OnAppTerminating() { |
| Cancel(); |
| } |
| -void PartialScreenshotEventFilter::OnLockStateChanged(bool locked) { |
| +void OverlayEventFilter::OnLockStateChanged(bool locked) { |
| Cancel(); |
| } |
| -void PartialScreenshotEventFilter::Activate(PartialScreenshotView* view) { |
| - view_ = view; |
| +void OverlayEventFilter::Activate(Delegate* delegate) { |
| + delegate_ = delegate; |
| } |
| -void PartialScreenshotEventFilter::Deactivate() { |
| - view_ = NULL; |
| +void OverlayEventFilter::Deactivate() { |
| + delegate_ = NULL; |
| } |
| -void PartialScreenshotEventFilter::Cancel() { |
| - if (view_) |
| - view_->Cancel(); |
| +void OverlayEventFilter::Cancel() { |
| + if (delegate_) |
| + delegate_->Cancel(); |
| } |
| } // namespace internal |
| } // namespace ash |