forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscreen_util.cc
66 lines (56 loc) · 2.17 KB
/
screen_util.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ash/screen_util.h"
#include "ash/shelf/shelf.h"
#include "ash/shell.h"
#include "base/logging.h"
#include "ui/aura/client/screen_position_client.h"
#include "ui/aura/window_event_dispatcher.h"
#include "ui/display/display.h"
#include "ui/display/manager/display_manager.h"
#include "ui/display/screen.h"
#include "ui/gfx/geometry/size_conversions.h"
#include "ui/wm/core/coordinate_conversion.h"
namespace ash {
// static
gfx::Rect ScreenUtil::GetMaximizedWindowBoundsInParent(aura::Window* window) {
if (Shelf::ForWindow(window)->shelf_widget())
return GetDisplayWorkAreaBoundsInParent(window);
return GetDisplayBoundsInParent(window);
}
// static
gfx::Rect ScreenUtil::GetDisplayBoundsInParent(aura::Window* window) {
gfx::Rect result =
display::Screen::GetScreen()->GetDisplayNearestWindow(window).bounds();
::wm::ConvertRectFromScreen(window->parent(), &result);
return result;
}
// static
gfx::Rect ScreenUtil::GetDisplayWorkAreaBoundsInParent(aura::Window* window) {
gfx::Rect result =
display::Screen::GetScreen()->GetDisplayNearestWindow(window).work_area();
::wm::ConvertRectFromScreen(window->parent(), &result);
return result;
}
// static
gfx::Rect ScreenUtil::GetDisplayWorkAreaBoundsInParentForLockScreen(
aura::Window* window) {
gfx::Rect bounds = Shelf::ForWindow(window)->GetUserWorkAreaBounds();
::wm::ConvertRectFromScreen(window->parent(), &bounds);
return bounds;
}
// static
gfx::Rect ScreenUtil::GetDisplayBoundsWithShelf(aura::Window* window) {
if (Shell::Get()->display_manager()->IsInUnifiedMode()) {
// In unified desktop mode, there is only one shelf in the first display.
const display::Display& first_display =
Shell::Get()->display_manager()->software_mirroring_display_list()[0];
gfx::SizeF size(first_display.size());
float scale = window->GetRootWindow()->bounds().height() / size.height();
size.Scale(scale, scale);
return gfx::Rect(gfx::ToCeiledSize(size));
}
return window->GetRootWindow()->bounds();
}
} // namespace ash