From 6fc5983d2f879409a0f2b8ba343e08af0b707e68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Salvador=20D=C3=ADaz=20Fau?= Date: Mon, 25 Aug 2025 17:24:21 +0200 Subject: [PATCH] Fixed GetScreenDPI in VirtualBox with Linux guest and using Lazarus --- source/uCEFMiscFunctions.pas | 10 +++++++--- update_CEF4Delphi.json | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/source/uCEFMiscFunctions.pas b/source/uCEFMiscFunctions.pas index 22fe231c..d2306c06 100644 --- a/source/uCEFMiscFunctions.pas +++ b/source/uCEFMiscFunctions.pas @@ -3129,6 +3129,8 @@ begin {$IFDEF LINUX} {$IFDEF FPC} + Result := 0; + if (Application <> nil) and (Application.MainForm <> nil) and (Application.MainForm.Monitor <> nil) then @@ -3140,9 +3142,11 @@ begin Result := screen.PrimaryMonitor.PixelsPerInch else Result := screen.PixelsPerInch; - end - else - Result := USER_DEFAULT_SCREEN_DPI; + end; + + // Workaround for a VirtualBox issue. + if (Result = 0) then + Result := USER_DEFAULT_SCREEN_DPI; {$ELSE} Result := -1; if TPlatformServices.Current.SupportsPlatformService(IFMXScreenService, TempService) then diff --git a/update_CEF4Delphi.json b/update_CEF4Delphi.json index f0b8d772..87f16467 100644 --- a/update_CEF4Delphi.json +++ b/update_CEF4Delphi.json @@ -2,7 +2,7 @@ "UpdateLazPackages" : [ { "ForceNotify" : true, - "InternalVersion" : 768, + "InternalVersion" : 769, "Name" : "cef4delphi_lazarus.lpk", "Version" : "139.0.28" }