| 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 2353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2364 } | 2364 } |
| 2365 View* active_mouse_view = GetActiveMouseView(); | 2365 View* active_mouse_view = GetActiveMouseView(); |
| 2366 if (target != active_mouse_view) { | 2366 if (target != active_mouse_view) { |
| 2367 SendMouseCaptureLostToActiveView(); | 2367 SendMouseCaptureLostToActiveView(); |
| 2368 active_mouse_view = target; | 2368 active_mouse_view = target; |
| 2369 SetActiveMouseView(active_mouse_view); | 2369 SetActiveMouseView(active_mouse_view); |
| 2370 if (active_mouse_view) { | 2370 if (active_mouse_view) { |
| 2371 gfx::Point target_point(target_menu_loc); | 2371 gfx::Point target_point(target_menu_loc); |
| 2372 View::ConvertPointToTarget( | 2372 View::ConvertPointToTarget( |
| 2373 target_menu, active_mouse_view, &target_point); | 2373 target_menu, active_mouse_view, &target_point); |
| 2374 ui::MouseEvent mouse_entered_event(ui::ET_MOUSE_ENTERED, target_point, | 2374 ui::MouseEvent mouse_entered_event( |
| 2375 target_point, ui::EventTimeForNow(), 0, | 2375 ui::ET_MOUSE_ENTERED, gfx::PointF(target_point), |
| 2376 0); | 2376 gfx::PointF(target_point), ui::EventTimeForNow(), 0, 0); |
| 2377 active_mouse_view->OnMouseEntered(mouse_entered_event); | 2377 active_mouse_view->OnMouseEntered(mouse_entered_event); |
| 2378 | 2378 |
| 2379 ui::MouseEvent mouse_pressed_event( | 2379 ui::MouseEvent mouse_pressed_event( |
| 2380 ui::ET_MOUSE_PRESSED, target_point, target_point, | 2380 ui::ET_MOUSE_PRESSED, gfx::PointF(target_point), |
| 2381 ui::EventTimeForNow(), event.flags(), event.changed_button_flags()); | 2381 gfx::PointF(target_point), ui::EventTimeForNow(), event.flags(), |
| 2382 event.changed_button_flags()); |
| 2382 active_mouse_view->OnMousePressed(mouse_pressed_event); | 2383 active_mouse_view->OnMousePressed(mouse_pressed_event); |
| 2383 } | 2384 } |
| 2384 } | 2385 } |
| 2385 | 2386 |
| 2386 if (active_mouse_view) { | 2387 if (active_mouse_view) { |
| 2387 gfx::Point target_point(target_menu_loc); | 2388 gfx::Point target_point(target_menu_loc); |
| 2388 View::ConvertPointToTarget(target_menu, active_mouse_view, &target_point); | 2389 View::ConvertPointToTarget(target_menu, active_mouse_view, &target_point); |
| 2389 ui::MouseEvent mouse_dragged_event( | 2390 ui::MouseEvent mouse_dragged_event( |
| 2390 ui::ET_MOUSE_DRAGGED, target_point, target_point, ui::EventTimeForNow(), | 2391 ui::ET_MOUSE_DRAGGED, gfx::PointF(target_point), |
| 2391 event.flags(), event.changed_button_flags()); | 2392 gfx::PointF(target_point), ui::EventTimeForNow(), event.flags(), |
| 2393 event.changed_button_flags()); |
| 2392 active_mouse_view->OnMouseDragged(mouse_dragged_event); | 2394 active_mouse_view->OnMouseDragged(mouse_dragged_event); |
| 2393 } | 2395 } |
| 2394 } | 2396 } |
| 2395 | 2397 |
| 2396 void MenuController::SendMouseReleaseToActiveView(SubmenuView* event_source, | 2398 void MenuController::SendMouseReleaseToActiveView(SubmenuView* event_source, |
| 2397 const ui::MouseEvent& event) { | 2399 const ui::MouseEvent& event) { |
| 2398 View* active_mouse_view = GetActiveMouseView(); | 2400 View* active_mouse_view = GetActiveMouseView(); |
| 2399 if (!active_mouse_view) | 2401 if (!active_mouse_view) |
| 2400 return; | 2402 return; |
| 2401 | 2403 |
| 2402 gfx::Point target_loc(event.location()); | 2404 gfx::Point target_loc(event.location()); |
| 2403 View::ConvertPointToScreen(event_source->GetScrollViewContainer(), | 2405 View::ConvertPointToScreen(event_source->GetScrollViewContainer(), |
| 2404 &target_loc); | 2406 &target_loc); |
| 2405 View::ConvertPointFromScreen(active_mouse_view, &target_loc); | 2407 View::ConvertPointFromScreen(active_mouse_view, &target_loc); |
| 2406 ui::MouseEvent release_event(ui::ET_MOUSE_RELEASED, target_loc, target_loc, | 2408 ui::MouseEvent release_event(ui::ET_MOUSE_RELEASED, gfx::PointF(target_loc), |
| 2407 ui::EventTimeForNow(), event.flags(), | 2409 gfx::PointF(target_loc), ui::EventTimeForNow(), |
| 2408 event.changed_button_flags()); | 2410 event.flags(), event.changed_button_flags()); |
| 2409 // Reset active mouse view before sending mouse released. That way if it calls | 2411 // Reset active mouse view before sending mouse released. That way if it calls |
| 2410 // back to us, we aren't in a weird state. | 2412 // back to us, we aren't in a weird state. |
| 2411 SetActiveMouseView(NULL); | 2413 SetActiveMouseView(NULL); |
| 2412 active_mouse_view->OnMouseReleased(release_event); | 2414 active_mouse_view->OnMouseReleased(release_event); |
| 2413 } | 2415 } |
| 2414 | 2416 |
| 2415 void MenuController::SendMouseCaptureLostToActiveView() { | 2417 void MenuController::SendMouseCaptureLostToActiveView() { |
| 2416 View* active_mouse_view = GetActiveMouseView(); | 2418 View* active_mouse_view = GetActiveMouseView(); |
| 2417 if (!active_mouse_view) | 2419 if (!active_mouse_view) |
| 2418 return; | 2420 return; |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2486 } | 2488 } |
| 2487 } | 2489 } |
| 2488 | 2490 |
| 2489 gfx::Screen* MenuController::GetScreen() { | 2491 gfx::Screen* MenuController::GetScreen() { |
| 2490 Widget* root = owner_ ? owner_->GetTopLevelWidget() : NULL; | 2492 Widget* root = owner_ ? owner_->GetTopLevelWidget() : NULL; |
| 2491 return root ? gfx::Screen::GetScreenFor(root->GetNativeView()) | 2493 return root ? gfx::Screen::GetScreenFor(root->GetNativeView()) |
| 2492 : gfx::Screen::GetNativeScreen(); | 2494 : gfx::Screen::GetNativeScreen(); |
| 2493 } | 2495 } |
| 2494 | 2496 |
| 2495 } // namespace views | 2497 } // namespace views |
| OLD | NEW |