summaryrefslogtreecommitdiffstats
path: root/ash/screen_ash.cc
diff options
context:
space:
mode:
authoroshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-07-18 16:40:06 +0000
committeroshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-07-18 16:40:06 +0000
commit8d625fbd16a1d20f5e34bd01b83b0402bd3b4c80 (patch)
tree4fd429027e6fe44e79e8395ae63d6542d7edf657 /ash/screen_ash.cc
parent87cc09add3a1a9ef94aaec1865fc3aaa23720aaa (diff)
downloadchromium_src-8d625fbd16a1d20f5e34bd01b83b0402bd3b4c80.zip
chromium_src-8d625fbd16a1d20f5e34bd01b83b0402bd3b4c80.tar.gz
chromium_src-8d625fbd16a1d20f5e34bd01b83b0402bd3b4c80.tar.bz2
* Use Virtual Screen Coordinates in more places
- When setting widget bounds. - Workspace Manager - When resizing - Restore bounds * Refactored ScreenPositionClient to manage Screen coordinates for different configurations. * Renamed GetBounds/SetBounds methods to GetScreen/ParentBounds to make it clear that in which coordinates you're dealing with. * I used InScreen/InParent for RestoreBounds because RestoreParent/ScreenBounds sounds strange. Converted Linux/Aura to use ScreenPositionClient. BUG=123160 TEST=several tests are updated to match VSC. added screen_ash_unittests. I'll update rest of tests when this is enable by default. Review URL: https://chromiumcodereview.appspot.com/10696023 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@147250 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash/screen_ash.cc')
-rw-r--r--ash/screen_ash.cc42
1 files changed, 37 insertions, 5 deletions
diff --git a/ash/screen_ash.cc b/ash/screen_ash.cc
index ccfb97e..a7adb30 100644
--- a/ash/screen_ash.cc
+++ b/ash/screen_ash.cc
@@ -7,6 +7,7 @@
#include "ash/shell.h"
#include "ash/wm/shelf_layout_manager.h"
#include "base/logging.h"
+#include "ui/aura/client/screen_position_client.h"
#include "ui/aura/env.h"
#include "ui/aura/display_manager.h"
#include "ui/aura/root_window.h"
@@ -28,19 +29,51 @@ ScreenAsh::~ScreenAsh() {
}
// static
-gfx::Rect ScreenAsh::GetMaximizedWindowBounds(aura::Window* window) {
+gfx::Rect ScreenAsh::GetMaximizedWindowParentBounds(aura::Window* window) {
if (window->GetRootWindow() == Shell::GetPrimaryRootWindow())
return Shell::GetInstance()->shelf()->GetMaximizedWindowBounds(window);
else
- return gfx::Screen::GetDisplayNearestWindow(window).bounds();
+ return GetDisplayParentBounds(window);
}
// static
-gfx::Rect ScreenAsh::GetUnmaximizedWorkAreaBounds(aura::Window* window) {
+gfx::Rect ScreenAsh::GetUnmaximizedWorkAreaParentBounds(aura::Window* window) {
if (window->GetRootWindow() == Shell::GetPrimaryRootWindow())
return Shell::GetInstance()->shelf()->GetUnmaximizedWorkAreaBounds(window);
else
- return gfx::Screen::GetDisplayNearestWindow(window).work_area();
+ return GetDisplayWorkAreaParentBounds(window);
+}
+
+// static
+gfx::Rect ScreenAsh::GetDisplayParentBounds(aura::Window* window) {
+ return ConvertRectFromScreen(
+ window->parent(),
+ gfx::Screen::GetDisplayNearestWindow(window).bounds());
+}
+
+// static
+gfx::Rect ScreenAsh::GetDisplayWorkAreaParentBounds(aura::Window* window) {
+ return ConvertRectFromScreen(
+ window->parent(),
+ gfx::Screen::GetDisplayNearestWindow(window).work_area());
+}
+
+// static
+gfx::Rect ScreenAsh::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 ScreenAsh::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());
}
gfx::Point ScreenAsh::GetCursorScreenPoint() {
@@ -50,7 +83,6 @@ gfx::Point ScreenAsh::GetCursorScreenPoint() {
gfx::NativeWindow ScreenAsh::GetWindowAtCursorScreenPoint() {
const gfx::Point point = gfx::Screen::GetCursorScreenPoint();
- // TODO(oshima): convert point to relateive to the root window.
return Shell::GetRootWindowAt(point)->GetTopWindowContainingPoint(point);
}