blob: ea11d87db5ac453ddf449773257f708bac8948a5 [file] [log] [blame]
[email protected]55ad8c12014-01-17 18:24:331// 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
sky287fe732017-01-09 22:29:187#include "ash/common/shelf/wm_shelf.h"
[email protected]55ad8c12014-01-17 18:24:338#include "ash/root_window_controller.h"
[email protected]55ad8c12014-01-17 18:24:339#include "ash/shell.h"
[email protected]55ad8c12014-01-17 18:24:3310#include "base/logging.h"
11#include "ui/aura/client/screen_position_client.h"
[email protected]fcc51c952014-02-21 21:31:2612#include "ui/aura/window_event_dispatcher.h"
oshimaf84b0da722016-04-27 19:47:1913#include "ui/display/display.h"
rjkroege72f8154f2016-10-29 00:49:0214#include "ui/display/manager/display_manager.h"
oshimaf84b0da722016-04-27 19:47:1915#include "ui/display/screen.h"
oshima5337ca92015-07-18 02:23:5716#include "ui/gfx/geometry/size_conversions.h"
yhanada698af192017-02-23 10:57:0717#include "ui/wm/core/coordinate_conversion.h"
[email protected]55ad8c12014-01-17 18:24:3318
19namespace ash {
20
[email protected]55ad8c12014-01-17 18:24:3321// static
22gfx::Rect ScreenUtil::GetMaximizedWindowBoundsInParent(aura::Window* window) {
jamescookb551aba2016-09-01 01:00:1623 aura::Window* root_window = window->GetRootWindow();
sky287fe732017-01-09 22:29:1824 if (GetRootWindowController(root_window)->wm_shelf()->shelf_widget())
[email protected]55ad8c12014-01-17 18:24:3325 return GetDisplayWorkAreaBoundsInParent(window);
26 else
27 return GetDisplayBoundsInParent(window);
28}
29
30// static
31gfx::Rect ScreenUtil::GetDisplayBoundsInParent(aura::Window* window) {
yhanada698af192017-02-23 10:57:0732 gfx::Rect result =
33 display::Screen::GetScreen()->GetDisplayNearestWindow(window).bounds();
34 ::wm::ConvertRectFromScreen(window->parent(), &result);
35 return result;
[email protected]55ad8c12014-01-17 18:24:3336}
37
38// static
39gfx::Rect ScreenUtil::GetDisplayWorkAreaBoundsInParent(aura::Window* window) {
yhanada698af192017-02-23 10:57:0740 gfx::Rect result =
41 display::Screen::GetScreen()->GetDisplayNearestWindow(window).work_area();
42 ::wm::ConvertRectFromScreen(window->parent(), &result);
43 return result;
[email protected]55ad8c12014-01-17 18:24:3344}
45
[email protected]55ad8c12014-01-17 18:24:3346} // namespace ash