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/debug/trace_event.h" | 8 #include "base/debug/trace_event.h" |
9 #include "ui/events/gestures/gesture_recognizer.h" | 9 #include "ui/events/gestures/gesture_recognizer.h" |
10 #include "ui/gfx/path.h" | 10 #include "ui/gfx/path.h" |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 } | 68 } |
69 | 69 |
70 void MenuHost::ShowMenuHost(bool do_capture) { | 70 void MenuHost::ShowMenuHost(bool do_capture) { |
71 // Doing a capture may make us get capture lost. Ignore it while we're in the | 71 // Doing a capture may make us get capture lost. Ignore it while we're in the |
72 // process of showing. | 72 // process of showing. |
73 base::AutoReset<bool> reseter(&ignore_capture_lost_, true); | 73 base::AutoReset<bool> reseter(&ignore_capture_lost_, true); |
74 ShowInactive(); | 74 ShowInactive(); |
75 if (do_capture) { | 75 if (do_capture) { |
76 // Cancel existing touches, so we don't miss some touch release/cancel | 76 // Cancel existing touches, so we don't miss some touch release/cancel |
77 // events due to the menu taking capture. | 77 // events due to the menu taking capture. |
78 ui::GestureRecognizer::Get()->TransferEventsTo(GetNativeWindow(), NULL); | 78 ui::GestureRecognizer::Get()->TransferEventsTo(NULL, NULL); |
79 native_widget_private()->SetCapture(); | 79 native_widget_private()->SetCapture(); |
80 } | 80 } |
81 } | 81 } |
82 | 82 |
83 void MenuHost::HideMenuHost() { | 83 void MenuHost::HideMenuHost() { |
84 ignore_capture_lost_ = true; | 84 ignore_capture_lost_ = true; |
85 ReleaseMenuHostCapture(); | 85 ReleaseMenuHostCapture(); |
86 Hide(); | 86 Hide(); |
87 ignore_capture_lost_ = false; | 87 ignore_capture_lost_ = false; |
88 } | 88 } |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 if (destroying_) | 134 if (destroying_) |
135 return; | 135 return; |
136 | 136 |
137 MenuController* menu_controller = | 137 MenuController* menu_controller = |
138 submenu_->GetMenuItem()->GetMenuController(); | 138 submenu_->GetMenuItem()->GetMenuController(); |
139 if (menu_controller && !menu_controller->drag_in_progress()) | 139 if (menu_controller && !menu_controller->drag_in_progress()) |
140 menu_controller->CancelAll(); | 140 menu_controller->CancelAll(); |
141 } | 141 } |
142 | 142 |
143 } // namespace views | 143 } // namespace views |
OLD | NEW |