From: Brian Clifton Date: Fri, 13 Jan 2017 07:18:42 +0000 (-0700) Subject: Properly handle borders for DPI > 100% on Windows X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=cf6e215a66687dc983cd81755275f95a78a25a10;p=platform%2Fframework%2Fweb%2Fcrosswalk-tizen.git Properly handle borders for DPI > 100% on Windows Fixes https://github.com/electron/electron/issues/4573 cc: @zcbenz, @kevinsawicki, @zeke --- diff --git a/atom/browser/native_window_views_win.cc b/atom/browser/native_window_views_win.cc index 1b523e9..4b086c2 100644 --- a/atom/browser/native_window_views_win.cc +++ b/atom/browser/native_window_views_win.cc @@ -147,6 +147,18 @@ bool NativeWindowViews::PreHandleMSG( } return false; } + /** Return zero (no-op) for non-client area events when window is frameless. + * \see WM_NCPAINT - https://msdn.microsoft.com/en-us/library/windows/desktop/dd145212(v=vs.85).aspx + * \see WM_NCCALCSIZE - https://msdn.microsoft.com/en-us/library/windows/desktop/ms632634(v=vs.85).aspx + */ + case WM_NCPAINT: + case WM_NCCALCSIZE: { + if (!has_frame()) { + *result = 0; + return true; + } + return false; + } default: return false; } diff --git a/atom/browser/ui/views/menu_layout.cc b/atom/browser/ui/views/menu_layout.cc index 8f8e636..687ffd3 100644 --- a/atom/browser/ui/views/menu_layout.cc +++ b/atom/browser/ui/views/menu_layout.cc @@ -6,6 +6,7 @@ #if defined(OS_WIN) #include "atom/browser/native_window_views.h" +#include "ui/display/win/screen_win.h" #endif namespace atom { @@ -13,13 +14,17 @@ namespace atom { namespace { #if defined(OS_WIN) -gfx::Rect SubstractBorderSize(gfx::Rect bounds) { - int border_width = GetSystemMetrics(SM_CXSIZEFRAME) - 1; - int border_height = GetSystemMetrics(SM_CYSIZEFRAME) - 1; - bounds.set_x(bounds.x() + border_width); - bounds.set_y(bounds.y() + border_height); - bounds.set_width(bounds.width() - 2 * border_width); - bounds.set_height(bounds.height() - 2 * border_height); +gfx::Rect SubtractBorderSize(gfx::Rect bounds) { + gfx::Point borderSize = gfx::Point( + GetSystemMetrics(SM_CXSIZEFRAME) - 1, // width + GetSystemMetrics(SM_CYSIZEFRAME) - 1 // height + ); + gfx::Point dpiAdjustedSize = display::win::ScreenWin::ScreenToDIPPoint(borderSize); + + bounds.set_x(bounds.x() + dpiAdjustedSize.x()); + bounds.set_y(bounds.y() + dpiAdjustedSize.y()); + bounds.set_width(bounds.width() - 2 * dpiAdjustedSize.x()); + bounds.set_height(bounds.height() - 2 * dpiAdjustedSize.y()); return bounds; } #endif @@ -39,7 +44,7 @@ void MenuLayout::Layout(views::View* host) { // Reserve border space for maximized frameless window so we won't have the // content go outside of screen. if (!window_->has_frame() && window_->IsMaximized()) { - gfx::Rect bounds = SubstractBorderSize(host->GetContentsBounds()); + gfx::Rect bounds = SubtractBorderSize(host->GetContentsBounds()); host->child_at(0)->SetBoundsRect(bounds); return; }