blob: c5edf76c6870a8993fb8795c6002a9c65be03b0a [file] [log] [blame]
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ui/views/widget/desktop_aura/desktop_screen_win.h"
#include "base/logging.h"
#include "ui/aura/window.h"
#include "ui/aura/window_event_dispatcher.h"
#include "ui/aura/window_tree_host.h"
#include "ui/gfx/display.h"
#include "ui/views/widget/desktop_aura/desktop_screen.h"
#include "ui/views/widget/desktop_aura/desktop_window_tree_host_win.h"
namespace {
MONITORINFO GetMonitorInfoForMonitor(HMONITOR monitor) {
MONITORINFO monitor_info = { 0 };
monitor_info.cbSize = sizeof(monitor_info);
GetMonitorInfo(monitor, &monitor_info);
return monitor_info;
}
gfx::Display GetDisplay(MONITORINFO& monitor_info) {
// TODO(oshima): Implement ID and Observer.
gfx::Display display(0, gfx::Rect(monitor_info.rcMonitor));
display.set_work_area(gfx::Rect(monitor_info.rcWork));
return display;
}
} // namespace
namespace views {
////////////////////////////////////////////////////////////////////////////////
// DesktopScreenWin, public:
DesktopScreenWin::DesktopScreenWin() {
}
DesktopScreenWin::~DesktopScreenWin() {
}
////////////////////////////////////////////////////////////////////////////////
// DesktopScreenWin, gfx::ScreenWin implementation:
bool DesktopScreenWin::IsDIPEnabled() {
return true;
}
gfx::Display DesktopScreenWin::GetDisplayMatching(
const gfx::Rect& match_rect) const {
return GetDisplayNearestPoint(match_rect.CenterPoint());
}
HWND DesktopScreenWin::GetHWNDFromNativeView(gfx::NativeView window) const {
aura::WindowTreeHost* host = window->GetHost();
return host ? host->GetAcceleratedWidget() : NULL;
}
gfx::NativeWindow DesktopScreenWin::GetNativeWindowFromHWND(HWND hwnd) const {
return (::IsWindow(hwnd)) ?
DesktopWindowTreeHostWin::GetContentWindowForHWND(hwnd) : NULL;
}
////////////////////////////////////////////////////////////////////////////////
gfx::Screen* CreateDesktopScreen() {
return new DesktopScreenWin;
}
} // namespace views