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 "base/win/windows_version.h" | 9 #include "base/win/windows_version.h" |
10 #include "dwmapi.h" | 10 #include "dwmapi.h" |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 // This function attempts to calculate the odd and varying difference | 66 // This function attempts to calculate the odd and varying difference |
67 // between the results of DwmGetWindowAttribute with the | 67 // between the results of DwmGetWindowAttribute with the |
68 // DWMWA_CAPTION_BUTTON_BOUNDS flag and the information from the | 68 // DWMWA_CAPTION_BUTTON_BOUNDS flag and the information from the |
69 // WM_GETTITLEBARINFOEX message. It will return an empirically determined | 69 // WM_GETTITLEBARINFOEX message. It will return an empirically determined |
70 // offset until the window has been activated and the message returns | 70 // offset until the window has been activated and the message returns |
71 // valid rectangles. | 71 // valid rectangles. |
72 int MinimizeButtonMetrics::GetButtonBoundsPositionOffset( | 72 int MinimizeButtonMetrics::GetButtonBoundsPositionOffset( |
73 const RECT& button_bounds, | 73 const RECT& button_bounds, |
74 const RECT& window_bounds) const { | 74 const RECT& window_bounds) const { |
75 if (button_bounds_position_offset_ == kInvalidOffset) { | 75 if (button_bounds_position_offset_ == kInvalidOffset) { |
76 if (!was_activated_) | 76 if (!was_activated_ || !IsWindowVisible(hwnd_)) |
77 return GetDefaultButtonBoundsOffset(); | 77 return GetDefaultButtonBoundsOffset(); |
78 TITLEBARINFOEX info = {0}; | 78 TITLEBARINFOEX info = {0}; |
79 info.cbSize = sizeof(info); | 79 info.cbSize = sizeof(info); |
80 SendMessage(hwnd_, WM_GETTITLEBARINFOEX, 0, | 80 SendMessage(hwnd_, WM_GETTITLEBARINFOEX, 0, |
81 reinterpret_cast<LPARAM>(&info)); | 81 reinterpret_cast<LPARAM>(&info)); |
82 if (info.rgrect[2].right == info.rgrect[2].left || | 82 if (info.rgrect[2].right == info.rgrect[2].left || |
83 (info.rgstate[2] & (STATE_SYSTEM_INVISIBLE | STATE_SYSTEM_OFFSCREEN | | 83 (info.rgstate[2] & (STATE_SYSTEM_INVISIBLE | STATE_SYSTEM_OFFSCREEN | |
84 STATE_SYSTEM_UNAVAILABLE))) | 84 STATE_SYSTEM_UNAVAILABLE))) |
85 return GetDefaultButtonBoundsOffset(); | 85 return GetDefaultButtonBoundsOffset(); |
86 button_bounds_position_offset_ = | 86 button_bounds_position_offset_ = |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 cached_minimize_button_x_delta_ = minimize_button_offset; | 182 cached_minimize_button_x_delta_ = minimize_button_offset; |
183 } else { | 183 } else { |
184 RECT client_rect = {0}; | 184 RECT client_rect = {0}; |
185 GetClientRect(hwnd_, &client_rect); | 185 GetClientRect(hwnd_, &client_rect); |
186 cached_minimize_button_x_delta_ = | 186 cached_minimize_button_x_delta_ = |
187 client_rect.right - minimize_button_offset; | 187 client_rect.right - minimize_button_offset; |
188 } | 188 } |
189 last_cached_minimize_button_x_delta_ = cached_minimize_button_x_delta_; | 189 last_cached_minimize_button_x_delta_ = cached_minimize_button_x_delta_; |
190 return minimize_button_offset; | 190 return minimize_button_offset; |
191 } | 191 } |
OLD | NEW |