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

Side by Side Diff: ui/views/controls/menu/menu_controller.cc

Issue 1915363002: Rename gfx::Display/Screen to display::Display/Screen in views/wm (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: more cleanups Created 4 years, 7 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 #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/macros.h" 9 #include "base/macros.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
11 #include "base/time/time.h" 11 #include "base/time/time.h"
12 #include "build/build_config.h" 12 #include "build/build_config.h"
13 #include "ui/base/dragdrop/drag_utils.h" 13 #include "ui/base/dragdrop/drag_utils.h"
14 #include "ui/base/dragdrop/os_exchange_data.h" 14 #include "ui/base/dragdrop/os_exchange_data.h"
15 #include "ui/display/screen.h"
15 #include "ui/events/event.h" 16 #include "ui/events/event.h"
16 #include "ui/events/event_utils.h" 17 #include "ui/events/event_utils.h"
17 #include "ui/gfx/canvas.h" 18 #include "ui/gfx/canvas.h"
18 #include "ui/gfx/geometry/point.h" 19 #include "ui/gfx/geometry/point.h"
19 #include "ui/gfx/geometry/vector2d.h" 20 #include "ui/gfx/geometry/vector2d.h"
20 #include "ui/gfx/native_widget_types.h" 21 #include "ui/gfx/native_widget_types.h"
21 #include "ui/gfx/screen.h"
22 #include "ui/native_theme/native_theme.h" 22 #include "ui/native_theme/native_theme.h"
23 #include "ui/views/controls/button/menu_button.h" 23 #include "ui/views/controls/button/menu_button.h"
24 #include "ui/views/controls/menu/menu_config.h" 24 #include "ui/views/controls/menu/menu_config.h"
25 #include "ui/views/controls/menu/menu_controller_delegate.h" 25 #include "ui/views/controls/menu/menu_controller_delegate.h"
26 #include "ui/views/controls/menu/menu_host_root_view.h" 26 #include "ui/views/controls/menu/menu_host_root_view.h"
27 #include "ui/views/controls/menu/menu_item_view.h" 27 #include "ui/views/controls/menu/menu_item_view.h"
28 #include "ui/views/controls/menu/menu_message_loop.h" 28 #include "ui/views/controls/menu/menu_message_loop.h"
29 #include "ui/views/controls/menu/menu_scroll_view_container.h" 29 #include "ui/views/controls/menu/menu_scroll_view_container.h"
30 #include "ui/views/controls/menu/submenu_view.h" 30 #include "ui/views/controls/menu/submenu_view.h"
31 #include "ui/views/drag_utils.h" 31 #include "ui/views/drag_utils.h"
(...skipping 1007 matching lines...) Expand 10 before | Expand all | Expand 10 after
1039 // MenuController may have been deleted, so check for an active instance 1039 // MenuController may have been deleted, so check for an active instance
1040 // before accessing member variables. 1040 // before accessing member variables.
1041 if (GetActiveInstance()) 1041 if (GetActiveInstance())
1042 TerminateNestedMessageLoopIfNecessary(); 1042 TerminateNestedMessageLoopIfNecessary();
1043 1043
1044 return ui::POST_DISPATCH_NONE; 1044 return ui::POST_DISPATCH_NONE;
1045 } 1045 }
1046 1046
1047 void MenuController::UpdateSubmenuSelection(SubmenuView* submenu) { 1047 void MenuController::UpdateSubmenuSelection(SubmenuView* submenu) {
1048 if (submenu->IsShowing()) { 1048 if (submenu->IsShowing()) {
1049 gfx::Point point = gfx::Screen::GetScreen()->GetCursorScreenPoint(); 1049 gfx::Point point = display::Screen::GetScreen()->GetCursorScreenPoint();
1050 const SubmenuView* root_submenu = 1050 const SubmenuView* root_submenu =
1051 submenu->GetMenuItem()->GetRootMenuItem()->GetSubmenu(); 1051 submenu->GetMenuItem()->GetRootMenuItem()->GetSubmenu();
1052 View::ConvertPointFromScreen( 1052 View::ConvertPointFromScreen(
1053 root_submenu->GetWidget()->GetRootView(), &point); 1053 root_submenu->GetWidget()->GetRootView(), &point);
1054 HandleMouseLocation(submenu, point); 1054 HandleMouseLocation(submenu, point);
1055 } 1055 }
1056 } 1056 }
1057 1057
1058 void MenuController::OnWidgetDestroying(Widget* widget) { 1058 void MenuController::OnWidgetDestroying(Widget* widget) {
1059 DCHECK_EQ(owner_, widget); 1059 DCHECK_EQ(owner_, widget);
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after
1394 (position == MENU_ANCHOR_TOPRIGHT || position == MENU_ANCHOR_TOPLEFT)) { 1394 (position == MENU_ANCHOR_TOPRIGHT || position == MENU_ANCHOR_TOPLEFT)) {
1395 pending_state_.anchor = position == MENU_ANCHOR_TOPRIGHT 1395 pending_state_.anchor = position == MENU_ANCHOR_TOPRIGHT
1396 ? MENU_ANCHOR_TOPLEFT 1396 ? MENU_ANCHOR_TOPLEFT
1397 : MENU_ANCHOR_TOPRIGHT; 1397 : MENU_ANCHOR_TOPRIGHT;
1398 } else { 1398 } else {
1399 pending_state_.anchor = position; 1399 pending_state_.anchor = position;
1400 } 1400 }
1401 1401
1402 // Calculate the bounds of the monitor we'll show menus on. Do this once to 1402 // Calculate the bounds of the monitor we'll show menus on. Do this once to
1403 // avoid repeated system queries for the info. 1403 // avoid repeated system queries for the info.
1404 pending_state_.monitor_bounds = gfx::Screen::GetScreen() 1404 pending_state_.monitor_bounds = display::Screen::GetScreen()
1405 ->GetDisplayNearestPoint(bounds.origin()) 1405 ->GetDisplayNearestPoint(bounds.origin())
1406 .work_area(); 1406 .work_area();
1407 1407
1408 if (!pending_state_.monitor_bounds.Contains(bounds)) { 1408 if (!pending_state_.monitor_bounds.Contains(bounds)) {
1409 // Use the monitor area if the work area doesn't contain the bounds. This 1409 // Use the monitor area if the work area doesn't contain the bounds. This
1410 // handles showing a menu from the launcher. 1410 // handles showing a menu from the launcher.
1411 gfx::Rect monitor_area = gfx::Screen::GetScreen() 1411 gfx::Rect monitor_area = display::Screen::GetScreen()
1412 ->GetDisplayNearestPoint(bounds.origin()) 1412 ->GetDisplayNearestPoint(bounds.origin())
1413 .bounds(); 1413 .bounds();
1414 if (monitor_area.Contains(bounds)) 1414 if (monitor_area.Contains(bounds))
1415 pending_state_.monitor_bounds = monitor_area; 1415 pending_state_.monitor_bounds = monitor_area;
1416 } 1416 }
1417 } 1417 }
1418 1418
1419 void MenuController::Accept(MenuItemView* item, int event_flags) { 1419 void MenuController::Accept(MenuItemView* item, int event_flags) {
1420 DCHECK(IsBlockingRun()); 1420 DCHECK(IsBlockingRun());
1421 result_ = item; 1421 result_ = item;
(...skipping 15 matching lines...) Expand all
1437 View* source_view = source->GetScrollViewContainer(); 1437 View* source_view = source->GetScrollViewContainer();
1438 if (mouse_location.x() >= 0 && 1438 if (mouse_location.x() >= 0 &&
1439 mouse_location.x() < source_view->width() && 1439 mouse_location.x() < source_view->width() &&
1440 mouse_location.y() >= 0 && 1440 mouse_location.y() >= 0 &&
1441 mouse_location.y() < source_view->height()) { 1441 mouse_location.y() < source_view->height()) {
1442 // The mouse is over the menu, no need to continue. 1442 // The mouse is over the menu, no need to continue.
1443 return false; 1443 return false;
1444 } 1444 }
1445 1445
1446 gfx::NativeWindow window_under_mouse = 1446 gfx::NativeWindow window_under_mouse =
1447 gfx::Screen::GetScreen()->GetWindowUnderCursor(); 1447 display::Screen::GetScreen()->GetWindowUnderCursor();
1448 // TODO(oshima): Replace with views only API. 1448 // TODO(oshima): Replace with views only API.
1449 if (!owner_ || window_under_mouse != owner_->GetNativeWindow()) 1449 if (!owner_ || window_under_mouse != owner_->GetNativeWindow())
1450 return false; 1450 return false;
1451 1451
1452 // The user moved the mouse outside the menu and over the owning window. See 1452 // The user moved the mouse outside the menu and over the owning window. See
1453 // if there is a sibling menu we should show. 1453 // if there is a sibling menu we should show.
1454 gfx::Point screen_point(mouse_location); 1454 gfx::Point screen_point(mouse_location);
1455 View::ConvertPointToScreen(source_view, &screen_point); 1455 View::ConvertPointToScreen(source_view, &screen_point);
1456 MenuAnchorPosition anchor; 1456 MenuAnchorPosition anchor;
1457 bool has_mnemonics; 1457 bool has_mnemonics;
(...skipping 865 matching lines...) Expand 10 before | Expand all | Expand 10 after
2323 const ui::LocatedEvent* event) { 2323 const ui::LocatedEvent* event) {
2324 // Cancel can lead to the deletion |source| so we save the view and window to 2324 // Cancel can lead to the deletion |source| so we save the view and window to
2325 // be used when reposting the event. 2325 // be used when reposting the event.
2326 gfx::Point screen_loc(event->location()); 2326 gfx::Point screen_loc(event->location());
2327 View::ConvertPointToScreen(source->GetScrollViewContainer(), &screen_loc); 2327 View::ConvertPointToScreen(source->GetScrollViewContainer(), &screen_loc);
2328 2328
2329 #if defined(OS_WIN) || defined(OS_CHROMEOS) 2329 #if defined(OS_WIN) || defined(OS_CHROMEOS)
2330 gfx::NativeView native_view = source->GetWidget()->GetNativeView(); 2330 gfx::NativeView native_view = source->GetWidget()->GetNativeView();
2331 gfx::NativeWindow window = nullptr; 2331 gfx::NativeWindow window = nullptr;
2332 if (native_view) { 2332 if (native_view) {
2333 gfx::Screen* screen = gfx::Screen::GetScreen(); 2333 display::Screen* screen = display::Screen::GetScreen();
2334 window = screen->GetWindowAtScreenPoint(screen_loc); 2334 window = screen->GetWindowAtScreenPoint(screen_loc);
2335 } 2335 }
2336 #endif 2336 #endif
2337 2337
2338 #if defined(OS_WIN) 2338 #if defined(OS_WIN)
2339 if (event->IsMouseEvent() || event->IsTouchEvent()) { 2339 if (event->IsMouseEvent() || event->IsTouchEvent()) {
2340 bool async_run = async_run_; 2340 bool async_run = async_run_;
2341 if (state_.item) { 2341 if (state_.item) {
2342 state_.item->GetRootMenuItem()->GetSubmenu()->ReleaseCapture(); 2342 state_.item->GetRootMenuItem()->GetSubmenu()->ReleaseCapture();
2343 RepostEventImpl(event, screen_loc, native_view, window); 2343 RepostEventImpl(event, screen_loc, native_view, window);
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after
2673 return; 2673 return;
2674 } 2674 }
2675 if (hot_button_) 2675 if (hot_button_)
2676 hot_button_->SetHotTracked(false); 2676 hot_button_->SetHotTracked(false);
2677 hot_button_ = hot_button; 2677 hot_button_ = hot_button;
2678 if (hot_button) 2678 if (hot_button)
2679 hot_button->SetHotTracked(true); 2679 hot_button->SetHotTracked(true);
2680 } 2680 }
2681 2681
2682 } // namespace views 2682 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/menu/menu_controller.h ('k') | ui/views/controls/scrollbar/base_scroll_bar.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698