Skip to content

Commit

Permalink
fix: Windows 7 frame showing for frameless non-resizable windows
Browse files Browse the repository at this point in the history
  • Loading branch information
rzhao271 committed Aug 17, 2022
1 parent 532025c commit 9fff3a3
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 45 deletions.
2 changes: 1 addition & 1 deletion patches/chromium/.patches
Expand Up @@ -116,4 +116,4 @@ chore_add_electron_deps_to_gitignores.patch
chore_allow_chromium_to_handle_synthetic_mouse_events_for_touch.patch
add_maximized_parameter_to_linuxui_getwindowframeprovider.patch
add_electron_deps_to_license_credits_file.patch
feat_add_set_can_resize_mutator.patch
fix_remove_caption-removing_style_call.patch
27 changes: 0 additions & 27 deletions patches/chromium/feat_add_set_can_resize_mutator.patch

This file was deleted.

35 changes: 35 additions & 0 deletions patches/chromium/fix_remove_caption-removing_style_call.patch
@@ -0,0 +1,35 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Raymond Zhao <7199958+rzhao271@users.noreply.github.com>
Date: Wed, 17 Aug 2022 13:49:40 -0700
Subject: fix: Remove caption-removing style call

There is a SetWindowLong call that removes WS_CAPTION for frameless
windows, but Electron uses WS_CAPTION even for frameless windows.

Removing this call only affects frameless windows, and it fixes
a visual glitch where they showed a Windows 7 style frame
during startup.

The if statement was originally introduced by
https://codereview.chromium.org/9372053/, and it was there to fix
a visual glitch with the close button showing up during startup
or resizing, but Electron does not seem to run into that issue
for frameless windows even with that block commented out.

diff --git a/ui/views/win/hwnd_message_handler.cc b/ui/views/win/hwnd_message_handler.cc
index c6810f162806b36494885b2f63982a756d4dcd38..92d030a3d24a7bb282f698a5591cf33ae14e06ed 100644
--- a/ui/views/win/hwnd_message_handler.cc
+++ b/ui/views/win/hwnd_message_handler.cc
@@ -1723,12 +1723,6 @@ LRESULT HWNDMessageHandler::OnCreate(CREATESTRUCT* create_struct) {
SendMessage(hwnd(), WM_CHANGEUISTATE, MAKELPARAM(UIS_CLEAR, UISF_HIDEFOCUS),
0);

- if (!delegate_->HasFrame()) {
- SetWindowLong(hwnd(), GWL_STYLE,
- GetWindowLong(hwnd(), GWL_STYLE) & ~WS_CAPTION);
- SendFrameChanged();
- }
-
// Get access to a modifiable copy of the system menu.
GetSystemMenu(hwnd(), false);

17 changes: 0 additions & 17 deletions shell/browser/native_window_views.cc
Expand Up @@ -281,24 +281,7 @@ NativeWindowViews::NativeWindowViews(const gin_helper::Dictionary& options,
new ElectronDesktopWindowTreeHostLinux(this, native_widget);
#endif

// Ref https://github.com/electron/electron/issues/30760
// Set the can_resize param before initializing the widget.
// When resizable_ is true, this causes the WS_THICKFRAME style
// to be passed into CreateWindowEx and SetWindowLong calls in
// WindowImpl::Init and HwndMessageHandler::SizeConstraintsChanged
// respectively. As a result, the Windows 7 frame doesn't show,
// but it isn't clear why this is the case.
// When resizable_ is false, WS_THICKFRAME is not passed into the
// SetWindowLong call, so the Windows 7 frame still shows.
// One workaround would be to call set_can_resize(true) here,
// and then move the SetCanResize(resizable_) call after the
// SetWindowLong call around line 365, but that's a much larger change.
set_can_resize(true);
widget()->Init(std::move(params));

// When the workaround above is not needed anymore, only this
// call should be necessary.
// With the workaround in place, this call doesn't do anything.
SetCanResize(resizable_);

bool fullscreen = false;
Expand Down

0 comments on commit 9fff3a3

Please sign in to comment.