Recent

Author Topic: App on high res monitors - Linux/Wine problems  (Read 4436 times)

bobonwhidbey

  • Hero Member
  • *****
  • Posts: 592
    • Double Dummy Solver - free download
App on high res monitors - Linux/Wine problems
« on: February 19, 2018, 02:39:13 am »
My app is designed under 96 PPI to look fine on lower res monitors. On high res monitors the buttons, text, and images look much smaller. To solve this I allow each user to increase the PPI by a factor from 0 to 100. Using
Code: Pascal  [Select][+][-]
  1. procedure AdjustScreen(aForm: TForm; var OldInc: integer; NewInc: integer);
  2. begin
  3.   if OldInc <> 0 then
  4.     aForm.AutoAdjustLayout(lapAutoAdjustForDPI, 96 + OldInc, 96, 0, 0);
  5.   aForm.AutoAdjustLayout(lapAutoAdjustForDPI, 96, 96 + NewInc, 0, 0);
  6.   OldInc := NewInc;
  7. end;        
Except for images which I adjust individually, this handles things well on Windows systems. User with Linux who run my app under Wine are having problems with this approach. Is there a better approach for allowing users to increase the size of components on their monitor? Is there a way to detect if a program is running under Wine?

Another minor problem - AutoAdjustLayout does not increase the size of the Menu bar, or its sub-menu items with this approach. Is there another approach for the menu bar of each form?

Lazarus 3.0RC2, FPC 3.2.2 x86_64-win64-win32/win64

dieselfan

  • New Member
  • *
  • Posts: 16
Re: App on high res monitors - Linux/Wine problems
« Reply #1 on: February 19, 2018, 08:04:06 am »
Has your user adjusted the DPI for the virtual drive under wine's settings? I generally use PlayOnLinux for configuring wine installs. I've had good success with this.
AMD 1800X
Manjaro KDE
Rarely Windows 10 Pro

avra

  • Hero Member
  • *****
  • Posts: 2514
    • Additional info
Re: App on high res monitors - Linux/Wine problems
« Reply #2 on: February 19, 2018, 10:15:29 am »
Is there a better approach for allowing users to increase the size of components on their monitor?
Proper way to deal with high DPI is explained here: http://wiki.lazarus.freepascal.org/High_DPI. It's relatively new so if you find some issues you should also check trunk version of Lazarus.

If for some reason you prefer the "old school" way, then you might want to take a look at this:
https://stackoverflow.com/questions/8296784/how-do-i-make-my-gui-behave-well-when-windows-font-scaling-is-greater-than-100
ct2laz - Conversion between Lazarus and CodeTyphon
bithelpers - Bit manipulation for standard types
pasettimino - Siemens S7 PLC lib

bobonwhidbey

  • Hero Member
  • *****
  • Posts: 592
    • Double Dummy Solver - free download
Re: App on high res monitors - Linux/Wine problems
« Reply #3 on: February 19, 2018, 04:23:50 pm »
I read that article but I don't understand what the writer means by "manifest", and it seems to be an important point.  :o

I have been very happy with AutoAdjustLayout. It handles MOST of the job very well, with just the problems mentioned in my initial post.
Lazarus 3.0RC2, FPC 3.2.2 x86_64-win64-win32/win64

wp

  • Hero Member
  • *****
  • Posts: 11858
Re: App on high res monitors - Linux/Wine problems
« Reply #4 on: February 19, 2018, 04:43:39 pm »
To get Hi-DPI support in Laz 1.8 you must do this
  • Remove your own scaling code
  • Open the project options, check the box "Use LCL scaling"
  • and in the next line check "use manifest support" and in the combobox "DPI awareness" select an "on" item.
Normally that's all. There's maybe some tweaking here and there, but ask again if you come to this point. There's no need to call AutoAdjustLayout.

Laz trunk contains also a rewritten imagelist which accepts images at several resolutions and upscales images to the new screen resolution (http://wiki.lazarus.freepascal.org/TImageList#Multiple-resolution_TImageList_in_Lazarus_1.9_and_newer).

To answer the question about the "manifest": https://en.wikipedia.org/wiki/Manifest_file
« Last Edit: February 19, 2018, 04:47:07 pm by wp »

Thaddy

  • Hero Member
  • *****
  • Posts: 14213
  • Probably until I exterminate Putin.
Re: App on high res monitors - Linux/Wine problems
« Reply #5 on: February 19, 2018, 05:56:46 pm »
@wp a better explanation is here: https://en.wikipedia.org/wiki/Manifesto but you are close. "Your intentions are good, plz don't let me be to misunderstood"....
The CS version is a subset of the real thing. If you do not understand the real thing there is no hope... (I know you do understand!)
Specialize a type, not a var.

bobonwhidbey

  • Hero Member
  • *****
  • Posts: 592
    • Double Dummy Solver - free download
Re: App on high res monitors - Linux/Wine problems
« Reply #6 on: February 19, 2018, 06:47:43 pm »
I have not been able to confirm this - but it SEEMS that Hi-DPI support is geared toward adjusting the screen output of my Laz app to the DPI of the user's monitor.

My desire is to increase the size of the components for users with poor eyesight.  One user with a 1920 x 1200 res monitor maybe happy with the size of the components in my app, while another user with the same monitor res, but with poorer eyesight, may want to have all the items enlarged. Thus I want to let the user choose the degree of enlargement.

Yes, I have Use LCL scaling checked as well as "use manifest support". Without using AutoAdjustLayout the size of components/items is unchanged.
Lazarus 3.0RC2, FPC 3.2.2 x86_64-win64-win32/win64

dieselfan

  • New Member
  • *
  • Posts: 16
Re: App on high res monitors - Linux/Wine problems
« Reply #7 on: February 19, 2018, 07:28:33 pm »
I have not been able to confirm this - but it SEEMS that Hi-DPI support is geared toward adjusting the screen output of my Laz app to the DPI of the user's monitor.
Which is why I suggested overriding in wine config. It will fool your app, as you mentioned they are running it through wine and not native linux . TBH I'm testing the new features of Laz 1.8 with HiDPI etc and it works ok but not ideal. I still find I have to do some manual calcs as I dev on 2x4k screens and my clients run 19". Even opening on Windows Laz vs Linux laz gives different sizes but I suspect it's Windows Server.
AMD 1800X
Manjaro KDE
Rarely Windows 10 Pro

wp

  • Hero Member
  • *****
  • Posts: 11858
Re: App on high res monitors - Linux/Wine problems
« Reply #8 on: February 19, 2018, 08:41:13 pm »
If you want to increase the overall size of forms and fonts to help visually impaired people you should adjust the corresponding settings of the OS, not of your application. In Windows you can find the corresponding settings in the control panel of the screen, set font size to "large fonts". Laz 1.8 will scale all controls according to this magnification factor automatically. This works on Windows and Linux. If this does not work in Wine then this is a problem of Wine, not of Lazarus.

avra

  • Hero Member
  • *****
  • Posts: 2514
    • Additional info
Re: App on high res monitors - Linux/Wine problems
« Reply #9 on: February 19, 2018, 09:14:09 pm »
My desire is to increase the size of the components for users with poor eyesight.  One user with a 1920 x 1200 res monitor maybe happy with the size of the components in my app, while another user with the same monitor res, but with poorer eyesight, may want to have all the items enlarged. Thus I want to let the user choose the degree of enlargement.
Ideally you would let OS handle size of all forms, but if for some reason you still want to do it your self then you should disable high dpi and manifest, and go "old school". Some 20 years ago it looked something like this:

Code: Pascal  [Select][+][-]
  1. procedure ScaleAllForms(ScaleFactor: integer); // range -3..0..3
  2. var
  3.   Divisor: integer;     // scaling equals 100 + (ScaleFactor * DivisorStep), so for DivisorStep = 10 we get 70..100..130
  4.   DivisorStep: integer; // scaling step
  5.   ix: integer;
  6. const
  7.   Multiplier = 100;
  8. begin
  9.   if ScaleFactor <> 0 then // no need for form size change when 0
  10.   begin
  11.     if ScaleFactor > 0 then // bigger step for enlarging, smaller step for shrinking
  12.       DivisorStep := 20
  13.     else
  14.       DivisorStep := 10;
  15.  
  16.     Divisor := Multiplier + (ScaleFactor * DivisorStep);
  17.  
  18.     with Screen do
  19.       for ix := 0 to FormCount - 1 do
  20.         if (Forms[ix].Name <> 'TmpReport') and (Forms[ix].Name <> 'TablesModule') then // no need for rescaling non visual forms
  21.           Forms[ix].ScaleBy(Divisor, Multiplier);
  22.   end;
  23. end;
  24.  

You will probably also need to use my CenterInParent() function from the last message in mentioned stackoverflow post and some other tweaks, but it will work.
ct2laz - Conversion between Lazarus and CodeTyphon
bithelpers - Bit manipulation for standard types
pasettimino - Siemens S7 PLC lib

dieselfan

  • New Member
  • *
  • Posts: 16
Re: App on high res monitors - Linux/Wine problems
« Reply #10 on: February 21, 2018, 08:56:05 am »
If you want to increase the overall size of forms and fonts to help visually impaired people you should adjust the corresponding settings of the OS, not of your application. In Windows you can find the corresponding settings in the control panel of the screen, set font size to "large fonts". Laz 1.8 will scale all controls according to this magnification factor automatically. This works on Windows and Linux. If this does not work in Wine then this is a problem of Wine, not of Lazarus.
Which is why I recommend the equivalent of doing it through wine. See attached pic
AMD 1800X
Manjaro KDE
Rarely Windows 10 Pro

 

TinyPortal © 2005-2018