[email protected] | 55ad8c1 | 2014-01-17 18:24:33 | [diff] [blame] | 1 | // Copyright 2014 The Chromium Authors. All rights reserved. |
2 | // Use of this source code is governed by a BSD-style license that can be | ||||
3 | // found in the LICENSE file. | ||||
4 | |||||
5 | #include "ash/screen_util.h" | ||||
6 | |||||
sky | 287fe73 | 2017-01-09 22:29:18 | [diff] [blame] | 7 | #include "ash/common/shelf/wm_shelf.h" |
[email protected] | 55ad8c1 | 2014-01-17 18:24:33 | [diff] [blame] | 8 | #include "ash/root_window_controller.h" |
[email protected] | 55ad8c1 | 2014-01-17 18:24:33 | [diff] [blame] | 9 | #include "ash/shell.h" |
[email protected] | 55ad8c1 | 2014-01-17 18:24:33 | [diff] [blame] | 10 | #include "base/logging.h" |
11 | #include "ui/aura/client/screen_position_client.h" | ||||
[email protected] | fcc51c95 | 2014-02-21 21:31:26 | [diff] [blame] | 12 | #include "ui/aura/window_event_dispatcher.h" |
oshima | f84b0da72 | 2016-04-27 19:47:19 | [diff] [blame] | 13 | #include "ui/display/display.h" |
rjkroege | 72f8154f | 2016-10-29 00:49:02 | [diff] [blame] | 14 | #include "ui/display/manager/display_manager.h" |
oshima | f84b0da72 | 2016-04-27 19:47:19 | [diff] [blame] | 15 | #include "ui/display/screen.h" |
oshima | 5337ca9 | 2015-07-18 02:23:57 | [diff] [blame] | 16 | #include "ui/gfx/geometry/size_conversions.h" |
yhanada | 698af19 | 2017-02-23 10:57:07 | [diff] [blame^] | 17 | #include "ui/wm/core/coordinate_conversion.h" |
[email protected] | 55ad8c1 | 2014-01-17 18:24:33 | [diff] [blame] | 18 | |
19 | namespace ash { | ||||
20 | |||||
[email protected] | 55ad8c1 | 2014-01-17 18:24:33 | [diff] [blame] | 21 | // static |
22 | gfx::Rect ScreenUtil::GetMaximizedWindowBoundsInParent(aura::Window* window) { | ||||
jamescook | b551aba | 2016-09-01 01:00:16 | [diff] [blame] | 23 | aura::Window* root_window = window->GetRootWindow(); |
sky | 287fe73 | 2017-01-09 22:29:18 | [diff] [blame] | 24 | if (GetRootWindowController(root_window)->wm_shelf()->shelf_widget()) |
[email protected] | 55ad8c1 | 2014-01-17 18:24:33 | [diff] [blame] | 25 | return GetDisplayWorkAreaBoundsInParent(window); |
26 | else | ||||
27 | return GetDisplayBoundsInParent(window); | ||||
28 | } | ||||
29 | |||||
30 | // static | ||||
31 | gfx::Rect ScreenUtil::GetDisplayBoundsInParent(aura::Window* window) { | ||||
yhanada | 698af19 | 2017-02-23 10:57:07 | [diff] [blame^] | 32 | gfx::Rect result = |
33 | display::Screen::GetScreen()->GetDisplayNearestWindow(window).bounds(); | ||||
34 | ::wm::ConvertRectFromScreen(window->parent(), &result); | ||||
35 | return result; | ||||
[email protected] | 55ad8c1 | 2014-01-17 18:24:33 | [diff] [blame] | 36 | } |
37 | |||||
38 | // static | ||||
39 | gfx::Rect ScreenUtil::GetDisplayWorkAreaBoundsInParent(aura::Window* window) { | ||||
yhanada | 698af19 | 2017-02-23 10:57:07 | [diff] [blame^] | 40 | gfx::Rect result = |
41 | display::Screen::GetScreen()->GetDisplayNearestWindow(window).work_area(); | ||||
42 | ::wm::ConvertRectFromScreen(window->parent(), &result); | ||||
43 | return result; | ||||
[email protected] | 55ad8c1 | 2014-01-17 18:24:33 | [diff] [blame] | 44 | } |
45 | |||||
[email protected] | 55ad8c1 | 2014-01-17 18:24:33 | [diff] [blame] | 46 | } // namespace ash |