This source file includes following definitions.
- OnKeyEvent
- OnLoginStateChanged
- OnAppTerminating
- OnLockStateChanged
- Activate
- Deactivate
- Cancel
#include "ash/wm/overlay_event_filter.h"
#include "ash/wm/partial_screenshot_view.h"
#include "ui/aura/window.h"
#include "ui/aura/window_delegate.h"
#include "ui/events/event.h"
#include "ui/views/widget/widget.h"
namespace ash {
OverlayEventFilter::OverlayEventFilter()
: delegate_(NULL) {
}
OverlayEventFilter::~OverlayEventFilter() {
delegate_ = NULL;
}
void OverlayEventFilter::OnKeyEvent(ui::KeyEvent* event) {
if (!delegate_)
return;
if (event->type() == ui::ET_TRANSLATED_KEY_PRESS ||
event->type() == ui::ET_TRANSLATED_KEY_RELEASE) {
return;
}
if (delegate_ && delegate_->IsCancelingKeyEvent(event))
Cancel();
aura::Window* target = static_cast<aura::Window*>(event->target());
if (!delegate_ || !delegate_->GetWindow() ||
!delegate_->GetWindow()->Contains(target))
event->StopPropagation();
}
void OverlayEventFilter::OnLoginStateChanged(
user::LoginStatus status) {
Cancel();
}
void OverlayEventFilter::OnAppTerminating() {
Cancel();
}
void OverlayEventFilter::OnLockStateChanged(bool locked) {
Cancel();
}
void OverlayEventFilter::Activate(Delegate* delegate) {
delegate_ = delegate;
}
void OverlayEventFilter::Deactivate() {
delegate_ = NULL;
}
void OverlayEventFilter::Cancel() {
if (delegate_)
delegate_->Cancel();
}
}