[Hacktoberfest] Improving Hi-DPI support on Windows as a Community
lists at mangomultimedia.com
Thu Oct 11 17:40:49 CEST 2018
Recently I've been investigating Hi-DPI related issues in the LC Windows
implementation. I thought about pestering the LC team (or paying them) to
prioritize these fixes, but then I realized it was October and I came up
with a different idea. In the spirit of Hacktoberfest I thought it would be
nice to try and organize a community effort around some improvements that
could be made to Hi-DPI support on Windows.
For those who aren't familiar with Hacktoberfest you can read more about it
at the url below. [Side note: submitting PRs for LC documentation updates
is a great way to earn a T-shirt.
LiveCode added support for Hi-DPI monitors almost 5 years ago. This is when
they added properties such as usePixelScaling, screenPixelScale,
screenPixelScales, etc. At the time, Windows had support for System DPI
Awareness. After LC added support Windows changed the APIs to support
different resolutions on each monitor. This is referred to as PerMonitor
API Awareness. This was in Windows 8.1. The APIs were further improved in
Windows 10. LiveCode needs to be updated to support these newer APIs.
I'm aware of the following limitations and bugs around Hi-DPI support on
1. The `screenPixelScales` reports the pixelScale of the primary monitor
for all attached monitors. For example, if you have a Windows 10 computer
with two monitors attached and the primary monitor is set to displays at
100% (1.0 pixelScale) and a second monitor at 200% (2.0 pixelScale) then
the `screenPixelScales` returns `1.0\n1.0` when it should return `1.0\n2.0`.
2. minWidth/minHeight/maxWidth/maxHeight are not handled properly on
monitors with a pixelScale > 1.0.
Fixing these issues in the LC Community
I think we can muster the LC Community troops and figure out how to fix
these issues. I spent some time the other day doing some research in an
attempt to figure out what needs to be done. I’ve been looking through the
source code and reviewing the Windows API docs on the web in order to
better understand the API changes required for switching from System DPI
Awareness to PerMonitor API Awareness in LiveCode.
I’ve looked at the [[ HiDPI ]] commits on GitHub and these two seem the
most pertinent. They contain the changes to the source code when the pixel
scale properties were added and the changes made specifically for Windows
This docs page on Microsoft's site is a nice introduction DPI Awareness:
Here are some notes I made in my research:
- I think that responding to the WM_DPICHANGED message to update windows
when DPI for a monitor changes should be pretty straightforward. I think
the MCDispatch::reopen_stack_windows() function in dispatch.cpp would
handle that as it is what is called when setting the pixelscale.
- I’m not sure about the switch from GetDpiForMonitor() to
GetDpiForWindow(). I would hope that if the LiveCode
w32-manifest-template-dpiaware.xml manifest were updated to include the
<dpiAwareness>PerMonitor</dpiAwareness> node that GetDpiForMonitor() would
return the proper pixel_scale in w32dce.cpp > DescribeMonitorsCallback. If
so then screenPixelScales may just start working.
What is needed?
In order to pull this off we would need some developers who are set up to
compile LC 9 on Windows and who are familiar with working with the Windows
APIs (C++). We also need people willing to test and review proposed code
changes and make sure we aren't missing anything.
I can provide a private Slack channel with audio/video/screen sharing
capabilities for a small group. I have some unused guests on my company
account that I can access for the duration of this project. I am not set up
to compile LC on Windows at this time.
Please respond to this thread if you are interested and have one or more of
the skills necessary to try and pull this off. I'm sure we could poke the
LC engineers for tips if we get stuck anywhere along the way.
More information about the use-livecode