Chromium Code Reviews| Index: chrome/browser/ui/views/frame/browser_frame_win.cc |
| =================================================================== |
| --- chrome/browser/ui/views/frame/browser_frame_win.cc (revision 142824) |
| +++ chrome/browser/ui/views/frame/browser_frame_win.cc (working copy) |
| @@ -6,7 +6,7 @@ |
| #include <dwmapi.h> |
| #include <shellapi.h> |
| - |
| +#include <vssym32.h> |
| #include <set> |
| #include "base/command_line.h" |
| @@ -31,6 +31,7 @@ |
| #include "googleurl/src/gurl.h" |
| #include "grit/generated_resources.h" |
| #include "grit/theme_resources.h" |
| +#include "ui/base/l10n/l10n_util.h" |
| #include "ui/base/models/simple_menu_model.h" |
| #include "ui/base/resource/resource_bundle.h" |
| #include "ui/base/theme_provider.h" |
| @@ -95,7 +96,8 @@ |
| browser_view_(browser_view), |
| browser_frame_(browser_frame), |
| system_menu_delegate_(new SystemMenuModelDelegate(browser_view, |
| - browser_view->browser())) { |
| + browser_view->browser())), |
| + cached_minimize_button_x_delta_(0) { |
| if (base::win::IsMetroProcess()) { |
| browser_view->SetWindowSwitcherButton( |
| MakeWindowSwitcherButton(this, browser_view->IsOffTheRecord())); |
| @@ -250,6 +252,12 @@ |
| views::NativeWidgetWin::Close(); |
| } |
| +void BrowserFrameWin::OnActivate(UINT action, BOOL minimized, HWND window) { |
| + views::NativeWidgetWin::OnActivate(action, minimized, window); |
| + if (action != WA_INACTIVE) |
|
sky
2012/06/21 16:38:40
Can you move this before the call to NativeWidgetW
ananta
2012/06/21 17:39:40
Done.
|
| + CacheMinimizeButtonDelta(); |
| +} |
| + |
| //////////////////////////////////////////////////////////////////////////////// |
| // BrowserFrameWin, NativeBrowserFrame implementation: |
| @@ -275,15 +283,29 @@ |
| } |
| int BrowserFrameWin::GetMinimizeButtonOffset() const { |
| + // The WM_GETTITLEBARINFOEX message can fail if we are not active/visible. |
| TITLEBARINFOEX titlebar_info; |
| titlebar_info.cbSize = sizeof(TITLEBARINFOEX); |
| - SendMessage(GetNativeView(), WM_GETTITLEBARINFOEX, 0, (WPARAM)&titlebar_info); |
| + BOOL ret = SendMessage(GetNativeView(), WM_GETTITLEBARINFOEX, 0, |
|
sky
2012/06/21 16:38:40
If this does fail, won't titlebar_info contain gar
ananta
2012/06/21 17:39:40
Unfortunately SendMessage always returns success.
|
| + reinterpret_cast<WPARAM>(&titlebar_info)); |
| CPoint minimize_button_corner(titlebar_info.rgrect[2].left, |
| titlebar_info.rgrect[2].top); |
| MapWindowPoints(HWND_DESKTOP, GetNativeView(), &minimize_button_corner, 1); |
| - return minimize_button_corner.x; |
| + if (minimize_button_corner.x) |
| + return minimize_button_corner.x; |
| + |
| + DCHECK(cached_minimize_button_x_delta_); |
| + |
| + RECT client_rect = {0}; |
| + GetClientRect(&client_rect); |
| + |
| + if (base::i18n::IsRTL()) { |
|
sky
2012/06/21 16:38:40
no {}
ananta
2012/06/21 17:39:40
Done.
|
| + return cached_minimize_button_x_delta_; |
| + } else { |
| + return client_rect.right - cached_minimize_button_x_delta_; |
| + } |
| } |
| void BrowserFrameWin::TabStripDisplayModeChanged() { |
| @@ -505,7 +527,25 @@ |
| UTF8ToWide(current_tab->GetURL().spec())); |
| } |
| +void BrowserFrameWin::CacheMinimizeButtonDelta() { |
| + int minimize_offset = GetMinimizeButtonOffset(); |
| + if (!minimize_offset) |
| + return; |
| + RECT rect = {0}; |
| + GetClientRect(&rect); |
| + // Calculate and cache the value of the minimize button delta, i.e. the |
| + // offset to be applied to the left or right edge of the client rect |
| + // depending on whether the language is RTL or not. |
| + // This cached value is only used if the WM_GETTITLEBARINFOEX message fails |
| + // to get the offset of the minimize button. |
| + if (base::i18n::IsRTL()) { |
|
sky
2012/06/21 16:38:40
no {}
ananta
2012/06/21 17:39:40
Done.
|
| + cached_minimize_button_x_delta_ = minimize_offset; |
| + } else { |
| + cached_minimize_button_x_delta_ = rect.right - minimize_offset; |
| + } |
| +} |
| + |
| //////////////////////////////////////////////////////////////////////////////// |
| // BrowserFrame, public: |