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

Side by Side Diff: chrome/browser/ui/views/frame/minimize_button_metrics_win.cc

Issue 2881563004: Clear the cached avatar button offset when the DPI scaling changes (Closed)
Patch Set: Created 3 years, 7 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 | « chrome/browser/ui/views/frame/minimize_button_metrics_win.h ('k') | no next file » | 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 #include "chrome/browser/ui/views/frame/minimize_button_metrics_win.h" 5 #include "chrome/browser/ui/views/frame/minimize_button_metrics_win.h"
6 6
7 #include "base/i18n/rtl.h" 7 #include "base/i18n/rtl.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/win/windows_version.h" 9 #include "base/win/windows_version.h"
10 #include "dwmapi.h" 10 #include "dwmapi.h"
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 DCHECK(!hwnd_); 80 DCHECK(!hwnd_);
81 hwnd_ = hwnd; 81 hwnd_ = hwnd;
82 } 82 }
83 83
84 void MinimizeButtonMetrics::OnHWNDActivated() { 84 void MinimizeButtonMetrics::OnHWNDActivated() {
85 was_activated_ = true; 85 was_activated_ = true;
86 // NOTE: we don't cache here as it seems only after the activate is the value 86 // NOTE: we don't cache here as it seems only after the activate is the value
87 // correct. 87 // correct.
88 } 88 }
89 89
90 void MinimizeButtonMetrics::OnDpiChanged() {
91 // This ensures that the next time GetMinimizeButtonOffsetX() is called, it
92 // will be recalculated, given the new scale factor.
93 cached_minimize_button_x_delta_ = 0;
94 }
95
90 // This function attempts to calculate the odd and varying difference 96 // This function attempts to calculate the odd and varying difference
91 // between the results of DwmGetWindowAttribute with the 97 // between the results of DwmGetWindowAttribute with the
92 // DWMWA_CAPTION_BUTTON_BOUNDS flag and the information from the 98 // DWMWA_CAPTION_BUTTON_BOUNDS flag and the information from the
93 // WM_GETTITLEBARINFOEX message. It will return an empirically determined 99 // WM_GETTITLEBARINFOEX message. It will return an empirically determined
94 // offset until the window has been activated and the message returns 100 // offset until the window has been activated and the message returns
95 // valid rectangles. 101 // valid rectangles.
96 int MinimizeButtonMetrics::GetButtonBoundsPositionOffset( 102 int MinimizeButtonMetrics::GetButtonBoundsPositionOffset(
97 const RECT& button_bounds, 103 const RECT& button_bounds,
98 const RECT& window_bounds) const { 104 const RECT& window_bounds) const {
99 if (button_bounds_position_offset_ == kInvalidOffset) { 105 if (button_bounds_position_offset_ == kInvalidOffset) {
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 cached_minimize_button_x_delta_ = minimize_button_offset; 212 cached_minimize_button_x_delta_ = minimize_button_offset;
207 } else { 213 } else {
208 RECT client_rect = {0}; 214 RECT client_rect = {0};
209 GetClientRect(hwnd_, &client_rect); 215 GetClientRect(hwnd_, &client_rect);
210 cached_minimize_button_x_delta_ = 216 cached_minimize_button_x_delta_ =
211 client_rect.right - minimize_button_offset; 217 client_rect.right - minimize_button_offset;
212 } 218 }
213 last_cached_minimize_button_x_delta_ = cached_minimize_button_x_delta_; 219 last_cached_minimize_button_x_delta_ = cached_minimize_button_x_delta_;
214 return minimize_button_offset; 220 return minimize_button_offset;
215 } 221 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/frame/minimize_button_metrics_win.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698