summaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authoryusukes@chromium.org <yusukes@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-27 06:07:29 +0000
committeryusukes@chromium.org <yusukes@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-27 06:07:29 +0000
commitda466603329aa087a935cf6d785e5a98136b72bf (patch)
tree1e2954de54266a1c6cd702a62199acd0b3106da0 /ui
parentdc909a9e56db63a207f21d2056c86f531aedc18f (diff)
downloadchromium_src-da466603329aa087a935cf6d785e5a98136b72bf.zip
chromium_src-da466603329aa087a935cf6d785e5a98136b72bf.tar.gz
chromium_src-da466603329aa087a935cf6d785e5a98136b72bf.tar.bz2
Send a key event to the RootWindow when no window is focused so the global shortcut keys could always work.
BUG=110572 TEST=ran the new tests in aura_shell_unittests Review URL: http://codereview.chromium.org/9290011 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@119383 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui')
-rw-r--r--ui/aura/root_window.cc40
1 files changed, 23 insertions, 17 deletions
diff --git a/ui/aura/root_window.cc b/ui/aura/root_window.cc
index 304f738..2b72290 100644
--- a/ui/aura/root_window.cc
+++ b/ui/aura/root_window.cc
@@ -58,11 +58,10 @@ bool IsNonClientLocation(Window* target, const gfx::Point& location) {
typedef std::vector<EventFilter*> EventFilters;
void GetEventFiltersToNotify(Window* target, EventFilters* filters) {
- Window* window = target->parent();
- while (window) {
- if (window->event_filter())
- filters->push_back(window->event_filter());
- window = window->parent();
+ while (target) {
+ if (target->event_filter())
+ filters->push_back(target->event_filter());
+ target = target->parent();
}
}
@@ -180,11 +179,8 @@ bool RootWindow::DispatchMouseEvent(MouseEvent* event) {
}
bool RootWindow::DispatchKeyEvent(KeyEvent* event) {
- if (focused_window_) {
- KeyEvent translated_event(*event);
- return ProcessKeyEvent(focused_window_, &translated_event);
- }
- return false;
+ KeyEvent translated_event(*event);
+ return ProcessKeyEvent(focused_window_, &translated_event);
}
bool RootWindow::DispatchScrollEvent(ScrollEvent* event) {
@@ -460,7 +456,7 @@ bool RootWindow::ProcessMouseEvent(Window* target, MouseEvent* event) {
return false;
EventFilters filters;
- GetEventFiltersToNotify(target, &filters);
+ GetEventFiltersToNotify(target->parent(), &filters);
for (EventFilters::const_reverse_iterator it = filters.rbegin();
it != filters.rend(); ++it) {
if ((*it)->PreHandleMouseEvent(target, event))
@@ -471,17 +467,27 @@ bool RootWindow::ProcessMouseEvent(Window* target, MouseEvent* event) {
}
bool RootWindow::ProcessKeyEvent(Window* target, KeyEvent* event) {
- if (!target->IsVisible())
- return false;
-
EventFilters filters;
- GetEventFiltersToNotify(target, &filters);
+
+ if (!target) {
+ // When no window is focused, send the key event to |this| so event filters
+ // for the window could check if the key is a global shortcut like Alt+Tab.
+ target = this;
+ GetEventFiltersToNotify(this, &filters);
+ } else {
+ if (!target->IsVisible())
+ return false;
+ GetEventFiltersToNotify(target->parent(), &filters);
+ }
+
for (EventFilters::const_reverse_iterator it = filters.rbegin();
it != filters.rend(); ++it) {
if ((*it)->PreHandleKeyEvent(target, event))
return true;
}
+ if (!target->delegate())
+ return false;
return target->delegate()->OnKeyEvent(event);
}
@@ -491,7 +497,7 @@ ui::TouchStatus RootWindow::ProcessTouchEvent(Window* target,
return ui::TOUCH_STATUS_UNKNOWN;
EventFilters filters;
- GetEventFiltersToNotify(target, &filters);
+ GetEventFiltersToNotify(target->parent(), &filters);
for (EventFilters::const_reverse_iterator it = filters.rbegin();
it != filters.rend(); ++it) {
ui::TouchStatus status = (*it)->PreHandleTouchEvent(target, event);
@@ -508,7 +514,7 @@ ui::GestureStatus RootWindow::ProcessGestureEvent(Window* target,
return ui::GESTURE_STATUS_UNKNOWN;
EventFilters filters;
- GetEventFiltersToNotify(target, &filters);
+ GetEventFiltersToNotify(target->parent(), &filters);
ui::GestureStatus status = ui::GESTURE_STATUS_UNKNOWN;
for (EventFilters::const_reverse_iterator it = filters.rbegin();
it != filters.rend(); ++it) {