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

Unified Diff: chrome/browser/ui/views/frame/browser_frame_win.cc

Issue 10638016: Merge 143447 - On Windows 8 when a metro application is snapped running desktop application windows… (Closed) Base URL: svn://svn.chromium.org/chrome/branches/1180/src/
Patch Set: Created 8 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/views/frame/browser_frame_win.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/views/frame/browser_frame_win.cc
===================================================================
--- chrome/browser/ui/views/frame/browser_frame_win.cc (revision 143635)
+++ chrome/browser/ui/views/frame/browser_frame_win.cc (working copy)
@@ -6,7 +6,6 @@
#include <dwmapi.h>
#include <shellapi.h>
-
#include <set>
#include "base/command_line.h"
@@ -31,6 +30,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"
@@ -86,6 +86,20 @@
return switcher_button;
}
+static int GetMinimizeButtonOffsetForWindow(gfx::NativeView window) {
+ // The WM_GETTITLEBARINFOEX message can fail if we are not active/visible.
+ TITLEBARINFOEX titlebar_info = {0};
+ titlebar_info.cbSize = sizeof(TITLEBARINFOEX);
+ SendMessage(window, WM_GETTITLEBARINFOEX, 0,
+ reinterpret_cast<WPARAM>(&titlebar_info));
+
+ CPoint minimize_button_corner(titlebar_info.rgrect[2].left,
+ titlebar_info.rgrect[2].top);
+ MapWindowPoints(HWND_DESKTOP, window, &minimize_button_corner, 1);
+ return minimize_button_corner.x;
+}
+
+
///////////////////////////////////////////////////////////////////////////////
// BrowserFrameWin, public:
@@ -95,7 +109,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 +265,12 @@
views::NativeWidgetWin::Close();
}
+void BrowserFrameWin::OnActivate(UINT action, BOOL minimized, HWND window) {
+ if (action != WA_INACTIVE)
+ CacheMinimizeButtonDelta();
+ views::NativeWidgetWin::OnActivate(action, minimized, window);
+}
+
////////////////////////////////////////////////////////////////////////////////
// BrowserFrameWin, NativeBrowserFrame implementation:
@@ -275,15 +296,25 @@
}
int BrowserFrameWin::GetMinimizeButtonOffset() const {
- TITLEBARINFOEX titlebar_info;
- titlebar_info.cbSize = sizeof(TITLEBARINFOEX);
- SendMessage(GetNativeView(), WM_GETTITLEBARINFOEX, 0, (WPARAM)&titlebar_info);
+ int minimize_button_offset =
+ GetMinimizeButtonOffsetForWindow(GetNativeView());
- CPoint minimize_button_corner(titlebar_info.rgrect[2].left,
- titlebar_info.rgrect[2].top);
- MapWindowPoints(HWND_DESKTOP, GetNativeView(), &minimize_button_corner, 1);
+ if (minimize_button_offset)
+ return minimize_button_offset;
- return minimize_button_corner.x;
+ // If we fail to get the minimize button offset via the WM_GETTITLEBARINFOEX
+ // message then calculate and return this via the
+ // cached_minimize_button_x_delta_ member value. Please see
+ // CacheMinimizeButtonDelta() for more details.
+ DCHECK(cached_minimize_button_x_delta_);
+
+ RECT client_rect = {0};
+ GetClientRect(&client_rect);
+
+ if (base::i18n::IsRTL())
+ return cached_minimize_button_x_delta_;
+ else
+ return client_rect.right - cached_minimize_button_x_delta_;
}
void BrowserFrameWin::TabStripDisplayModeChanged() {
@@ -505,7 +536,24 @@
UTF8ToWide(current_tab->GetURL().spec()));
}
+void BrowserFrameWin::CacheMinimizeButtonDelta() {
+ int minimize_offset = GetMinimizeButtonOffsetForWindow(GetNativeView());
+ 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())
+ cached_minimize_button_x_delta_ = minimize_offset;
+ else
+ cached_minimize_button_x_delta_ = rect.right - minimize_offset;
+}
+
////////////////////////////////////////////////////////////////////////////////
// BrowserFrame, public:
« no previous file with comments | « chrome/browser/ui/views/frame/browser_frame_win.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698