| 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_DISPLAY_WIN_SCREEN_WIN_H_ | 5 #ifndef UI_DISPLAY_WIN_SCREEN_WIN_H_ |
| 6 #define UI_DISPLAY_WIN_SCREEN_WIN_H_ | 6 #define UI_DISPLAY_WIN_SCREEN_WIN_H_ |
| 7 | 7 |
| 8 #include <windows.h> | 8 #include <windows.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 std::vector<display::Display> GetAllDisplays() const override; | 104 std::vector<display::Display> GetAllDisplays() const override; |
| 105 display::Display GetDisplayNearestWindow( | 105 display::Display GetDisplayNearestWindow( |
| 106 gfx::NativeView window) const override; | 106 gfx::NativeView window) const override; |
| 107 display::Display GetDisplayNearestPoint( | 107 display::Display GetDisplayNearestPoint( |
| 108 const gfx::Point& point) const override; | 108 const gfx::Point& point) const override; |
| 109 display::Display GetDisplayMatching( | 109 display::Display GetDisplayMatching( |
| 110 const gfx::Rect& match_rect) const override; | 110 const gfx::Rect& match_rect) const override; |
| 111 display::Display GetPrimaryDisplay() const override; | 111 display::Display GetPrimaryDisplay() const override; |
| 112 void AddObserver(display::DisplayObserver* observer) override; | 112 void AddObserver(display::DisplayObserver* observer) override; |
| 113 void RemoveObserver(display::DisplayObserver* observer) override; | 113 void RemoveObserver(display::DisplayObserver* observer) override; |
| 114 gfx::Rect ScreenToDIPRectInWindow( |
| 115 gfx::NativeView view, const gfx::Rect& screen_rect) const override; |
| 116 gfx::Rect DIPToScreenRectInWindow( |
| 117 gfx::NativeView view, const gfx::Rect& dip_rect) const override; |
| 114 | 118 |
| 115 void UpdateFromDisplayInfos(const std::vector<DisplayInfo>& display_infos); | 119 void UpdateFromDisplayInfos(const std::vector<DisplayInfo>& display_infos); |
| 116 | 120 |
| 117 // Virtual to support mocking by unit tests. | 121 // Virtual to support mocking by unit tests. |
| 118 virtual void Initialize(); | 122 virtual void Initialize(); |
| 119 virtual MONITORINFOEX MonitorInfoFromScreenPoint( | 123 virtual MONITORINFOEX MonitorInfoFromScreenPoint( |
| 120 const gfx::Point& screen_point) const; | 124 const gfx::Point& screen_point) const; |
| 121 virtual MONITORINFOEX MonitorInfoFromScreenRect(const gfx::Rect& screen_rect) | 125 virtual MONITORINFOEX MonitorInfoFromScreenRect(const gfx::Rect& screen_rect) |
| 122 const; | 126 const; |
| 123 virtual MONITORINFOEX MonitorInfoFromWindow(HWND hwnd, DWORD default_options) | 127 virtual MONITORINFOEX MonitorInfoFromWindow(HWND hwnd, DWORD default_options) |
| 124 const; | 128 const; |
| 125 virtual HWND GetRootWindow(HWND hwnd) const; | 129 virtual HWND GetRootWindow(HWND hwnd) const; |
| 126 | 130 |
| 127 private: | 131 private: |
| 128 void OnWndProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam); | 132 void OnWndProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam); |
| 129 | 133 |
| 130 // Returns the ScreenWinDisplay closest to or enclosing |hwnd|. | 134 // Returns the ScreenWinDisplay closest to or enclosing |hwnd|. |
| 131 ScreenWinDisplay GetScreenWinDisplayNearestHWND(HWND hwnd) const; | 135 ScreenWinDisplay GetScreenWinDisplayNearestHWND(HWND hwnd) const; |
| 132 | 136 |
| 133 // Returns the ScreenWinDisplay closest to or enclosing |screen_rect|. | 137 // Returns the ScreenWinDisplay closest to or enclosing |screen_rect|. |
| 134 ScreenWinDisplay GetScreenWinDisplayNearestScreenRect( | 138 ScreenWinDisplay GetScreenWinDisplayNearestScreenRect( |
| 135 const gfx::Rect& screen_rect) const; | 139 const gfx::Rect& screen_rect) const; |
| 136 | 140 |
| 137 // Returns the ScreenWinDisplay closest to or enclosing |screen_point|. | 141 // Returns the ScreenWinDisplay closest to or enclosing |screen_point|. |
| 138 ScreenWinDisplay GetScreenWinDisplayNearestScreenPoint( | 142 ScreenWinDisplay GetScreenWinDisplayNearestScreenPoint( |
| 139 const gfx::Point& screen_point) const; | 143 const gfx::Point& screen_point) const; |
| 140 | 144 |
| 145 // Returns the ScreenWinDisplay closest to or enclosing |dip_point|. |
| 146 ScreenWinDisplay GetScreenWinDisplayNearestDIPPoint( |
| 147 const gfx::Point& dip_point) const; |
| 148 |
| 149 // Returns the ScreenWinDisplay closest to or enclosing |dip_rect|. |
| 150 ScreenWinDisplay GetScreenWinDisplayNearestDIPRect( |
| 151 const gfx::Rect& dip_rect) const; |
| 152 |
| 141 // Returns the ScreenWinDisplay corresponding to the primary monitor. | 153 // Returns the ScreenWinDisplay corresponding to the primary monitor. |
| 142 ScreenWinDisplay GetPrimaryScreenWinDisplay() const; | 154 ScreenWinDisplay GetPrimaryScreenWinDisplay() const; |
| 143 | 155 |
| 144 ScreenWinDisplay GetScreenWinDisplay(const MONITORINFOEX& monitor_info) const; | 156 ScreenWinDisplay GetScreenWinDisplay(const MONITORINFOEX& monitor_info) const; |
| 145 | 157 |
| 158 static float GetScaleFactorForHWND(HWND hwnd); |
| 159 |
| 160 // Returns the result of calling |getter| with |value| on the global |
| 161 // ScreenWin if it exists, otherwise return the default ScreenWinDisplay. |
| 162 template <typename Getter, typename GetterType> |
| 163 static ScreenWinDisplay GetScreenWinDisplayVia(Getter getter, |
| 164 GetterType value); |
| 165 |
| 146 // Helper implementing the DisplayObserver handling. | 166 // Helper implementing the DisplayObserver handling. |
| 147 DisplayChangeNotifier change_notifier_; | 167 DisplayChangeNotifier change_notifier_; |
| 148 | 168 |
| 149 std::unique_ptr<gfx::SingletonHwndObserver> singleton_hwnd_observer_; | 169 std::unique_ptr<gfx::SingletonHwndObserver> singleton_hwnd_observer_; |
| 150 | 170 |
| 151 // Current list of ScreenWinDisplays. | 171 // Current list of ScreenWinDisplays. |
| 152 std::vector<ScreenWinDisplay> screen_win_displays_; | 172 std::vector<ScreenWinDisplay> screen_win_displays_; |
| 153 | 173 |
| 154 DISALLOW_COPY_AND_ASSIGN(ScreenWin); | 174 DISALLOW_COPY_AND_ASSIGN(ScreenWin); |
| 155 }; | 175 }; |
| 156 | 176 |
| 157 } // namespace win | 177 } // namespace win |
| 158 } // namespace display | 178 } // namespace display |
| 159 | 179 |
| 160 #endif // UI_DISPLAY_WIN_SCREEN_WIN_H_ | 180 #endif // UI_DISPLAY_WIN_SCREEN_WIN_H_ |
| OLD | NEW |