| Index: chrome/browser/ui/views/frame/minimize_button_metrics_win.cc
|
| diff --git a/chrome/browser/ui/views/frame/minimize_button_metrics_win.cc b/chrome/browser/ui/views/frame/minimize_button_metrics_win.cc
|
| index 095f2574c83c9ed91b29b7ec8972c8022cbe5d8d..80fd29d775a6971d3b9f933fe6d51fdafafb2dbd 100644
|
| --- a/chrome/browser/ui/views/frame/minimize_button_metrics_win.cc
|
| +++ b/chrome/browser/ui/views/frame/minimize_button_metrics_win.cc
|
| @@ -24,6 +24,12 @@ const int kWin8ButtonBoundsPositionOffset = 10;
|
| const int kWin10ButtonBoundsPositionOffset = 6;
|
| const int kInvalidOffset = static_cast<int>(0x80000000);
|
|
|
| +// These constant were determined manually by testing on Windows 7, 8 and 10.
|
| +const int kWin7ButtonHeight = 20;
|
| +const int kWin8ButtonHeight = 20;
|
| +const int kWin10ButtonHeight = 28;
|
| +const int kInvalidHeight = static_cast<int>(0x80000000);
|
| +
|
| using base::win::GetVersion;
|
| using display::win::ScreenWin;
|
|
|
| @@ -35,6 +41,14 @@ int GetDefaultButtonBoundsOffset() {
|
| return kWin7ButtonBoundsPositionOffset;
|
| }
|
|
|
| +int GetDefaultButtonHeight() {
|
| + if (GetVersion() >= base::win::VERSION_WIN10)
|
| + return kWin10ButtonHeight;
|
| + if (GetVersion() >= base::win::VERSION_WIN8)
|
| + return kWin8ButtonHeight;
|
| + return kWin7ButtonHeight;
|
| +}
|
| +
|
| } // namespace
|
|
|
| // static
|
| @@ -43,6 +57,9 @@ int MinimizeButtonMetrics::last_cached_minimize_button_x_delta_ = 0;
|
| // static
|
| int MinimizeButtonMetrics::button_bounds_position_offset_ = kInvalidOffset;
|
|
|
| +// static
|
| +int MinimizeButtonMetrics::button_bounds_height_ = kInvalidHeight;
|
| +
|
| MinimizeButtonMetrics::MinimizeButtonMetrics()
|
| : hwnd_(nullptr),
|
| cached_minimize_button_x_delta_(last_cached_minimize_button_x_delta_),
|
| @@ -123,7 +140,7 @@ int MinimizeButtonMetrics::GetMinimizeButtonOffsetForWindow() const {
|
| TITLEBARINFOEX titlebar_info = {0};
|
| titlebar_info.cbSize = sizeof(TITLEBARINFOEX);
|
| SendMessage(hwnd_, WM_GETTITLEBARINFOEX, 0,
|
| - reinterpret_cast<WPARAM>(&titlebar_info));
|
| + reinterpret_cast<LPARAM>(&titlebar_info));
|
|
|
| // Under DWM WM_GETTITLEBARINFOEX won't return the right thing until after
|
| // WM_NCACTIVATE (maybe it returns classic values?). In an attempt to
|
| @@ -189,3 +206,28 @@ int MinimizeButtonMetrics::GetAndCacheMinimizeButtonOffsetX() const {
|
| last_cached_minimize_button_x_delta_ = cached_minimize_button_x_delta_;
|
| return minimize_button_offset;
|
| }
|
| +
|
| +int MinimizeButtonMetrics::GetMinimizeButtonHeight() const {
|
| + // It's hard to get the height of the caption buttons exactly right for all
|
| + // resolutions/DPI settings. GetSystemMetricsForDpi is probaly the real
|
| + // solution [http://crbug.com/668278], but GetSystemMetrics provides a good
|
| + // approximation for now.
|
| +
|
| + // Note that the following methods do not return the correct result with DPI
|
| + // scaling settings other than 100%:
|
| + // DwmGetWindowAttribute(hwnd_, DWMWA_CAPTION_BUTTON_BOUNDS, ...)
|
| + // SendMessage(hwnd_, WM_GETTITLEBARINFOEX, ...)
|
| + // display::win::ScreenWin::GetSystemMetricsInDIP(SM_CYSIZE)
|
| + // display::win::ScreenWin::GetSystemMetricsForHwnd(hwnd_, SM_CYSIZE)
|
| +
|
| + if (button_bounds_height_ == kInvalidHeight) {
|
| + int button_height_from_sysmetrics = GetSystemMetrics(SM_CYSIZE);
|
| + if (button_height_from_sysmetrics == 0) {
|
| + DLOG(ERROR) << "GetSystemMetrics(SM_CYSIZE) error " << ::GetLastError();
|
| + return GetDefaultButtonHeight();
|
| + }
|
| + button_bounds_height_ = button_height_from_sysmetrics;
|
| + }
|
| +
|
| + return button_bounds_height_;
|
| +}
|
|
|