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

Side by Side Diff: ui/gfx/win/display_manager.h

Issue 1426933002: Refactor Windows DPI Point, Rect, and Size for Multiple Monitor DPI Awareness (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed Other Unit Tests - Moved Inner Classes Outside Created 4 years, 11 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
(Empty)
1 // Copyright 2016 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_WIN_DISPLAY_MANAGER_H_
6 #define UI_GFX_WIN_DISPLAY_MANAGER_H_
7
8 #include <windows.h>
9 #include <memory>
10 #include <vector>
11
12 #include "base/macros.h"
13 #include "base/memory/singleton.h"
14 #include "base/observer_list.h"
15 #include "ui/gfx/display.h"
16 #include "ui/gfx/gfx_export.h"
17
18 namespace gfx {
19
20 class Point;
21 class Rect;
22 class ScreenWin;
23 class SingletonHwndObserver;
24
25 namespace win {
26
27 class DisplayManagerObserver;
28 class DisplayInfo;
29 class ScreenWinDisplay;
30
31 // Holds all of the ScreenWinDisplays corresponding to a Windows HMONITOR.
32 class GFX_EXPORT DisplayManager {
33 public:
34 static DisplayManager* GetInstance();
35
36 void AddObserver(DisplayManagerObserver* observer);
37 void RemoveObserver(DisplayManagerObserver* observer);
38
39 const std::vector<ScreenWinDisplay>& GetScreenWinDisplays();
40 ScreenWinDisplay GetScreenWinDisplay(const MONITORINFOEX& monitor_info) const;
41 ScreenWinDisplay GetScreenWinDisplayNearestHWND(HWND hwnd) const;
42 ScreenWinDisplay GetScreenWinDisplayNearestScreenRect(
43 const Rect& screen_rect) const;
44 ScreenWinDisplay GetScreenWinDisplayNearestScreenPoint(
45 const Point& screen_point) const;
46 ScreenWinDisplay GetScreenWinDisplayNearestDIPRect(const Rect& dip_rect)
47 const;
48 ScreenWinDisplay GetScreenWinDisplayNearestDIPPoint(const Point& dip_point)
49 const;
50 ScreenWinDisplay GetPrimaryScreenWinDisplay() const;
51 float GetScaleFactorForHWND(HWND hwnd) const;
52 float GetScaleFactorForScreenPoint(const Point& screen_point) const;
53
54 // For Unit Tests.
55 virtual MONITORINFOEX MonitorInfoFromScreenPoint(
56 const gfx::Point& screen_point) const;
57 virtual MONITORINFOEX MonitorInfoFromScreenRect(const gfx::Rect& screen_rect)
58 const;
59 virtual MONITORINFOEX MonitorInfoFromWindow(HWND hwnd) const;
60 virtual HWND GetRootWindow(HWND hwnd) const;
61
62 protected:
63 friend std::default_delete<DisplayManager>;
64
65 static void SetInstanceForTesting(scoped_ptr<DisplayManager> display_manager);
66
67 DisplayManager();
68 virtual ~DisplayManager();
69
70 void UpdateFromDisplayInfos(const std::vector<DisplayInfo>& display_infos);
71
72 private:
73 void WndProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam);
74
75 scoped_ptr<gfx::SingletonHwndObserver> singleton_hwnd_observer_;
76 base::ObserverList<DisplayManagerObserver, true> observer_list_;
77 std::vector<ScreenWinDisplay> screen_win_displays_;
78
79 DISALLOW_COPY_AND_ASSIGN(DisplayManager);
80 };
81
82 } // namespace win
83 } // namespace gfx
84
85 #endif // UI_GFX_WIN_DISPLAY_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698