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

Unified Diff: content/browser/renderer_host/render_message_filter_win.cc

Issue 7799004: Make the "get window rect" message handlers report the work area, rather than the true window siz... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 9 years, 4 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/renderer_host/render_message_filter_win.cc
===================================================================
--- content/browser/renderer_host/render_message_filter_win.cc (revision 98485)
+++ content/browser/renderer_host/render_message_filter_win.cc (working copy)
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -8,33 +8,51 @@
#include "third_party/WebKit/Source/WebKit/chromium/public/WebScreenInfo.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/win/WebScreenInfoFactory.h"
-using WebKit::WebScreenInfo;
-using WebKit::WebScreenInfoFactory;
+namespace {
-// We get null window_ids passed into the two functions below; please see
-// http://crbug.com/9060 for more details.
+// Returns the "visible window rect" for |window|, defined roughly as "what the
+// user thinks of as the window". See comments below regarding the difference
+// between this and the true window rect when the window is maximized.
+gfx::Rect GetVisibleWindowRect(HWND window) {
+ // We get null |window_id|s passed into the two functions below; see bug 9060.
+ // Probably this should be removed and we should prevent this case.
+ if (!IsWindow(window))
+ return gfx::Rect();
+ RECT window_rect = {0};
+ GetWindowRect(window, &window_rect);
+ gfx::Rect rect(window_rect);
+
+ // Maximized windows are outdented from the work area by the frame thickness
+ // even though this "frame" is not painted. This confuses code (and people)
+ // that think of a maximized window as corresponding exactly to the work area.
+ // Correct for this by subtracting the frame thickness back off.
+ if (IsZoomed(window)) {
+ rect.Inset(GetSystemMetrics(SM_CXSIZEFRAME),
+ GetSystemMetrics(SM_CYSIZEFRAME));
Ben Goodger (Google) 2011/08/30 20:06:24 Are all Windows apps typically larger than the wor
Peter Kasting 2011/08/30 20:08:53 As far as I know, yes. I double-checked with Word
+ }
+ return rect;
+}
+
+};
+
+
// TODO(shess): Provide a mapping from reply_msg->routing_id() to HWND
// so that we can eliminate the NativeViewId parameter.
void RenderMessageFilter::OnGetWindowRect(gfx::NativeViewId window_id,
gfx::Rect* rect) {
- HWND window = gfx::NativeViewFromId(window_id);
- RECT window_rect = {0};
- GetWindowRect(window, &window_rect);
- *rect = window_rect;
+ *rect = GetVisibleWindowRect(gfx::NativeViewFromId(window_id));
}
void RenderMessageFilter::OnGetRootWindowRect(gfx::NativeViewId window_id,
gfx::Rect* rect) {
- HWND window = gfx::NativeViewFromId(window_id);
- RECT window_rect = {0};
- HWND root_window = ::GetAncestor(window, GA_ROOT);
- GetWindowRect(root_window, &window_rect);
- *rect = window_rect;
+ *rect = GetVisibleWindowRect(GetAncestor(gfx::NativeViewFromId(window_id),
+ GA_ROOT));
}
void RenderMessageFilter::OnGetScreenInfo(gfx::NativeViewId view,
WebKit::WebScreenInfo* results) {
- *results = WebScreenInfoFactory::screenInfo(gfx::NativeViewFromId(view));
+ *results =
+ WebKit::WebScreenInfoFactory::screenInfo(gfx::NativeViewFromId(view));
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698