electron: Strange overflowing window when maximizing a frameless window

  • Electron version: 0.37.4
  • Operating system: Windows

When I maximize my frameless electron window a small part of the window in an unmaximized state is visible on a secondary monitor.

Screenshot electronbug

You can visibly see the “line between the monitors” and you can see some really strange overhanging content that is over that line.

Steps to reproduce

  1. Open an electron app
  2. Maximize the app on your secondary display
  3. Look closely for the overflow onto your primary display

This might take a few times to trigger, it appears to do it about 70% of the time 😕

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 69 (6 by maintainers)

Commits related to this issue

Most upvoted comments

Coming on on the 4 year anniversary of this bug being reported.

Still seeing this issue on three electron apps I use. Visual Studio Code, Discord and Slack.

Still an issue with discord

Still an issue for me as well on Windows using VSCode, and Discord; however not an issue with Spotify. Manifests for me just as going past the screen edges, without bleeding onto another monitor. This is enough to miss the locations of things like errors/warnings shown on the outside of the scrollbar in VSCode.

Should note that this only happens on my non-primary 1080p monitors (100% scaling, one horizontal, one vertical), and this doesn’t happen on my primary 2160p screen at 250% scaling.

Discord shows these versions in the sidebar on the preferences screen:

Stable 63252 (7138483)
Host 0.0.306
Windows 10 64-Bit (10.0.19041)

VSCode:

Version: 1.47.0-insider (system setup)
Commit: 04203498480e48be84d86f5763e126c7c5bf22e0
Date: 2020-06-30T09:00:22.588Z
Electron: 7.3.2
Chrome: 78.0.3904.130
Node.js: 12.8.1
V8: 7.8.279.23-electron.0
OS: Windows_NT x64 10.0.19041

Spotify only gives a version 1.1.37.690.g8f3b16fc in the About screen.

So is this issue getting fixed or what?

Still an issue with Discord. Microsoft Teams has this exact problem aswell. electron_overflow

Still seeing this issue on three electron apps I use. Visual Studio Code, Discord and Slack.

@IlanVivanco Yep, Discord has it’s header cut a bit, GitHub Desktop and others have an overflow issue.

@radencode @adi518

Perhaps we are talking about different issues. The issue adi linked (#8728) is different from this issue.

The other issue is related to the edges of frameless windows being cut off by 8 pixels. This issue is related to frameless windows overflowing onto different monitors.

You can see that my fix for this issue works, here: https://www.youtube.com/watch?v=9NG2e5UIJoA

The other issue could probably be fixed in the same part of the code I’m working on - I’ll look into that and submit a PR with both fixes if I can.

Yes it does fix the issue but it gets rid of native animations and the window will no longer be maximized on double click of nav bar.

issue will also occur on a single screen with the windows task bar on the right or left edge of the screen.

The root cause for this issue happening on multiple monitors having this issue can be read about here: https://blogs.msdn.microsoft.com/oldnewthing/20120326-00/?p=8003

When the window is maximized and the window thinks it has a frame, Windows will actually position the window offscreen (so that the “frame” doesn’t show). There are then two approaches for solving in electron:

  1. Update native_window_views_win.cc and handle the WM_GETMINMAXINFO event in PreHandleMSG(). You’ll be able to get the coords from the l_param and can update them to be the expected values (x/y of 0,0 instead of -7,-7) and set *result to 0 / return true.
  2. In the constructor for native_window_views.cc, unfortunately WS_THICKFRAME (among other styles such as WS_CAPTION and extended styles) are passed in (which trigger incorrect frame calculations). These styles can be removed completely and resizing still does work properly (at least in my testing). This would be my suggested approach.

I should note that using Better Discord is against Discord ToS for Modify of the client.

You agree not to (and not to attempt to) (i) use the Service for any use or purpose other than as expressly permitted by these Terms;(ii) copy, adapt, modify, prepare derivative works based upon, distribute, license, sell, transfer, publicly display, publicly perform, transmit, stream, broadcast, attempt to discover any source code, reverse engineer, decompile, disassemble, or otherwise exploit the Service or any portion of the Service, except as expressly permitted in these Terms; or (iii) use data mining, robots, spiders, or similar data gathering and extraction tools on the Service.

Latest information for Canary: Canary 72828 (05bcb5a) Host 0.0.291 is running on Discord’s Custom Electron/9.3.5 Code & Release of which seen here https://github.com/discord/electron.

The issue has been reported on Discord’s Bug Hunting Server (Discord Testers) a few times and this has been the default reason of rejecting the report implying this isn’t a Discord issue and a known issue on Electron side. This might explain the reason for people coming here regarding the issue still existing for Discord.

Please note I am simply one of the members of Discord Bug Hunting Community and not speaking on behalf of them

Yes, Electron normally doesn’t set the process variable for security reasons, but you can modify Discord to cause it to set it, as described in /issues/18139 and SimulatedGREG/electron-vue/issues/871. BetterDiscord will also make that modification for you, as it is necessary for it to work, which is what I did to check.

Discord

Canary 70913 (a6804b8)
Host 0.0.285
Windows 10 64-Bit (10.0.18363)

The issue doesn’t appear anymore. The maximized window correctly fits the screen.

Discord

Canary 70821 (b649fde)
Host 0.0.285
Windows 10 64-Bit (10.0.18363)

The issue appears, but they fixed (made a workaround) an oversized server/channel indications on the left when window is maximized! Meaning, now if window is maximized the indicators are not hidden (off-screen) like they were before.

Same with the Discord.

It’s impossible to view left indicators of channels when window is maximized!

I am using electron-prebuild 1.4.13, when maximize the window, the first time it works fine, but the second time, the window has a margin to the screen top.

I am using windows 10.

BTW, What’s app desktop has the same issue.

@radencode @adi518 Please try out this build. It should fix both issues.

There’s still some overflow at the bottom, but that was there before - and with this fix it’s not actually part of the page, so nothing is cut off. I’m still investigating into that.

@adi518, please try the following file. It is a copy of electron-quick-start with both versions of electron.

Opening Start Normal Electron.bat should have the overflow issue. Opening Start Overflow Test.bat should not have the issue.

electron-quick-start.zip (big file - two versions of electron)