Skip to content

Conversation

@ash-impl
Copy link

closes #661

@github-project-automation github-project-automation bot moved this to 📬 Needs triage in glazewm Jun 24, 2025
@ash-impl ash-impl force-pushed the fix/display_scaling_issues branch from ab50e92 to 7db5edb Compare June 24, 2025 23:27
@ash-impl ash-impl marked this pull request as draft June 24, 2025 23:57
@ash-impl
Copy link
Author

Screenshots for the fixes below. Note that these screenshots go across monitors with scaling 125% for left monitor and 100% for my right monitor which is the boundary crossed in these screenshots. For reference-The power icon is the rightmost icon on my YASB status bar on both monitors.

Problem 1 as stated in #661
Before Fix
Screenshot 2025-06-25 072938
After Fix
Screenshot 2025-06-25 073245WithFix

Problem 2 as stated in #661
Before Fix
Screenshot 2025-06-25 072746
After Fix
Screenshot 2025-06-25 073141WithFix

@ash-impl ash-impl marked this pull request as ready for review June 25, 2025 11:43
@lars-berger
Copy link
Member

thank you for the fix 💜

do the windows in question have a very large shadow borders which then crosses over to the other monitor? i'm still not fully wrapping my head around how the problem occurs in the first place. do these wonky scaled windows take up more % than they should when you have many windows open (even after the PR fix)?

@ash-impl
Copy link
Author

Hi @lars-berger, thank you for your response. I think the issue was more that we were passing 'None' to methods like 'apply_delta' that accepted optional scale factors for different monitors which resulted in incorrect calculations affecting window size accuracy.

@lars-berger
Copy link
Member

lars-berger commented Dec 19, 2025

@ash-impl did some testing on a fresh W11 machine and from what i can tell, we shouldn't be scaling the border gaps. we get the border size by diffing GetWindowRect (includes shadow borders) and DwmGetWindowAttribute(..., DWMWA_EXTENDED_FRAME_BOUNDS, ...) (doesn't include shadow borders), and apparently both give already scaled rects.

image image

1) with PR changes (borders are a bit wonky), 2) without changes

unfortunately i'm also unable to reproduce the underlying issue (maybe it's only on W10?). monitor 1 is 150% and monitor 2 is 100%, and then i'm moving an admin window (Event Viewer) between the two monitors like in #661.

image

my guess is that the root cause is border_delta or shadow_border_delta is returning some crazy large value. could you try logging them? do they return a different value when doing a cross-monitor move vs. a move within the same monitor?

// window_getters.rs

  fn total_border_delta(
    &self,
    scale_factor: Option<f32>,
  ) -> anyhow::Result<RectDelta> {
    let border_delta = self.border_delta();
    let shadow_border_delta = self.native().shadow_border_delta()?;
    tracing::info!("{:?}", border_delta);
    tracing::info!("{:?}", shadow_border_delta);
    // ...
  }

could you also see if it makes a difference to refresh border delta prior to redrawing?

// platform_sync.rs

    window.native().refresh_border_position()?; // add this
    
    let rect = window
      .to_rect()?
      .apply_delta(&window.total_border_delta()?, None); // leave the rect calculation as-is

@ash-impl
Copy link
Author

Hi @lars-berger thank you for your response.
You're right about not wanting to scale border gaps.

I have since switched to using a single monitor only thanks to your great work on this application and then workplace upgraded to W11 (where I'm not sure this issue persists because of single monitor use).
I saw the issue only with Windows applications like Event Viewer, task manager etc. Other applications were working just fine. I have also since then gained a better understanding of this code-base for personal learning. And I can't seem to pin point why those applications in particular were the ones giving grief. My initial changes seemed to have worked for me in solving those issues with these code changes back when I was working on this.

I can test with your recommendations of logging, and work on this more in a couple weeks if it's still an issue (On W10 or W11).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: 📬 Needs triage

Development

Successfully merging this pull request may close these issues.

[Bug] Display scaling causes wrong window size

2 participants