- add sources.
[platform/framework/web/crosswalk.git] / src / ui / views / widget / desktop_aura / desktop_screen_win.cc
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 "ui/views/widget/desktop_aura/desktop_screen_win.h"
6
7 #include "base/logging.h"
8 #include "ui/aura/root_window.h"
9 #include "ui/aura/root_window_host.h"
10 #include "ui/gfx/display.h"
11 #include "ui/views/widget/desktop_aura/desktop_root_window_host_win.h"
12 #include "ui/views/widget/desktop_aura/desktop_screen.h"
13
14 namespace {
15
16 MONITORINFO GetMonitorInfoForMonitor(HMONITOR monitor) {
17   MONITORINFO monitor_info = { 0 };
18   monitor_info.cbSize = sizeof(monitor_info);
19   GetMonitorInfo(monitor, &monitor_info);
20   return monitor_info;
21 }
22
23 gfx::Display GetDisplay(MONITORINFO& monitor_info) {
24   // TODO(oshima): Implement ID and Observer.
25   gfx::Display display(0, gfx::Rect(monitor_info.rcMonitor));
26   display.set_work_area(gfx::Rect(monitor_info.rcWork));
27   return display;
28 }
29
30 }  // namespace
31
32 namespace views {
33
34 ////////////////////////////////////////////////////////////////////////////////
35 // DesktopScreenWin, public:
36
37 DesktopScreenWin::DesktopScreenWin() {
38 }
39
40 DesktopScreenWin::~DesktopScreenWin() {
41 }
42
43 ////////////////////////////////////////////////////////////////////////////////
44 // DesktopScreenWin, gfx::ScreenWin implementation:
45
46 bool DesktopScreenWin::IsDIPEnabled() {
47   return true;
48 }
49
50 gfx::Display DesktopScreenWin::GetDisplayMatching(
51     const gfx::Rect& match_rect) const {
52   return GetDisplayNearestPoint(match_rect.CenterPoint());
53 }
54
55 HWND DesktopScreenWin::GetHWNDFromNativeView(gfx::NativeView window) const {
56   aura::WindowEventDispatcher* dispatcher = window->GetDispatcher();
57   return dispatcher ? dispatcher->GetAcceleratedWidget() : NULL;
58 }
59
60 gfx::NativeWindow DesktopScreenWin::GetNativeWindowFromHWND(HWND hwnd) const {
61   return (::IsWindow(hwnd)) ?
62       DesktopRootWindowHostWin::GetContentWindowForHWND(hwnd) : NULL;
63 }
64
65 ////////////////////////////////////////////////////////////////////////////////
66
67 gfx::Screen* CreateDesktopScreen() {
68   return new DesktopScreenWin;
69 }
70
71 }  // namespace views