Commit 782a8e94 authored by ananta@chromium.org's avatar ananta@chromium.org

Fix the black patch which would appear at the top of app windows in Chrome...

Fix the black patch which would appear at the top of app windows in Chrome desktop windows with HiDPI

The bug occurs because the non client insets which account for the window frame are retrieved via the
GetSystemMetrics API which returns values in pixels.

Changes as below:-
1. Renamed the GlassAppWindowFrameViewWin::GetGlassInsets function to GetGlassInsetsInDIP.
2. Replaced calls to the GetSystemMetrics API in the GetGlassInsetsInDIP function with the dpi helper
   GetSystemMetricsInDIP.
3. Added code to convert the insets to pixels in the AppWindowDesktopWindowTreeHostWin::UpdateDWMFrame
   function.

BUG=392603
TBR=benwells

Review URL: https://codereview.chromium.org/382013004

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@282682 0039d316-1c4b-4281-b951-d872f2087c98
parent be4bd27a
......@@ -73,10 +73,19 @@ void AppWindowDesktopWindowTreeHostWin::UpdateDWMFrame() {
// Otherwise, we need to figure out how to extend the glass in.
if (app_window_->glass_frame_view()) {
gfx::Insets insets = app_window_->glass_frame_view()->GetGlassInsets();
margins.cxLeftWidth = insets.left();
margins.cxRightWidth = insets.right();
margins.cyBottomHeight = insets.bottom();
margins.cyTopHeight = insets.top();
// The DWM API's expect values in pixels. We need to convert from DIP to
// pixels here.
gfx::Rect insets_rect_in_pixels(insets.left(),
insets.top(),
insets.right() - insets.left(),
insets.bottom() - insets.top());
insets_rect_in_pixels = gfx::win::DIPToScreenRect(insets_rect_in_pixels);
margins.cxLeftWidth = insets_rect_in_pixels.x();
margins.cxRightWidth =
insets_rect_in_pixels.x() + insets_rect_in_pixels.width();
margins.cyBottomHeight =
insets_rect_in_pixels.y() + insets_rect_in_pixels.height();
margins.cyTopHeight = insets_rect_in_pixels.y();
}
DwmExtendFrameIntoClientArea(GetHWND(), &margins);
......
......@@ -6,6 +6,7 @@
#include "apps/ui/native_app_window.h"
#include "ui/base/hit_test.h"
#include "ui/gfx/win/dpi.h"
#include "ui/views/widget/widget.h"
#include "ui/views/widget/widget_delegate.h"
......@@ -32,9 +33,11 @@ gfx::Insets GlassAppWindowFrameViewWin::GetGlassInsets() const {
// for that.
// Also make sure the insets don't go below 1, as bad things happen when they
// do.
int caption_height = std::max(
0, GetSystemMetrics(SM_CYSMICON) + GetSystemMetrics(SM_CYSIZEFRAME) - 1);
int frame_size = std::max(1, GetSystemMetrics(SM_CXSIZEFRAME) - 1);
int caption_height = std::max(0,
gfx::win::GetSystemMetricsInDIP(SM_CYSMICON) +
gfx::win::GetSystemMetricsInDIP(SM_CYSIZEFRAME) - 1);
int frame_size =
std::max(1, gfx::win::GetSystemMetricsInDIP(SM_CXSIZEFRAME) - 1);
return gfx::Insets(
frame_size + caption_height, frame_size, frame_size, frame_size);
}
......@@ -73,7 +76,7 @@ int GlassAppWindowFrameViewWin::NonClientHitTest(const gfx::Point& point) {
: false;
// Don't allow overlapping resize handles when the window is maximized or
// fullscreen, as it can't be resized in those states.
int resize_border = GetSystemMetrics(SM_CXSIZEFRAME);
int resize_border = gfx::win::GetSystemMetricsInDIP(SM_CXSIZEFRAME);
int frame_component =
GetHTComponentForFrame(point,
resize_border,
......
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