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.
5 #include "ui/views/widget/desktop_aura/desktop_screen_win.h"
7 #include "base/logging.h"
8 #include "ui/aura/root_window.h"
9 #include "ui/aura/window.h"
10 #include "ui/aura/window_tree_host.h"
11 #include "ui/gfx/display.h"
12 #include "ui/views/widget/desktop_aura/desktop_screen.h"
13 #include "ui/views/widget/desktop_aura/desktop_window_tree_host_win.h"
17 MONITORINFO GetMonitorInfoForMonitor(HMONITOR monitor) {
18 MONITORINFO monitor_info = { 0 };
19 monitor_info.cbSize = sizeof(monitor_info);
20 GetMonitorInfo(monitor, &monitor_info);
24 gfx::Display GetDisplay(MONITORINFO& monitor_info) {
25 // TODO(oshima): Implement ID and Observer.
26 gfx::Display display(0, gfx::Rect(monitor_info.rcMonitor));
27 display.set_work_area(gfx::Rect(monitor_info.rcWork));
35 ////////////////////////////////////////////////////////////////////////////////
36 // DesktopScreenWin, public:
38 DesktopScreenWin::DesktopScreenWin() {
41 DesktopScreenWin::~DesktopScreenWin() {
44 ////////////////////////////////////////////////////////////////////////////////
45 // DesktopScreenWin, gfx::ScreenWin implementation:
47 bool DesktopScreenWin::IsDIPEnabled() {
51 gfx::Display DesktopScreenWin::GetDisplayMatching(
52 const gfx::Rect& match_rect) const {
53 return GetDisplayNearestPoint(match_rect.CenterPoint());
56 HWND DesktopScreenWin::GetHWNDFromNativeView(gfx::NativeView window) const {
57 aura::WindowEventDispatcher* dispatcher = window->GetDispatcher();
58 return dispatcher ? dispatcher->host()->GetAcceleratedWidget() : NULL;
61 gfx::NativeWindow DesktopScreenWin::GetNativeWindowFromHWND(HWND hwnd) const {
62 return (::IsWindow(hwnd)) ?
63 DesktopWindowTreeHostWin::GetContentWindowForHWND(hwnd) : NULL;
66 ////////////////////////////////////////////////////////////////////////////////
68 gfx::Screen* CreateDesktopScreen() {
69 return new DesktopScreenWin;