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

Unified Diff: ui/views/view.cc

Issue 1544803004: Fix accelerator handling for in-menu buttons in the app menu. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Replace ChromeOS check with Aura check Created 4 years, 10 months 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
Index: ui/views/view.cc
diff --git a/ui/views/view.cc b/ui/views/view.cc
index 45467ab23dbfc0fdbf68fdd9ad1ef9532bd20e64..3051e9450bab98251e64221079b7475c9579c06e 100644
--- a/ui/views/view.cc
+++ b/ui/views/view.cc
@@ -1146,7 +1146,25 @@ bool View::AcceleratorPressed(const ui::Accelerator& accelerator) {
}
bool View::CanHandleAccelerators() const {
- return enabled() && IsDrawn() && GetWidget() && GetWidget()->IsVisible();
+ const Widget* widget = GetWidget();
+ if (!enabled() || !IsDrawn() || !widget || !widget->IsVisible()) {
msw 2016/02/04 22:45:36 nit: curlies not needed
meacer 2016/02/09 20:33:32 Done.
+ return false;
+ }
+#if defined(USE_AURA)
+ // Aura windows have an associated FocusManagerEventHandler which adds
+ // currently focused view as an event PreTarget. However, the focused view
+ // isn't always the right view to handle accelerators: It should only
+ // handle them when active. Only top level widgets can be active, so
+ // for child widgets check if they are focused instead.
+ bool child = GetWidget() && GetWidget()->GetTopLevelWidget() != GetWidget();
msw 2016/02/04 22:45:36 nit: re-use |widget| here and below.
meacer 2016/02/09 20:33:32 Done.
+ bool focus_in_child =
+ GetWidget() &&
+ GetWidget()->GetRootView()->Contains(GetFocusManager()->GetFocusedView());
+ if ((child && !focus_in_child) || (!child && !widget->IsActive())) {
msw 2016/02/04 22:45:36 nit: curlies not needed
meacer 2016/02/09 20:33:32 Done.
+ return false;
+ }
+#endif
+ return true;
}
// Focus -----------------------------------------------------------------------

Powered by Google App Engine
This is Rietveld 408576698