Skip to content

Resize handle size does not adapt to dpi #51385

Closed

Description

@t57ser

Preflight Checklist

Electron Version

42.0.0-beta.6

What operating system(s) are you using?

Windows

Operating System Version

Windows 10

What arch are you using?

x64

Last Known Working Electron version

No response

Does the issue also appear in Chromium / Google Chrome?

I don't know how to test

Expected Behavior

When a window changes its scaling, the resize handle size should grow/shrink with the scaling.
Window opened with 100% scaling has a resize handle of 8px, when changing the scaling to 150% the resize handle should be 12px

Actual Behavior

Electron only gets the resize handle size initially and does not change it anymore. when changing scale the resize handle size does not update

Testcase Gist URL

No response

Additional Information

Probably related: #50706
const int thickness = ::GetSystemMetrics(SM_CXSIZEFRAME) + ::GetSystemMetrics(SM_CXPADDEDBORDER);
Should maybe GetSystemMetricsForDpi be used? with the current dpi of the window to support multi display setups

Activity

  1. added theissue type on Apr 29, 2026
  2. moved this to 👀 Unsorted Items in 42-x-yon Apr 29, 2026
  3. nikwen commented on Apr 29, 2026

    @nikwen
    Member

    Good point! Thanks for opening the issue.

    Just to confirm, is this a regression or has this never worked?

    CC @mitchchn.

  4. t57ser commented on Apr 29, 2026

    @t57ser
    ContributorAuthor

    @nikwen Since the resize handle used to be inside the client area I can't easily tell.
    I am using a tool called "window inspector" to compare the window rect with the client rect

    Image The difference is the resize handle itself
  5. moved this from 👀 Unsorted Items to 👍 Does Not Block Stable in 42-x-yon Apr 29, 2026
  6. ckerr commented on Apr 30, 2026

    @ckerr
    Member

    Probably related: #50706

    CC @mitchchn

  7. mitchchn commented on Apr 30, 2026

    @mitchchn
    Member

    Does the issue also appear in Chromium / Google Chrome?

    I don't know how to test

    Could you test Chrome the same way you did for Electron? It would be good to know if this is handled upstream.

  8. nikwen commented on Apr 30, 2026

    @nikwen
    Member

    @mitchchn Not sure if that matters here to be honest.

    I believe @t57ser pointed out the exact line that needs to be fixed:

    const int thickness = ::GetSystemMetrics(SM_CXSIZEFRAME) +
    ::GetSystemMetrics(SM_CXPADDEDBORDER);

    You already introduced the right version in #50706

    const int thickness =
    display::win::GetScreenWin()->GetSystemMetricsInDIP(SM_CXSIZEFRAME) +
    display::win::GetScreenWin()->GetSystemMetricsInDIP(SM_CXPADDEDBORDER);

    Unless I'm missing something. In that case, please correct me. 🙂

  9. mitchchn commented on May 4, 2026

    @mitchchn
    Member

    @nikwen I believe it's actually the other way around, we should be using screen pixels everywhere since DIP will always return the same logical insets. But it's more than just a one-line change (hopefully not too much more). Investigating...

  10. t57ser commented on May 4, 2026

    @t57ser
    ContributorAuthor

    I'm not sure what GetSystemMetricsInDIP is, what I was refering to was this: https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getsystemmetricsfordpi
    It accepts a dpi value as a second parameter which could be taken from: https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getdpiforwindow

    If GetSystemMetricsInDIP always returns the same value (logical), which for 100% scaling would be a sum of 8px, then the change could be as mentioned above and just multiply the result by the window DPI

    thickness = (frame + border) * dpi

    Maybe something like display::win::GetScreenWin()->GetDpi() exists?
    EDIT: should rather be on the window, like window_->has_frame() something like window_->getDpi()

  11. mitchchn commented on May 5, 2026

    @mitchchn
    Member

    Turns out there was a specific method in Chrome to get the handle size for the current monitor's DPI (which is used in Chrome for this purpose):

      const int thickness = ui::GetResizableFrameThicknessFromMonitorInDIP(
          monitor, /*has_caption=*/false);
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions