mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-07 22:58:14 +02:00
LCL: Prevent an error when Monitor.PixelsPerInch=0 which may happen with GTK3 + Wayland. Issue #36220, patch from David.
git-svn-id: trunk@62212 -
This commit is contained in:
parent
6fe903d537
commit
8e1067a191
@ -70,17 +70,18 @@ end;
|
||||
Gets called after the construction of the object
|
||||
------------------------------------------------------------------------------}
|
||||
procedure TCustomForm.AfterConstruction;
|
||||
var
|
||||
MonPPI: Integer;
|
||||
begin
|
||||
SetRestoredBounds(Left, Top, Width, Height, True);
|
||||
|
||||
DoCreate;
|
||||
|
||||
EndFormUpdate; // the BeginFormUpdate is in CreateNew
|
||||
inherited AfterConstruction;
|
||||
|
||||
if Application.Scaled and Scaled and (Monitor.PixelsPerInch<>PixelsPerInch) then
|
||||
AutoAdjustLayout(lapAutoAdjustForDPI, PixelsPerInch, Monitor.PixelsPerInch,
|
||||
Width, MulDiv(Width, Monitor.PixelsPerInch, PixelsPerInch));
|
||||
MonPPI := Monitor.PixelsPerInch;
|
||||
if Application.Scaled and Scaled and (MonPPI > 0) and (MonPPI <> PixelsPerInch) then
|
||||
AutoAdjustLayout(lapAutoAdjustForDPI, PixelsPerInch, MonPPI,
|
||||
Width, MulDiv(Width, MonPPI, PixelsPerInch));
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
@ -423,17 +424,19 @@ begin
|
||||
end;
|
||||
|
||||
procedure TCustomForm.AutoScale;
|
||||
var
|
||||
MonPPI: Integer;
|
||||
begin
|
||||
if not Scaled then
|
||||
begin
|
||||
Scaled := True; // will execute AutoScale
|
||||
Exit;
|
||||
end;
|
||||
|
||||
if Application.Scaled and (PixelsPerInch<>Monitor.PixelsPerInch) then
|
||||
AutoAdjustLayout(lapAutoAdjustForDPI, PixelsPerInch, Monitor.PixelsPerInch,
|
||||
MulDiv(Width, Monitor.PixelsPerInch, PixelsPerInch),
|
||||
MulDiv(Height, Monitor.PixelsPerInch, PixelsPerInch));
|
||||
MonPPI := Monitor.PixelsPerInch;
|
||||
if Application.Scaled and (MonPPI > 0) and (MonPPI <> PixelsPerInch) then
|
||||
AutoAdjustLayout(lapAutoAdjustForDPI, PixelsPerInch, MonPPI,
|
||||
MulDiv(Width, MonPPI, PixelsPerInch),
|
||||
MulDiv(Height, MonPPI, PixelsPerInch));
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
@ -2276,10 +2279,13 @@ end;
|
||||
procedure TCustomForm.Show;
|
||||
------------------------------------------------------------------------------}
|
||||
procedure TCustomForm.Show;
|
||||
var
|
||||
MonPPI: Integer;
|
||||
begin
|
||||
if Application.Scaled and Scaled and (Monitor.PixelsPerInch<>PixelsPerInch) then
|
||||
AutoAdjustLayout(lapAutoAdjustForDPI, PixelsPerInch, Monitor.PixelsPerInch,
|
||||
Width, MulDiv(Width, Monitor.PixelsPerInch, PixelsPerInch));
|
||||
MonPPI := Monitor.PixelsPerInch;
|
||||
if Application.Scaled and Scaled and (MonPPI > 0) and (MonPPI <> PixelsPerInch) then
|
||||
AutoAdjustLayout(lapAutoAdjustForDPI, PixelsPerInch, MonPPI,
|
||||
Width, MulDiv(Width, MonPPI, PixelsPerInch));
|
||||
|
||||
Visible := True;
|
||||
{ wxMaximized secondary forms are not being shown maximized }
|
||||
|
Loading…
Reference in New Issue
Block a user