coordinate_conversion.cc revision 2a99a7e74a7f215066514fe81d2bfa6639d9eddd
1// Copyright (c) 2012 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/wm/coordinate_conversion.h"
6
7#include "ash/display/display_controller.h"
8#include "ash/shell.h"
9#include "ui/aura/client/screen_position_client.h"
10#include "ui/aura/root_window.h"
11#include "ui/gfx/display.h"
12#include "ui/gfx/point.h"
13#include "ui/gfx/rect.h"
14#include "ui/gfx/screen.h"
15
16namespace ash {
17namespace wm {
18
19aura::RootWindow* GetRootWindowAt(const gfx::Point& point) {
20  const gfx::Display& display =
21      Shell::GetScreen()->GetDisplayNearestPoint(point);
22  DCHECK(display.is_valid());
23  // TODO(yusukes): Move coordinate_conversion.cc and .h to ui/aura/ once
24  // GetRootWindowForDisplayId() is moved to aura::Env.
25  return Shell::GetInstance()->display_controller()->
26      GetRootWindowForDisplayId(display.id());
27}
28
29aura::RootWindow* GetRootWindowMatching(const gfx::Rect& rect) {
30  const gfx::Display& display = Shell::GetScreen()->GetDisplayMatching(rect);
31  return Shell::GetInstance()->display_controller()->
32      GetRootWindowForDisplayId(display.id());
33}
34
35void ConvertPointToScreen(aura::Window* window, gfx::Point* point) {
36  aura::client::GetScreenPositionClient(window->GetRootWindow())->
37      ConvertPointToScreen(window, point);
38}
39
40void ConvertPointFromScreen(aura::Window* window,
41                            gfx::Point* point_in_screen) {
42  aura::client::GetScreenPositionClient(window->GetRootWindow())->
43      ConvertPointFromScreen(window, point_in_screen);
44}
45
46}  // namespace wm
47}  // namespace ash
48