From fe8726d77556616d407644fabe94c82e6ac82710 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Tue, 11 Apr 2017 13:08:15 -0700 Subject: [PATCH 1/4] Use Chrome default client inset handling --- atom/browser/native_window_views.cc | 24 ------------------- atom/browser/ui/views/win_frame_view.cc | 1 - .../win/atom_desktop_window_tree_host_win.cc | 8 ------- .../win/atom_desktop_window_tree_host_win.h | 1 - electron.gyp | 7 +++++- 5 files changed, 6 insertions(+), 35 deletions(-) diff --git a/atom/browser/native_window_views.cc b/atom/browser/native_window_views.cc index 615c848daac8..690a47ececbd 100644 --- a/atom/browser/native_window_views.cc +++ b/atom/browser/native_window_views.cc @@ -70,20 +70,6 @@ const int kMenuBarHeight = 25; #endif #if defined(OS_WIN) -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; -} - void FlipWindowStyle(HWND handle, bool on, DWORD flag) { DWORD style = ::GetWindowLong(handle, GWL_STYLE); if (on) @@ -1279,16 +1265,6 @@ void NativeWindowViews::HandleKeyboardEvent( } void NativeWindowViews::Layout() { -#if defined(OS_WIN) - // Reserve border space for maximized frameless window so we won't have the - // content go outside of screen. - if (!has_frame() && IsMaximized()) { - gfx::Rect bounds = SubtractBorderSize(GetContentsBounds()); - web_view_->SetBoundsRect(bounds); - return; - } -#endif - const auto size = GetContentsBounds().size(); const auto menu_bar_bounds = menu_bar_ ? gfx::Rect(0, 0, size.width(), kMenuBarHeight) : gfx::Rect(); diff --git a/atom/browser/ui/views/win_frame_view.cc b/atom/browser/ui/views/win_frame_view.cc index fca7cb23347c..3908a2774ef9 100644 --- a/atom/browser/ui/views/win_frame_view.cc +++ b/atom/browser/ui/views/win_frame_view.cc @@ -23,7 +23,6 @@ WinFrameView::WinFrameView() { WinFrameView::~WinFrameView() { } - gfx::Rect WinFrameView::GetWindowBoundsForClientBounds( const gfx::Rect& client_bounds) const { return views::GetWindowBoundsForClientBounds( diff --git a/atom/browser/ui/win/atom_desktop_window_tree_host_win.cc b/atom/browser/ui/win/atom_desktop_window_tree_host_win.cc index 9cc2ef9e8d22..84a6d9aa3e50 100644 --- a/atom/browser/ui/win/atom_desktop_window_tree_host_win.cc +++ b/atom/browser/ui/win/atom_desktop_window_tree_host_win.cc @@ -25,12 +25,4 @@ bool AtomDesktopWindowTreeHostWin::PreHandleMSG( return delegate_->PreHandleMSG(message, w_param, l_param, result); } -/** Override the client area inset - * Returning true forces a border of 0 for frameless windows - */ -bool AtomDesktopWindowTreeHostWin::GetClientAreaInsets( - gfx::Insets* insets) const { - return !HasFrame(); -} - } // namespace atom diff --git a/atom/browser/ui/win/atom_desktop_window_tree_host_win.h b/atom/browser/ui/win/atom_desktop_window_tree_host_win.h index 2df70547c5ba..47e4cb6aed2a 100644 --- a/atom/browser/ui/win/atom_desktop_window_tree_host_win.h +++ b/atom/browser/ui/win/atom_desktop_window_tree_host_win.h @@ -27,7 +27,6 @@ class AtomDesktopWindowTreeHostWin : public views::DesktopWindowTreeHostWin { protected: bool PreHandleMSG( UINT message, WPARAM w_param, LPARAM l_param, LRESULT* result) override; - bool GetClientAreaInsets(gfx::Insets* insets) const override; private: MessageHandlerDelegate* delegate_; // weak ref diff --git a/electron.gyp b/electron.gyp index 7775907380d7..6a54c389993c 100644 --- a/electron.gyp +++ b/electron.gyp @@ -126,7 +126,12 @@ 'VCManifestTool': { 'EmbedManifest': 'true', 'AdditionalManifestFiles': 'atom/browser/resources/win/atom.manifest', - } + }, + 'VCLinkerTool': { + 'AdditionalOptions': [ + "/SUBSYSTEM:WINDOWS,5.02" + ], + }, }, 'copies': [ { From 1a75bf8fb9c6e2298202c7eed3d1fc9154982d4f Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Tue, 11 Apr 2017 14:35:09 -0700 Subject: [PATCH 2/4] Add comment to subsystem linker option --- electron.gyp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/electron.gyp b/electron.gyp index 6a54c389993c..c3f632c9eb82 100644 --- a/electron.gyp +++ b/electron.gyp @@ -129,6 +129,8 @@ }, 'VCLinkerTool': { 'AdditionalOptions': [ + # Chrome builds with this minimum environment which changes the + # values returned from APIs like GetSystemMetrics(SM_CXSIZEFRAME) "/SUBSYSTEM:WINDOWS,5.02" ], }, From 4ca4eb01d412185921ea5fa09636642410047a6f Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Tue, 11 Apr 2017 14:44:22 -0700 Subject: [PATCH 3/4] Use MinimumRequiredVersion instead of argument --- electron.gyp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/electron.gyp b/electron.gyp index c3f632c9eb82..6070b84d385a 100644 --- a/electron.gyp +++ b/electron.gyp @@ -128,11 +128,9 @@ 'AdditionalManifestFiles': 'atom/browser/resources/win/atom.manifest', }, 'VCLinkerTool': { - 'AdditionalOptions': [ - # Chrome builds with this minimum environment which changes the - # values returned from APIs like GetSystemMetrics(SM_CXSIZEFRAME) - "/SUBSYSTEM:WINDOWS,5.02" - ], + # Chrome builds with this minimum environment which changes the + # values returned from APIs like GetSystemMetrics(SM_CXSIZEFRAME) + 'MinimumRequiredVersion': '5.02' }, }, 'copies': [ From 108f246d89dc928095b8ea6447ce42d6ad73a23a Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Tue, 11 Apr 2017 14:54:34 -0700 Subject: [PATCH 4/4] Add SubSystem setting --- electron.gyp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/electron.gyp b/electron.gyp index 6070b84d385a..8c3718b1cd60 100644 --- a/electron.gyp +++ b/electron.gyp @@ -128,9 +128,14 @@ 'AdditionalManifestFiles': 'atom/browser/resources/win/atom.manifest', }, 'VCLinkerTool': { - # Chrome builds with this minimum environment which changes the - # values returned from APIs like GetSystemMetrics(SM_CXSIZEFRAME) - 'MinimumRequiredVersion': '5.02' + # Chrome builds with this minimum environment which makes e.g. + # GetSystemMetrics(SM_CXSIZEFRAME) return Windows XP/2003 + # compatible metrics. See: https://crbug.com/361720 + # + # The following two settings translate to a linker flag + # of /SUBSYSTEM:WINDOWS,5.02 + 'MinimumRequiredVersion': '5.02', + 'SubSystem': '2', }, }, 'copies': [