OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ui/gfx/screen_win.h" | 5 #include "ui/gfx/screen_win.h" |
6 | 6 |
7 #include <windows.h> | 7 #include <windows.h> |
8 | 8 |
| 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" |
9 #include "base/hash.h" | 11 #include "base/hash.h" |
10 #include "base/logging.h" | 12 #include "base/logging.h" |
11 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
12 #include "base/win/win_util.h" | 14 #include "base/win/win_util.h" |
13 #include "ui/gfx/display.h" | 15 #include "ui/gfx/display.h" |
14 #include "ui/gfx/win/dpi.h" | 16 #include "ui/gfx/win/dpi.h" |
15 | 17 |
16 namespace { | 18 namespace { |
17 | 19 |
18 MONITORINFOEX GetMonitorInfoForMonitor(HMONITOR monitor) { | 20 MONITORINFOEX GetMonitorInfoForMonitor(HMONITOR monitor) { |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 EnumDisplayMonitors(NULL, NULL, EnumMonitorCallback, | 80 EnumDisplayMonitors(NULL, NULL, EnumMonitorCallback, |
79 reinterpret_cast<LPARAM>(&displays)); | 81 reinterpret_cast<LPARAM>(&displays)); |
80 return displays; | 82 return displays; |
81 } | 83 } |
82 | 84 |
83 } // namespace | 85 } // namespace |
84 | 86 |
85 namespace gfx { | 87 namespace gfx { |
86 | 88 |
87 ScreenWin::ScreenWin() | 89 ScreenWin::ScreenWin() |
88 : displays_(GetDisplays()) { | 90 : displays_(GetDisplays()), |
89 SingletonHwnd::GetInstance()->AddObserver(this); | 91 singleton_hwnd_observer_(new SingletonHwndObserver( |
90 } | 92 base::Bind(&ScreenWin::OnWndProc, base::Unretained(this)))) {} |
91 | 93 |
92 ScreenWin::~ScreenWin() { | 94 ScreenWin::~ScreenWin() {} |
93 SingletonHwnd::GetInstance()->RemoveObserver(this); | |
94 } | |
95 | 95 |
96 gfx::Point ScreenWin::GetCursorScreenPoint() { | 96 gfx::Point ScreenWin::GetCursorScreenPoint() { |
97 POINT pt; | 97 POINT pt; |
98 GetCursorPos(&pt); | 98 GetCursorPos(&pt); |
99 gfx::Point cursor_pos_pixels(pt); | 99 gfx::Point cursor_pos_pixels(pt); |
100 return gfx::win::ScreenToDIPPoint(cursor_pos_pixels); | 100 return gfx::win::ScreenToDIPPoint(cursor_pos_pixels); |
101 } | 101 } |
102 | 102 |
103 gfx::NativeWindow ScreenWin::GetWindowUnderCursor() { | 103 gfx::NativeWindow ScreenWin::GetWindowUnderCursor() { |
104 POINT cursor_loc; | 104 POINT cursor_loc; |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 NOTREACHED(); | 193 NOTREACHED(); |
194 return NULL; | 194 return NULL; |
195 } | 195 } |
196 | 196 |
197 NativeWindow ScreenWin::GetNativeWindowFromHWND(HWND hwnd) const { | 197 NativeWindow ScreenWin::GetNativeWindowFromHWND(HWND hwnd) const { |
198 NOTREACHED(); | 198 NOTREACHED(); |
199 return NULL; | 199 return NULL; |
200 } | 200 } |
201 | 201 |
202 } // namespace gfx | 202 } // namespace gfx |
OLD | NEW |