Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 #include "ui/views/controls/menu/menu_host.h" | 5 #include "ui/views/controls/menu/menu_host.h" |
| 6 | 6 |
| 7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/trace_event/trace_event.h" | 9 #include "base/trace_event/trace_event.h" |
| 10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
| 11 #include "ui/aura/window_observer.h" | |
| 12 #include "ui/events/gestures/gesture_recognizer.h" | 11 #include "ui/events/gestures/gesture_recognizer.h" |
| 13 #include "ui/gfx/path.h" | 12 #include "ui/gfx/path.h" |
| 14 #include "ui/native_theme/native_theme.h" | 13 #include "ui/native_theme/native_theme.h" |
| 15 #include "ui/views/controls/menu/menu_controller.h" | 14 #include "ui/views/controls/menu/menu_controller.h" |
| 16 #include "ui/views/controls/menu/menu_host_root_view.h" | 15 #include "ui/views/controls/menu/menu_host_root_view.h" |
| 17 #include "ui/views/controls/menu/menu_item_view.h" | 16 #include "ui/views/controls/menu/menu_item_view.h" |
| 18 #include "ui/views/controls/menu/menu_scroll_view_container.h" | 17 #include "ui/views/controls/menu/menu_scroll_view_container.h" |
| 19 #include "ui/views/controls/menu/submenu_view.h" | 18 #include "ui/views/controls/menu/submenu_view.h" |
| 20 #include "ui/views/round_rect_painter.h" | 19 #include "ui/views/round_rect_painter.h" |
| 21 #include "ui/views/widget/native_widget_private.h" | 20 #include "ui/views/widget/native_widget_private.h" |
| 22 #include "ui/views/widget/widget.h" | 21 #include "ui/views/widget/widget.h" |
| 23 | 22 |
| 24 #if !defined(OS_MACOSX) | 23 #if defined(USE_AURA) && !defined(OS_MACOSX) |
| 25 #include "ui/aura/window.h" | 24 #include "ui/aura/window.h" // nogncheck |
| 25 #include "ui/aura/window_observer.h" // nogncheck | |
| 26 #endif | 26 #endif |
| 27 | 27 |
| 28 namespace views { | 28 namespace views { |
| 29 | 29 |
| 30 namespace internal { | 30 namespace internal { |
| 31 | 31 |
| 32 #if !defined(OS_MACOSX) | 32 #if !defined(OS_MACOSX) |
| 33 // This class adds itself as the pre target handler for the |window| | 33 // This class adds itself as the pre target handler for the |window| |
| 34 // passed in. It currently handles touch events and forwards them to the | 34 // passed in. It currently handles touch events and forwards them to the |
| 35 // controller. Reason for this approach is views does not get raw touch | 35 // controller. Reason for this approach is views does not get raw touch |
| 36 // events which we need to determine if a touch happened outside the bounds | 36 // events which we need to determine if a touch happened outside the bounds |
| 37 // of the menu. | 37 // of the menu. |
| 38 class PreMenuEventDispatchHandler : public ui::EventHandler, | 38 class PreMenuEventDispatchHandler : public ui::EventHandler, |
|
tapted
2016/09/19 03:23:36
This should be moved to a file like ui/views/contr
| |
| 39 aura::WindowObserver { | 39 aura::WindowObserver { |
| 40 public: | 40 public: |
| 41 PreMenuEventDispatchHandler(const MenuController* controller, | 41 PreMenuEventDispatchHandler(const MenuController* controller, |
| 42 SubmenuView* submenu, | 42 SubmenuView* submenu, |
| 43 aura::Window* window) | 43 aura::Window* window) |
| 44 : menu_controller_(const_cast<MenuController*>(controller)), | 44 : menu_controller_(const_cast<MenuController*>(controller)), |
| 45 submenu_(submenu), | 45 submenu_(submenu), |
| 46 window_(window) { | 46 window_(window) { |
| 47 window_->AddPreTargetHandler(this); | 47 window_->AddPreTargetHandler(this); |
| 48 window_->AddObserver(this); | 48 window_->AddObserver(this); |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 239 } | 239 } |
| 240 menu_controller->OnDragComplete(should_close); | 240 menu_controller->OnDragComplete(should_close); |
| 241 | 241 |
| 242 // We may have lost capture in the drag and drop, but are remaining open. | 242 // We may have lost capture in the drag and drop, but are remaining open. |
| 243 // Return capture so we get MouseCaptureLost events. | 243 // Return capture so we get MouseCaptureLost events. |
| 244 if (!should_close) | 244 if (!should_close) |
| 245 native_widget_private()->SetCapture(); | 245 native_widget_private()->SetCapture(); |
| 246 } | 246 } |
| 247 | 247 |
| 248 } // namespace views | 248 } // namespace views |
| OLD | NEW |