OLD | NEW |
| (Empty) |
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. | |
4 | |
5 #ifndef UI_DISPLAY_WIN_SCREEN_WIN_H_ | |
6 #define UI_DISPLAY_WIN_SCREEN_WIN_H_ | |
7 | |
8 #include <windows.h> | |
9 | |
10 #include <vector> | |
11 | |
12 #include "base/macros.h" | |
13 #include "ui/display/display_export.h" | |
14 #include "ui/gfx/display_change_notifier.h" | |
15 #include "ui/gfx/native_widget_types.h" | |
16 #include "ui/gfx/screen.h" | |
17 #include "ui/gfx/win/singleton_hwnd_observer.h" | |
18 | |
19 namespace gfx { | |
20 class Display; | |
21 class Point; | |
22 class Rect; | |
23 } // namespace gfx | |
24 | |
25 namespace display { | |
26 namespace win { | |
27 | |
28 class DisplayInfo; | |
29 class ScreenWinDisplay; | |
30 | |
31 class DISPLAY_EXPORT ScreenWin : public gfx::Screen { | |
32 public: | |
33 ScreenWin(); | |
34 ~ScreenWin() override; | |
35 | |
36 // Returns the HWND associated with the NativeView. | |
37 virtual HWND GetHWNDFromNativeView(gfx::NativeView window) const; | |
38 | |
39 // Returns the NativeView associated with the HWND. | |
40 virtual gfx::NativeWindow GetNativeWindowFromHWND(HWND hwnd) const; | |
41 | |
42 protected: | |
43 // gfx::Screen: | |
44 gfx::Point GetCursorScreenPoint() override; | |
45 gfx::NativeWindow GetWindowUnderCursor() override; | |
46 gfx::NativeWindow GetWindowAtScreenPoint(const gfx::Point& point) override; | |
47 int GetNumDisplays() const override; | |
48 std::vector<gfx::Display> GetAllDisplays() const override; | |
49 gfx::Display GetDisplayNearestWindow(gfx::NativeView window) const override; | |
50 gfx::Display GetDisplayNearestPoint(const gfx::Point& point) const override; | |
51 gfx::Display GetDisplayMatching(const gfx::Rect& match_rect) const override; | |
52 gfx::Display GetPrimaryDisplay() const override; | |
53 void AddObserver(gfx::DisplayObserver* observer) override; | |
54 void RemoveObserver(gfx::DisplayObserver* observer) override; | |
55 | |
56 void UpdateFromDisplayInfos(const std::vector<DisplayInfo>& display_infos); | |
57 | |
58 // Virtual to support mocking by unit tests. | |
59 virtual void Initialize(); | |
60 virtual MONITORINFOEX MonitorInfoFromScreenPoint( | |
61 const gfx::Point& screen_point) const; | |
62 virtual MONITORINFOEX MonitorInfoFromScreenRect(const gfx::Rect& screen_rect) | |
63 const; | |
64 virtual MONITORINFOEX MonitorInfoFromWindow(HWND hwnd, DWORD default_options) | |
65 const; | |
66 virtual HWND GetRootWindow(HWND hwnd) const; | |
67 | |
68 private: | |
69 void OnWndProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam); | |
70 | |
71 // Returns the ScreenWinDisplay closest to or enclosing |hwnd|. | |
72 ScreenWinDisplay GetScreenWinDisplayNearestHWND(HWND hwnd) const; | |
73 | |
74 // Returns the ScreenWinDisplay closest to or enclosing |screen_rect|. | |
75 ScreenWinDisplay GetScreenWinDisplayNearestScreenRect( | |
76 const gfx::Rect& screen_rect) const; | |
77 | |
78 // Returns the ScreenWinDisplay closest to or enclosing |screen_point|. | |
79 ScreenWinDisplay GetScreenWinDisplayNearestScreenPoint( | |
80 const gfx::Point& screen_point) const; | |
81 | |
82 // Returns the ScreenWinDisplay corresponding to the primary monitor. | |
83 ScreenWinDisplay GetPrimaryScreenWinDisplay() const; | |
84 | |
85 ScreenWinDisplay GetScreenWinDisplay(const MONITORINFOEX& monitor_info) const; | |
86 | |
87 // Helper implementing the DisplayObserver handling. | |
88 gfx::DisplayChangeNotifier change_notifier_; | |
89 | |
90 scoped_ptr<gfx::SingletonHwndObserver> singleton_hwnd_observer_; | |
91 | |
92 // Current list of ScreenWinDisplays. | |
93 std::vector<ScreenWinDisplay> screen_win_displays_; | |
94 | |
95 DISALLOW_COPY_AND_ASSIGN(ScreenWin); | |
96 }; | |
97 | |
98 } // namespace win | |
99 } // namespace display | |
100 | |
101 #endif // UI_DISPLAY_WIN_SCREEN_WIN_H_ | |
OLD | NEW |