OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "chrome/browser/ui/views/toolbar/toolbar_button.h" | 5 #include "chrome/browser/ui/views/toolbar/toolbar_button.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" | 8 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" |
9 #include "grit/theme_resources.h" | 9 #include "grit/theme_resources.h" |
10 #include "grit/ui_strings.h" | 10 #include "grit/ui_strings.h" |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 int left_bound = GetSystemMetrics(SM_XVIRTUALSCREEN); | 170 int left_bound = GetSystemMetrics(SM_XVIRTUALSCREEN); |
171 #elif defined(OS_CHROMEOS) | 171 #elif defined(OS_CHROMEOS) |
172 // A window won't overlap between displays on ChromeOS. | 172 // A window won't overlap between displays on ChromeOS. |
173 // Use the left bound of the display on which | 173 // Use the left bound of the display on which |
174 // the menu button exists. | 174 // the menu button exists. |
175 gfx::NativeView view = GetWidget()->GetNativeView(); | 175 gfx::NativeView view = GetWidget()->GetNativeView(); |
176 gfx::Display display = gfx::Screen::GetScreenFor( | 176 gfx::Display display = gfx::Screen::GetScreenFor( |
177 view)->GetDisplayNearestWindow(view); | 177 view)->GetDisplayNearestWindow(view); |
178 int left_bound = display.bounds().x(); | 178 int left_bound = display.bounds().x(); |
179 #else | 179 #else |
180 int left_bound = 0; | 180 // The window might be positioned over the edge between two screens. We'll |
181 NOTIMPLEMENTED(); | 181 // want to position the dropdown on the screen the mouse cursor is on. |
| 182 gfx::NativeView view = GetWidget()->GetNativeView(); |
| 183 gfx::Screen* screen = gfx::Screen::GetScreenFor(view); |
| 184 gfx::Display display = screen->GetDisplayNearestPoint( |
| 185 screen->GetCursorScreenPoint()); |
| 186 int left_bound = display.bounds().x(); |
182 #endif | 187 #endif |
183 if (menu_position.x() < left_bound) | 188 if (menu_position.x() < left_bound) |
184 menu_position.set_x(left_bound); | 189 menu_position.set_x(left_bound); |
185 | 190 |
186 // Make the button look depressed while the menu is open. | 191 // Make the button look depressed while the menu is open. |
187 SetState(STATE_PRESSED); | 192 SetState(STATE_PRESSED); |
188 | 193 |
189 menu_showing_ = true; | 194 menu_showing_ = true; |
190 | 195 |
191 // Create and run menu. Display an empty menu if model is NULL. | 196 // Create and run menu. Display an empty menu if model is NULL. |
(...skipping 27 matching lines...) Expand all Loading... |
219 | 224 |
220 // Need to explicitly clear mouse handler so that events get sent | 225 // Need to explicitly clear mouse handler so that events get sent |
221 // properly after the menu finishes running. If we don't do this, then | 226 // properly after the menu finishes running. If we don't do this, then |
222 // the first click to other parts of the UI is eaten. | 227 // the first click to other parts of the UI is eaten. |
223 SetMouseHandler(NULL); | 228 SetMouseHandler(NULL); |
224 | 229 |
225 // Set the state back to normal after the drop down menu is closed. | 230 // Set the state back to normal after the drop down menu is closed. |
226 if (state_ != STATE_DISABLED) | 231 if (state_ != STATE_DISABLED) |
227 SetState(STATE_NORMAL); | 232 SetState(STATE_NORMAL); |
228 } | 233 } |
OLD | NEW |