[Hacktoberfest] Improving Hi-DPI support on Windows as a Community

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

[Hacktoberfest] Improving Hi-DPI support on Windows as a Community

Geoff Canyon via use-livecode
Hi all,

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.

https://hacktoberfest.digitalocean.com

-------------------------—
Background
—-—-—-—-—-—-—-

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
Windows:

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`.

https://quality.livecode.com/show_bug.cgi?id=19542

2. minWidth/minHeight/maxWidth/maxHeight are not handled properly on
monitors with a pixelScale > 1.0.

https://quality.livecode.com/show_bug.cgi?id=14314

--------------------—-—-
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
implementation.

https://github.com/livecode/livecode/commit/1373bfdb7dc267d86e1a66953dce78d2046824d4
https://github.com/livecode/livecode/commit/27f65afb96de93873a435525fb684ff704abc575

This docs page on Microsoft's site is a nice introduction DPI Awareness:

https://docs.microsoft.com/en-us/windows/desktop/hidpi/high-dpi-desktop-application-development-on-windows#per-monitor-and-per-monitor-v2-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.

--
Trevor DeVore
ScreenSteps
www.screensteps.com
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: [Hacktoberfest] Improving Hi-DPI support on Windows as a Community

Geoff Canyon via use-livecode
> 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.

What about a room on Gitter to keep it public?

Cheers

Monte

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: [Hacktoberfest] Improving Hi-DPI support on Windows as a Community

Geoff Canyon via use-livecode
On Thu, Oct 11, 2018 at 6:42 PM Monte Goulding via use-livecode <
[hidden email]> wrote:

> > 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.
>
> What about a room on Gitter to keep it public?
>

We could do that but Gitter frustrates me :-) Gitter is always resetting
the vscroll in conversations and losing my place. I offer up the Slack
option as I'm in Slack all day for my own company work and I find it very
efficient. Plus I find having audio/video/screenshare available to work
through things is very helpful.

--
Trevor DeVore
ScreenSteps
www.screensteps.com
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: [Hacktoberfest] Improving Hi-DPI support on Windows as a Community

Geoff Canyon via use-livecode


> On 12 Oct 2018, at 12:52 pm, Trevor DeVore via use-livecode <[hidden email]> wrote:
>
> We could do that but Gitter frustrates me :-) Gitter is always resetting
> the vscroll in conversations and losing my place. I offer up the Slack
> option as I'm in Slack all day for my own company work and I find it very
> efficient. Plus I find having audio/video/screenshare available to work
> through things is very helpful.

OK, fair enough. Slack is handy ;-)

Cheers

Monte
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: [Hacktoberfest] Improving Hi-DPI support on Windows as a Community

Geoff Canyon via use-livecode
In reply to this post by Geoff Canyon via use-livecode
On Thu, Oct 11, 2018 at 10:40 AM Trevor DeVore <[hidden email]>
wrote:

> I'm aware of the following limitations and bugs around Hi-DPI support on
> Windows:
>
> 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`.
>
> https://quality.livecode.com/show_bug.cgi?id=19542
>

An update for anyone interested. Today I finished setting up a build
environment for LiveCode Community on Windows and I started doing some
testing. Fixing `the screenPixelScales` issue was actually really easy. It
was just a matter of adding some XML to the engine/standalone manifests.
You can see what I've changed so far at the following url. It compares a
branch I created to the LiveCode develop-9.0 branch:

https://github.com/livecode/livecode/compare/develop-9.0...trevordevore:tkd-dpiawareness?expand=1

The next item of business is to update `the screenPixelScale of stack
tStack`. It currently returns the wrong value on secondary displays. I'm
guessing it involves switching to GetDpiForWindow() in the code.

Another to-do item is that the WM_DPICHANGED message needs to be handled
and do something like call `MCDispatch::reopen_stack_windows()`.

--
Trevor DeVore
ScreenSteps
www.screensteps.com

>
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: [Hacktoberfest] Improving Hi-DPI support on Windows as a Community

Geoff Canyon via use-livecode
On Mon, Nov 5, 2018 at 11:15 PM Trevor DeVore <[hidden email]>
wrote:

> On Thu, Oct 11, 2018 at 10:40 AM Trevor DeVore <[hidden email]>
> wrote:
>
>> I'm aware of the following limitations and bugs around Hi-DPI support on
>> Windows:
>>
>> 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`.
>>
>> https://quality.livecode.com/show_bug.cgi?id=19542
>>
>
> An update for anyone interested. Today I finished setting up a build
> environment for LiveCode Community on Windows and I started doing some
> testing. Fixing `the screenPixelScales` issue was actually really easy. It
> was just a matter of adding some XML to the engine/standalone manifests.
> You can see what I've changed so far at the following url. It compares a
> branch I created to the LiveCode develop-9.0 branch:
>
>
> https://github.com/livecode/livecode/compare/develop-9.0...trevordevore:tkd-dpiawareness?expand=1
>
> The next item of business is to update `the screenPixelScale of stack
> tStack`. It currently returns the wrong value on secondary displays. I'm
> guessing it involves switching to GetDpiForWindow() in the code.
>

 There isn't actually a `screenPixelScale` property for a stack so ignore
the comment above.

I have done a fair bit of testing and further research. I've updated the
bug report with my notes:

https://quality.livecode.com/show_bug.cgi?id=19542#c6

If anyone feels they can jump in and provide some additional coding or
testing it would be great.

--
Trevor DeVore
ScreenSteps
www.screensteps.com
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: [Hacktoberfest] Improving Hi-DPI support on Windows as a Community

Geoff Canyon via use-livecode
Thanks for you work on this Trevor. I suspect stack positions when switching between monitors of dissimmilar resolution will benifit from this.

Bob S


> On Nov 6, 2018, at 09:10 , Trevor DeVore via use-livecode <[hidden email]> wrote:
>
> On Mon, Nov 5, 2018 at 11:15 PM Trevor DeVore <[hidden email]>
> wrote:
>
>> On Thu, Oct 11, 2018 at 10:40 AM Trevor DeVore <[hidden email]>
>> wrote:
>>
>>> I'm aware of the following limitations and bugs around Hi-DPI support on
>>> Windows:
>>>
>>> 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`.
>>>
>>> https://quality.livecode.com/show_bug.cgi?id=19542
>>>
>>
>> An update for anyone interested. Today I finished setting up a build
>> environment for LiveCode Community on Windows and I started doing some
>> testing. Fixing `the screenPixelScales` issue was actually really easy. It
>> was just a matter of adding some XML to the engine/standalone manifests.
>> You can see what I've changed so far at the following url. It compares a
>> branch I created to the LiveCode develop-9.0 branch:
>>
>>
>> https://github.com/livecode/livecode/compare/develop-9.0...trevordevore:tkd-dpiawareness?expand=1
>>
>> The next item of business is to update `the screenPixelScale of stack
>> tStack`. It currently returns the wrong value on secondary displays. I'm
>> guessing it involves switching to GetDpiForWindow() in the code.
>>
>
> There isn't actually a `screenPixelScale` property for a stack so ignore
> the comment above.
>
> I have done a fair bit of testing and further research. I've updated the
> bug report with my notes:
>
> https://quality.livecode.com/show_bug.cgi?id=19542#c6
>
> If anyone feels they can jump in and provide some additional coding or
> testing it would be great.
>
> --
> Trevor DeVore
> ScreenSteps
> www.screensteps.com
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode


_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: [Hacktoberfest] Improving Hi-DPI support on Windows as a Community

Geoff Canyon via use-livecode
In reply to this post by Geoff Canyon via use-livecode
Thanks everyone for your efforts on this and other bugs.

On Tue, Nov 6, 2018 at 12:10 PM, Trevor DeVore via use-livecode <
[hidden email]> wrote:

> On Mon, Nov 5, 2018 at 11:15 PM Trevor DeVore <[hidden email]>
> wrote:
>
> > On Thu, Oct 11, 2018 at 10:40 AM Trevor DeVore <
> [hidden email]>
> > wrote:
> >
> >> I'm aware of the following limitations and bugs around Hi-DPI support on
> >> Windows:
> >>
> >> 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`.
> >>
> >> https://quality.livecode.com/show_bug.cgi?id=19542
> >>
> >
> > An update for anyone interested. Today I finished setting up a build
> > environment for LiveCode Community on Windows and I started doing some
> > testing. Fixing `the screenPixelScales` issue was actually really easy.
> It
> > was just a matter of adding some XML to the engine/standalone manifests.
> > You can see what I've changed so far at the following url. It compares a
> > branch I created to the LiveCode develop-9.0 branch:
> >
> >
> > https://github.com/livecode/livecode/compare/develop-9.0..
> .trevordevore:tkd-dpiawareness?expand=1
> >
> > The next item of business is to update `the screenPixelScale of stack
> > tStack`. It currently returns the wrong value on secondary displays. I'm
> > guessing it involves switching to GetDpiForWindow() in the code.
> >
>
>  There isn't actually a `screenPixelScale` property for a stack so ignore
> the comment above.
>
> I have done a fair bit of testing and further research. I've updated the
> bug report with my notes:
>
> https://quality.livecode.com/show_bug.cgi?id=19542#c6
>
> If anyone feels they can jump in and provide some additional coding or
> testing it would be great.
>
> --
> Trevor DeVore
> ScreenSteps
> www.screensteps.com
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode