8000 Fix frameless window overflow on Windows by kevinsawicki · Pull Request #9167 · electron/electron · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Fix frameless window overflow on Windows #9167

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Apr 13, 2017
Merged

Fix frameless window overflow on Windows #9167

merged 4 commits into from
Apr 13, 2017

Conversation

kevinsawicki
Copy link
Contributor
@kevinsawicki kevinsawicki commented Apr 11, 2017

This pull request is an attempt to fix #5267 and #8728.

It removes the custom inset handling in Electron and instead uses Chrome's default inset handling in hwnd_message_handler.cc.

This previously did not work because Electron was using different a different linker flag than Chrome that resulted in the system metrics returning incorrect values.

I'm not sure if lowering the SUBSYSTEM flag to 5.02 has any other consequences, but it does seem to prevent the overflow of maximized frameless windows.

Fixes #5267
Fixes #8728
Refs #9140
Refs #8808

/cc @poiru @bsclifton @TheSBros @juturu

@kevinsawicki
Copy link
Contributor Author

I looked into this initially because I was seeing that Chrome app maximized frameless windows did not exhibit the overflow behavior and traced it down to GetSystemMetrics(SM_CXSIZEFRAME) returning 5 in Electron and 13 in Chrome which led me to the SUBSYSTEM linker flag being different between the two apps.

Copy link
Contributor
@poiru poiru left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great find, thank you! 👏

@odensc
Copy link
odensc commented Apr 11, 2017

Still getting some overflow, 150% DPI on Windows 10:

Unmaximized (height: 5px on top):

Maximized (only 1 pixel is shown):

@kevinsawicki
Copy link
Contributor Author

Still getting some overflow, 150% DPI on Windows 10:

@TheSBros Just to confirm, did you run npm run bootstrap -- --dev -v before building this branch? A re-bootstrap is needed since this pull request changes the linker flags.

@odensc
Copy link
odensc commented Apr 11, 2017

@kevinsawicki I ran python script/bootstrap.py -v - but I just ran that command and the same thing happens.

@kevinsawicki
Copy link
Contributor Author

I ran python script/bootstrap.py -v - but I just ran that command and the same thing happens.

Hmm, having trouble reproducing this on a Windows 10 VM, can you check all the edges with the following:

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <style>
      body, html {
        padding: 0;
        margin: 0;
      }

      #outer {
        border: 5px solid red;
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
      }

      #inner {
        border: 5px solid blue;
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        padding: 20px;
      }
    </style>
  </head>
  <body>
    <div id="outer">
      <div id="inner">
        <button onclick="require('electron').remote.getCurrentWindow().maximize()">Maximize</button>
        <button onclick="require('electron').remote.getCurrentWindow().unmaximize()">Unmaximize</button>
        <button onclick="window.close()">Close</button>
      </div>
    </div>
  </body>
</html>

@poiru
Copy link
Contributor
poiru commented Apr 11, 2017

Note that this doesn't fully fix the overflow (but that is seemingly impossible). On Win10, a maximized window will overflow on the top/left/bottom/right as follows:

  • 100%: 1px T/L/B/R
  • 125%: 1px T/L, 2px B/R
  • 150%: 2px T/L, 2px B/R
  • 175%: 2px T/L, 3px B/R
  • 200%: 0.5px T/L/B/R

So @TheSBros, I would expect you too see 2px missing from the top, but 4px seems high.

@kevinsawicki
Copy link
Contributor Author

150%: 2px T/L, 2px B/R

Interesting, I'm only seeing it overflow 1px on each side at this scale.

@odensc
Copy link
odensc commented Apr 11, 2017

@kevinsawicki Not sure what's up - just deleted Electron and cloned a fresh repo, now it works.

I'm also getting a 2px overflow on all sides, as @poiru said. Definitely better than before.

@kevinsawicki
Copy link
Contributor Author
kevinsawicki commented Apr 11, 2017

I'm also getting a 2px overflow on all sides, as @poiru said. Definitely better than before.

So with the following tweaked page, you don't see a red border at all when maximized?

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <style>
      body, html {
        padding: 0;
        margin: 0;
      }

      #outer {
        border: 2px solid red;
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
      }

      #inner {
        border: 5px solid blue;
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        padding: 20px;
      }
    </style>
  </head>
  <body>
    <div id="outer">
      <div id="inner">
        <button onclick="require('electron').remote.getCurrentWindow().maximize()">Maximize</button>
        <button onclick="require('electron').remote.getCurrentWindow().unmaximize()">Unmaximize</button>
        <button onclick="window.close()">Close</button>
      </div>
    </div>
  </body>
</html>

@poiru
Copy link
Contributor
poiru commented Apr 11, 2017

@kevinsawicki This is what I see:
corners

Perhaps it's not exactly 2px, but definitely in that ballpark. Also note the differently sized red parts.

@kevinsawicki
Copy link
Contributor Author

Perhaps it's not exactly 2px, but definitely in that ballpark. Also note the differently sized red parts.

Yeah, I'm seeing the different sized parts as well at certain DPIs, so frustrating.

@odensc
Copy link
odensc commented Apr 11, 2017

@kevinsawicki I'm talking in terms of 2px display pixel overflow. (e.g. when opening the image in GIMP and looking how many pixels there are)

With 150% DPI, 1 CSS pixel == 1.5 display pixels. I'm still seeing a 2px overflow with that HTML - but there's still a pixel of red left on each side because it's actually 3 pixels.

@kevinsawicki
Copy link
Contributor Author

I'm talking in terms of 2px display pixel overflow.

Ah okay, 👍 💻

@kevinsawicki kevinsawicki force-pushed the frameless-overflow3 branch 2 times, most recently from 7984316 to 9211119 Compare April 12, 2017 21:06
Copy link
Contributor
@juturu juturu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change looks much better. Haven't seen any issues with this change yet.

Copy link
@odensc odensc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉

@poiru poiru force-pushed the frameless-overflow3 branch from 9211119 to 108f246 Compare April 13, 2017 10:07
@poiru poiru merged commit 0c1d603 into master Apr 13, 2017
@poiru poiru deleted the frameless-overflow3 branch April 13, 2017 10:08
@poiru
Copy link
Contributor
poiru commented Apr 13, 2017

@kevinsawicki I rebased this on top of #9166 and also went ahead and merged it. Hopefully that was OK as this has been approved by everyone and I need this for another PR.

@serious-angel
Copy link
serious-angel commented Oct 5, 2020

Sorry, but the issue still persists. Please, take a look into #5267- it's still active.

@reitowo
Copy link
Contributor
reitowo commented Nov 29, 2024

This PR actually cause a new bug when maximized frameless window use background material and it will make the 8px border with a acrylic effect.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Frameless maximize overflow Strange overflowing window when maximizing a frameless window
6 participants
0