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

Side by Side Diff: ui/views/view.cc

Issue 2604793002: Allow Widget to pass accelerator handling to its parent.
Patch Set: Created 3 years, 11 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #define _USE_MATH_DEFINES // For VC++ to get M_PI. This has to be first. 5 #define _USE_MATH_DEFINES // For VC++ to get M_PI. This has to be first.
6 6
7 #include "ui/views/view.h" 7 #include "ui/views/view.h"
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <cmath> 10 #include <cmath>
(...skipping 1197 matching lines...) Expand 10 before | Expand all | Expand 10 after
1208 // adds currently focused view as an event PreTarget (see 1208 // adds currently focused view as an event PreTarget (see
1209 // DesktopNativeWidgetAura::InitNativeWidget). However, the focused view isn't 1209 // DesktopNativeWidgetAura::InitNativeWidget). However, the focused view isn't
1210 // always the right view to handle accelerators: It should only handle them 1210 // always the right view to handle accelerators: It should only handle them
1211 // when active. Only top level widgets can be active, so for child widgets 1211 // when active. Only top level widgets can be active, so for child widgets
1212 // check if they are focused instead. ChromeOS also behaves different than 1212 // check if they are focused instead. ChromeOS also behaves different than
1213 // Linux when an extension popup is about to handle the accelerator. 1213 // Linux when an extension popup is about to handle the accelerator.
1214 bool child = widget && widget->GetTopLevelWidget() != widget; 1214 bool child = widget && widget->GetTopLevelWidget() != widget;
1215 bool focus_in_child = 1215 bool focus_in_child =
1216 widget && 1216 widget &&
1217 widget->GetRootView()->Contains(GetFocusManager()->GetFocusedView()); 1217 widget->GetRootView()->Contains(GetFocusManager()->GetFocusedView());
1218 if ((child && !focus_in_child) || (!child && !widget->IsActive())) 1218 if ((child && !focus_in_child) ||
1219 (!child && !widget->CanHandleAccelerators()))
1219 return false; 1220 return false;
1220 #endif 1221 #endif
1221 return true; 1222 return true;
1222 } 1223 }
1223 1224
1224 // Focus ----------------------------------------------------------------------- 1225 // Focus -----------------------------------------------------------------------
1225 1226
1226 bool View::HasFocus() const { 1227 bool View::HasFocus() const {
1227 const FocusManager* focus_manager = GetFocusManager(); 1228 const FocusManager* focus_manager = GetFocusManager();
1228 return focus_manager && (focus_manager->GetFocusedView() == this); 1229 return focus_manager && (focus_manager->GetFocusedView() == this);
(...skipping 1294 matching lines...) Expand 10 before | Expand all | Expand 10 after
2523 // Message the RootView to do the drag and drop. That way if we're removed 2524 // Message the RootView to do the drag and drop. That way if we're removed
2524 // the RootView can detect it and avoid calling us back. 2525 // the RootView can detect it and avoid calling us back.
2525 gfx::Point widget_location(event.location()); 2526 gfx::Point widget_location(event.location());
2526 ConvertPointToWidget(this, &widget_location); 2527 ConvertPointToWidget(this, &widget_location);
2527 widget->RunShellDrag(this, data, widget_location, drag_operations, source); 2528 widget->RunShellDrag(this, data, widget_location, drag_operations, source);
2528 // WARNING: we may have been deleted. 2529 // WARNING: we may have been deleted.
2529 return true; 2530 return true;
2530 } 2531 }
2531 2532
2532 } // namespace views 2533 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698