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

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

Issue 2151903002: Exclude caption button bounds from non-client frame hit testing (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Slightly better code. Don't scale the small inset Created 4 years, 5 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: 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..a5d6595234351bfa7b641cf0224fd6af480ba90d 100644
--- a/chrome/browser/ui/views/frame/glass_browser_frame_view.cc
+++ b/chrome/browser/ui/views/frame/glass_browser_frame_view.cc
@@ -21,6 +21,7 @@
#include "components/prefs/pref_service.h"
#include "components/signin/core/browser/signin_header_helper.h"
#include "components/signin/core/common/profile_management_switches.h"
+#include "dwmapi.h"
Peter Kasting 2016/07/18 19:12:15 This should be in <> and moved up above the <utili
kylix_rd 2016/07/18 20:35:10 Done.
#include "grit/theme_resources.h"
#include "skia/ext/image_operations.h"
#include "ui/base/material_design/material_design_controller.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,10 @@ 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
+// sizable frame "peeks" through. This will ensure that the behavior is
Peter Kasting 2016/07/18 19:12:16 Nit: sizable frame -> resize border I would omit
kylix_rd 2016/07/18 20:35:10 Done.
+// consistent with most Windows applications.
+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 +251,28 @@ 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
+ // of the window. This code will ensure that the mouse isn't set to a size
Peter Kasting 2016/07/18 19:12:15 Nit: of -> corner of
kylix_rd 2016/07/18 20:35:10 Done.
+ // 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};
+ const HWND hwnd = views::HWNDForWidget(frame());
Peter Kasting 2016/07/18 19:12:15 Nit: I'd probably just inline this into the next s
kylix_rd 2016/07/18 20:35:10 Done.
+
Peter Kasting 2016/07/18 19:12:16 Nit: No blank here
kylix_rd 2016/07/18 20:35:10 Done.
+ if (SUCCEEDED(DwmGetWindowAttribute(hwnd, DWMWA_CAPTION_BUTTON_BOUNDS,
+ &button_bounds,
+ sizeof(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.
Peter Kasting 2016/07/18 19:12:15 Nit: This comment really belongs on the Inset() ca
kylix_rd 2016/07/18 20:35:10 Done.
+ gfx::Rect buttons = gfx::ConvertRectToDIP(display::win::GetDPIScale(),
+ gfx::Rect(button_bounds));
+ buttons.Inset(0, kCaptionButtonTopInset, 0, 0);
Peter Kasting 2016/07/18 19:12:16 Is it correct to inset after scaling? It's hard f
kylix_rd 2016/07/18 20:35:10 From my (admittedly empirical) investigation, it d
+ if (buttons.Contains(point))
+ return (HTNOWHERE);
Peter Kasting 2016/07/18 19:12:16 Should this be HTCAPTION? Nit: No parens
kylix_rd 2016/07/18 20:35:10 I want to ensure that subsequent processing lands
+ }
+ }
+
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
« 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