| 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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 static gfx::Rect DIPToClientRect(HWND hwnd, const gfx::Rect& dip_bounds); | 82 static gfx::Rect DIPToClientRect(HWND hwnd, const gfx::Rect& dip_bounds); |
| 83 | 83 |
| 84 // Converts a physical size to a DIP size. | 84 // Converts a physical size to a DIP size. |
| 85 // The DPI scale is performed relative to the display nearest to |hwnd|. | 85 // The DPI scale is performed relative to the display nearest to |hwnd|. |
| 86 static gfx::Size ScreenToDIPSize(HWND hwnd, const gfx::Size& size_in_pixels); | 86 static gfx::Size ScreenToDIPSize(HWND hwnd, const gfx::Size& size_in_pixels); |
| 87 | 87 |
| 88 // Converts a DIP size to a physical size. | 88 // Converts a DIP size to a physical size. |
| 89 // The DPI scale is performed relative to the display nearest to |hwnd|. | 89 // The DPI scale is performed relative to the display nearest to |hwnd|. |
| 90 static gfx::Size DIPToScreenSize(HWND hwnd, const gfx::Size& dip_size); | 90 static gfx::Size DIPToScreenSize(HWND hwnd, const gfx::Size& dip_size); |
| 91 | 91 |
| 92 // Returns the result of GetSystemMetrics for |metric| scaled to |hwnd|'s DPI. |
| 93 static int GetSystemMetricsForHwnd(HWND hwnd, int metric); |
| 94 |
| 92 // Returns the HWND associated with the NativeView. | 95 // Returns the HWND associated with the NativeView. |
| 93 virtual HWND GetHWNDFromNativeView(gfx::NativeView window) const; | 96 virtual HWND GetHWNDFromNativeView(gfx::NativeView window) const; |
| 94 | 97 |
| 95 // Returns the NativeView associated with the HWND. | 98 // Returns the NativeView associated with the HWND. |
| 96 virtual gfx::NativeWindow GetNativeWindowFromHWND(HWND hwnd) const; | 99 virtual gfx::NativeWindow GetNativeWindowFromHWND(HWND hwnd) const; |
| 97 | 100 |
| 98 protected: | 101 protected: |
| 99 // display::Screen: | 102 // display::Screen: |
| 100 gfx::Point GetCursorScreenPoint() override; | 103 gfx::Point GetCursorScreenPoint() override; |
| 101 bool IsWindowUnderCursor(gfx::NativeWindow window) override; | 104 bool IsWindowUnderCursor(gfx::NativeWindow window) override; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 120 | 123 |
| 121 // Virtual to support mocking by unit tests. | 124 // Virtual to support mocking by unit tests. |
| 122 virtual void Initialize(); | 125 virtual void Initialize(); |
| 123 virtual MONITORINFOEX MonitorInfoFromScreenPoint( | 126 virtual MONITORINFOEX MonitorInfoFromScreenPoint( |
| 124 const gfx::Point& screen_point) const; | 127 const gfx::Point& screen_point) const; |
| 125 virtual MONITORINFOEX MonitorInfoFromScreenRect(const gfx::Rect& screen_rect) | 128 virtual MONITORINFOEX MonitorInfoFromScreenRect(const gfx::Rect& screen_rect) |
| 126 const; | 129 const; |
| 127 virtual MONITORINFOEX MonitorInfoFromWindow(HWND hwnd, DWORD default_options) | 130 virtual MONITORINFOEX MonitorInfoFromWindow(HWND hwnd, DWORD default_options) |
| 128 const; | 131 const; |
| 129 virtual HWND GetRootWindow(HWND hwnd) const; | 132 virtual HWND GetRootWindow(HWND hwnd) const; |
| 133 virtual int GetSystemMetrics(int metric) const; |
| 130 | 134 |
| 131 private: | 135 private: |
| 132 void OnWndProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam); | 136 void OnWndProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam); |
| 133 | 137 |
| 134 // Returns the ScreenWinDisplay closest to or enclosing |hwnd|. | 138 // Returns the ScreenWinDisplay closest to or enclosing |hwnd|. |
| 135 ScreenWinDisplay GetScreenWinDisplayNearestHWND(HWND hwnd) const; | 139 ScreenWinDisplay GetScreenWinDisplayNearestHWND(HWND hwnd) const; |
| 136 | 140 |
| 137 // Returns the ScreenWinDisplay closest to or enclosing |screen_rect|. | 141 // Returns the ScreenWinDisplay closest to or enclosing |screen_rect|. |
| 138 ScreenWinDisplay GetScreenWinDisplayNearestScreenRect( | 142 ScreenWinDisplay GetScreenWinDisplayNearestScreenRect( |
| 139 const gfx::Rect& screen_rect) const; | 143 const gfx::Rect& screen_rect) const; |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 // Current list of ScreenWinDisplays. | 175 // Current list of ScreenWinDisplays. |
| 172 std::vector<ScreenWinDisplay> screen_win_displays_; | 176 std::vector<ScreenWinDisplay> screen_win_displays_; |
| 173 | 177 |
| 174 DISALLOW_COPY_AND_ASSIGN(ScreenWin); | 178 DISALLOW_COPY_AND_ASSIGN(ScreenWin); |
| 175 }; | 179 }; |
| 176 | 180 |
| 177 } // namespace win | 181 } // namespace win |
| 178 } // namespace display | 182 } // namespace display |
| 179 | 183 |
| 180 #endif // UI_DISPLAY_WIN_SCREEN_WIN_H_ | 184 #endif // UI_DISPLAY_WIN_SCREEN_WIN_H_ |
| OLD | NEW |