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

Unified Diff: ui/aura_shell/desktop_event_filter.cc

Issue 8565018: [Aura] Support additonal event filters in DesktopEventFilter. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix typo and remove no-longer-needed algorithm header Created 9 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/aura_shell/desktop_event_filter.h ('k') | ui/aura_shell/desktop_event_filter_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/aura_shell/desktop_event_filter.cc
diff --git a/ui/aura_shell/desktop_event_filter.cc b/ui/aura_shell/desktop_event_filter.cc
index 3d17865b069be2301f74e71ef5d8e3276089f845..d69ead118f5b8531c642c99d7b192ad33f9c0c13 100644
--- a/ui/aura_shell/desktop_event_filter.cc
+++ b/ui/aura_shell/desktop_event_filter.cc
@@ -47,6 +47,17 @@ DesktopEventFilter::DesktopEventFilter()
}
DesktopEventFilter::~DesktopEventFilter() {
+ // Additional filters are not owned by DesktopEventFilter and they
+ // should all be removed when running here. |filters_| has
+ // check_empty == true and will DCHECK failure if it is not empty.
+}
+
+void DesktopEventFilter::AddFilter(aura::EventFilter* filter) {
+ filters_.AddObserver(filter);
+}
+
+void DesktopEventFilter::RemoveFilter(aura::EventFilter* filter) {
+ filters_.RemoveObserver(filter);
}
////////////////////////////////////////////////////////////////////////////////
@@ -54,11 +65,14 @@ DesktopEventFilter::~DesktopEventFilter() {
bool DesktopEventFilter::PreHandleKeyEvent(aura::Window* target,
aura::KeyEvent* event) {
- return false;
+ return FilterKeyEvent(target, event);
}
bool DesktopEventFilter::PreHandleMouseEvent(aura::Window* target,
aura::MouseEvent* event) {
+ if (FilterMouseEvent(target, event))
+ return true;
+
switch (event->type()) {
case ui::ET_MOUSE_PRESSED:
ActivateIfNecessary(target, event);
@@ -75,6 +89,10 @@ bool DesktopEventFilter::PreHandleMouseEvent(aura::Window* target,
ui::TouchStatus DesktopEventFilter::PreHandleTouchEvent(
aura::Window* target,
aura::TouchEvent* event) {
+ ui::TouchStatus status = FilterTouchEvent(target, event);
+ if (status != ui::TOUCH_STATUS_UNKNOWN)
+ return status;
+
if (event->type() == ui::ET_TOUCH_PRESSED)
ActivateIfNecessary(target, event);
return ui::TOUCH_STATUS_UNKNOWN;
@@ -105,5 +123,43 @@ void DesktopEventFilter::HandleMouseMoved(aura::Window* target,
aura::Desktop::GetInstance()->SetCursor(cursor);
}
+bool DesktopEventFilter::FilterKeyEvent(aura::Window* target,
+ aura::KeyEvent* event) {
+ bool handled = false;
+ if (filters_.might_have_observers()) {
+ ObserverListBase<aura::EventFilter>::Iterator it(filters_);
+ aura::EventFilter* filter;
+ while (!handled && (filter = it.GetNext()) != NULL)
+ handled = filter->PreHandleKeyEvent(target, event);
+ }
+ return handled;
+}
+
+bool DesktopEventFilter::FilterMouseEvent(aura::Window* target,
+ aura::MouseEvent* event) {
+ bool handled = false;
+ if (filters_.might_have_observers()) {
+ ObserverListBase<aura::EventFilter>::Iterator it(filters_);
+ aura::EventFilter* filter;
+ while (!handled && (filter = it.GetNext()) != NULL)
+ handled = filter->PreHandleMouseEvent(target, event);
+ }
+ return handled;
+}
+
+ui::TouchStatus DesktopEventFilter::FilterTouchEvent(aura::Window* target,
+ aura::TouchEvent* event) {
+ ui::TouchStatus status = ui::TOUCH_STATUS_UNKNOWN;
+ if (filters_.might_have_observers()) {
+ ObserverListBase<aura::EventFilter>::Iterator it(filters_);
+ aura::EventFilter* filter;
+ while (status == ui::TOUCH_STATUS_UNKNOWN &&
+ (filter = it.GetNext()) != NULL) {
+ status = filter->PreHandleTouchEvent(target, event);
+ }
+ }
+ return status;
+}
+
} // namespace internal
} // namespace aura_shell
« no previous file with comments | « ui/aura_shell/desktop_event_filter.h ('k') | ui/aura_shell/desktop_event_filter_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698