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..5754c8c080970885c5b830d0b82700826dbc38f7 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,29 @@ 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 will ensure that the mouse isn't set to a |
|
Peter Kasting
2016/07/19 02:48:34
Tiny nit: will ensure that -> ensures
kylix_rd
2016/07/19 14:11:14
Is this a stylistic subjective preference or just
Peter Kasting
2016/07/19 22:44:52
I think "will ensure" is a bit unclear because it
kylix_rd
2016/07/20 16:04:25
Fair enough. I'll defer to your judgement on this.
|
| + // 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. |
|
Peter Kasting
2016/07/19 02:48:34
Wait, isn't this sort of backwards? If the region
kylix_rd
2016/07/19 14:11:14
I'd thought about all of that. Yes, I would rather
Peter Kasting
2016/07/19 22:44:52
I think the issue is that since the mouse coord pa
kylix_rd
2016/07/20 16:04:25
I think we're in agreement here. This is the best
|
| + 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 |