Commit 15633635 authored by Taylor Bergquist's avatar Taylor Bergquist Committed by Commit Bot

Include non-resize-handle border in frame insets.

https://crrev.com/c/1149273 used a new Windows API,
GetSystemMetricsForDpi, to better handle multi-monitor high DPI frame
sizing scenarios.  However this API does not perpetuate a backwards-
compatibility behavior we were relying on before, where SM_CXSIZEFRAME
would include the non-resize-handle border space, SM_CXPADDEDBORDER,
(added in Vista) in addition to the resize handle space.  As a result,
we weren't accounting for that border space when calculating client area
insets.  This CL includes that space explicitly.

Bug: 873860
Bug: 874884
Bug: 876687
Change-Id: I19a9bde9c684e801cefb5f98162dba64ece295af
Reviewed-on: https://chromium-review.googlesource.com/1176824Reviewed-by: default avatarScott Violet <sky@chromium.org>
Reviewed-by: default avatarRobert Liao <robliao@chromium.org>
Commit-Queue: Taylor Bergquist <tbergquist@chromium.org>
Cr-Commit-Position: refs/heads/master@{#585374}
parent 4516de02
......@@ -9,6 +9,7 @@
#include "base/win/windows_version.h"
#include "extensions/browser/app_window/native_app_window.h"
#include "ui/base/hit_test.h"
#include "ui/base/win/hwnd_metrics.h"
#include "ui/display/win/screen_win.h"
#include "ui/views/widget/widget.h"
#include "ui/views/widget/widget_delegate.h"
......@@ -56,11 +57,8 @@ gfx::Insets GlassAppWindowFrameViewWin::GetClientAreaInsets(
int border_thickness = 1;
insets.Set(0, 0, border_thickness, border_thickness);
} else {
// On Windows 10 we use a 1 pixel non client border which is too thin as a
// resize target. This inset extends the resize region.
int resize_border = display::win::ScreenWin::GetSystemMetricsForMonitor(
monitor, SM_CXSIZEFRAME);
insets.Set(0, resize_border, resize_border, resize_border);
const int frame_thickness = ui::GetFrameThickness(monitor);
insets.Set(0, frame_thickness, frame_thickness, frame_thickness);
}
return insets;
}
......
......@@ -22,6 +22,7 @@
#include "chrome/common/chrome_constants.h"
#include "ui/base/material_design/material_design_controller.h"
#include "ui/base/theme_provider.h"
#include "ui/base/win/hwnd_metrics.h"
#include "ui/display/win/screen_win.h"
#include "ui/gfx/geometry/point.h"
#include "ui/views/controls/menu/native_menu_win.h"
......@@ -100,9 +101,7 @@ bool BrowserDesktopWindowTreeHostWin::GetClientAreaInsets(
// In fullscreen mode there is no frame.
*insets = gfx::Insets();
} else {
const int frame_thickness =
display::win::ScreenWin::GetSystemMetricsForMonitor(monitor,
SM_CXSIZEFRAME);
const int frame_thickness = ui::GetFrameThickness(monitor);
// Reduce the Windows non-client border size because we extend the border
// into our client area in UpdateDWMFrame(). The top inset must be 0 or
// else Windows will draw a full native titlebar outside the client area.
......
......@@ -303,6 +303,8 @@ component("base") {
"win/foreground_helper.h",
"win/hidden_window.cc",
"win/hidden_window.h",
"win/hwnd_metrics.cc",
"win/hwnd_metrics.h",
"win/hwnd_subclass.cc",
"win/hwnd_subclass.h",
"win/internal_constants.cc",
......
// Copyright 2018 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.
#include "ui/base/win/hwnd_metrics.h"
#include <windows.h>
#include "ui/display/win/screen_win.h"
namespace ui {
int GetFrameThickness(HMONITOR monitor) {
// On Windows 10 the visible frame border is one pixel thick, but there is
// some additional non-visible space: SM_CXSIZEFRAME (the resize handle)
// and SM_CXPADDEDBORDER (additional border space that isn't part of the
// resize handle).
const int resize_frame_thickness =
display::win::ScreenWin::GetSystemMetricsForMonitor(monitor,
SM_CXSIZEFRAME);
const int padding_thickness =
display::win::ScreenWin::GetSystemMetricsForMonitor(monitor,
SM_CXPADDEDBORDER);
return resize_frame_thickness + padding_thickness;
}
} // namespace ui
// Copyright 2018 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.
#ifndef UI_BASE_WIN_HWND_METRICS_H_
#define UI_BASE_WIN_HWND_METRICS_H_
#include <windows.h>
#include "ui/base/ui_base_export.h"
namespace ui {
// The size, in pixels, of the non-client frame around a window on |monitor|.
UI_BASE_EXPORT int GetFrameThickness(HMONITOR monitor);
} // namespace ui
#endif // UI_BASE_WIN_HWND_METRICS_H_
......@@ -31,6 +31,7 @@
#include "ui/base/ime/text_input_type.h"
#include "ui/base/ui_base_features.h"
#include "ui/base/view_prop.h"
#include "ui/base/win/hwnd_metrics.h"
#include "ui/base/win/internal_constants.h"
#include "ui/base/win/lock_state.h"
#include "ui/base/win/mouse_wheel_util.h"
......@@ -1365,13 +1366,11 @@ bool HWNDMessageHandler::GetClientAreaInsets(gfx::Insets* insets,
if (IsMaximized()) {
// Windows automatically adds a standard width border to all sides when a
// window is maximized.
// TODO(870135): This should be using ScreenWin::GetSystemMetricsForMonitor,
// but doing so causes some clipping on sub-processes that are DPI unaware.
int border_thickness = GetSystemMetrics(SM_CXSIZEFRAME);
int frame_thickness = ui::GetFrameThickness(monitor);
if (!delegate_->HasFrame())
border_thickness -= 1;
*insets = gfx::Insets(
border_thickness, border_thickness, border_thickness, border_thickness);
frame_thickness -= 1;
*insets = gfx::Insets(frame_thickness, frame_thickness, frame_thickness,
frame_thickness);
return true;
}
......
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