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

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: Rebase to bdd95f1 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
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 <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_; 66 // The DisplayManager itself manages lifetime and keeps itself alive.
57 67 gfx::win::DisplayManager* display_manager_;
oshima 2016/01/30 00:10:33 Please use GetInstance(), as it may refer to stale
robliao 2016/01/30 01:23:52 Done.
58 // Current list of displays.
59 std::vector<gfx::Display> displays_;
60 68
61 DISALLOW_COPY_AND_ASSIGN(ScreenWin); 69 DISALLOW_COPY_AND_ASSIGN(ScreenWin);
62 }; 70 };
63 71
64 } // namespace gfx 72 } // namespace gfx
65 73
66 #endif // UI_GFX_SCREEN_WIN_H_ 74 #endif // UI_GFX_SCREEN_WIN_H_
OLDNEW
« no previous file with comments | « ui/gfx/gfx.gyp ('k') | ui/gfx/screen_win.cc » ('j') | ui/gfx/test/display_util.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698