Chromium Code Reviews| Index: chrome/browser/ui/views/frame/glass_browser_frame_view.cc |
| diff --git a/chrome/browser/ui/views/frame/glass_browser_frame_view.cc b/chrome/browser/ui/views/frame/glass_browser_frame_view.cc |
| index 64f28ac79fffb97eb8023698a873f66fa1ab2cc2..b8700b63d186c9aacb152a20c60a2da9b321d764 100644 |
| --- a/chrome/browser/ui/views/frame/glass_browser_frame_view.cc |
| +++ b/chrome/browser/ui/views/frame/glass_browser_frame_view.cc |
| @@ -4,6 +4,7 @@ |
| #include "chrome/browser/ui/views/frame/glass_browser_frame_view.h" |
| +#include <dwmapi.h> |
| #include <utility> |
| #include "base/strings/utf_string_conversions.h" |
| @@ -28,6 +29,7 @@ |
| #include "ui/base/theme_provider.h" |
| #include "ui/display/win/dpi.h" |
| #include "ui/gfx/canvas.h" |
| +#include "ui/gfx/geometry/dip_util.h" |
| #include "ui/gfx/icon_util.h" |
| #include "ui/gfx/image/image.h" |
| #include "ui/gfx/scoped_canvas.h" |
| @@ -70,6 +72,9 @@ const int kNewTabCaptionMaximizedSpacing = 16; |
| // TODO(bsep): Windows 10 caption buttons look very different and we would like |
| // the profile switcher button to match on that platform. |
| 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 |
| // handle. |image| is resized to desired |width| and |height| if needed. |
| @@ -245,6 +250,32 @@ int GlassBrowserFrameView::NonClientHitTest(const gfx::Point& point) { |
| if (frame_component != HTNOWHERE) |
| 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)); |
| + // Even though the tiny area above the caption buttons is very difficult |
| + // to hit, this ensures behavioral consistency with other top-level |
| + // windows. It is worth noting that this area is the same size (1px) |
| + // regardless of the current scale factor. For that reason the rect is |
| + // inset after it is adjusted for the device scale. Even so, this is less |
| + // than ideal since conversion to DIPs may lose some precision. Given |
| + // that the API doesn't take that into account, at this point this is the |
| + // best we can do. |
|
Peter Kasting
2016/07/20 18:47:44
Nit: This still reads pretty confusingly to me. W
|
| + buttons.Inset(0, kCaptionButtonTopInset, 0, 0); |
| + if (buttons.Contains(point)) |
| + return HTNOWHERE; |
| + } |
| + } |
| + |
| int top_border_thickness = FrameTopBorderThickness(false); |
| // 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 |