1
0
mirror of https://github.com/salvadordf/CEF4Delphi.git synced 2025-01-03 10:15:38 +02:00

Fixed context menu position in Firemonkey OSR demos running in high DPI monitors

Fixed touch and pen handling function in Firemonkey OSR demos running in high DPI monitors.
Fixed issue #431: Outdated DCPCrypt project link
This commit is contained in:
salvadordf 2022-07-28 11:07:26 +02:00
parent 394186de88
commit 9a1a3bb325
8 changed files with 120 additions and 84 deletions

View File

@ -42,7 +42,7 @@ Delphinus-Support
* [DCEF3](https://github.com/hgourvest/dcef3)
* [fpCEF3](https://github.com/dliw/fpCEF3)
* [CEF](https://bitbucket.org/chromiumembedded/cef/)
* [DCPcrypt](http://www.cityinthesky.co.uk/opensource/dcpcrypt/)
* [DCPcrypt](https://sourceforge.net/projects/lazarus-ccr/files/DCPcrypt/)
* [Chromium](https://chromium.googlesource.com/chromium/src/)
## Attribution

View File

@ -1,7 +1,7 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ProjectGuid>{BE24D13B-2634-4064-8746-AB331419C5FA}</ProjectGuid>
<ProjectVersion>19.3</ProjectVersion>
<ProjectVersion>19.4</ProjectVersion>
<FrameworkType>FMX</FrameworkType>
<MainSource>FMXExternalPumpBrowser.dpr</MainSource>
<Base>True</Base>
@ -219,7 +219,7 @@
<DCC_RemoteDebug>false</DCC_RemoteDebug>
<AppEnableRuntimeThemes>true</AppEnableRuntimeThemes>
<VerInfo_Locale>1033</VerInfo_Locale>
<AppDPIAwarenessMode>PerMonitor</AppDPIAwarenessMode>
<AppDPIAwarenessMode>PerMonitorV2</AppDPIAwarenessMode>
<VerInfo_IncludeVerInfo>true</VerInfo_IncludeVerInfo>
</PropertyGroup>
<PropertyGroup Condition="'$(Cfg_1_Win64)'!=''">
@ -276,9 +276,8 @@
</Excluded_Packages>
</Delphi.Personality>
<Deployment Version="3">
<DeployFile LocalName="..\..\bin\FMXExternalPumpBrowser.exe" Configuration="Debug" Class="ProjectOutput">
<Platform Name="Win32">
<RemoteName>FMXExternalPumpBrowser.exe</RemoteName>
<DeployFile LocalName="$(BDS)\Redist\iossimulator\libcgunwind.1.0.dylib" Class="DependencyModule">
<Platform Name="iOSSimulator">
<Overwrite>true</Overwrite>
</Platform>
</DeployFile>
@ -292,11 +291,6 @@
<Overwrite>true</Overwrite>
</Platform>
</DeployFile>
<DeployFile LocalName="$(BDS)\Redist\iossimulator\libcgunwind.1.0.dylib" Class="DependencyModule">
<Platform Name="iOSSimulator">
<Overwrite>true</Overwrite>
</Platform>
</DeployFile>
<DeployFile LocalName="$(BDS)\Redist\osx32\libcgsqlite3.dylib" Class="DependencyModule">
<Platform Name="OSX32">
<Overwrite>true</Overwrite>
@ -312,6 +306,12 @@
<Overwrite>true</Overwrite>
</Platform>
</DeployFile>
<DeployFile LocalName="..\..\bin\FMXExternalPumpBrowser.exe" Configuration="Debug" Class="ProjectOutput">
<Platform Name="Win32">
<RemoteName>FMXExternalPumpBrowser.exe</RemoteName>
<Overwrite>true</Overwrite>
</Platform>
</DeployFile>
<DeployClass Name="AdditionalDebugSymbols">
<Platform Name="iOSSimulator">
<Operation>1</Operation>
@ -1437,17 +1437,17 @@
<Operation>1</Operation>
</Platform>
</DeployClass>
<ProjectRoot Platform="OSX32" Name="$(PROJECTNAME).app"/>
<ProjectRoot Platform="OSX64" Name="$(PROJECTNAME).app"/>
<ProjectRoot Platform="Win32" Name="$(PROJECTNAME)"/>
<ProjectRoot Platform="Android64" Name="$(PROJECTNAME)"/>
<ProjectRoot Platform="Android" Name="$(PROJECTNAME)"/>
<ProjectRoot Platform="Win64" Name="$(PROJECTNAME)"/>
<ProjectRoot Platform="OSXARM64" Name="$(PROJECTNAME).app"/>
<ProjectRoot Platform="Android64" Name="$(PROJECTNAME)"/>
<ProjectRoot Platform="iOSDevice32" Name="$(PROJECTNAME).app"/>
<ProjectRoot Platform="iOSDevice64" Name="$(PROJECTNAME).app"/>
<ProjectRoot Platform="Linux64" Name="$(PROJECTNAME)"/>
<ProjectRoot Platform="iOSSimulator" Name="$(PROJECTNAME).app"/>
<ProjectRoot Platform="Linux64" Name="$(PROJECTNAME)"/>
<ProjectRoot Platform="OSX32" Name="$(PROJECTNAME).app"/>
<ProjectRoot Platform="OSX64" Name="$(PROJECTNAME).app"/>
<ProjectRoot Platform="OSXARM64" Name="$(PROJECTNAME).app"/>
<ProjectRoot Platform="Win32" Name="$(PROJECTNAME)"/>
<ProjectRoot Platform="Win64" Name="$(PROJECTNAME)"/>
</Deployment>
<Platforms>
<Platform value="Android">False</Platform>

View File

@ -591,11 +591,11 @@ var
TempScale : single;
begin
TempScale := Panel1.ScreenScale;
TempViewPt.x := LogicalToDevice(viewX, TempScale);
TempViewPt.y := LogicalToDevice(viewY, TempScale);
TempViewPt.x := viewX;
TempViewPt.y := viewY;
TempScreenPt := Panel1.ClientToScreen(TempViewPt);
screenX := TempScreenPt.x;
screenY := TempScreenPt.y;
screenX := LogicalToDevice(TempScreenPt.x, TempScale);
screenY := LogicalToDevice(TempScreenPt.y, TempScale);
Result := True;
end;
@ -811,25 +811,23 @@ end;
procedure TFMXExternalPumpBrowserFrm.DoResize;
begin
try
if (FResizeCS <> nil) then
begin
FResizeCS.Acquire;
if (FResizeCS <> nil) then
try
FResizeCS.Acquire;
if FResizing then
FPendingResize := True
if FResizing then
FPendingResize := True
else
if Panel1.BufferIsResized then
chrmosr.Invalidate(PET_VIEW)
else
if Panel1.BufferIsResized then
chrmosr.Invalidate(PET_VIEW)
else
begin
FResizing := True;
chrmosr.WasResized;
end;
end;
finally
if (FResizeCS <> nil) then FResizeCS.Release;
end;
begin
FResizing := True;
chrmosr.WasResized;
end;
finally
FResizeCS.Release;
end;
end;
procedure TFMXExternalPumpBrowserFrm.SetBounds(ALeft, ATop, AWidth, AHeight: Integer);
@ -1064,6 +1062,7 @@ var
TempPenInfo : POINTER_PEN_INFO;
TempTouchEvent : TCefTouchEvent;
TempPoint : TPoint;
TempScale : single;
begin
Result := False;
if not(GetPointerPenInfo(aID, @TempPenInfo)) then exit;
@ -1110,8 +1109,11 @@ begin
if ((TempPenInfo.pointerInfo.pointerFlags and POINTER_FLAG_CANCELED) <> 0) then
TempTouchEvent.type_ := CEF_TET_CANCELLED;
TempPoint := Panel1.ScreenToClient(TempPenInfo.pointerInfo.ptPixelLocation);
// TFMXBufferPanel.ScreenToClient applies the scale factor. No need to call DeviceToLogical to set TempTouchEvent.
TempScale := Panel1.ScreenScale;
TempPoint.x := DeviceToLogical(TempPenInfo.pointerInfo.ptPixelLocation.x, TempScale);
TempPoint.y := DeviceToLogical(TempPenInfo.pointerInfo.ptPixelLocation.y, TempScale);
TempPoint := Panel1.ScreenToClient(TempPoint);
TempTouchEvent.x := TempPoint.x;
TempTouchEvent.y := TempPoint.y;
@ -1123,6 +1125,7 @@ var
TempTouchInfo : POINTER_TOUCH_INFO;
TempTouchEvent : TCefTouchEvent;
TempPoint : TPoint;
TempScale : single;
begin
Result := False;
if not(GetPointerTouchInfo(aID, @TempTouchInfo)) then exit;
@ -1157,8 +1160,12 @@ begin
if ((TempTouchInfo.pointerInfo.pointerFlags and POINTER_FLAG_CANCELED) <> 0) then
TempTouchEvent.type_ := CEF_TET_CANCELLED;
TempPoint := Panel1.ScreenToClient(TempTouchInfo.pointerInfo.ptPixelLocation);
// TFMXBufferPanel.ScreenToClient applies the scale factor. No need to call DeviceToLogical to set TempTouchEvent.
TempScale := Panel1.ScreenScale;
TempPoint.x := DeviceToLogical(TempTouchInfo.pointerInfo.ptPixelLocation.x, TempScale);
TempPoint.y := DeviceToLogical(TempTouchInfo.pointerInfo.ptPixelLocation.y, TempScale);
TempPoint := Panel1.ScreenToClient(TempPoint);
//TempPoint := Panel1.ScreenToClient(TempTouchInfo.pointerInfo.ptPixelLocation);
TempTouchEvent.x := TempPoint.x;
TempTouchEvent.y := TempPoint.y;

View File

@ -219,7 +219,7 @@
<DCC_RemoteDebug>false</DCC_RemoteDebug>
<AppEnableRuntimeThemes>true</AppEnableRuntimeThemes>
<VerInfo_Locale>1033</VerInfo_Locale>
<AppDPIAwarenessMode>PerMonitor</AppDPIAwarenessMode>
<AppDPIAwarenessMode>PerMonitorV2</AppDPIAwarenessMode>
<VerInfo_IncludeVerInfo>true</VerInfo_IncludeVerInfo>
</PropertyGroup>
<PropertyGroup Condition="'$(Cfg_1_Win64)'!=''">
@ -281,12 +281,12 @@
<Overwrite>true</Overwrite>
</Platform>
</DeployFile>
<DeployFile LocalName="$(BDS)\Redist\iossimulator\libPCRE.dylib" Class="DependencyModule">
<DeployFile LocalName="$(BDS)\Redist\iossimulator\libpcre.dylib" Class="DependencyModule">
<Platform Name="iOSSimulator">
<Overwrite>true</Overwrite>
</Platform>
</DeployFile>
<DeployFile LocalName="$(BDS)\Redist\iossimulator\libpcre.dylib" Class="DependencyModule">
<DeployFile LocalName="$(BDS)\Redist\iossimulator\libPCRE.dylib" Class="DependencyModule">
<Platform Name="iOSSimulator">
<Overwrite>true</Overwrite>
</Platform>

View File

@ -124,6 +124,7 @@ type
function CancelPreviousClick(const x, y : single; var aCurrentTime : integer) : boolean;
procedure DoRedraw;
procedure DoResize;
function RealScreenScale: single;
{$IFDEF MSWINDOWS}
function SendCompMessage(aMsg : cardinal; aWParam : WPARAM = 0; aLParam : LPARAM = 0) : boolean;
function ArePointerEventsSupported : boolean;
@ -190,7 +191,7 @@ implementation
{$R *.fmx}
uses
System.SysUtils, System.Math, FMX.Platform, FMX.Platform.Win,
System.SysUtils, System.Math, FMX.Platform, FMX.Platform.Win, FMX.Helpers.Win,
uCEFMiscFunctions, uCEFApplication, uFMXApplicationService;
procedure GlobalCEFApp_OnScheduleMessagePumpWork(const aDelayMS : int64);
@ -576,15 +577,16 @@ procedure TMainForm.chrmosrGetScreenPoint( Sender : TObject;
var screenY : Integer;
out Result : Boolean);
var
TempPoint : TPointF;
TempScreenPt, TempViewPt : TPointF;
TempScale : single;
begin
TempPoint.x := LogicalToDevice(viewX, GlobalCEFApp.DeviceScaleFactor);
TempPoint.y := LogicalToDevice(viewY, GlobalCEFApp.DeviceScaleFactor);
// LocalToScreen applies the scale factor. No need to call LogicalToDevice to set TempViewPt.
TempPoint := Panel1.LocalToScreen(TempPoint);
screenX := round(TempPoint.x);
screenY := round(TempPoint.y);
Result := True;
TempScale := RealScreenScale;
TempViewPt.x := viewX;
TempViewPt.y := viewY;
TempScreenPt := Panel1.LocalToScreen(TempViewPt);
screenX := LogicalToDevice(round(TempScreenPt.x), TempScale);
screenY := LogicalToDevice(round(TempScreenPt.y), TempScale);
Result := True;
end;
procedure TMainForm.chrmosrGetViewRect( Sender : TObject;
@ -681,6 +683,21 @@ begin
chrmosr.WasResized;
end;
function TMainForm.RealScreenScale: single;
var
TempHandle: TCefWindowHandle;
begin
if assigned(GlobalCEFApp) then
result := GlobalCEFApp.DeviceScaleFactor
else
result := 1;
TempHandle := FmxHandleToHWND(Handle);
if (TempHandle <> 0) then
Result := GetWndScale(TempHandle);
end;
procedure TMainForm.SetBounds(ALeft, ATop, AWidth, AHeight: Integer);
var
PositionChanged: Boolean;
@ -934,6 +951,7 @@ var
TempPenInfo : POINTER_PEN_INFO;
TempTouchEvent : TCefTouchEvent;
TempPointF : TPointF;
TempScale : single;
begin
Result := False;
if not(GetPointerPenInfo(aID, @TempPenInfo)) then exit;
@ -980,10 +998,11 @@ begin
if ((TempPenInfo.pointerInfo.pointerFlags and POINTER_FLAG_CANCELED) <> 0) then
TempTouchEvent.type_ := CEF_TET_CANCELLED;
TempPointF.x := TempPenInfo.pointerInfo.ptPixelLocation.x;
TempPointF.y := TempPenInfo.pointerInfo.ptPixelLocation.y;
TempScale := RealScreenScale;
TempPointF.x := DeviceToLogical(TempPenInfo.pointerInfo.ptPixelLocation.x, TempScale);
TempPointF.y := DeviceToLogical(TempPenInfo.pointerInfo.ptPixelLocation.y, TempScale);
TempPointF := Panel1.ScreenToLocal(TempPointF);
// ScreenToLocal applies the scale factor. No need to call DeviceToLogical to set TempTouchEvent.
TempTouchEvent.x := round(TempPointF.x);
TempTouchEvent.y := round(TempPointF.y);
@ -995,6 +1014,7 @@ var
TempTouchInfo : POINTER_TOUCH_INFO;
TempTouchEvent : TCefTouchEvent;
TempPointF : TPointF;
TempScale : single;
begin
Result := False;
if not(GetPointerTouchInfo(aID, @TempTouchInfo)) then exit;
@ -1029,10 +1049,11 @@ begin
if ((TempTouchInfo.pointerInfo.pointerFlags and POINTER_FLAG_CANCELED) <> 0) then
TempTouchEvent.type_ := CEF_TET_CANCELLED;
TempPointF.x := TempTouchInfo.pointerInfo.ptPixelLocation.x;
TempPointF.y := TempTouchInfo.pointerInfo.ptPixelLocation.y;
TempScale := RealScreenScale;
TempPointF.x := DeviceToLogical(TempTouchInfo.pointerInfo.ptPixelLocation.x, TempScale);
TempPointF.y := DeviceToLogical(TempTouchInfo.pointerInfo.ptPixelLocation.y, TempScale);
TempPointF := Panel1.ScreenToLocal(TempPointF);
// ScreenToLocal applies the scale factor. No need to call DeviceToLogical to set TempTouchEvent.
TempTouchEvent.x := round(TempPointF.x);
TempTouchEvent.y := round(TempPointF.y);

View File

@ -1,7 +1,7 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ProjectGuid>{7AA2E07C-ACFB-4174-A9F1-083E9BB483BC}</ProjectGuid>
<ProjectVersion>19.3</ProjectVersion>
<ProjectVersion>19.4</ProjectVersion>
<FrameworkType>FMX</FrameworkType>
<MainSource>FMXTabbedOSRBrowser.dpr</MainSource>
<Base>True</Base>
@ -281,14 +281,13 @@
</Excluded_Packages>
</Delphi.Personality>
<Deployment Version="3">
<DeployFile LocalName="$(BDS)\Redist\iossimulator\libpcre.dylib" Class="DependencyModule">
<DeployFile LocalName="$(BDS)\Redist\iossimulator\libcgunwind.1.0.dylib" Class="DependencyModule">
<Platform Name="iOSSimulator">
<Overwrite>true</Overwrite>
</Platform>
</DeployFile>
<DeployFile LocalName="..\..\..\bin\FMXTabbedOSRBrowser.exe" Configuration="Debug" Class="ProjectOutput">
<Platform Name="Win32">
<RemoteName>FMXTabbedOSRBrowser.exe</RemoteName>
<DeployFile LocalName="$(BDS)\Redist\iossimulator\libpcre.dylib" Class="DependencyModule">
<Platform Name="iOSSimulator">
<Overwrite>true</Overwrite>
</Platform>
</DeployFile>
@ -297,8 +296,9 @@
<Overwrite>true</Overwrite>
</Platform>
</DeployFile>
<DeployFile LocalName="$(BDS)\Redist\iossimulator\libcgunwind.1.0.dylib" Class="DependencyModule">
<Platform Name="iOSSimulator">
<DeployFile LocalName="..\..\..\bin\FMXTabbedOSRBrowser.exe" Configuration="Debug" Class="ProjectOutput">
<Platform Name="Win32">
<RemoteName>FMXTabbedOSRBrowser.exe</RemoteName>
<Overwrite>true</Overwrite>
</Platform>
</DeployFile>
@ -1383,17 +1383,17 @@
<Operation>1</Operation>
</Platform>
</DeployClass>
<ProjectRoot Platform="OSX32" Name="$(PROJECTNAME).app"/>
<ProjectRoot Platform="OSX64" Name="$(PROJECTNAME).app"/>
<ProjectRoot Platform="Win32" Name="$(PROJECTNAME)"/>
<ProjectRoot Platform="Android64" Name="$(PROJECTNAME)"/>
<ProjectRoot Platform="Android" Name="$(PROJECTNAME)"/>
<ProjectRoot Platform="Win64" Name="$(PROJECTNAME)"/>
<ProjectRoot Platform="OSXARM64" Name="$(PROJECTNAME).app"/>
<ProjectRoot Platform="Android64" Name="$(PROJECTNAME)"/>
<ProjectRoot Platform="iOSDevice32" Name="$(PROJECTNAME).app"/>
<ProjectRoot Platform="iOSDevice64" Name="$(PROJECTNAME).app"/>
<ProjectRoot Platform="Linux64" Name="$(PROJECTNAME)"/>
<ProjectRoot Platform="iOSSimulator" Name="$(PROJECTNAME).app"/>
<ProjectRoot Platform="Linux64" Name="$(PROJECTNAME)"/>
<ProjectRoot Platform="OSX32" Name="$(PROJECTNAME).app"/>
<ProjectRoot Platform="OSX64" Name="$(PROJECTNAME).app"/>
<ProjectRoot Platform="OSXARM64" Name="$(PROJECTNAME).app"/>
<ProjectRoot Platform="Win32" Name="$(PROJECTNAME)"/>
<ProjectRoot Platform="Win64" Name="$(PROJECTNAME)"/>
</Deployment>
<Platforms>
<Platform value="Android">False</Platform>

View File

@ -496,11 +496,11 @@ var
TempScale : single;
begin
TempScale := FMXBufferPanel1.ScreenScale;
TempViewPt.x := LogicalToDevice(viewX, TempScale);
TempViewPt.y := LogicalToDevice(viewY, TempScale);
TempViewPt.x := viewX;
TempViewPt.y := viewY;
TempScreenPt := FMXBufferPanel1.ClientToScreen(TempViewPt);
screenX := TempScreenPt.x;
screenY := TempScreenPt.y;
screenX := LogicalToDevice(TempScreenPt.x, TempScale);
screenY := LogicalToDevice(TempScreenPt.y, TempScale);
Result := True;
end;
@ -903,6 +903,7 @@ var
TempPenInfo : POINTER_PEN_INFO;
TempTouchEvent : TCefTouchEvent;
TempPoint : TPoint;
TempScale : single;
begin
Result := False;
@ -950,8 +951,11 @@ begin
if ((TempPenInfo.pointerInfo.pointerFlags and POINTER_FLAG_CANCELED) <> 0) then
TempTouchEvent.type_ := CEF_TET_CANCELLED;
TempPoint := FMXBufferPanel1.ScreenToClient(TempPenInfo.pointerInfo.ptPixelLocation);
// TFMXBufferPanel.ScreenToClient applies the scale factor. No need to call DeviceToLogical to set TempTouchEvent.
TempScale := FMXBufferPanel1.ScreenScale;
TempPoint.x := DeviceToLogical(TempPenInfo.pointerInfo.ptPixelLocation.x, TempScale);
TempPoint.y := DeviceToLogical(TempPenInfo.pointerInfo.ptPixelLocation.y, TempScale);
TempPoint := FMXBufferPanel1.ScreenToClient(TempPoint);
TempTouchEvent.x := TempPoint.x;
TempTouchEvent.y := TempPoint.y;
@ -963,6 +967,7 @@ var
TempTouchInfo : POINTER_TOUCH_INFO;
TempTouchEvent : TCefTouchEvent;
TempPoint : TPoint;
TempScale : single;
begin
Result := False;
@ -998,8 +1003,11 @@ begin
if ((TempTouchInfo.pointerInfo.pointerFlags and POINTER_FLAG_CANCELED) <> 0) then
TempTouchEvent.type_ := CEF_TET_CANCELLED;
TempPoint := FMXBufferPanel1.ScreenToClient(TempTouchInfo.pointerInfo.ptPixelLocation);
// TFMXBufferPanel.ScreenToClient applies the scale factor. No need to call DeviceToLogical to set TempTouchEvent.
TempScale := FMXBufferPanel1.ScreenScale;
TempPoint.x := DeviceToLogical(TempTouchInfo.pointerInfo.ptPixelLocation.x, TempScale);
TempPoint.y := DeviceToLogical(TempTouchInfo.pointerInfo.ptPixelLocation.y, TempScale);
TempPoint := FMXBufferPanel1.ScreenToClient(TempPoint);
TempTouchEvent.x := TempPoint.x;
TempTouchEvent.y := TempPoint.y;

View File

@ -2,7 +2,7 @@
"UpdateLazPackages" : [
{
"ForceNotify" : true,
"InternalVersion" : 418,
"InternalVersion" : 419,
"Name" : "cef4delphi_lazarus.lpk",
"Version" : "103.0.12.0"
}