| 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_controller.h" | 5 #include "ui/views/controls/menu/menu_controller.h" |
| 6 | 6 |
| 7 #include "base/i18n/case_conversion.h" | 7 #include "base/i18n/case_conversion.h" |
| 8 #include "base/i18n/rtl.h" | 8 #include "base/i18n/rtl.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
| (...skipping 2237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2248 } | 2248 } |
| 2249 View* active_mouse_view = GetActiveMouseView(); | 2249 View* active_mouse_view = GetActiveMouseView(); |
| 2250 if (target != active_mouse_view) { | 2250 if (target != active_mouse_view) { |
| 2251 SendMouseCaptureLostToActiveView(); | 2251 SendMouseCaptureLostToActiveView(); |
| 2252 active_mouse_view = target; | 2252 active_mouse_view = target; |
| 2253 SetActiveMouseView(active_mouse_view); | 2253 SetActiveMouseView(active_mouse_view); |
| 2254 if (active_mouse_view) { | 2254 if (active_mouse_view) { |
| 2255 gfx::Point target_point(target_menu_loc); | 2255 gfx::Point target_point(target_menu_loc); |
| 2256 View::ConvertPointToTarget( | 2256 View::ConvertPointToTarget( |
| 2257 target_menu, active_mouse_view, &target_point); | 2257 target_menu, active_mouse_view, &target_point); |
| 2258 ui::MouseEvent mouse_entered_event(ui::ET_MOUSE_ENTERED, target_point, | 2258 ui::MouseEvent mouse_entered_event( |
| 2259 target_point, ui::EventTimeForNow(), 0, | 2259 ui::ET_MOUSE_ENTERED, gfx::PointF(target_point), |
| 2260 0); | 2260 gfx::PointF(target_point), ui::EventTimeForNow(), 0, 0); |
| 2261 active_mouse_view->OnMouseEntered(mouse_entered_event); | 2261 active_mouse_view->OnMouseEntered(mouse_entered_event); |
| 2262 | 2262 |
| 2263 ui::MouseEvent mouse_pressed_event( | 2263 ui::MouseEvent mouse_pressed_event( |
| 2264 ui::ET_MOUSE_PRESSED, target_point, target_point, | 2264 ui::ET_MOUSE_PRESSED, gfx::PointF(target_point), |
| 2265 ui::EventTimeForNow(), event.flags(), event.changed_button_flags()); | 2265 gfx::PointF(target_point), ui::EventTimeForNow(), event.flags(), |
| 2266 event.changed_button_flags()); |
| 2266 active_mouse_view->OnMousePressed(mouse_pressed_event); | 2267 active_mouse_view->OnMousePressed(mouse_pressed_event); |
| 2267 } | 2268 } |
| 2268 } | 2269 } |
| 2269 | 2270 |
| 2270 if (active_mouse_view) { | 2271 if (active_mouse_view) { |
| 2271 gfx::Point target_point(target_menu_loc); | 2272 gfx::Point target_point(target_menu_loc); |
| 2272 View::ConvertPointToTarget(target_menu, active_mouse_view, &target_point); | 2273 View::ConvertPointToTarget(target_menu, active_mouse_view, &target_point); |
| 2273 ui::MouseEvent mouse_dragged_event( | 2274 ui::MouseEvent mouse_dragged_event( |
| 2274 ui::ET_MOUSE_DRAGGED, target_point, target_point, ui::EventTimeForNow(), | 2275 ui::ET_MOUSE_DRAGGED, gfx::PointF(target_point), |
| 2275 event.flags(), event.changed_button_flags()); | 2276 gfx::PointF(target_point), ui::EventTimeForNow(), event.flags(), |
| 2277 event.changed_button_flags()); |
| 2276 active_mouse_view->OnMouseDragged(mouse_dragged_event); | 2278 active_mouse_view->OnMouseDragged(mouse_dragged_event); |
| 2277 } | 2279 } |
| 2278 } | 2280 } |
| 2279 | 2281 |
| 2280 void MenuController::SendMouseReleaseToActiveView(SubmenuView* event_source, | 2282 void MenuController::SendMouseReleaseToActiveView(SubmenuView* event_source, |
| 2281 const ui::MouseEvent& event) { | 2283 const ui::MouseEvent& event) { |
| 2282 View* active_mouse_view = GetActiveMouseView(); | 2284 View* active_mouse_view = GetActiveMouseView(); |
| 2283 if (!active_mouse_view) | 2285 if (!active_mouse_view) |
| 2284 return; | 2286 return; |
| 2285 | 2287 |
| 2286 gfx::Point target_loc(event.location()); | 2288 gfx::Point target_loc(event.location()); |
| 2287 View::ConvertPointToScreen(event_source->GetScrollViewContainer(), | 2289 View::ConvertPointToScreen(event_source->GetScrollViewContainer(), |
| 2288 &target_loc); | 2290 &target_loc); |
| 2289 View::ConvertPointFromScreen(active_mouse_view, &target_loc); | 2291 View::ConvertPointFromScreen(active_mouse_view, &target_loc); |
| 2290 ui::MouseEvent release_event(ui::ET_MOUSE_RELEASED, target_loc, target_loc, | 2292 ui::MouseEvent release_event(ui::ET_MOUSE_RELEASED, gfx::PointF(target_loc), |
| 2291 ui::EventTimeForNow(), event.flags(), | 2293 gfx::PointF(target_loc), ui::EventTimeForNow(), |
| 2292 event.changed_button_flags()); | 2294 event.flags(), event.changed_button_flags()); |
| 2293 // Reset active mouse view before sending mouse released. That way if it calls | 2295 // Reset active mouse view before sending mouse released. That way if it calls |
| 2294 // back to us, we aren't in a weird state. | 2296 // back to us, we aren't in a weird state. |
| 2295 SetActiveMouseView(NULL); | 2297 SetActiveMouseView(NULL); |
| 2296 active_mouse_view->OnMouseReleased(release_event); | 2298 active_mouse_view->OnMouseReleased(release_event); |
| 2297 } | 2299 } |
| 2298 | 2300 |
| 2299 void MenuController::SendMouseCaptureLostToActiveView() { | 2301 void MenuController::SendMouseCaptureLostToActiveView() { |
| 2300 View* active_mouse_view = GetActiveMouseView(); | 2302 View* active_mouse_view = GetActiveMouseView(); |
| 2301 if (!active_mouse_view) | 2303 if (!active_mouse_view) |
| 2302 return; | 2304 return; |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2370 } | 2372 } |
| 2371 } | 2373 } |
| 2372 | 2374 |
| 2373 gfx::Screen* MenuController::GetScreen() { | 2375 gfx::Screen* MenuController::GetScreen() { |
| 2374 Widget* root = owner_ ? owner_->GetTopLevelWidget() : NULL; | 2376 Widget* root = owner_ ? owner_->GetTopLevelWidget() : NULL; |
| 2375 return root ? gfx::Screen::GetScreenFor(root->GetNativeView()) | 2377 return root ? gfx::Screen::GetScreenFor(root->GetNativeView()) |
| 2376 : gfx::Screen::GetNativeScreen(); | 2378 : gfx::Screen::GetNativeScreen(); |
| 2377 } | 2379 } |
| 2378 | 2380 |
| 2379 } // namespace views | 2381 } // namespace views |
| OLD | NEW |