Chromium Code Reviews| 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 ----------------------------------------------------------------------- |