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