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

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

Issue 11030017: Add context to gfx::Screen calls in support of simultaneous desktop+ash (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix some new gfx::Screen additions Created 8 years, 2 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 | Annotate | Revision Log
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/run_loop.h" 9 #include "base/run_loop.h"
10 #include "base/time.h" 10 #include "base/time.h"
(...skipping 686 matching lines...) Expand 10 before | Expand all | Expand 10 after
697 } 697 }
698 698
699 void MenuController::OnDragExitedScrollButton(SubmenuView* source) { 699 void MenuController::OnDragExitedScrollButton(SubmenuView* source) {
700 StartCancelAllTimer(); 700 StartCancelAllTimer();
701 SetDropMenuItem(NULL, MenuDelegate::DROP_NONE); 701 SetDropMenuItem(NULL, MenuDelegate::DROP_NONE);
702 StopScrolling(); 702 StopScrolling();
703 } 703 }
704 704
705 void MenuController::UpdateSubmenuSelection(SubmenuView* submenu) { 705 void MenuController::UpdateSubmenuSelection(SubmenuView* submenu) {
706 if (submenu->IsShowing()) { 706 if (submenu->IsShowing()) {
707 gfx::Point point = gfx::Screen::GetCursorScreenPoint(); 707 gfx::Point point = GetScreen()->GetCursorScreenPoint();
708 const SubmenuView* root_submenu = 708 const SubmenuView* root_submenu =
709 submenu->GetMenuItem()->GetRootMenuItem()->GetSubmenu(); 709 submenu->GetMenuItem()->GetRootMenuItem()->GetSubmenu();
710 views::View::ConvertPointFromScreen( 710 views::View::ConvertPointFromScreen(
711 root_submenu->GetWidget()->GetRootView(), &point); 711 root_submenu->GetWidget()->GetRootView(), &point);
712 HandleMouseLocation(submenu, point); 712 HandleMouseLocation(submenu, point);
713 } 713 }
714 } 714 }
715 715
716 void MenuController::SetSelection(MenuItemView* menu_item, 716 void MenuController::SetSelection(MenuItemView* menu_item,
717 int selection_types) { 717 int selection_types) {
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after
1101 // Reverse anchor position for RTL languages. 1101 // Reverse anchor position for RTL languages.
1102 if (base::i18n::IsRTL()) { 1102 if (base::i18n::IsRTL()) {
1103 pending_state_.anchor = position == MenuItemView::TOPRIGHT ? 1103 pending_state_.anchor = position == MenuItemView::TOPRIGHT ?
1104 MenuItemView::TOPLEFT : MenuItemView::TOPRIGHT; 1104 MenuItemView::TOPLEFT : MenuItemView::TOPRIGHT;
1105 } else { 1105 } else {
1106 pending_state_.anchor = position; 1106 pending_state_.anchor = position;
1107 } 1107 }
1108 1108
1109 // Calculate the bounds of the monitor we'll show menus on. Do this once to 1109 // Calculate the bounds of the monitor we'll show menus on. Do this once to
1110 // avoid repeated system queries for the info. 1110 // avoid repeated system queries for the info.
1111 pending_state_.monitor_bounds = gfx::Screen::GetDisplayNearestPoint( 1111 pending_state_.monitor_bounds = GetScreen()->GetDisplayNearestPoint(
1112 bounds.origin()).work_area(); 1112 bounds.origin()).work_area();
1113 #if defined(USE_ASH) 1113 #if defined(USE_ASH)
1114 if (!pending_state_.monitor_bounds.Contains(bounds)) { 1114 if (!pending_state_.monitor_bounds.Contains(bounds)) {
1115 // Use the monitor area if the work area doesn't contain the bounds. This 1115 // Use the monitor area if the work area doesn't contain the bounds. This
1116 // handles showing a menu from the launcher. 1116 // handles showing a menu from the launcher.
1117 gfx::Rect monitor_area = 1117 gfx::Rect monitor_area = GetScreen()->GetDisplayNearestPoint(
1118 gfx::Screen::GetDisplayNearestPoint(bounds.origin()).bounds(); 1118 bounds.origin()).bounds();
1119 if (monitor_area.Contains(bounds)) 1119 if (monitor_area.Contains(bounds))
1120 pending_state_.monitor_bounds = monitor_area; 1120 pending_state_.monitor_bounds = monitor_area;
1121 } 1121 }
1122 #endif 1122 #endif
1123 } 1123 }
1124 1124
1125 void MenuController::Accept(MenuItemView* item, int mouse_event_flags) { 1125 void MenuController::Accept(MenuItemView* item, int mouse_event_flags) {
1126 DCHECK(IsBlockingRun()); 1126 DCHECK(IsBlockingRun());
1127 result_ = item; 1127 result_ = item;
1128 if (item && !menu_stack_.empty() && 1128 if (item && !menu_stack_.empty() &&
(...skipping 13 matching lines...) Expand all
1142 View* source_view = source->GetScrollViewContainer(); 1142 View* source_view = source->GetScrollViewContainer();
1143 if (mouse_location.x() >= 0 && 1143 if (mouse_location.x() >= 0 &&
1144 mouse_location.x() < source_view->width() && 1144 mouse_location.x() < source_view->width() &&
1145 mouse_location.y() >= 0 && 1145 mouse_location.y() >= 0 &&
1146 mouse_location.y() < source_view->height()) { 1146 mouse_location.y() < source_view->height()) {
1147 // The mouse is over the menu, no need to continue. 1147 // The mouse is over the menu, no need to continue.
1148 return false; 1148 return false;
1149 } 1149 }
1150 1150
1151 gfx::NativeWindow window_under_mouse = 1151 gfx::NativeWindow window_under_mouse =
1152 gfx::Screen::GetWindowAtCursorScreenPoint(); 1152 GetScreen()->GetWindowAtCursorScreenPoint();
1153 // TODO(oshima): Replace with views only API. 1153 // TODO(oshima): Replace with views only API.
1154 if (window_under_mouse != owner_->GetNativeWindow()) 1154 if (window_under_mouse != owner_->GetNativeWindow())
1155 return false; 1155 return false;
1156 1156
1157 // The user moved the mouse outside the menu and over the owning window. See 1157 // The user moved the mouse outside the menu and over the owning window. See
1158 // if there is a sibling menu we should show. 1158 // if there is a sibling menu we should show.
1159 gfx::Point screen_point(mouse_location); 1159 gfx::Point screen_point(mouse_location);
1160 View::ConvertPointToScreen(source_view, &screen_point); 1160 View::ConvertPointToScreen(source_view, &screen_point);
1161 MenuItemView::AnchorPosition anchor; 1161 MenuItemView::AnchorPosition anchor;
1162 bool has_mnemonics; 1162 bool has_mnemonics;
(...skipping 964 matching lines...) Expand 10 before | Expand all | Expand 10 after
2127 } 2127 }
2128 2128
2129 #if defined(USE_AURA) 2129 #if defined(USE_AURA)
2130 void MenuController::OnWindowActivated(aura::Window* active, 2130 void MenuController::OnWindowActivated(aura::Window* active,
2131 aura::Window* old_active) { 2131 aura::Window* old_active) {
2132 if (!drag_in_progress_) 2132 if (!drag_in_progress_)
2133 Cancel(EXIT_ALL); 2133 Cancel(EXIT_ALL);
2134 } 2134 }
2135 #endif 2135 #endif
2136 2136
2137 gfx::Screen* MenuController::GetScreen() const {
2138 #if defined(USE_AURA)
2139 return gfx::Screen::GetScreenFor(root_window_);
2140 #else
2141 return gfx::Screen::GetNativeScreen();
2142 #endif
2143 }
2144
2137 } // namespace views 2145 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698