Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2197)

Unified Diff: ash/screen_util.cc

Issue 138003007: [Cleanup] Screen cleanup (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: make sure screen_for_shutdown is reset everytime Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ash/screen_util.h ('k') | ash/screen_util_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/screen_util.cc
diff --git a/ash/screen_util.cc b/ash/screen_util.cc
new file mode 100644
index 0000000000000000000000000000000000000000..2e7bcc507a2202fae7b7b7d5461a54e2c7742a53
--- /dev/null
+++ b/ash/screen_util.cc
@@ -0,0 +1,87 @@
+// Copyright (c) 2012 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/display/display_controller.h"
+#include "ash/display/display_manager.h"
+#include "ash/root_window_controller.h"
+#include "ash/shelf/shelf_layout_manager.h"
+#include "ash/shelf/shelf_widget.h"
+#include "ash/shell.h"
+#include "ash/wm/coordinate_conversion.h"
+#include "base/logging.h"
+#include "ui/aura/client/screen_position_client.h"
+#include "ui/aura/root_window.h"
+#include "ui/gfx/display.h"
+#include "ui/gfx/screen.h"
+
+namespace ash {
+
+namespace {
+internal::DisplayManager* GetDisplayManager() {
+ return Shell::GetInstance()->display_manager();
+}
+}
+
+// static
+gfx::Display ScreenUtil::FindDisplayContainingPoint(const gfx::Point& point) {
+ return GetDisplayManager()->FindDisplayContainingPoint(point);
+}
+
+// static
+gfx::Rect ScreenUtil::GetMaximizedWindowBoundsInParent(aura::Window* window) {
+ if (internal::GetRootWindowController(window->GetRootWindow())->shelf())
+ return GetDisplayWorkAreaBoundsInParent(window);
+ else
+ return GetDisplayBoundsInParent(window);
+}
+
+// static
+gfx::Rect ScreenUtil::GetDisplayBoundsInParent(aura::Window* window) {
+ return ConvertRectFromScreen(
+ window->parent(),
+ Shell::GetScreen()->GetDisplayNearestWindow(window).bounds());
+}
+
+// static
+gfx::Rect ScreenUtil::GetDisplayWorkAreaBoundsInParent(aura::Window* window) {
+ return ConvertRectFromScreen(
+ window->parent(),
+ Shell::GetScreen()->GetDisplayNearestWindow(window).work_area());
+}
+
+// static
+gfx::Rect ScreenUtil::ConvertRectToScreen(aura::Window* window,
+ const gfx::Rect& rect) {
+ gfx::Point point = rect.origin();
+ aura::client::GetScreenPositionClient(window->GetRootWindow())->
+ ConvertPointToScreen(window, &point);
+ return gfx::Rect(point, rect.size());
+}
+
+// static
+gfx::Rect ScreenUtil::ConvertRectFromScreen(aura::Window* window,
+ const gfx::Rect& rect) {
+ gfx::Point point = rect.origin();
+ aura::client::GetScreenPositionClient(window->GetRootWindow())->
+ ConvertPointFromScreen(window, &point);
+ return gfx::Rect(point, rect.size());
+}
+
+// static
+const gfx::Display& ScreenUtil::GetSecondaryDisplay() {
+ internal::DisplayManager* display_manager = GetDisplayManager();
+ CHECK_EQ(2U, display_manager->GetNumDisplays());
+ return display_manager->GetDisplayAt(0).id() ==
+ Shell::GetScreen()->GetPrimaryDisplay().id() ?
+ display_manager->GetDisplayAt(1) : display_manager->GetDisplayAt(0);
+}
+
+// static
+const gfx::Display& ScreenUtil::GetDisplayForId(int64 display_id) {
+ return GetDisplayManager()->GetDisplayForId(display_id);
+}
+
+} // namespace ash
« no previous file with comments | « ash/screen_util.h ('k') | ash/screen_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698