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 "ash/shell.h" | 5 #include "ash/shell.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "ash/accelerators/focus_manager_factory.h" | 10 #include "ash/accelerators/focus_manager_factory.h" |
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
314 } | 314 } |
315 | 315 |
316 // static | 316 // static |
317 aura::RootWindow* Shell::GetRootWindowAt(const gfx::Point& point) { | 317 aura::RootWindow* Shell::GetRootWindowAt(const gfx::Point& point) { |
318 if (!internal::DisplayController::IsVirtualScreenCoordinatesEnabled()) | 318 if (!internal::DisplayController::IsVirtualScreenCoordinatesEnabled()) |
319 return GetPrimaryRootWindow(); | 319 return GetPrimaryRootWindow(); |
320 RootWindowList root_windows = GetAllRootWindows(); | 320 RootWindowList root_windows = GetAllRootWindows(); |
321 for (RootWindowList::const_iterator iter = root_windows.begin(); | 321 for (RootWindowList::const_iterator iter = root_windows.begin(); |
322 iter != root_windows.end(); ++iter) { | 322 iter != root_windows.end(); ++iter) { |
323 aura::RootWindow* root_window = *iter; | 323 aura::RootWindow* root_window = *iter; |
324 if (root_window->bounds().Contains(point)) | 324 const gfx::Display& display = |
| 325 gfx::Screen::GetDisplayNearestWindow(root_window); |
| 326 if (display.bounds().Contains(point)) |
325 return root_window; | 327 return root_window; |
326 } | 328 } |
327 // Fallback to the primary window if there is no root window containing | 329 // Fallback to the primary window if there is no root window containing |
328 // the |point|. | 330 // the |point|. |
329 return GetPrimaryRootWindow(); | 331 return GetPrimaryRootWindow(); |
330 } | 332 } |
331 | 333 |
332 // static | 334 // static |
333 aura::RootWindow* Shell::GetRootWindowMatching(const gfx::Rect& rect) { | 335 aura::RootWindow* Shell::GetRootWindowMatching(const gfx::Rect& rect) { |
334 if (!internal::DisplayController::IsVirtualScreenCoordinatesEnabled()) | 336 if (!internal::DisplayController::IsVirtualScreenCoordinatesEnabled()) |
335 return GetPrimaryRootWindow(); | 337 return GetPrimaryRootWindow(); |
336 if (rect.IsEmpty()) | 338 if (rect.IsEmpty()) |
337 return GetRootWindowAt(rect.origin()); | 339 return GetRootWindowAt(rect.origin()); |
338 RootWindowList root_windows = GetAllRootWindows(); | 340 RootWindowList root_windows = GetAllRootWindows(); |
339 int max = 0; | 341 int max = 0; |
340 aura::RootWindow* matching = NULL; | 342 aura::RootWindow* matching = NULL; |
341 for (RootWindowList::const_iterator iter = root_windows.begin(); | 343 for (RootWindowList::const_iterator iter = root_windows.begin(); |
342 iter != root_windows.end(); ++iter) { | 344 iter != root_windows.end(); ++iter) { |
343 aura::RootWindow* root_window = *iter; | 345 aura::RootWindow* root_window = *iter; |
344 gfx::Rect intersect = root_window->bounds().Intersect(rect); | 346 const gfx::Display& display = |
| 347 gfx::Screen::GetDisplayNearestWindow(root_window); |
| 348 gfx::Rect intersect = display.bounds().Intersect(rect); |
345 int area = intersect.width() * intersect.height(); | 349 int area = intersect.width() * intersect.height(); |
346 if (area > max) { | 350 if (area > max) { |
347 max = area; | 351 max = area; |
348 matching = root_window; | 352 matching = root_window; |
349 } | 353 } |
350 } | 354 } |
351 // Fallback to the primary window if there is no matching root window. | 355 // Fallback to the primary window if there is no matching root window. |
352 return matching ? matching : GetPrimaryRootWindow(); | 356 return matching ? matching : GetPrimaryRootWindow(); |
353 } | 357 } |
354 | 358 |
(...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
780 } | 784 } |
781 | 785 |
782 void Shell::ShowCursor(bool visible) { | 786 void Shell::ShowCursor(bool visible) { |
783 RootWindowList root_windows = GetAllRootWindows(); | 787 RootWindowList root_windows = GetAllRootWindows(); |
784 for (RootWindowList::iterator iter = root_windows.begin(); | 788 for (RootWindowList::iterator iter = root_windows.begin(); |
785 iter != root_windows.end(); ++iter) | 789 iter != root_windows.end(); ++iter) |
786 (*iter)->ShowCursor(visible); | 790 (*iter)->ShowCursor(visible); |
787 } | 791 } |
788 | 792 |
789 } // namespace ash | 793 } // namespace ash |
OLD | NEW |