Commit 5db27ec3 authored by kylixrd's avatar kylixrd Committed by Commit bot

This ensures that the non-client frame hit testing doesn't extend down into...

This ensures that the non-client frame hit testing doesn't extend down into the caption button (minimize, maximize, close) area, thus giving the user the impression that the frame is resizable at that point.

BUG=548619

Review-Url: https://codereview.chromium.org/2151903002
Cr-Commit-Position: refs/heads/master@{#406651}
parent f17ff1ab
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include "chrome/browser/ui/views/frame/glass_browser_frame_view.h" #include "chrome/browser/ui/views/frame/glass_browser_frame_view.h"
#include <dwmapi.h>
#include <utility> #include <utility>
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
...@@ -28,6 +29,7 @@ ...@@ -28,6 +29,7 @@
#include "ui/base/theme_provider.h" #include "ui/base/theme_provider.h"
#include "ui/display/win/dpi.h" #include "ui/display/win/dpi.h"
#include "ui/gfx/canvas.h" #include "ui/gfx/canvas.h"
#include "ui/gfx/geometry/dip_util.h"
#include "ui/gfx/icon_util.h" #include "ui/gfx/icon_util.h"
#include "ui/gfx/image/image.h" #include "ui/gfx/image/image.h"
#include "ui/gfx/scoped_canvas.h" #include "ui/gfx/scoped_canvas.h"
...@@ -70,6 +72,9 @@ const int kNewTabCaptionMaximizedSpacing = 16; ...@@ -70,6 +72,9 @@ const int kNewTabCaptionMaximizedSpacing = 16;
// TODO(bsep): Windows 10 caption buttons look very different and we would like // TODO(bsep): Windows 10 caption buttons look very different and we would like
// the profile switcher button to match on that platform. // the profile switcher button to match on that platform.
const int kProfileSwitcherButtonHeight = 20; const int kProfileSwitcherButtonHeight = 20;
// There is a small one-pixel strip right above the caption buttons in which the
// resize border "peeks" through.
const int kCaptionButtonTopInset = 1;
// Converts the |image| to a Windows icon and returns the corresponding HICON // Converts the |image| to a Windows icon and returns the corresponding HICON
// handle. |image| is resized to desired |width| and |height| if needed. // handle. |image| is resized to desired |width| and |height| if needed.
...@@ -245,6 +250,31 @@ int GlassBrowserFrameView::NonClientHitTest(const gfx::Point& point) { ...@@ -245,6 +250,31 @@ int GlassBrowserFrameView::NonClientHitTest(const gfx::Point& point) {
if (frame_component != HTNOWHERE) if (frame_component != HTNOWHERE)
return frame_component; return frame_component;
// On Windows 8+, the caption buttons are almost butted up to the top right
// corner of the window. This code ensures the mouse isn't set to a size
// cursor while hovering over the caption buttons, thus giving the incorrect
// impression that the user can resize the window.
if (base::win::GetVersion() >= base::win::VERSION_WIN8) {
RECT button_bounds = {0};
if (SUCCEEDED(DwmGetWindowAttribute(views::HWNDForWidget(frame()),
DWMWA_CAPTION_BUTTON_BOUNDS,
&button_bounds,
sizeof(button_bounds)))) {
gfx::Rect buttons = gfx::ConvertRectToDIP(display::win::GetDPIScale(),
gfx::Rect(button_bounds));
// The sizing region at the window edge above the caption buttons is
// 1 px regardless of scale factor. If we inset by 1 before converting
// to DIPs, the precision loss might eliminate this region entirely. The
// best we can do is to inset after conversion. This guarantees we'll
// show the resize cursor when resizing is possible. The cost of which
// is also maybe showing it over the portion of the DIP that isn't the
// outermost pixel.
buttons.Inset(0, kCaptionButtonTopInset, 0, 0);
if (buttons.Contains(point))
return HTNOWHERE;
}
}
int top_border_thickness = FrameTopBorderThickness(false); int top_border_thickness = FrameTopBorderThickness(false);
// We want the resize corner behavior to apply to the kResizeCornerWidth // We want the resize corner behavior to apply to the kResizeCornerWidth
// pixels at each end of the top and bottom edges. Because |point|'s x // pixels at each end of the top and bottom edges. Because |point|'s x
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment