| 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 #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/logging.h" | 7 #include "base/logging.h" | 
| 8 #include "base/i18n/rtl.h" | 8 #include "base/i18n/rtl.h" | 
| 9 #include "ui/base/win/shell.h" | 9 #include "ui/base/win/shell.h" | 
| 10 #include "ui/gfx/win/dpi.h" | 10 #include "ui/display/win/dpi.h" | 
| 11 | 11 | 
| 12 namespace { | 12 namespace { | 
| 13 | 13 | 
| 14 int GetMinimizeButtonOffsetForWindow(HWND hwnd) { | 14 int GetMinimizeButtonOffsetForWindow(HWND hwnd) { | 
| 15   // The WM_GETTITLEBARINFOEX message can fail if we are not active/visible. By | 15   // The WM_GETTITLEBARINFOEX message can fail if we are not active/visible. By | 
| 16   // fail we get a location of 0; the return status code is always the same and | 16   // fail we get a location of 0; the return status code is always the same and | 
| 17   // similarly the state never seems to change (titlebar_info.rgstate). | 17   // similarly the state never seems to change (titlebar_info.rgstate). | 
| 18   TITLEBARINFOEX titlebar_info = {0}; | 18   TITLEBARINFOEX titlebar_info = {0}; | 
| 19   titlebar_info.cbSize = sizeof(TITLEBARINFOEX); | 19   titlebar_info.cbSize = sizeof(TITLEBARINFOEX); | 
| 20   SendMessage(hwnd, WM_GETTITLEBARINFOEX, 0, | 20   SendMessage(hwnd, WM_GETTITLEBARINFOEX, 0, | 
| 21               reinterpret_cast<WPARAM>(&titlebar_info)); | 21               reinterpret_cast<WPARAM>(&titlebar_info)); | 
| 22 | 22 | 
| 23   if (titlebar_info.rgrect[2].left == titlebar_info.rgrect[2].right || | 23   if (titlebar_info.rgrect[2].left == titlebar_info.rgrect[2].right || | 
| 24       (titlebar_info.rgstate[2] & (STATE_SYSTEM_INVISIBLE | | 24       (titlebar_info.rgstate[2] & (STATE_SYSTEM_INVISIBLE | | 
| 25                                    STATE_SYSTEM_OFFSCREEN | | 25                                    STATE_SYSTEM_OFFSCREEN | | 
| 26                                    STATE_SYSTEM_UNAVAILABLE))) { | 26                                    STATE_SYSTEM_UNAVAILABLE))) { | 
| 27     return 0; | 27     return 0; | 
| 28   } | 28   } | 
| 29 | 29 | 
| 30   // WM_GETTITLEBARINFOEX returns rects in screen coordinates in pixels. | 30   // WM_GETTITLEBARINFOEX returns rects in screen coordinates in pixels. | 
| 31   // We need to convert the minimize button corner offset to DIP before | 31   // We need to convert the minimize button corner offset to DIP before | 
| 32   // returning it. | 32   // returning it. | 
| 33   POINT minimize_button_corner = { titlebar_info.rgrect[2].left, 0 }; | 33   POINT minimize_button_corner = { titlebar_info.rgrect[2].left, 0 }; | 
| 34   MapWindowPoints(HWND_DESKTOP, hwnd, &minimize_button_corner, 1); | 34   MapWindowPoints(HWND_DESKTOP, hwnd, &minimize_button_corner, 1); | 
| 35   return minimize_button_corner.x / gfx::GetDPIScale(); | 35   return minimize_button_corner.x / display::win::GetDPIScale(); | 
| 36 } | 36 } | 
| 37 | 37 | 
| 38 }  // namespace | 38 }  // namespace | 
| 39 | 39 | 
| 40 // static | 40 // static | 
| 41 int MinimizeButtonMetrics::last_cached_minimize_button_x_delta_ = 0; | 41 int MinimizeButtonMetrics::last_cached_minimize_button_x_delta_ = 0; | 
| 42 | 42 | 
| 43 MinimizeButtonMetrics::MinimizeButtonMetrics() | 43 MinimizeButtonMetrics::MinimizeButtonMetrics() | 
| 44     : hwnd_(nullptr), | 44     : hwnd_(nullptr), | 
| 45       cached_minimize_button_x_delta_(last_cached_minimize_button_x_delta_), | 45       cached_minimize_button_x_delta_(last_cached_minimize_button_x_delta_), | 
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 95     cached_minimize_button_x_delta_ = minimize_button_offset; | 95     cached_minimize_button_x_delta_ = minimize_button_offset; | 
| 96   } else { | 96   } else { | 
| 97     RECT client_rect = {0}; | 97     RECT client_rect = {0}; | 
| 98     GetClientRect(hwnd_, &client_rect); | 98     GetClientRect(hwnd_, &client_rect); | 
| 99     cached_minimize_button_x_delta_ = | 99     cached_minimize_button_x_delta_ = | 
| 100         client_rect.right - minimize_button_offset; | 100         client_rect.right - minimize_button_offset; | 
| 101   } | 101   } | 
| 102   last_cached_minimize_button_x_delta_ = cached_minimize_button_x_delta_; | 102   last_cached_minimize_button_x_delta_ = cached_minimize_button_x_delta_; | 
| 103   return minimize_button_offset; | 103   return minimize_button_offset; | 
| 104 } | 104 } | 
| OLD | NEW | 
|---|