diff options
author | oshima@google.com <oshima@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-07-22 22:45:03 +0000 |
---|---|---|
committer | oshima@google.com <oshima@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-07-22 22:45:03 +0000 |
commit | 8c7f65db00d5994cc430be11934ec564a894ec76 (patch) | |
tree | fac501ea2588816be1665529bcda1d7093dddccf /ui/gfx/screen_win.cc | |
parent | 9b867976a757b80ed566a49736d1c3591e7cc3e4 (diff) | |
download | chromium_src-8c7f65db00d5994cc430be11934ec564a894ec76.zip chromium_src-8c7f65db00d5994cc430be11934ec564a894ec76.tar.gz chromium_src-8c7f65db00d5994cc430be11934ec564a894ec76.tar.bz2 |
Move screen.h to ui/gfx because Screen doesn't depend on views, and they're useful outside views.
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/7483014
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@93724 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/gfx/screen_win.cc')
-rw-r--r-- | ui/gfx/screen_win.cc | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/ui/gfx/screen_win.cc b/ui/gfx/screen_win.cc new file mode 100644 index 0000000..530cebe --- /dev/null +++ b/ui/gfx/screen_win.cc @@ -0,0 +1,62 @@ +// Copyright (c) 2011 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/gfx/screen.h" + +#include <windows.h> + +namespace gfx { + +// static +gfx::Point Screen::GetCursorScreenPoint() { + POINT pt; + GetCursorPos(&pt); + return gfx::Point(pt); +} + +// static +gfx::Rect Screen::GetMonitorWorkAreaNearestWindow(gfx::NativeWindow window) { + MONITORINFO monitor_info; + monitor_info.cbSize = sizeof(monitor_info); + GetMonitorInfo(MonitorFromWindow(window, MONITOR_DEFAULTTONEAREST), + &monitor_info); + return gfx::Rect(monitor_info.rcWork); +} + +// static +gfx::Rect Screen::GetMonitorAreaNearestWindow(gfx::NativeWindow window) { + MONITORINFO monitor_info; + monitor_info.cbSize = sizeof(monitor_info); + GetMonitorInfo(MonitorFromWindow(window, MONITOR_DEFAULTTONEAREST), + &monitor_info); + return gfx::Rect(monitor_info.rcMonitor); +} + +static gfx::Rect GetMonitorAreaOrWorkAreaNearestPoint(const gfx::Point& point, + bool work_area) { + POINT initial_loc = { point.x(), point.y() }; + HMONITOR monitor = MonitorFromPoint(initial_loc, MONITOR_DEFAULTTONEAREST); + MONITORINFO mi = {0}; + mi.cbSize = sizeof(mi); + if (monitor && GetMonitorInfo(monitor, &mi)) + return gfx::Rect(work_area ? mi.rcWork : mi.rcMonitor); + return gfx::Rect(); +} + +// static +gfx::Rect Screen::GetMonitorWorkAreaNearestPoint(const gfx::Point& point) { + return GetMonitorAreaOrWorkAreaNearestPoint(point, true); +} + +// static +gfx::Rect Screen::GetMonitorAreaNearestPoint(const gfx::Point& point) { + return GetMonitorAreaOrWorkAreaNearestPoint(point, false); +} + +gfx::NativeWindow Screen::GetWindowAtCursorScreenPoint() { + POINT location; + return GetCursorPos(&location) ? WindowFromPoint(location) : NULL; +} + +} // namespace gfx |