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

Side by Side Diff: ui/display/win/screen_win.h

Issue 2165173002: Only Update the Scale Factor if the Scale Factor Actually Changed (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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 | « no previous file | ui/display/win/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_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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
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. 92 // Returns the result of GetSystemMetrics for |metric| scaled to |hwnd|'s DPI.
93 static int GetSystemMetricsForHwnd(HWND hwnd, int metric); 93 static int GetSystemMetricsForHwnd(HWND hwnd, int metric);
94 94
95 // Returns |hwnd|'s scale factor.
96 static float GetScaleFactorForHWND(HWND hwnd);
97
95 // Returns the HWND associated with the NativeView. 98 // Returns the HWND associated with the NativeView.
96 virtual HWND GetHWNDFromNativeView(gfx::NativeView window) const; 99 virtual HWND GetHWNDFromNativeView(gfx::NativeView window) const;
97 100
98 // Returns the NativeView associated with the HWND. 101 // Returns the NativeView associated with the HWND.
99 virtual gfx::NativeWindow GetNativeWindowFromHWND(HWND hwnd) const; 102 virtual gfx::NativeWindow GetNativeWindowFromHWND(HWND hwnd) const;
100 103
101 protected: 104 protected:
102 // display::Screen: 105 // display::Screen:
103 gfx::Point GetCursorScreenPoint() override; 106 gfx::Point GetCursorScreenPoint() override;
104 bool IsWindowUnderCursor(gfx::NativeWindow window) override; 107 bool IsWindowUnderCursor(gfx::NativeWindow window) override;
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 155
153 // Returns the ScreenWinDisplay closest to or enclosing |dip_rect|. 156 // Returns the ScreenWinDisplay closest to or enclosing |dip_rect|.
154 ScreenWinDisplay GetScreenWinDisplayNearestDIPRect( 157 ScreenWinDisplay GetScreenWinDisplayNearestDIPRect(
155 const gfx::Rect& dip_rect) const; 158 const gfx::Rect& dip_rect) const;
156 159
157 // Returns the ScreenWinDisplay corresponding to the primary monitor. 160 // Returns the ScreenWinDisplay corresponding to the primary monitor.
158 ScreenWinDisplay GetPrimaryScreenWinDisplay() const; 161 ScreenWinDisplay GetPrimaryScreenWinDisplay() const;
159 162
160 ScreenWinDisplay GetScreenWinDisplay(const MONITORINFOEX& monitor_info) const; 163 ScreenWinDisplay GetScreenWinDisplay(const MONITORINFOEX& monitor_info) const;
161 164
162 static float GetScaleFactorForHWND(HWND hwnd);
163
164 // Returns the result of calling |getter| with |value| on the global 165 // Returns the result of calling |getter| with |value| on the global
165 // ScreenWin if it exists, otherwise return the default ScreenWinDisplay. 166 // ScreenWin if it exists, otherwise return the default ScreenWinDisplay.
166 template <typename Getter, typename GetterType> 167 template <typename Getter, typename GetterType>
167 static ScreenWinDisplay GetScreenWinDisplayVia(Getter getter, 168 static ScreenWinDisplay GetScreenWinDisplayVia(Getter getter,
168 GetterType value); 169 GetterType value);
169 170
170 void RecordDisplayScaleFactors() const; 171 void RecordDisplayScaleFactors() const;
171 172
172 // Helper implementing the DisplayObserver handling. 173 // Helper implementing the DisplayObserver handling.
173 DisplayChangeNotifier change_notifier_; 174 DisplayChangeNotifier change_notifier_;
174 175
175 std::unique_ptr<gfx::SingletonHwndObserver> singleton_hwnd_observer_; 176 std::unique_ptr<gfx::SingletonHwndObserver> singleton_hwnd_observer_;
176 177
177 // Current list of ScreenWinDisplays. 178 // Current list of ScreenWinDisplays.
178 std::vector<ScreenWinDisplay> screen_win_displays_; 179 std::vector<ScreenWinDisplay> screen_win_displays_;
179 180
180 DISALLOW_COPY_AND_ASSIGN(ScreenWin); 181 DISALLOW_COPY_AND_ASSIGN(ScreenWin);
181 }; 182 };
182 183
183 } // namespace win 184 } // namespace win
184 } // namespace display 185 } // namespace display
185 186
186 #endif // UI_DISPLAY_WIN_SCREEN_WIN_H_ 187 #endif // UI_DISPLAY_WIN_SCREEN_WIN_H_
OLDNEW
« no previous file with comments | « no previous file | ui/display/win/screen_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698