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/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"
16 MONITORINFO GetMonitorInfoForMonitor(HMONITOR monitor) {
17 MONITORINFO monitor_info = { 0 };
18 monitor_info.cbSize = sizeof(monitor_info);
19 GetMonitorInfo(monitor, &monitor_info);
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));
34 ////////////////////////////////////////////////////////////////////////////////
35 // DesktopScreenWin, public:
37 DesktopScreenWin::DesktopScreenWin() {
40 DesktopScreenWin::~DesktopScreenWin() {
43 ////////////////////////////////////////////////////////////////////////////////
44 // DesktopScreenWin, gfx::ScreenWin implementation:
46 bool DesktopScreenWin::IsDIPEnabled() {
50 gfx::Display DesktopScreenWin::GetDisplayMatching(
51 const gfx::Rect& match_rect) const {
52 return GetDisplayNearestPoint(match_rect.CenterPoint());
55 HWND DesktopScreenWin::GetHWNDFromNativeView(gfx::NativeView window) const {
56 aura::WindowEventDispatcher* dispatcher = window->GetDispatcher();
57 return dispatcher ? dispatcher->GetAcceleratedWidget() : NULL;
60 gfx::NativeWindow DesktopScreenWin::GetNativeWindowFromHWND(HWND hwnd) const {
61 return (::IsWindow(hwnd)) ?
62 DesktopRootWindowHostWin::GetContentWindowForHWND(hwnd) : NULL;
65 ////////////////////////////////////////////////////////////////////////////////
67 gfx::Screen* CreateDesktopScreen() {
68 return new DesktopScreenWin;