Skip to content
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

Higher resolutions causes applications with the chromium and firefox rule flag to have a border gap #207

Open
keepitsane opened this issue Dec 17, 2020 · 2 comments · May be fixed by #293
Labels
bug Something isn't working

Comments

@keepitsane
Copy link
Contributor

Seems like the higher the monitor resolution the bigger the gap between the appbar and the window becomes.

This monitor 1 at 3440 * 1440
image

This monitor 2 at 1920 * 1080
image

This monitor 3 at 2560 * 1440
image

If I take monitor 3 and lower the resolution to 1920 * 1080 the gap goes away complete.
image

When using firefox I only get a gap on the top most edge below the appbar when the resolution is about 1920*1080. For the left, right, and bottom edge I see no gap at all at any resolution.

When testing out the chromium version of Microsoft Edge, with the chromium rule set in my config. I see no gap at all on both monitor 1 (3440 * 1440) and monitor 2 (1920 * 1080), but a slight gap at the top on monitor 3 (2560 * 1440).

Left is Firefox and right is Edge
image

Adjust monitor 3 to 1920 * 1080 fixes it for both
image

Regardless of the browser and resolution I only see a gap at the top, never on the sides or bottom.

Also looking at the first set of screenshots I think why monitor 1 doesn't have a gap at all with Edge is because for some reason the gap on Edge is smaller the Firefox so it is able to fill the smaller gap in comparison to monitor 3.

@ramirezmike
Copy link
Collaborator

I've been checking this out a bit and I think a fix will likely come from src/renderer/win.rs. Here's a couple things I've been looking at regarding this issue.

The first thing I noticed on the machine I develop on when I go into Windows and run nog I'm getting 0 out from the calls to GetSystemMetricsForDpi which according to the docs is an error. I changed some of the code locally a bit to test to attempt GetSystemMetricsForDpi and then fall back on GetSystemMetrics which does give me results.

A little verbose but something like this...

            let border_width = match GetSystemMetricsForDpi(SM_CXFRAME, display.dpi) {
                                  0 => {
                                      use_dpi = false;
                                      GetSystemMetrics(SM_CXFRAME)
                                  },
                                  x @ _ => {
                                      use_dpi = true;
                                      x
                                  }
                               };
            let border_height = if use_dpi { GetSystemMetricsForDpi(SM_CYFRAME, display.dpi) } 
                                else { GetSystemMetrics(SM_CYFRAME) };

And also calling AdjustWindowRectEx instead of AdjustWindowRectExForDpi if the Dpi functions returns 0.

Doing that makes it behave a bit more consistently across my monitors but there's still size issues that I think are caused by the Windows rect functions and Chrome/Firefox using this shadow border thing. The weird offset rendering that @keepitsane posted above and that I've noticed on my machines matches the sizes of these shadow borders.

I tried this to find the shadow offset in order to size the Chrome window better:

                    let mut clientRect = RECT { bottom: 0, left: 0, right: 0, top: 0 };
                    GetClientRect(window.id.into(), &mut clientRect);
                    let mut windowRect = RECT { bottom: 0, left: 0, right: 0, top: 0 };
                    GetWindowRect(window.id.into(), &mut windowRect);
                    top += (windowRect.bottom - windowRect.top) - clientRect.bottom;

And it looks a bit more aligned. The following shows the chrome window surrounded by notepad tiles. Left side is unfocused and right side is focused.

focus_comparison_chrome

But Firefox placed in the same spot behaves very differently:

focus_comparison_firefox

Additionally at some point when resizing tiles if I make a firefox tile too small it just starts ignoring the sizing like this (notice the left/right side alignments of the tile above the firefox window and the tile below it but firefox just overlaps everything)

firefox_ignoring

I'll keep messing with it but honestly if there's a way to just remove the shadow border on them that might be easier. I might experiment with manually setting styles.

@TimUntersberger
Copy link
Owner

The borders of chrome/firefox are really a fucking mystery. I have no idea who the fuck thought this would be a good idea.

I'll keep messing with it but honestly if there's a way to just remove the shadow border on them that might be easier. I might experiment with manually setting styles.

Initially I tried to automatically calculate the border size to then size the window correctly, but I couldn't manage to do it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants