Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(27)

Side by Side Diff: ui/gfx/screen_win.h

Issue 1639623003: ScreenWin Testability and Restructuring (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Sync + VS2015 Friendly - struct -> class to maintain immutability Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/gfx/gfx.gyp ('k') | ui/gfx/screen_win.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <windows.h>
9 #include "base/gtest_prod_util.h" 9
10 #include <vector>
11
10 #include "base/macros.h" 12 #include "base/macros.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "ui/gfx/display_change_notifier.h" 13 #include "ui/gfx/display_change_notifier.h"
13 #include "ui/gfx/gfx_export.h" 14 #include "ui/gfx/gfx_export.h"
15 #include "ui/gfx/native_widget_types.h"
14 #include "ui/gfx/screen.h" 16 #include "ui/gfx/screen.h"
15 #include "ui/gfx/win/singleton_hwnd_observer.h" 17 #include "ui/gfx/win/singleton_hwnd_observer.h"
16 18
17 namespace gfx { 19 namespace gfx {
18 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
19 class GFX_EXPORT ScreenWin : public Screen { 32 class GFX_EXPORT ScreenWin : public Screen {
20 public: 33 public:
21 ScreenWin(); 34 ScreenWin();
22 ~ScreenWin() override; 35 ~ScreenWin() override;
23 36
24 // Returns the HWND associated with the NativeView. 37 // Returns the HWND associated with the NativeView.
25 virtual HWND GetHWNDFromNativeView(NativeView window) const; 38 virtual HWND GetHWNDFromNativeView(NativeView window) const;
26 39
27 // Returns the NativeView associated with the HWND. 40 // Returns the NativeView associated with the HWND.
28 virtual NativeWindow GetNativeWindowFromHWND(HWND hwnd) const; 41 virtual NativeWindow GetNativeWindowFromHWND(HWND hwnd) const;
29 42
30 protected: 43 protected:
31 // Overridden from gfx::Screen: 44 // gfx::Screen:
32 gfx::Point GetCursorScreenPoint() override; 45 gfx::Point GetCursorScreenPoint() override;
33 gfx::NativeWindow GetWindowUnderCursor() override; 46 gfx::NativeWindow GetWindowUnderCursor() override;
34 gfx::NativeWindow GetWindowAtScreenPoint(const gfx::Point& point) override; 47 gfx::NativeWindow GetWindowAtScreenPoint(const gfx::Point& point) override;
35 int GetNumDisplays() const override; 48 int GetNumDisplays() const override;
36 std::vector<gfx::Display> GetAllDisplays() const override; 49 std::vector<gfx::Display> GetAllDisplays() const override;
37 gfx::Display GetDisplayNearestWindow(gfx::NativeView window) const override; 50 gfx::Display GetDisplayNearestWindow(gfx::NativeView window) const override;
38 gfx::Display GetDisplayNearestPoint(const gfx::Point& point) const override; 51 gfx::Display GetDisplayNearestPoint(const gfx::Point& point) const override;
39 gfx::Display GetDisplayMatching(const gfx::Rect& match_rect) const override; 52 gfx::Display GetDisplayMatching(const gfx::Rect& match_rect) const override;
40 gfx::Display GetPrimaryDisplay() const override; 53 gfx::Display GetPrimaryDisplay() const override;
41 void AddObserver(DisplayObserver* observer) override; 54 void AddObserver(DisplayObserver* observer) override;
42 void RemoveObserver(DisplayObserver* observer) override; 55 void RemoveObserver(DisplayObserver* observer) override;
43 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
44 private: 70 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); 71 void OnWndProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam);
49 72
50 static std::vector<gfx::Display> GetDisplaysForMonitorInfos( 73 // Returns the ScreenWinDisplay closest to or enclosing |hwnd|.
51 const std::vector<MONITORINFOEX>& monitor_infos); 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;
52 89
53 // Helper implementing the DisplayObserver handling. 90 // Helper implementing the DisplayObserver handling.
54 gfx::DisplayChangeNotifier change_notifier_; 91 gfx::DisplayChangeNotifier change_notifier_;
55 92
56 scoped_ptr<SingletonHwndObserver> singleton_hwnd_observer_; 93 scoped_ptr<SingletonHwndObserver> singleton_hwnd_observer_;
57 94
58 // Current list of displays. 95 // Current list of ScreenWinDisplays.
59 std::vector<gfx::Display> displays_; 96 std::vector<gfx::win::ScreenWinDisplay> screen_win_displays_;
60 97
61 DISALLOW_COPY_AND_ASSIGN(ScreenWin); 98 DISALLOW_COPY_AND_ASSIGN(ScreenWin);
62 }; 99 };
63 100
64 } // namespace gfx 101 } // namespace gfx
65 102
66 #endif // UI_GFX_SCREEN_WIN_H_ 103 #endif // UI_GFX_SCREEN_WIN_H_
OLDNEW
« no previous file with comments | « ui/gfx/gfx.gyp ('k') | ui/gfx/screen_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698