LongDirtyAnimAlf / fpcupdeluxe

A GUI based installer for FPC and Lazarus
505 stars 94 forks source link

The interface is blurry in Windows system while the scale is 125% #594

Closed DrPeaboss closed 1 year ago

DrPeaboss commented 1 year ago

I use Win11. As the title, the interface is so blurry in my laptop while the scale is 125%. I think > 125 would have the same result.

I found out that the DPI wareness in project options is off in fpcupdeluxe.lpi, if I turn it on and compile, the interface became clear.

So why is it closed, is there any problem?

LongDirtyAnimAlf commented 1 year ago

This is done like this because fpcupdeluxe is cross-compiled to many systems, and I do not know if the GUI will keep working on all those systems with DPI enabled. In fact, it was very much work to get the GUI working on all these systems, so I am a little scared in changing this.

DrPeaboss commented 1 year ago

In Lazarus project options, the checkbox with "Use manifest resource (and enable themes)" seems to Windows only, the DPI awareness option below it maybe for Windows system only, not affect other systems.

I don't have many cross compilers, can you have a simple test?

Or you can turn DPI awareness on for windows only when compiling the release binary.

LongDirtyAnimAlf commented 1 year ago

Twice you use the words "seems" and "maybe". And that is the problem. Its effect outside of Windows is (also) unknown to me. And I do not dare to take the risk. Fpcupdeluxe is just a 1 trick pony. A blurry GUI is not a problem. Again. You might be right, but I do not dare to take the risk. I have done the high DPI once and it results were bad when scaling the components on the form. But I will look into the old code once again.

LongDirtyAnimAlf commented 1 year ago

Extra. I have replaced the win32 binary with a scaled one. Please test. https://github.com/LongDirtyAnimAlf/fpcupdeluxe/releases/download/v2.2.0s/fpcupdeluxe-i386-win32.exe

DrPeaboss commented 1 year ago

Twice you use the words "seems" and "maybe". And that is the problem. Its effect outside of Windows is (also) unknown to me. And I do not dare to take the risk. Fpcupdeluxe is just a 1 trick pony. A blurry GUI is not a problem. Again. You might be right, but I do not dare to take the risk. I have done the high DPI once and it results were bad when scaling the components on the form. But I will look into the old code once again.

Yes, we don't need to use fpcupdeluxe very often. So it's really not a problem. The wiki https://wiki.freepascal.org/High_DPI doesn't look very detailed about cross platform. Recently I am going to try cross compiling and do some tests.

Extra. I have replaced the win32 binary with a scaled one. Please test. https://github.com/LongDirtyAnimAlf/fpcupdeluxe/releases/download/v2.2.0s/fpcupdeluxe-i386-win32.exe

I did test and the GUI is clear, but I found that the window size is not correct. I know when the window closed, it will save the information to fpcupdeluxe.ini. When I run it again, it will read it, but the size of window became 1.25x.

DrPeaboss commented 1 year ago
procedure TForm1.FormCreate(Sender:TObject);
begin
  PixelsPerInch:=96;
  Width:=1536;
  Height:=864;
end;

In Windows, if the DPI scale is 125%, run this code will create a 1920x1080 window.

LongDirtyAnimAlf commented 1 year ago

New binary should behave better. Please test. https://github.com/LongDirtyAnimAlf/fpcupdeluxe/releases/download/v2.2.0s/fpcupdeluxe-i386-win32.exe

DrPeaboss commented 1 year ago

Perfect! Thank you very much!

DrPeaboss commented 1 year ago

These days I'm using fpcupdeluxe to install cross compiler for arm embedded, I found the release of 2.4.0a and have a try, unfortunately, the blurry GUI appeared.

I compared the binary of 2.2.0t and 2.4.0a, and found clues, see the shot:

diff_2 4a_2 2t

In fact, the Hi DPI of GUI application in Windows is depending on the manifest of the manifest with <dpiAware>True</dpiAware>, the LCL scaling let the GUI easier to achieve Hi DPI, but without this hint, the Windows would not think the exe support Hi DPI and use simple scale which caused the blur.

To figure out whether the DPI aware option in manifest for Windows influence Linux and others, I made a test.

  1. Compile one project twice and generate two file, first one set DPI aware true and second one false, and use readelf to search the different sections. In fact, there is only fpc.resources section is different.

  2. I use Ubuntu to test the two files, and the GUI is same, even I use scale factor 125% and 150%, it doesn't care. It's an issue of Lazarus(In fact the Hi DPI support is not good in most of Linux desktops).

So the conclusion is the DPI aware option in manifest is Windows only(In theory, test 1 is enough). Btw, when you create a GUI project in Lazarus, the manifest is set and the DPI aware is true by default.

Please set the DPI aware to True in manifest to completely solve this issue.