Skip to content

Bug: Fix/improve DPI handling #99

Closed

Description

@gorbunovav

Describe the bug
Despite HASS.Agent app reporting that it is Per-monitor DPI Aware the DPI processing is not correct.
It seems that only the main window looks ok, all other windows have elements sizing issues.

Current workaround is to override DPI settings for the HASS.Agent executable with the "System (Enhanced)" value (which disables DPI handling by the application).

Possible solutions: improve interface scaling or make the app report itself as non-DPI Aware to let the OS handle scaling.

To Reproduce

  1. Set display scale to something greater than 100%
  2. Restart HASS.Agent app
  3. Open tray menu, configuration window, quick actions window
  4. See issues with elements sizing

Expected behavior
Interfaces scales correctly

Screenshots

Misc info (please complete the following information):

  • Windows build (ideally screenshot/info of winver.exe output): Windows 11 Pro 22H2 22621.160
  • Windows' UI language: English
  • HASS.Agent version: 2022.13.0-beta1

Please check what's applicable (multiple answers possible):

  • Installed via installer
  • Installed manually
  • Problem occurs in HASS.Agent
  • Problem occurs in Satellite Service

Activity

  1. LAB02-Admin commented on Jun 28, 2022

    @LAB02-Admin
    Member

    Blegh, so ugly. I'm aware and I'm very sorry. I've already been messing with it for hours, but the current combination of winforms/syncfusion just isn't working out.

    So I'll probably have to rebuild the entire app from the ground up, you can imagine I'm not really looking forward to that :p

  2. LAB02-Admin commented on Jun 28, 2022

    @LAB02-Admin
    Member

    I've created a ticket: [hassagent-112]

    I'm closing this ticket, not because I'm not doing it, but to keep the GitHub list tidy and all my todo's in one place. I'll report back here when I've fixed this!

  3. self-assigned this
    on Jun 28, 2022
  4. gorbunovav commented on Jun 28, 2022

    @gorbunovav
    Author

    @LAB02-Admin what about disabling the DpiAwareness flag for the app for now?
    https://docs.microsoft.com/en-us/dotnet/framework/configure-apps/file-schema/winforms/

    https://docs.microsoft.com/en-us/dotnet/framework/configure-apps/file-schema/winforms/windows-forms-add-configuration-element (check the DpiAwareness key).

    Windows is able to handle the app resizing ok, as far as I can see:
    Screenshot 2022-06-28 132334

  5. LAB02-Admin commented on Jun 28, 2022

    @LAB02-Admin
    Member

    Yea that was my initial workaround, but then the new webview doesn't render correctly [#62] :(

  6. gorbunovav commented on Jun 28, 2022

    @gorbunovav
    Author

    Current workaround is to override DPI settings for the HASS.Agent executable with the "System (Enhanced)" value (which disables DPI handling by the application).

    @LAB02-Admin with this workaround the webview sizing is correct for me 🤔So not sure what was causing issues in #62

  7. LAB02-Admin commented on Jun 28, 2022

    @LAB02-Admin
    Member

    Oh, interesting! I'll look into it and do some more tests, thanks :)

  8. ezpl commented on Jul 20, 2022

    @ezpl

    @LAB02-Admin what about disabling the DpiAwareness flag for the app for now? https://docs.microsoft.com/en-us/dotnet/framework/configure-apps/file-schema/winforms/

    https://docs.microsoft.com/en-us/dotnet/framework/configure-apps/file-schema/winforms/windows-forms-add-configuration-element (check the DpiAwareness key).

    I wanted to test this by adding an app-config file in the HASS.Agent directory. Unfortunately it does not seem to work. Might need to be defined in the application itself to be read?

    HASS.Agent.exe.config

    <?xml version="1.0" encoding="utf-8"?>
    <configuration>
      <System.Windows.Forms.ApplicationConfigurationSection>
        <add key="DpiAwareness" value="false" />
      </System.Windows.Forms.ApplicationConfigurationSection>
    </configuration>

    Update:
    I guess .net 6 applications do not read the .config file. Also tried this aproach in
    HASS.Agent.runtimeconfig.json

     "configProperties": {
          "System.Reflection.Metadata.MetadataUpdater.IsSupported": false,
          "Switch.System.Windows.DoNotScaleForDpiChanges": true
        }
  9. LAB02-Admin commented on Aug 12, 2022

    @LAB02-Admin
    Member

    Implemented in the latest beta, let me know how it works out: https://github.com/LAB02-Research/HASS.Agent/releases/tag/2022.13.0-beta2

  10. gorbunovav commented on Aug 12, 2022

    @gorbunovav
    Author

    @LAB02-Admin Hi! Yes, it works for me. Thank you!

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

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions