dbsoft / dwindows

Dynamic Windows Library Mirror
Other
8 stars 1 forks source link

dwindows application doesn't follow system screen scaling #2

Closed peprnp closed 2 years ago

peprnp commented 2 years ago

My screen is natively 96dpi but I set it to scale to 125% in control panel. Other toolkits happily follow this setting but dwindows is not. It still renders as 96dpi. Please fix this. Thanks.

dbsoft commented 2 years ago

This is on Windows I assume? I'll take a look at it for 3.3...

With the exception of pixmap/bitmaps on Mac it handles scaling for Retina displays.

peprnp commented 2 years ago

This is on Windows I assume? I'll take a look at it for 3.3...

With the exception of pixmap/bitmaps on Mac it handles scaling for Retina displays.

Yes, Windows.

dbsoft commented 2 years ago

Ok, after doing some research... there are a bunch of different ways to make it DPI aware... however most of them require handling DPI changes.... so initially I will just enable DPI awareness for the non-client area.... and detect the DPI during dw_init() and use what was detected for the client area from that point on. This should allow basic DPI-awareness on Windows versions from Vista and later.

To allow handling of DPI changes, it gets a bit more complicated since the interface has already been created and we may have queried and saved sizes that would now be invalidated. So in the future we I may need to create a SIGNAL/CALLBACK that will notify us of DPI changes that will allow us to change the layout at that time.

dbsoft commented 2 years ago

@peprnp So testing on Windows 10.... the 125% Scale option does work for me without enabling any DPI awareness. The system basically does its own scaling when it isn't enabled... what kind of behavior do you expect?

dwtest100 dwtest125

peprnp commented 2 years ago

To allow handling of DPI changes, it gets a bit more complicated since the interface has already been created and we may have queried and saved sizes that would now be invalidated. So in the future we I may need to create a SIGNAL/CALLBACK that will notify us of DPI changes that will allow us to change the layout at that time.

This is too far from my original problem. My problem is I already set to scale to 125% before I run dwindows but dwindows doesn't follow my setting.

peprnp commented 2 years ago

@peprnp So testing on Windows 10.... the 125% Scale option does work for me without enabling any DPI awareness. The system basically does its own scaling when it isn't enabled... what kind of behavior do you expect?

I'm on Windows 8.1 and also running Windows 7 in VirtualBox. On both of my Windows dwindows (dwtest to be clear) doesn't follow the scaling setting of the system. I don't know much about this scaling stuff either. I expect it to be consistent with other applications. I confirm GTK and Qt applications look consistent with other native Win32 applications.

dbsoft commented 2 years ago

Ok, I'll test on those versions and see what I can do.

Update: So on Windows 8.1, it does scale things up.... but it doesn't change the window size:

VirtualBox_Windows 8 1_16_08_2022_22_51_07 VirtualBox_Windows 8 1_16_08_2022_22_55_14

Not sure how to handle this without completely messing with the window coordinates.

dbsoft commented 2 years ago

Thinking about what I can do to handle all situations, I can implement a scaling feature that will change the behavior on Windows 7 through 8.1... where it detects the scaling and applies it to the sizes during dw_window_g/set_size() functions on top-level windows. When enabled it will result in scaling up the size when setting it and scaling it down when retrieving it. When disabled the APIs will return the actual sizes with no scaling.

Windows 7 is out of support and 8.1 will be at the end of this year, so not sure what the default setting should be.... but the impact of this change will be diminishing as time goes on either way.

peprnp commented 2 years ago

Thinking about what I can do to handle all situations, I can implement a scaling feature that will change the behavior on Windows 7 through 8.1... where it detects the scaling and applies it to the sizes during dw_window_g/set_size() functions on top-level windows. When enabled it will result in scaling up the size when setting it and scaling it down when retrieving it. When disabled the APIs will return the actual sizes with no scaling.

Windows 7 is out of support and 8.1 will be at the end of this year, so not sure what the default setting should be.... but the impact of this change will be diminishing as time goes on either way.

I have another idea. Just update the dwindows document to notice the users of this issue but do nothing. I will upgrade to Windows 10 (or switch to Linux) anyway.

dbsoft commented 2 years ago

Ok well, if this isn't a big issue for you I'll close this issue for now, but it is on my list for something to think about.... changes regarding this might end up in 3.3 if I have time before its release. Thanks for the input!