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 #ifndef UI_GFX_SCREEN_WIN_H_ | 5 #ifndef UI_GFX_SCREEN_WIN_H_ |
6 #define UI_GFX_SCREEN_WIN_H_ | 6 #define UI_GFX_SCREEN_WIN_H_ |
7 | 7 |
8 #include "base/compiler_specific.h" | 8 #include <vector> |
9 #include "base/gtest_prod_util.h" | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
11 #include "base/memory/scoped_ptr.h" | |
12 #include "ui/gfx/display_change_notifier.h" | 11 #include "ui/gfx/display_change_notifier.h" |
13 #include "ui/gfx/gfx_export.h" | 12 #include "ui/gfx/gfx_export.h" |
| 13 #include "ui/gfx/native_widget_types.h" |
14 #include "ui/gfx/screen.h" | 14 #include "ui/gfx/screen.h" |
15 #include "ui/gfx/win/singleton_hwnd_observer.h" | 15 #include "ui/gfx/win/display_manager_observer.h" |
16 | 16 |
17 namespace gfx { | 17 namespace gfx { |
18 | 18 |
19 class GFX_EXPORT ScreenWin : public Screen { | 19 class Display; |
| 20 class Point; |
| 21 class Rect; |
| 22 |
| 23 namespace win { |
| 24 |
| 25 class DisplayManager; |
| 26 class ScreenWinDisplay; |
| 27 |
| 28 } // namespace win |
| 29 |
| 30 class GFX_EXPORT ScreenWin : public Screen, |
| 31 public gfx::win::DisplayManagerObserver { |
20 public: | 32 public: |
21 ScreenWin(); | 33 ScreenWin(); |
22 ~ScreenWin() override; | 34 ~ScreenWin() override; |
23 | 35 |
24 // Returns the HWND associated with the NativeView. | 36 // Returns the HWND associated with the NativeView. |
25 virtual HWND GetHWNDFromNativeView(NativeView window) const; | 37 virtual HWND GetHWNDFromNativeView(NativeView window) const; |
26 | 38 |
27 // Returns the NativeView associated with the HWND. | 39 // Returns the NativeView associated with the HWND. |
28 virtual NativeWindow GetNativeWindowFromHWND(HWND hwnd) const; | 40 virtual NativeWindow GetNativeWindowFromHWND(HWND hwnd) const; |
29 | 41 |
30 protected: | 42 protected: |
31 // Overridden from gfx::Screen: | 43 // gfx::Screen: |
32 gfx::Point GetCursorScreenPoint() override; | 44 gfx::Point GetCursorScreenPoint() override; |
33 gfx::NativeWindow GetWindowUnderCursor() override; | 45 gfx::NativeWindow GetWindowUnderCursor() override; |
34 gfx::NativeWindow GetWindowAtScreenPoint(const gfx::Point& point) override; | 46 gfx::NativeWindow GetWindowAtScreenPoint(const gfx::Point& point) override; |
35 int GetNumDisplays() const override; | 47 int GetNumDisplays() const override; |
36 std::vector<gfx::Display> GetAllDisplays() const override; | 48 std::vector<gfx::Display> GetAllDisplays() const override; |
37 gfx::Display GetDisplayNearestWindow(gfx::NativeView window) const override; | 49 gfx::Display GetDisplayNearestWindow(gfx::NativeView window) const override; |
38 gfx::Display GetDisplayNearestPoint(const gfx::Point& point) const override; | 50 gfx::Display GetDisplayNearestPoint(const gfx::Point& point) const override; |
39 gfx::Display GetDisplayMatching(const gfx::Rect& match_rect) const override; | 51 gfx::Display GetDisplayMatching(const gfx::Rect& match_rect) const override; |
40 gfx::Display GetPrimaryDisplay() const override; | 52 gfx::Display GetPrimaryDisplay() const override; |
41 void AddObserver(DisplayObserver* observer) override; | 53 void AddObserver(DisplayObserver* observer) override; |
42 void RemoveObserver(DisplayObserver* observer) override; | 54 void RemoveObserver(DisplayObserver* observer) override; |
43 | 55 |
| 56 // gfx::win::DisplayManagerObserver: |
| 57 void OnDisplaysChanged( |
| 58 const std::vector<gfx::win::ScreenWinDisplay>& old_screen_win_displays, |
| 59 const std::vector<gfx::win::ScreenWinDisplay>& new_screen_win_displays) |
| 60 override; |
| 61 |
44 private: | 62 private: |
45 FRIEND_TEST_ALL_PREFIXES(ScreenWinTest, SingleDisplay1x); | |
46 FRIEND_TEST_ALL_PREFIXES(ScreenWinTest, SingleDisplay2x); | |
47 | |
48 void OnWndProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam); | |
49 | |
50 static std::vector<gfx::Display> GetDisplaysForMonitorInfos( | |
51 const std::vector<MONITORINFOEX>& monitor_infos); | |
52 | |
53 // Helper implementing the DisplayObserver handling. | 63 // Helper implementing the DisplayObserver handling. |
54 gfx::DisplayChangeNotifier change_notifier_; | 64 gfx::DisplayChangeNotifier change_notifier_; |
55 | 65 |
56 scoped_ptr<SingletonHwndObserver> singleton_hwnd_observer_; | |
57 | |
58 // Current list of displays. | |
59 std::vector<gfx::Display> displays_; | |
60 | |
61 DISALLOW_COPY_AND_ASSIGN(ScreenWin); | 66 DISALLOW_COPY_AND_ASSIGN(ScreenWin); |
62 }; | 67 }; |
63 | 68 |
64 } // namespace gfx | 69 } // namespace gfx |
65 | 70 |
66 #endif // UI_GFX_SCREEN_WIN_H_ | 71 #endif // UI_GFX_SCREEN_WIN_H_ |
OLD | NEW |