1
0
mirror of https://github.com/salvadordf/CEF4Delphi.git synced 2025-08-14 21:42:50 +02:00

Fixed issue #256

Removed non working Linux demos for now.
This commit is contained in:
Salvador Diaz Fau
2020-12-30 19:40:07 +01:00
parent e7eae21105
commit 05680d5abc
24 changed files with 970 additions and 1895 deletions

View File

@@ -1,2 +0,0 @@
rmdir /S /Q lib
rmdir /S /Q backup

View File

@@ -1,91 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<CONFIG>
<ProjectOptions>
<Version Value="11"/>
<PathDelim Value="\"/>
<General>
<Flags>
<MainUnitHasUsesSectionForAllUnits Value="False"/>
<MainUnitHasCreateFormStatements Value="False"/>
<MainUnitHasTitleStatement Value="False"/>
<MainUnitHasScaledStatement Value="False"/>
</Flags>
<SessionStorage Value="InProjectDir"/>
<MainUnit Value="0"/>
<Title Value="OSRExternalPumpBrowser"/>
<UseAppBundle Value="False"/>
<ResourceType Value="res"/>
</General>
<BuildModes Count="1">
<Item1 Name="Default" Default="True"/>
</BuildModes>
<PublishOptions>
<Version Value="2"/>
<UseFileFilters Value="True"/>
</PublishOptions>
<RunParams>
<FormatVersion Value="2"/>
<Modes Count="0"/>
</RunParams>
<RequiredPackages Count="2">
<Item1>
<PackageName Value="CEF4Delphi_Lazarus"/>
</Item1>
<Item2>
<PackageName Value="LCL"/>
</Item2>
</RequiredPackages>
<Units Count="2">
<Unit0>
<Filename Value="OSRExternalPumpBrowser.lpr"/>
<IsPartOfProject Value="True"/>
</Unit0>
<Unit1>
<Filename Value="uOSRExternalPumpBrowser.pas"/>
<IsPartOfProject Value="True"/>
<ComponentName Value="OSRExternalPumpBrowserFrm"/>
<HasResources Value="True"/>
<ResourceBaseClass Value="Form"/>
</Unit1>
</Units>
</ProjectOptions>
<CompilerOptions>
<Version Value="11"/>
<PathDelim Value="\"/>
<Target>
<Filename Value="..\..\..\bin\OSRExternalPumpBrowser"/>
</Target>
<SearchPaths>
<IncludeFiles Value="$(ProjOutDir)"/>
<UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
</SearchPaths>
<Parsing>
<SyntaxOptions>
<SyntaxMode Value="Delphi"/>
</SyntaxOptions>
</Parsing>
<Linking>
<Options>
<Win32>
<GraphicApplication Value="True"/>
</Win32>
</Options>
</Linking>
<Other>
<CustomOptions Value="-dBorland -dVer150 -dDelphi7 -dCompiler6_Up -dPUREPASCAL -dUseCthreads"/>
</Other>
</CompilerOptions>
<Debugging>
<Exceptions Count="3">
<Item1>
<Name Value="EAbort"/>
</Item1>
<Item2>
<Name Value="ECodetoolError"/>
</Item2>
<Item3>
<Name Value="EFOpenError"/>
</Item3>
</Exceptions>
</Debugging>
</CONFIG>

View File

@@ -1,78 +0,0 @@
// ************************************************************************
// ***************************** CEF4Delphi *******************************
// ************************************************************************
//
// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based
// browser in Delphi applications.
//
// The original license of DCEF3 still applies to CEF4Delphi.
//
// For more information about CEF4Delphi visit :
// https://www.briskbard.com/index.php?lang=en&pageid=cef
//
// Copyright © 2018 Salvador Díaz Fau. All rights reserved.
//
// ************************************************************************
// ************ vvvv Original license and comments below vvvv *************
// ************************************************************************
(*
* Delphi Chromium Embedded 3
*
* Usage allowed under the restrictions of the Lesser GNU General Public License
* or alternatively the restrictions of the Mozilla Public License 1.1
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
* the specific language governing rights and limitations under the License.
*
* Unit owner : Henri Gourvest <hgourvest@gmail.com>
* Web site : http://www.progdigy.com
* Repository : http://code.google.com/p/delphichromiumembedded/
* Group : http://groups.google.com/group/delphichromiumembedded
*
* Embarcadero Technologies, Inc is not permitted to use or redistribute
* this source code without explicit permission.
*
*)
program OSRExternalPumpBrowser;
{$MODE Delphi}
{$I cef.inc}
uses
{$IFDEF UNIX}{$IFDEF UseCThreads}
cthreads,
cmem,
{$ENDIF}{$ENDIF}
Interfaces, Forms,
uCEFApplication,
uCEFWorkScheduler,
uOSRExternalPumpBrowser in 'uOSRExternalPumpBrowser.pas' {OSRExternalPumpBrowserFrm};
{.$R *.res}
// CEF3 needs to set the LARGEADDRESSAWARE flag which allows 32-bit processes to use up to 3GB of RAM.
{$SetPEFlags $20}
begin
// GlobalCEFApp creation and initialization moved to a different unit to fix the memory leak described in the bug #89
// https://github.com/salvadordf/CEF4Delphi/issues/89
CreateGlobalCEFApp;
if GlobalCEFApp.StartMainProcess then
begin
Application.Initialize;
Application.CreateForm(TOSRExternalPumpBrowserFrm, OSRExternalPumpBrowserFrm);
Application.Run;
// The form needs to be destroyed *BEFORE* stopping the scheduler.
OSRExternalPumpBrowserFrm.Free;
GlobalCEFWorkScheduler.StopScheduler;
end;
DestroyGlobalCEFApp;
DestroyGlobalCEFWorkScheduler;
end.

View File

@@ -1,202 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<CONFIG>
<ProjectSession>
<PathDelim Value="\"/>
<Version Value="11"/>
<BuildModes Active="Default"/>
<Units Count="12">
<Unit0>
<Filename Value="OSRExternalPumpBrowser.lpr"/>
<IsPartOfProject Value="True"/>
<EditorIndex Value="-1"/>
<TopLine Value="39"/>
<CursorPos X="30" Y="66"/>
<UsageCount Value="28"/>
<DefaultSyntaxHighlighter Value="Delphi"/>
</Unit0>
<Unit1>
<Filename Value="uOSRExternalPumpBrowser.pas"/>
<IsPartOfProject Value="True"/>
<ComponentName Value="OSRExternalPumpBrowserFrm"/>
<HasResources Value="True"/>
<ResourceBaseClass Value="Form"/>
<IsVisibleTab Value="True"/>
<TopLine Value="67"/>
<CursorPos X="63" Y="108"/>
<UsageCount Value="28"/>
<Bookmarks Count="1">
<Item0 X="72" Y="518" ID="1"/>
</Bookmarks>
<Loaded Value="True"/>
<LoadedDesigner Value="True"/>
<DefaultSyntaxHighlighter Value="Delphi"/>
</Unit1>
<Unit2>
<Filename Value="..\..\..\source\uCEFApplication.pas"/>
<EditorIndex Value="-1"/>
<TopLine Value="412"/>
<CursorPos X="39" Y="425"/>
<UsageCount Value="11"/>
</Unit2>
<Unit3>
<Filename Value="..\..\..\source\uCEFInterfaces.pas"/>
<EditorIndex Value="-1"/>
<TopLine Value="157"/>
<CursorPos X="100" Y="168"/>
<UsageCount Value="11"/>
</Unit3>
<Unit4>
<Filename Value="C:\lazarus\lcl\lcltype.pp"/>
<UnitName Value="LCLType"/>
<EditorIndex Value="-1"/>
<TopLine Value="59"/>
<CursorPos X="32" Y="68"/>
<UsageCount Value="10"/>
<DefaultSyntaxHighlighter Value="Delphi"/>
</Unit4>
<Unit5>
<Filename Value="C:\lazarus\lcl\include\wincontrol.inc"/>
<EditorIndex Value="-1"/>
<TopLine Value="5667"/>
<CursorPos Y="5683"/>
<UsageCount Value="10"/>
<DefaultSyntaxHighlighter Value="Delphi"/>
</Unit5>
<Unit6>
<Filename Value="..\..\..\source\uCEFMediaObserver.pas"/>
<EditorIndex Value="-1"/>
<TopLine Value="266"/>
<CursorPos X="13" Y="86"/>
<UsageCount Value="10"/>
</Unit6>
<Unit7>
<Filename Value="..\..\..\source\uCEFLinkedWindowParent.pas"/>
<EditorIndex Value="-1"/>
<TopLine Value="61"/>
<UsageCount Value="10"/>
</Unit7>
<Unit8>
<Filename Value="..\..\..\source\uCEFChromiumCore.pas"/>
<EditorIndex Value="-1"/>
<TopLine Value="904"/>
<CursorPos Y="925"/>
<UsageCount Value="10"/>
</Unit8>
<Unit9>
<Filename Value="..\..\..\source\uCEFMediaObserverComponent.pas"/>
<EditorIndex Value="-1"/>
<TopLine Value="115"/>
<UsageCount Value="10"/>
</Unit9>
<Unit10>
<Filename Value="..\..\..\..\..\..\..\usr\share\fpcsrc\3.2.0\rtl\wince\windows.pp"/>
<EditorIndex Value="-1"/>
<TopLine Value="25"/>
<CursorPos X="5" Y="44"/>
<UsageCount Value="10"/>
</Unit10>
<Unit11>
<Filename Value="..\SimpleOSRBrowser\usimpleosrbrowser.pas"/>
<ComponentName Value="Form1"/>
<HasResources Value="True"/>
<ResourceBaseClass Value="Form"/>
<UnitName Value="uSimpleOSRBrowser"/>
<EditorIndex Value="-1"/>
<TopLine Value="150"/>
<CursorPos X="80" Y="175"/>
<UsageCount Value="10"/>
<DefaultSyntaxHighlighter Value="Delphi"/>
</Unit11>
</Units>
<JumpHistory Count="21" HistoryIndex="20">
<Position1>
<Filename Value="uOSRExternalPumpBrowser.pas"/>
<Caret Line="762" Column="73" TopLine="739"/>
</Position1>
<Position2>
<Filename Value="uOSRExternalPumpBrowser.pas"/>
<Caret Line="123" Column="30" TopLine="104"/>
</Position2>
<Position3>
<Filename Value="uOSRExternalPumpBrowser.pas"/>
<Caret Line="203" Column="18" TopLine="171"/>
</Position3>
<Position4>
<Filename Value="uOSRExternalPumpBrowser.pas"/>
<Caret Line="209" Column="18" TopLine="177"/>
</Position4>
<Position5>
<Filename Value="uOSRExternalPumpBrowser.pas"/>
<Caret Line="415" Column="24" TopLine="383"/>
</Position5>
<Position6>
<Filename Value="uOSRExternalPumpBrowser.pas"/>
<Caret Line="420" Column="30" TopLine="388"/>
</Position6>
<Position7>
<Filename Value="uOSRExternalPumpBrowser.pas"/>
<Caret Line="468" Column="74" TopLine="447"/>
</Position7>
<Position8>
<Filename Value="uOSRExternalPumpBrowser.pas"/>
<Caret Line="50" Column="20" TopLine="27"/>
</Position8>
<Position9>
<Filename Value="uOSRExternalPumpBrowser.pas"/>
<Caret Line="162" Column="52" TopLine="125"/>
</Position9>
<Position10>
<Filename Value="uOSRExternalPumpBrowser.pas"/>
<Caret Line="170" Column="65" TopLine="133"/>
</Position10>
<Position11>
<Filename Value="uOSRExternalPumpBrowser.pas"/>
<Caret Line="162" Column="37" TopLine="130"/>
</Position11>
<Position12>
<Filename Value="uOSRExternalPumpBrowser.pas"/>
<Caret Line="616" Column="82" TopLine="596"/>
</Position12>
<Position13>
<Filename Value="uOSRExternalPumpBrowser.pas"/>
<Caret Line="77" TopLine="58"/>
</Position13>
<Position14>
<Filename Value="uOSRExternalPumpBrowser.pas"/>
<Caret Line="668" Column="56" TopLine="651"/>
</Position14>
<Position15>
<Filename Value="uOSRExternalPumpBrowser.pas"/>
<Caret Line="127" Column="34" TopLine="109"/>
</Position15>
<Position16>
<Filename Value="uOSRExternalPumpBrowser.pas"/>
<Caret Line="595" Column="42" TopLine="573"/>
</Position16>
<Position17>
<Filename Value="uOSRExternalPumpBrowser.pas"/>
<Caret Line="115" Column="41" TopLine="100"/>
</Position17>
<Position18>
<Filename Value="uOSRExternalPumpBrowser.pas"/>
<Caret Line="641" Column="54" TopLine="614"/>
</Position18>
<Position19>
<Filename Value="uOSRExternalPumpBrowser.pas"/>
<Caret Line="121" TopLine="102"/>
</Position19>
<Position20>
<Filename Value="uOSRExternalPumpBrowser.pas"/>
<Caret Line="537" TopLine="506"/>
</Position20>
<Position21>
<Filename Value="uOSRExternalPumpBrowser.pas"/>
<Caret Line="639" Column="84" TopLine="632"/>
</Position21>
</JumpHistory>
<RunParams>
<FormatVersion Value="2"/>
<Modes Count="0" ActiveMode=""/>
</RunParams>
</ProjectSession>
</CONFIG>

View File

@@ -1,456 +0,0 @@
// ************************************************************************
// ***************************** CEF4Delphi *******************************
// ************************************************************************
//
// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based
// browser in Delphi applications.
//
// The original license of DCEF3 still applies to CEF4Delphi.
//
// For more information about CEF4Delphi visit :
// https://www.briskbard.com/index.php?lang=en&pageid=cef
//
// Copyright � 2017 Salvador Diaz Fau. All rights reserved.
//
// ************************************************************************
// ************ vvvv Original license and comments below vvvv *************
// ************************************************************************
(*
* Delphi Chromium Embedded 3
*
* Usage allowed under the restrictions of the Lesser GNU General Public License
* or alternatively the restrictions of the Mozilla Public License 1.1
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
* the specific language governing rights and limitations under the License.
*
* Unit owner : Henri Gourvest <hgourvest@gmail.com>
* Web site : http://www.progdigy.com
* Repository : http://code.google.com/p/delphichromiumembedded/
* Group : http://groups.google.com/group/delphichromiumembedded
*
* Embarcadero Technologies, Inc is not permitted to use or redistribute
* this source code without explicit permission.
*
*)
// The complete list of compiler versions is here :
// http://docwiki.embarcadero.com/RADStudio/Tokyo/en/Compiler_Versions
{$DEFINE DELPHI_VERSION_UNKNOW}
// Delphi 5
{$IFDEF VER130}
{$UNDEF DELPHI_VERSION_UNKNOW}
{$DEFINE DELPHI5_UP}
{$ENDIF}
// Delphi 6
{$IFDEF VER140}
{$UNDEF DELPHI_VERSION_UNKNOW}
{$DEFINE DELPHI5_UP}
{$DEFINE DELPHI6_UP}
{$ENDIF}
// Delphi 7
{$IFDEF VER150}
{$UNDEF DELPHI_VERSION_UNKNOW}
{$DEFINE DELPHI5_UP}
{$DEFINE DELPHI6_UP}
{$DEFINE DELPHI7_UP}
{$ENDIF}
// Delphi 8
{$IFDEF VER160}
{$UNDEF DELPHI_VERSION_UNKNOW}
{$DEFINE DELPHI5_UP}
{$DEFINE DELPHI6_UP}
{$DEFINE DELPHI7_UP}
{$DEFINE DELPHI8_UP}
{$ENDIF}
// Delphi 2005
{$IFDEF VER170}
{$UNDEF DELPHI_VERSION_UNKNOW}
{$DEFINE DELPHI5_UP}
{$DEFINE DELPHI6_UP}
{$DEFINE DELPHI7_UP}
{$DEFINE DELPHI8_UP}
{$DEFINE DELPHI9_UP}
{$ENDIF}
{$IFDEF VER180}
{$UNDEF DELPHI_VERSION_UNKNOW}
// Delphi 2007
{$IFDEF VER185}
{$DEFINE DELPHI5_UP}
{$DEFINE DELPHI6_UP}
{$DEFINE DELPHI7_UP}
{$DEFINE DELPHI8_UP}
{$DEFINE DELPHI9_UP}
{$DEFINE DELPHI10_UP}
{$DEFINE DELPHI11_UP}
// Delphi 2006
{$ELSE}
{$DEFINE DELPHI5_UP}
{$DEFINE DELPHI6_UP}
{$DEFINE DELPHI7_UP}
{$DEFINE DELPHI8_UP}
{$DEFINE DELPHI9_UP}
{$DEFINE DELPHI10_UP}
{$ENDIF}
{$ENDIF}
// Delphi 2009
{$IFDEF VER200}
{$UNDEF DELPHI_VERSION_UNKNOW}
{$DEFINE DELPHI5_UP}
{$DEFINE DELPHI6_UP}
{$DEFINE DELPHI7_UP}
{$DEFINE DELPHI8_UP}
{$DEFINE DELPHI9_UP}
{$DEFINE DELPHI10_UP}
{$DEFINE DELPHI11_UP}
{$DEFINE DELPHI12_UP}
{$ENDIF}
//Delphi 2010
{$IFDEF VER210}
{$UNDEF DELPHI_VERSION_UNKNOW}
{$DEFINE DELPHI5_UP}
{$DEFINE DELPHI6_UP}
{$DEFINE DELPHI7_UP}
{$DEFINE DELPHI8_UP}
{$DEFINE DELPHI9_UP}
{$DEFINE DELPHI10_UP}
{$DEFINE DELPHI11_UP}
{$DEFINE DELPHI12_UP}
{$DEFINE DELPHI14_UP}
{$ENDIF}
// Delphi XE
{$IFDEF VER220}
{$UNDEF DELPHI_VERSION_UNKNOW}
{$DEFINE DELPHI5_UP}
{$DEFINE DELPHI6_UP}
{$DEFINE DELPHI7_UP}
{$DEFINE DELPHI8_UP}
{$DEFINE DELPHI9_UP}
{$DEFINE DELPHI10_UP}
{$DEFINE DELPHI11_UP}
{$DEFINE DELPHI12_UP}
{$DEFINE DELPHI14_UP}
{$DEFINE DELPHI15_UP}
{$ENDIF}
// Delphi XE2 (First FireMonkey and 64bit compiler)
{$IFDEF VER230}
{$UNDEF DELPHI_VERSION_UNKNOW}
{$DEFINE DELPHI5_UP}
{$DEFINE DELPHI6_UP}
{$DEFINE DELPHI7_UP}
{$DEFINE DELPHI8_UP}
{$DEFINE DELPHI9_UP}
{$DEFINE DELPHI10_UP}
{$DEFINE DELPHI11_UP}
{$DEFINE DELPHI12_UP}
{$DEFINE DELPHI14_UP}
{$DEFINE DELPHI15_UP}
{$DEFINE DELPHI16_UP}
{$ENDIF}
// Delphi XE3
{$IFDEF VER240}
{$UNDEF DELPHI_VERSION_UNKNOW}
{$DEFINE DELPHI5_UP}
{$DEFINE DELPHI6_UP}
{$DEFINE DELPHI7_UP}
{$DEFINE DELPHI8_UP}
{$DEFINE DELPHI9_UP}
{$DEFINE DELPHI10_UP}
{$DEFINE DELPHI11_UP}
{$DEFINE DELPHI12_UP}
{$DEFINE DELPHI14_UP}
{$DEFINE DELPHI15_UP}
{$DEFINE DELPHI16_UP}
{$DEFINE DELPHI17_UP}
{$ENDIF}
// Delphi XE4
{$IFDEF VER250}
{$UNDEF DELPHI_VERSION_UNKNOW}
{$DEFINE DELPHI5_UP}
{$DEFINE DELPHI6_UP}
{$DEFINE DELPHI7_UP}
{$DEFINE DELPHI8_UP}
{$DEFINE DELPHI9_UP}
{$DEFINE DELPHI10_UP}
{$DEFINE DELPHI11_UP}
{$DEFINE DELPHI12_UP}
{$DEFINE DELPHI14_UP}
{$DEFINE DELPHI15_UP}
{$DEFINE DELPHI16_UP}
{$DEFINE DELPHI17_UP}
{$DEFINE DELPHI18_UP}
{$ENDIF}
// Delphi XE5
{$IFDEF VER260}
{$UNDEF DELPHI_VERSION_UNKNOW}
{$DEFINE DELPHI5_UP}
{$DEFINE DELPHI6_UP}
{$DEFINE DELPHI7_UP}
{$DEFINE DELPHI8_UP}
{$DEFINE DELPHI9_UP}
{$DEFINE DELPHI10_UP}
{$DEFINE DELPHI11_UP}
{$DEFINE DELPHI12_UP}
{$DEFINE DELPHI14_UP}
{$DEFINE DELPHI15_UP}
{$DEFINE DELPHI16_UP}
{$DEFINE DELPHI17_UP}
{$DEFINE DELPHI18_UP}
{$DEFINE DELPHI19_UP}
{$ENDIF}
// Delphi XE6
{$IFDEF VER270}
{$UNDEF DELPHI_VERSION_UNKNOW}
{$DEFINE DELPHI5_UP}
{$DEFINE DELPHI6_UP}
{$DEFINE DELPHI7_UP}
{$DEFINE DELPHI8_UP}
{$DEFINE DELPHI9_UP}
{$DEFINE DELPHI10_UP}
{$DEFINE DELPHI11_UP}
{$DEFINE DELPHI12_UP}
{$DEFINE DELPHI14_UP}
{$DEFINE DELPHI15_UP}
{$DEFINE DELPHI16_UP}
{$DEFINE DELPHI17_UP}
{$DEFINE DELPHI18_UP}
{$DEFINE DELPHI19_UP}
{$DEFINE DELPHI20_UP}
{$ENDIF}
// Delphi XE7
{$IFDEF VER280}
{$UNDEF DELPHI_VERSION_UNKNOW}
{$DEFINE DELPHI5_UP}
{$DEFINE DELPHI6_UP}
{$DEFINE DELPHI7_UP}
{$DEFINE DELPHI8_UP}
{$DEFINE DELPHI9_UP}
{$DEFINE DELPHI10_UP}
{$DEFINE DELPHI11_UP}
{$DEFINE DELPHI12_UP}
{$DEFINE DELPHI14_UP}
{$DEFINE DELPHI15_UP}
{$DEFINE DELPHI16_UP}
{$DEFINE DELPHI17_UP}
{$DEFINE DELPHI18_UP}
{$DEFINE DELPHI19_UP}
{$DEFINE DELPHI20_UP}
{$DEFINE DELPHI21_UP}
{$ENDIF}
// Delphi XE8
{$IFDEF VER290}
{$UNDEF DELPHI_VERSION_UNKNOW}
{$DEFINE DELPHI5_UP}
{$DEFINE DELPHI6_UP}
{$DEFINE DELPHI7_UP}
{$DEFINE DELPHI8_UP}
{$DEFINE DELPHI9_UP}
{$DEFINE DELPHI10_UP}
{$DEFINE DELPHI11_UP}
{$DEFINE DELPHI12_UP}
{$DEFINE DELPHI14_UP}
{$DEFINE DELPHI15_UP}
{$DEFINE DELPHI16_UP}
{$DEFINE DELPHI17_UP}
{$DEFINE DELPHI18_UP}
{$DEFINE DELPHI19_UP}
{$DEFINE DELPHI20_UP}
{$DEFINE DELPHI21_UP}
{$DEFINE DELPHI22_UP}
{$ENDIF VER290}
// Rad Studio 10 - Delphi Seattle
{$IFDEF VER300}
{$UNDEF DELPHI_VERSION_UNKNOW}
{$DEFINE DELPHI5_UP}
{$DEFINE DELPHI6_UP}
{$DEFINE DELPHI7_UP}
{$DEFINE DELPHI8_UP}
{$DEFINE DELPHI9_UP}
{$DEFINE DELPHI10_UP}
{$DEFINE DELPHI11_UP}
{$DEFINE DELPHI12_UP}
{$DEFINE DELPHI14_UP}
{$DEFINE DELPHI15_UP}
{$DEFINE DELPHI16_UP}
{$DEFINE DELPHI17_UP}
{$DEFINE DELPHI18_UP}
{$DEFINE DELPHI19_UP}
{$DEFINE DELPHI20_UP}
{$DEFINE DELPHI21_UP}
{$DEFINE DELPHI22_UP}
{$DEFINE DELPHI23_UP}
{$ENDIF}
// Rad Studio 10.1 - Delphi Berlin
{$IFDEF VER310}
{$UNDEF DELPHI_VERSION_UNKNOW}
{$DEFINE DELPHI5_UP}
{$DEFINE DELPHI6_UP}
{$DEFINE DELPHI7_UP}
{$DEFINE DELPHI8_UP}
{$DEFINE DELPHI9_UP}
{$DEFINE DELPHI10_UP}
{$DEFINE DELPHI11_UP}
{$DEFINE DELPHI12_UP}
{$DEFINE DELPHI14_UP}
{$DEFINE DELPHI15_UP}
{$DEFINE DELPHI16_UP}
{$DEFINE DELPHI17_UP}
{$DEFINE DELPHI18_UP}
{$DEFINE DELPHI19_UP}
{$DEFINE DELPHI20_UP}
{$DEFINE DELPHI21_UP}
{$DEFINE DELPHI22_UP}
{$DEFINE DELPHI23_UP}
{$DEFINE DELPHI24_UP}
{$ENDIF}
// Rad Studio 10.2 - Delphi Tokyo
{$IFDEF VER320}
{$UNDEF DELPHI_VERSION_UNKNOW}
{$DEFINE DELPHI5_UP}
{$DEFINE DELPHI6_UP}
{$DEFINE DELPHI7_UP}
{$DEFINE DELPHI8_UP}
{$DEFINE DELPHI9_UP}
{$DEFINE DELPHI10_UP}
{$DEFINE DELPHI11_UP}
{$DEFINE DELPHI12_UP}
{$DEFINE DELPHI14_UP}
{$DEFINE DELPHI15_UP}
{$DEFINE DELPHI16_UP}
{$DEFINE DELPHI17_UP}
{$DEFINE DELPHI18_UP}
{$DEFINE DELPHI19_UP}
{$DEFINE DELPHI20_UP}
{$DEFINE DELPHI21_UP}
{$DEFINE DELPHI22_UP}
{$DEFINE DELPHI23_UP}
{$DEFINE DELPHI24_UP}
{$DEFINE DELPHI25_UP}
{$ENDIF}
// Rad Studio 10.3 - Delphi Rio
{$IFDEF VER330}
{$UNDEF DELPHI_VERSION_UNKNOW}
{$DEFINE DELPHI5_UP}
{$DEFINE DELPHI6_UP}
{$DEFINE DELPHI7_UP}
{$DEFINE DELPHI8_UP}
{$DEFINE DELPHI9_UP}
{$DEFINE DELPHI10_UP}
{$DEFINE DELPHI11_UP}
{$DEFINE DELPHI12_UP}
{$DEFINE DELPHI14_UP}
{$DEFINE DELPHI15_UP}
{$DEFINE DELPHI16_UP}
{$DEFINE DELPHI17_UP}
{$DEFINE DELPHI18_UP}
{$DEFINE DELPHI19_UP}
{$DEFINE DELPHI20_UP}
{$DEFINE DELPHI21_UP}
{$DEFINE DELPHI22_UP}
{$DEFINE DELPHI23_UP}
{$DEFINE DELPHI24_UP}
{$DEFINE DELPHI25_UP}
{$DEFINE DELPHI26_UP}
{$ENDIF}
// Rad Studio 10.4 - Delphi Sydney
{$IFDEF VER340}
{$UNDEF DELPHI_VERSION_UNKNOW}
{$DEFINE DELPHI5_UP}
{$DEFINE DELPHI6_UP}
{$DEFINE DELPHI7_UP}
{$DEFINE DELPHI8_UP}
{$DEFINE DELPHI9_UP}
{$DEFINE DELPHI10_UP}
{$DEFINE DELPHI11_UP}
{$DEFINE DELPHI12_UP}
{$DEFINE DELPHI14_UP}
{$DEFINE DELPHI15_UP}
{$DEFINE DELPHI16_UP}
{$DEFINE DELPHI17_UP}
{$DEFINE DELPHI18_UP}
{$DEFINE DELPHI19_UP}
{$DEFINE DELPHI20_UP}
{$DEFINE DELPHI21_UP}
{$DEFINE DELPHI22_UP}
{$DEFINE DELPHI23_UP}
{$DEFINE DELPHI24_UP}
{$DEFINE DELPHI25_UP}
{$DEFINE DELPHI26_UP}
{$DEFINE DELPHI27_UP}
{$ENDIF}
{$IFDEF FPC}
{$DEFINE SUPPORTS_INLINE}
{$IF DEFINED(FPC_FULLVERSION) AND (FPC_FULLVERSION >= 30200)}
{$DEFINE FPC_VER_320}
{$IFEND}
{$ELSE}
{$IFDEF DELPHI_VERSION_UNKNOW}
{$DEFINE DELPHI5_UP}
{$DEFINE DELPHI6_UP}
{$DEFINE DELPHI7_UP}
{$DEFINE DELPHI8_UP}
{$DEFINE DELPHI9_UP}
{$DEFINE DELPHI10_UP}
{$DEFINE DELPHI11_UP}
{$DEFINE DELPHI12_UP}
{$DEFINE DELPHI14_UP}
{$DEFINE DELPHI15_UP}
{$DEFINE DELPHI16_UP}
{$DEFINE DELPHI17_UP}
{$DEFINE DELPHI18_UP}
{$DEFINE DELPHI19_UP}
{$DEFINE DELPHI20_UP}
{$DEFINE DELPHI21_UP}
{$DEFINE DELPHI22_UP}
{$DEFINE DELPHI23_UP}
{$DEFINE DELPHI24_UP}
{$DEFINE DELPHI25_UP}
{$DEFINE DELPHI26_UP}
{$DEFINE DELPHI27_UP}
{$ENDIF}
{$ENDIF}
{$IFDEF DELPHI9_UP}
{$DEFINE SUPPORTS_INLINE}
{$ENDIF}
{$IF DEFINED(CPUX32) OR
DEFINED(CPU386) OR
DEFINED(CPUi386) OR
DEFINED(CPUPOWERPC32) OR
DEFINED(CPUSPARC32) OR
DEFINED(CPU32BITS) OR
DEFINED(CPUARM32) OR
DEFINED(WIN32) OR
DEFINED(IOS32) OR
DEFINED(MACOS32) OR
DEFINED(LINUX32) OR
DEFINED(POSIX32) OR
DEFINED(ANDROID32)}
{$DEFINE TARGET_32BITS}
{$IFEND}

View File

@@ -1,143 +0,0 @@
object OSRExternalPumpBrowserFrm: TOSRExternalPumpBrowserFrm
Left = 293
Height = 584
Top = 210
Width = 913
Caption = 'Initializing browser. Please wait...'
ClientHeight = 584
ClientWidth = 913
Color = clBtnFace
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'Tahoma'
OnCloseQuery = FormCloseQuery
OnCreate = FormCreate
OnDestroy = FormDestroy
OnHide = FormHide
OnShow = FormShow
Position = poScreenCenter
LCLVersion = '2.0.10.0'
object NavControlPnl: TPanel
Left = 0
Height = 21
Top = 0
Width = 913
Align = alTop
BevelOuter = bvNone
ClientHeight = 21
ClientWidth = 913
Enabled = False
TabOrder = 0
object ComboBox1: TComboBox
Left = 0
Height = 21
Top = 0
Width = 844
Align = alClient
ItemHeight = 0
ItemIndex = 0
Items.Strings = (
'https://www.google.com'
'https://html5demos.com/drag'
'https://www.w3schools.com/tags/tryit.asp?filename=tryhtml5_select_form'
'https://www.briskbard.com'
'https://frames-per-second.appspot.com/'
'https://www.youtube.com'
)
OnEnter = ComboBox1Enter
TabOrder = 0
Text = 'https://www.google.com'
end
object Panel2: TPanel
Left = 844
Height = 21
Top = 0
Width = 69
Align = alRight
BevelOuter = bvNone
ClientHeight = 21
ClientWidth = 69
TabOrder = 1
object GoBtn: TButton
Left = 0
Height = 21
Top = 0
Width = 31
Align = alLeft
Caption = 'Go'
OnClick = GoBtnClick
OnEnter = GoBtnEnter
TabOrder = 0
end
object SnapshotBtn: TButton
Left = 38
Height = 21
Hint = 'Take snapshot'
Top = 0
Width = 31
Align = alRight
Caption = 'µ'
Font.CharSet = SYMBOL_CHARSET
Font.Color = clWindowText
Font.Height = -24
Font.Name = 'Webdings'
OnClick = SnapshotBtnClick
OnEnter = SnapshotBtnEnter
ParentFont = False
ParentShowHint = False
ShowHint = True
TabOrder = 1
end
end
end
object Panel1: TBufferPanel
Left = 0
Height = 563
Top = 21
Width = 913
Align = alClient
OnUTF8KeyPress = Panel1UTF8KeyPress
Caption = 'Panel1'
TabOrder = 1
TabStop = True
OnClick = Panel1Click
OnEnter = Panel1Enter
OnExit = Panel1Exit
OnMouseDown = Panel1MouseDown
OnMouseMove = Panel1MouseMove
OnMouseUp = Panel1MouseUp
OnMouseWheel = Panel1MouseWheel
OnKeyDown = Panel1KeyDown
OnKeyUp = Panel1KeyUp
OnResize = Panel1Resize
end
object chrmosr: TChromium
OnTooltip = chrmosrTooltip
OnCursorChange = chrmosrCursorChange
OnBeforePopup = chrmosrBeforePopup
OnAfterCreated = chrmosrAfterCreated
OnBeforeClose = chrmosrBeforeClose
OnGetViewRect = chrmosrGetViewRect
OnGetScreenPoint = chrmosrGetScreenPoint
OnGetScreenInfo = chrmosrGetScreenInfo
OnPopupShow = chrmosrPopupShow
OnPopupSize = chrmosrPopupSize
OnPaint = chrmosrPaint
Left = 24
Top = 56
end
object SaveDialog1: TSaveDialog
Title = 'Save snapshot'
DefaultExt = '.bmp'
Filter = 'Bitmap files (*.bmp)|*.BMP'
Left = 24
Top = 278
end
object Timer1: TTimer
Enabled = False
Interval = 300
OnTimer = Timer1Timer
Left = 24
Top = 206
end
end

View File

@@ -1,732 +0,0 @@
// ************************************************************************
// ***************************** CEF4Delphi *******************************
// ************************************************************************
//
// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based
// browser in Delphi applications.
//
// The original license of DCEF3 still applies to CEF4Delphi.
//
// For more information about CEF4Delphi visit :
// https://www.briskbard.com/index.php?lang=en&pageid=cef
//
// Copyright � 2020 Salvador Diaz Fau. All rights reserved.
//
// ************************************************************************
// ************ vvvv Original license and comments below vvvv *************
// ************************************************************************
(*
* Delphi Chromium Embedded 3
*
* Usage allowed under the restrictions of the Lesser GNU General Public License
* or alternatively the restrictions of the Mozilla Public License 1.1
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
* the specific language governing rights and limitations under the License.
*
* Unit owner : Henri Gourvest <hgourvest@gmail.com>
* Web site : http://www.progdigy.com
* Repository : http://code.google.com/p/delphichromiumembedded/
* Group : http://groups.google.com/group/delphichromiumembedded
*
* Embarcadero Technologies, Inc is not permitted to use or redistribute
* this source code without explicit permission.
*
*)
unit uOSRExternalPumpBrowser;
{$MODE OBJFPC}{$H+}
{$I cef.inc}
interface
uses
Classes, SysUtils, LCLType, Variants, SyncObjs, Graphics, Controls,
Forms, Dialogs, StdCtrls, ExtCtrls, Types,
uCEFChromium, uCEFTypes, uCEFInterfaces, uCEFConstants, uCEFBufferPanel,
uCEFWorkScheduler;
type
{ TOSRExternalPumpBrowserFrm }
TOSRExternalPumpBrowserFrm = class(TForm)
NavControlPnl: TPanel;
chrmosr: TChromium;
ComboBox1: TComboBox;
Panel2: TPanel;
GoBtn: TButton;
SnapshotBtn: TButton;
SaveDialog1: TSaveDialog;
Timer1: TTimer;
Panel1: TBufferPanel;
procedure GoBtnClick(Sender: TObject);
procedure GoBtnEnter(Sender: TObject);
procedure Panel1Enter(Sender: TObject);
procedure Panel1Exit(Sender: TObject);
procedure Panel1Resize(Sender: TObject);
procedure Panel1Click(Sender: TObject);
procedure Panel1MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
procedure Panel1MouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
procedure Panel1MouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
procedure Panel1MouseWheel(Sender: TObject; Shift: TShiftState; WheelDelta: Integer; MousePos: TPoint; var Handled: Boolean);
procedure Panel1KeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
procedure Panel1KeyUp(Sender: TObject; var Key: Word; Shift: TShiftState);
procedure Panel1UTF8KeyPress(Sender: TObject; var UTF8Key: TUTF8Char);
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure FormHide(Sender: TObject);
procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
procedure chrmosrPaint(Sender: TObject; const browser: ICefBrowser; kind: TCefPaintElementType; dirtyRectsCount: NativeUInt; const dirtyRects: PCefRectArray; const buffer: Pointer; aWidth, aHeight: Integer);
procedure chrmosrCursorChange(Sender: TObject; const browser: ICefBrowser; aCursor: HICON; cursorType: TCefCursorType; const customCursorInfo: PCefCursorInfo; var aResult : boolean);
procedure chrmosrGetViewRect(Sender: TObject; const browser: ICefBrowser; var rect: TCefRect);
procedure chrmosrGetScreenPoint(Sender: TObject; const browser: ICefBrowser; viewX, viewY: Integer; var screenX, screenY: Integer; out Result: Boolean);
procedure chrmosrGetScreenInfo(Sender: TObject; const browser: ICefBrowser; var screenInfo: TCefScreenInfo; out Result: Boolean);
procedure chrmosrPopupShow(Sender: TObject; const browser: ICefBrowser; aShow: Boolean);
procedure chrmosrPopupSize(Sender: TObject; const browser: ICefBrowser; const rect: PCefRect);
procedure chrmosrAfterCreated(Sender: TObject; const browser: ICefBrowser);
procedure chrmosrTooltip(Sender: TObject; const browser: ICefBrowser; var aText: ustring; out Result: Boolean);
procedure chrmosrBeforePopup(Sender: TObject; const browser: ICefBrowser; const frame: ICefFrame; const targetUrl, targetFrameName: ustring; targetDisposition: TCefWindowOpenDisposition; userGesture: Boolean; const popupFeatures: TCefPopupFeatures; var windowInfo: TCefWindowInfo; var client: ICefClient; var settings: TCefBrowserSettings; var extra_info: ICefDictionaryValue; var noJavascriptAccess: Boolean; var Result: Boolean);
procedure chrmosrBeforeClose(Sender: TObject; const browser: ICefBrowser);
procedure SnapshotBtnClick(Sender: TObject);
procedure SnapshotBtnEnter(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
procedure ComboBox1Enter(Sender: TObject);
protected
FbFirst : boolean;
FPopUpBitmap : TBitmap;
FPopUpRect : TRect;
FShowPopUp : boolean;
FResizing : boolean;
FPendingResize : boolean;
FCanClose : boolean;
FClosing : boolean;
FResizeCS : TCriticalSection;
function SendCompMessage(aMsg : cardinal) : boolean;
function getModifiers(Shift: TShiftState): TCefEventFlags;
function GetButton(Button: TMouseButton): TCefMouseButtonType;
procedure DoResize;
procedure BrowserCreated(Data: PtrInt);
procedure BrowserCloseForm(Data: PtrInt);
procedure PendingResize(Data: PtrInt);
procedure PendingInvalidate(Data: PtrInt);
public
{ Public declarations }
end;
var
OSRExternalPumpBrowserFrm : TOSRExternalPumpBrowserFrm;
// This is a simple browser in OSR mode (off-screen rendering).
// It was necessary to destroy the browser following the destruction sequence described in
// the MDIBrowser demo but in OSR mode there are some modifications.
// This is the destruction sequence in OSR mode :
// 1- FormCloseQuery sets CanClose to the initial FCanClose value (False) and calls chrmosr.CloseBrowser(True).
// 2- chrmosr.CloseBrowser(True) will trigger chrmosr.OnClose and we have to
// set "Result" to false and CEF will destroy the internal browser immediately.
// 3- chrmosr.OnBeforeClose is triggered because the internal browser was destroyed.
// FCanClose is set to True and sends WM_CLOSE to the form.
procedure CreateGlobalCEFApp;
procedure GlobalCEFApp_OnScheduleMessagePumpWork(const aDelayMS : int64);
implementation
{$R *.lfm}
uses
Math,
uCEFMiscFunctions, uCEFApplication;
procedure GlobalCEFApp_OnScheduleMessagePumpWork(const aDelayMS : int64);
begin
if (GlobalCEFWorkScheduler <> nil) then
GlobalCEFWorkScheduler.ScheduleMessagePumpWork(aDelayMS);
end;
procedure CreateGlobalCEFApp;
var
TempHome, TempBinDir : ustring;
begin
TempHome := IncludeTrailingPathDelimiter(GetEnvironmentVariable('HOME'));
TempBinDir := TempHome + 'Lazarus/CEF4Delphi/bin';
// TCEFWorkScheduler will call cef_do_message_loop_work when
// it's told in the GlobalCEFApp.OnScheduleMessagePumpWork event.
// GlobalCEFWorkScheduler needs to be created before the
// GlobalCEFApp.StartMainProcess call.
GlobalCEFWorkScheduler := TCEFWorkScheduler.Create(nil);
GlobalCEFApp := TCefApplication.Create;
GlobalCEFApp.WindowlessRenderingEnabled := True;
GlobalCEFApp.EnableHighDPISupport := True;
GlobalCEFApp.ExternalMessagePump := True;
GlobalCEFApp.MultiThreadedMessageLoop := False;
GlobalCEFApp.OnScheduleMessagePumpWork := @GlobalCEFApp_OnScheduleMessagePumpWork;
GlobalCEFApp.SetCurrentDir := True;
if DirectoryExists(TempBinDir) then
begin
GlobalCEFApp.FrameworkDirPath := TempBinDir;
GlobalCEFApp.ResourcesDirPath := TempBinDir;
GlobalCEFApp.LocalesDirPath := TempBinDir + '/locales';
end;
// Add a debug log in the BIN directory
GlobalCEFApp.LogFile := 'cef.log';
GlobalCEFApp.LogSeverity := LOGSEVERITY_VERBOSE;
end;
procedure TOSRExternalPumpBrowserFrm.GoBtnClick(Sender: TObject);
begin
FResizeCS.Acquire;
FResizing := False;
FPendingResize := False;
FResizeCS.Release;
chrmosr.LoadURL(ComboBox1.Text);
end;
procedure TOSRExternalPumpBrowserFrm.GoBtnEnter(Sender: TObject);
begin
chrmosr.SendFocusEvent(False);
end;
procedure TOSRExternalPumpBrowserFrm.chrmosrAfterCreated(Sender: TObject; const browser: ICefBrowser);
begin
SendCompMessage(CEF_AFTERCREATED);
end;
procedure TOSRExternalPumpBrowserFrm.chrmosrBeforeClose(Sender: TObject; const browser: ICefBrowser);
begin
FCanClose := True;
SendCompMessage(CEF_BEFORECLOSE);
end;
procedure TOSRExternalPumpBrowserFrm.Panel1UTF8KeyPress(Sender: TObject; var UTF8Key: TUTF8Char);
var
TempKeyEvent : TCefKeyEvent;
TempString : UnicodeString;
begin
if Panel1.Focused then
begin
TempString := UTF8Decode(UTF8Key);
if (length(TempString) > 0) then
begin
TempKeyEvent.kind := KEYEVENT_CHAR;
TempKeyEvent.modifiers := EVENTFLAG_NONE;
TempKeyEvent.windows_key_code := ord(TempString[1]);
TempKeyEvent.native_key_code := 0;
TempKeyEvent.is_system_key := ord(False);
TempKeyEvent.character := #0;
TempKeyEvent.unmodified_character := #0;
TempKeyEvent.focus_on_editable_field := ord(False);
chrmosr.SendKeyEvent(@TempKeyEvent);
end;
end;
end;
procedure TOSRExternalPumpBrowserFrm.chrmosrBeforePopup(Sender: TObject;
const browser: ICefBrowser; const frame: ICefFrame; const targetUrl,
targetFrameName: ustring; targetDisposition: TCefWindowOpenDisposition;
userGesture: Boolean; const popupFeatures: TCefPopupFeatures;
var windowInfo: TCefWindowInfo; var client: ICefClient;
var settings: TCefBrowserSettings;
var extra_info: ICefDictionaryValue;
var noJavascriptAccess: Boolean;
var Result: Boolean);
begin
// For simplicity, this demo blocks all popup windows and new tabs
Result := (targetDisposition in [WOD_NEW_FOREGROUND_TAB, WOD_NEW_BACKGROUND_TAB, WOD_NEW_POPUP, WOD_NEW_WINDOW]);
end;
procedure TOSRExternalPumpBrowserFrm.chrmosrCursorChange(Sender : TObject;
const browser : ICefBrowser;
aCursor : HICON;
cursorType : TCefCursorType;
const customCursorInfo : PCefCursorInfo;
var aResult : boolean);
begin
Panel1.Cursor := CefCursorToWindowsCursor(cursorType);
aResult := True;
end;
procedure TOSRExternalPumpBrowserFrm.chrmosrGetScreenInfo(Sender : TObject;
const browser : ICefBrowser;
var screenInfo : TCefScreenInfo;
out Result : Boolean);
var
TempRect : TCEFRect;
TempScale : single;
begin
TempScale := Panel1.ScreenScale;
TempRect.x := 0;
TempRect.y := 0;
TempRect.width := DeviceToLogical(Panel1.Width, TempScale);
TempRect.height := DeviceToLogical(Panel1.Height, TempScale);
screenInfo.device_scale_factor := TempScale;
screenInfo.depth := 0;
screenInfo.depth_per_component := 0;
screenInfo.is_monochrome := Ord(False);
screenInfo.rect := TempRect;
screenInfo.available_rect := TempRect;
Result := True;
end;
procedure TOSRExternalPumpBrowserFrm.chrmosrGetScreenPoint(Sender: TObject;
const browser: ICefBrowser; viewX, viewY: Integer; var screenX,
screenY: Integer; out Result: Boolean);
var
TempScreenPt, TempViewPt : TPoint;
TempScale : single;
begin
TempScale := Panel1.ScreenScale;
TempViewPt.x := LogicalToDevice(viewX, TempScale);
TempViewPt.y := LogicalToDevice(viewY, TempScale);
TempScreenPt := Panel1.ClientToScreen(TempViewPt);
screenX := TempScreenPt.x;
screenY := TempScreenPt.y;
Result := True;
end;
procedure TOSRExternalPumpBrowserFrm.chrmosrGetViewRect(Sender : TObject;
const browser : ICefBrowser;
var rect : TCefRect);
var
TempScale : single;
begin
TempScale := Panel1.ScreenScale;
rect.x := 0;
rect.y := 0;
rect.width := DeviceToLogical(Panel1.Width, TempScale);
rect.height := DeviceToLogical(Panel1.Height, TempScale);
end;
procedure TOSRExternalPumpBrowserFrm.chrmosrPaint(Sender: TObject; const browser: ICefBrowser;
kind: TCefPaintElementType; dirtyRectsCount: NativeUInt;
const dirtyRects: PCefRectArray; const buffer: Pointer; aWidth,
aHeight: Integer);
var
src, dst: PByte;
i, j, TempLineSize, TempSrcOffset, TempDstOffset, SrcStride : Integer;
n : NativeUInt;
TempWidth, TempHeight : integer;
TempBufferBits : Pointer;
TempForcedResize : boolean;
TempBitmap : TBitmap;
TempSrcRect : TRect;
begin
try
FResizeCS.Acquire;
TempForcedResize := False;
if Panel1.BeginBufferDraw then
begin
if (kind = PET_POPUP) then
begin
if (FPopUpBitmap = nil) or
(aWidth <> FPopUpBitmap.Width) or
(aHeight <> FPopUpBitmap.Height) then
begin
if (FPopUpBitmap <> nil) then FPopUpBitmap.Free;
FPopUpBitmap := TBitmap.Create;
FPopUpBitmap.PixelFormat := pf32bit;
FPopUpBitmap.HandleType := bmDIB;
FPopUpBitmap.Width := aWidth;
FPopUpBitmap.Height := aHeight;
end;
TempBitmap := FPopUpBitmap;
TempBitmap.BeginUpdate;
TempWidth := FPopUpBitmap.Width;
TempHeight := FPopUpBitmap.Height;
end
else
begin
TempForcedResize := Panel1.UpdateBufferDimensions(aWidth, aHeight) or not(Panel1.BufferIsResized(False));
TempBitmap := Panel1.Buffer;
TempBitmap.BeginUpdate;
TempWidth := Panel1.BufferWidth;
TempHeight := Panel1.BufferHeight;
end;
SrcStride := aWidth * SizeOf(TRGBQuad);
n := 0;
while (n < dirtyRectsCount) do
begin
if (dirtyRects^[n].x >= 0) and (dirtyRects^[n].y >= 0) then
begin
TempLineSize := min(dirtyRects^[n].width, TempWidth - dirtyRects^[n].x) * SizeOf(TRGBQuad);
if (TempLineSize > 0) then
begin
TempSrcOffset := ((dirtyRects^[n].y * aWidth) + dirtyRects^[n].x) * SizeOf(TRGBQuad);
TempDstOffset := (dirtyRects^[n].x * SizeOf(TRGBQuad));
src := @PByte(buffer)[TempSrcOffset];
i := 0;
j := min(dirtyRects^[n].height, TempHeight - dirtyRects^[n].y);
while (i < j) do
begin
TempBufferBits := TempBitmap.Scanline[dirtyRects^[n].y + i];
dst := @PByte(TempBufferBits)[TempDstOffset];
Move(src^, dst^, TempLineSize);
Inc(src, SrcStride);
inc(i);
end;
end;
end;
inc(n);
end;
TempBitmap.EndUpdate;
if FShowPopup and (FPopUpBitmap <> nil) then
begin
TempSrcRect := Rect(0, 0,
min(FPopUpRect.Right - FPopUpRect.Left, FPopUpBitmap.Width),
min(FPopUpRect.Bottom - FPopUpRect.Top, FPopUpBitmap.Height));
Panel1.BufferDraw(FPopUpBitmap, TempSrcRect, FPopUpRect);
end;
Panel1.EndBufferDraw;
SendCompMessage(CEF_PENDINGINVALIDATE);
if (kind = PET_VIEW) then
begin
if TempForcedResize or FPendingResize then
SendCompMessage(CEF_PENDINGRESIZE);
FResizing := False;
FPendingResize := False;
end;
end;
finally
FResizeCS.Release;
end;
end;
procedure TOSRExternalPumpBrowserFrm.chrmosrPopupShow(Sender : TObject;
const browser : ICefBrowser;
aShow : Boolean);
begin
if aShow then
FShowPopUp := True
else
begin
FShowPopUp := False;
FPopUpRect := rect(0, 0, 0, 0);
if (chrmosr <> nil) then chrmosr.Invalidate(PET_VIEW);
end;
end;
procedure TOSRExternalPumpBrowserFrm.chrmosrPopupSize(Sender : TObject;
const browser : ICefBrowser;
const rect : PCefRect);
begin
LogicalToDevice(rect^, Panel1.ScreenScale);
FPopUpRect.Left := rect^.x;
FPopUpRect.Top := rect^.y;
FPopUpRect.Right := rect^.x + rect^.width - 1;
FPopUpRect.Bottom := rect^.y + rect^.height - 1;
end;
procedure TOSRExternalPumpBrowserFrm.chrmosrTooltip(Sender: TObject; const browser: ICefBrowser; var aText: ustring; out Result: Boolean);
begin
Panel1.hint := aText;
Panel1.ShowHint := (length(aText) > 0);
Result := True;
end;
procedure TOSRExternalPumpBrowserFrm.ComboBox1Enter(Sender: TObject);
begin
chrmosr.SendFocusEvent(False);
end;
function TOSRExternalPumpBrowserFrm.SendCompMessage(aMsg : cardinal) : boolean;
begin
case aMsg of
CEF_AFTERCREATED : Application.QueueAsyncCall(@BrowserCreated, 0);
CEF_BEFORECLOSE : Application.QueueAsyncCall(@BrowserCloseForm, 0);
CEF_PENDINGRESIZE : Application.QueueAsyncCall(@PendingResize, 0);
CEF_PENDINGINVALIDATE : Application.QueueAsyncCall(@PendingInvalidate, 0);
end;
end;
function TOSRExternalPumpBrowserFrm.getModifiers(Shift: TShiftState): TCefEventFlags;
begin
Result := EVENTFLAG_NONE;
if (ssShift in Shift) then Result := Result or EVENTFLAG_SHIFT_DOWN;
if (ssAlt in Shift) then Result := Result or EVENTFLAG_ALT_DOWN;
if (ssCtrl in Shift) then Result := Result or EVENTFLAG_CONTROL_DOWN;
if (ssLeft in Shift) then Result := Result or EVENTFLAG_LEFT_MOUSE_BUTTON;
if (ssRight in Shift) then Result := Result or EVENTFLAG_RIGHT_MOUSE_BUTTON;
if (ssMiddle in Shift) then Result := Result or EVENTFLAG_MIDDLE_MOUSE_BUTTON;
end;
function TOSRExternalPumpBrowserFrm.GetButton(Button: TMouseButton): TCefMouseButtonType;
begin
case Button of
TMouseButton.mbRight : Result := MBT_RIGHT;
TMouseButton.mbMiddle : Result := MBT_MIDDLE;
else Result := MBT_LEFT;
end;
end;
procedure TOSRExternalPumpBrowserFrm.BrowserCreated(Data: PtrInt);
begin
Caption := 'Simple Lazarus OSR Browser';
NavControlPnl.Enabled := True;
end;
procedure TOSRExternalPumpBrowserFrm.BrowserCloseForm(Data: PtrInt);
begin
Close;
end;
procedure TOSRExternalPumpBrowserFrm.PendingResize(Data: PtrInt);
begin
DoResize;
end;
procedure TOSRExternalPumpBrowserFrm.PendingInvalidate(Data: PtrInt);
begin
Panel1.Invalidate;
end;
procedure TOSRExternalPumpBrowserFrm.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
begin
CanClose := FCanClose;
if not(FClosing) then
begin
FClosing := True;
Visible := False;
chrmosr.CloseBrowser(True);
end;
end;
procedure TOSRExternalPumpBrowserFrm.FormCreate(Sender: TObject);
begin
FbFirst := False;
FPopUpBitmap := nil;
FPopUpRect := rect(0, 0, 0, 0);
FShowPopUp := False;
FResizing := False;
FPendingResize := False;
FCanClose := False;
FClosing := False;
FResizeCS := TCriticalSection.Create;
end;
procedure TOSRExternalPumpBrowserFrm.FormDestroy(Sender: TObject);
begin
if (FPopUpBitmap <> nil) then FreeAndNil(FPopUpBitmap);
if (FResizeCS <> nil) then FreeAndNil(FResizeCS);
end;
procedure TOSRExternalPumpBrowserFrm.FormHide(Sender: TObject);
begin
chrmosr.SendFocusEvent(False);
chrmosr.WasHidden(True);
end;
procedure TOSRExternalPumpBrowserFrm.FormShow(Sender: TObject);
begin
if chrmosr.Initialized then
begin
chrmosr.WasHidden(False);
chrmosr.SendFocusEvent(True);
end
else
begin
// opaque white background color
chrmosr.Options.BackgroundColor := CefColorSetARGB($FF, $FF, $FF, $FF);
chrmosr.DefaultURL := ComboBox1.Text;
if not(chrmosr.CreateBrowser(nil, '')) then
Timer1.Enabled := True;
end;
end;
procedure TOSRExternalPumpBrowserFrm.Panel1Click(Sender: TObject);
begin
Panel1.SetFocus;
end;
procedure TOSRExternalPumpBrowserFrm.Panel1MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
var
TempEvent : TCefMouseEvent;
begin
Panel1.SetFocus;
TempEvent.x := X;
TempEvent.y := Y;
TempEvent.modifiers := getModifiers(Shift);
DeviceToLogical(TempEvent, Panel1.ScreenScale);
chrmosr.SendMouseClickEvent(@TempEvent, GetButton(Button), False, 1);
end;
procedure TOSRExternalPumpBrowserFrm.Panel1MouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
var
TempEvent : TCefMouseEvent;
begin
TempEvent.x := x;
TempEvent.y := y;
TempEvent.modifiers := getModifiers(Shift);
DeviceToLogical(TempEvent, Panel1.ScreenScale);
chrmosr.SendMouseMoveEvent(@TempEvent, False);
end;
procedure TOSRExternalPumpBrowserFrm.Panel1MouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
var
TempEvent : TCefMouseEvent;
begin
TempEvent.x := X;
TempEvent.y := Y;
TempEvent.modifiers := getModifiers(Shift);
DeviceToLogical(TempEvent, Panel1.ScreenScale);
chrmosr.SendMouseClickEvent(@TempEvent, GetButton(Button), True, 1);
end;
procedure TOSRExternalPumpBrowserFrm.Panel1Resize(Sender: TObject);
begin
DoResize;
end;
procedure TOSRExternalPumpBrowserFrm.DoResize;
begin
try
FResizeCS.Acquire;
if FResizing then
FPendingResize := True
else
if Panel1.BufferIsResized then
chrmosr.Invalidate(PET_VIEW)
else
begin
FResizing := True;
chrmosr.WasResized;
end;
finally
FResizeCS.Release;
end;
end;
procedure TOSRExternalPumpBrowserFrm.Panel1Enter(Sender: TObject);
begin
chrmosr.SendFocusEvent(True);
end;
procedure TOSRExternalPumpBrowserFrm.Panel1Exit(Sender: TObject);
begin
chrmosr.SendFocusEvent(False);
end;
procedure TOSRExternalPumpBrowserFrm.Panel1KeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
var
TempKeyEvent : TCefKeyEvent;
begin
if (Key <> 0) and (chrmosr <> nil) then
begin
TempKeyEvent.kind := KEYEVENT_RAWKEYDOWN;
TempKeyEvent.modifiers := getModifiers(Shift);
TempKeyEvent.windows_key_code := Key;
TempKeyEvent.native_key_code := 0;
TempKeyEvent.is_system_key := ord(False);
TempKeyEvent.character := #0;
TempKeyEvent.unmodified_character := #0;
TempKeyEvent.focus_on_editable_field := ord(False);
chrmosr.SendKeyEvent(@TempKeyEvent);
if (Key in [VK_LEFT, VK_RIGHT, VK_UP, VK_DOWN, VK_TAB]) then Key := 0;
end;
end;
procedure TOSRExternalPumpBrowserFrm.Panel1KeyUp(Sender: TObject; var Key: Word; Shift: TShiftState);
var
TempKeyEvent : TCefKeyEvent;
begin
if (Key <> 0) and (chrmosr <> nil) then
begin
TempKeyEvent.kind := KEYEVENT_KEYUP;
TempKeyEvent.modifiers := getModifiers(Shift);
TempKeyEvent.windows_key_code := Key;
TempKeyEvent.native_key_code := 0;
TempKeyEvent.is_system_key := ord(False);
TempKeyEvent.character := #0;
TempKeyEvent.unmodified_character := #0;
TempKeyEvent.focus_on_editable_field := ord(False);
chrmosr.SendKeyEvent(@TempKeyEvent);
end;
end;
procedure TOSRExternalPumpBrowserFrm.Panel1MouseWheel(Sender: TObject; Shift: TShiftState;
WheelDelta: Integer; MousePos: TPoint; var Handled: Boolean);
var
TempEvent : TCefMouseEvent;
begin
TempEvent.x := MousePos.x;
TempEvent.y := MousePos.y;
TempEvent.modifiers := getModifiers(Shift);
DeviceToLogical(TempEvent, Panel1.ScreenScale);
chrmosr.SendMouseWheelEvent(@TempEvent, 0, WheelDelta);
end;
procedure TOSRExternalPumpBrowserFrm.SnapshotBtnClick(Sender: TObject);
begin
if SaveDialog1.Execute then Panel1.SaveToFile(SaveDialog1.FileName);
end;
procedure TOSRExternalPumpBrowserFrm.SnapshotBtnEnter(Sender: TObject);
begin
chrmosr.SendFocusEvent(False);
end;
procedure TOSRExternalPumpBrowserFrm.Timer1Timer(Sender: TObject);
begin
Timer1.Enabled := False;
if not(chrmosr.CreateBrowser(nil, '')) and
not(chrmosr.Initialized) then
Timer1.Enabled := True;
end;
end.

View File

@@ -33,7 +33,7 @@
<PackageName Value="LCL"/>
</Item2>
</RequiredPackages>
<Units Count="2">
<Units Count="3">
<Unit0>
<Filename Value="SimpleBrowser2.lpr"/>
<IsPartOfProject Value="True"/>
@@ -46,6 +46,11 @@
<ResourceBaseClass Value="Form"/>
<UnitName Value="uSimpleBrowser2"/>
</Unit1>
<Unit2>
<Filename Value="interfaces.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="Interfaces"/>
</Unit2>
</Units>
</ProjectOptions>
<CompilerOptions>

View File

@@ -42,8 +42,9 @@ program SimpleBrowser2;
uses
{$IFDEF UNIX}{$IFDEF UseCThreads}
cthreads,
cmem,
{$ENDIF}{$ENDIF}
{$ENDIF}{$ENDIF}
// "Interfaces" is a custom unit used to initialize the LCL WidgetSet
// We keep the same name to avoid a Lazarus warning.
Interfaces, // this includes the LCL widgetset
Forms, uSimpleBrowser2,
{ you can add units after this }
@@ -56,11 +57,15 @@ begin
if GlobalCEFApp.StartMainProcess then
begin
// The LCL Widgetset must be initialized after the CEF initialization and
// only in the browser process.
CustomWidgetSetInitialization;
RequireDerivedFormResource:=True;
Application.Scaled:=True;
Application.Initialize;
Application.CreateForm(TForm1, Form1);
Application.Run;
Application.Run;
CustomWidgetSetFinalization;
end;
DestroyGlobalCEFApp;

View File

@@ -3,15 +3,14 @@
<ProjectSession>
<Version Value="11"/>
<BuildModes Active="Default"/>
<Units Count="11">
<Units Count="55">
<Unit0>
<Filename Value="SimpleBrowser2.lpr"/>
<IsPartOfProject Value="True"/>
<EditorIndex Value="1"/>
<TopLine Value="27"/>
<CursorPos X="49" Y="58"/>
<UsageCount Value="22"/>
<Loaded Value="True"/>
<EditorIndex Value="-1"/>
<TopLine Value="18"/>
<CursorPos X="74" Y="42"/>
<UsageCount Value="44"/>
</Unit0>
<Unit1>
<Filename Value="usimplebrowser2.pas"/>
@@ -20,138 +19,522 @@
<HasResources Value="True"/>
<ResourceBaseClass Value="Form"/>
<UnitName Value="uSimpleBrowser2"/>
<IsVisibleTab Value="True"/>
<TopLine Value="122"/>
<CursorPos X="66" Y="149"/>
<UsageCount Value="22"/>
<CursorPos X="80" Y="223"/>
<UsageCount Value="44"/>
<Bookmarks Count="1">
<Item0 Y="250" ID="3"/>
</Bookmarks>
<Loaded Value="True"/>
<LoadedDesigner Value="True"/>
</Unit1>
<Unit2>
<Filename Value="interfaces.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="Interfaces"/>
<EditorIndex Value="-1"/>
<UsageCount Value="42"/>
</Unit2>
<Unit3>
<Filename Value="../../../../source/uCEFConstants.pas"/>
<EditorIndex Value="-1"/>
<TopLine Value="571"/>
<CursorPos X="66" Y="597"/>
<UsageCount Value="10"/>
</Unit2>
<Unit3>
<UsageCount Value="9"/>
</Unit3>
<Unit4>
<Filename Value="../../../../source/uCEFApplicationCore.pas"/>
<EditorIndex Value="-1"/>
<TopLine Value="891"/>
<CursorPos X="63" Y="1021"/>
<UsageCount Value="10"/>
</Unit3>
<Unit4>
<UsageCount Value="9"/>
</Unit4>
<Unit5>
<Filename Value="/usr/share/lazarus/2.0.6/lcl/lclrescache.pas"/>
<UnitName Value="LCLResCache"/>
<EditorIndex Value="-1"/>
<TopLine Value="379"/>
<CursorPos Y="398"/>
<UsageCount Value="10"/>
</Unit4>
<Unit5>
<UsageCount Value="9"/>
</Unit5>
<Unit6>
<Filename Value="../../../../source/uCEFMiscFunctions.pas"/>
<EditorIndex Value="-1"/>
<TopLine Value="1025"/>
<CursorPos X="80" Y="1040"/>
<UsageCount Value="10"/>
</Unit5>
<Unit6>
<UsageCount Value="9"/>
</Unit6>
<Unit7>
<Filename Value="/usr/share/lazarus/2.0.6/lcl/include/application.inc"/>
<EditorIndex Value="-1"/>
<TopLine Value="1019"/>
<CursorPos X="127" Y="1047"/>
<UsageCount Value="10"/>
</Unit6>
<Unit7>
<UsageCount Value="9"/>
</Unit7>
<Unit8>
<Filename Value="../../../../source/uCEFChromium.pas"/>
<EditorIndex Value="-1"/>
<TopLine Value="284"/>
<CursorPos Y="312"/>
<UsageCount Value="10"/>
</Unit7>
<Unit8>
<UsageCount Value="9"/>
</Unit8>
<Unit9>
<Filename Value="../../../../source/uCEFChromiumCore.pas"/>
<EditorIndex Value="-1"/>
<TopLine Value="4369"/>
<CursorPos X="40" Y="4378"/>
<UsageCount Value="10"/>
</Unit8>
<Unit9>
<UsageCount Value="9"/>
</Unit9>
<Unit10>
<Filename Value="/usr/share/fpcsrc/3.0.4/rtl/objpas/classes/classesh.inc"/>
<EditorIndex Value="-1"/>
<TopLine Value="1556"/>
<CursorPos X="3" Y="1573"/>
<UsageCount Value="10"/>
</Unit9>
<Unit10>
<UsageCount Value="9"/>
</Unit10>
<Unit11>
<Filename Value="/usr/share/fpcsrc/3.0.4/rtl/objpas/sysutils/osutilsh.inc"/>
<EditorIndex Value="-1"/>
<CursorPos X="10" Y="26"/>
<UsageCount Value="9"/>
</Unit11>
<Unit12>
<Filename Value="../../../source/uCEFWindowParent.pas"/>
<EditorIndex Value="-1"/>
<TopLine Value="41"/>
<CursorPos X="49" Y="86"/>
<UsageCount Value="13"/>
</Unit12>
<Unit13>
<Filename Value="../../../source/uCEFWinControl.pas"/>
<EditorIndex Value="2"/>
<TopLine Value="51"/>
<CursorPos X="29" Y="73"/>
<UsageCount Value="19"/>
<Loaded Value="True"/>
</Unit13>
<Unit14>
<Filename Value="/usr/share/lazarus/2.0.10/lcl/include/winapih.inc"/>
<EditorIndex Value="-1"/>
<TopLine Value="195"/>
<CursorPos X="10" Y="222"/>
<UsageCount Value="9"/>
</Unit14>
<Unit15>
<Filename Value="../../../../fpCEF3/cef3types.pas"/>
<EditorIndex Value="-1"/>
<UsageCount Value="9"/>
</Unit15>
<Unit16>
<Filename Value="../../../../fpCEF3/Component/cef3lcl.pas"/>
<EditorIndex Value="-1"/>
<TopLine Value="744"/>
<CursorPos X="62" Y="784"/>
<UsageCount Value="11"/>
</Unit16>
<Unit17>
<Filename Value="../../../source/uCEFChromium.pas"/>
<EditorIndex Value="-1"/>
<TopLine Value="48"/>
<CursorPos X="3" Y="66"/>
<UsageCount Value="14"/>
</Unit17>
<Unit18>
<Filename Value="../../../source/uCEFChromiumCore.pas"/>
<IsVisibleTab Value="True"/>
<EditorIndex Value="3"/>
<TopLine Value="2524"/>
<CursorPos X="59" Y="2566"/>
<UsageCount Value="20"/>
<Bookmarks Count="2">
<Item0 Y="2564" ID="1"/>
<Item1 Y="4727" ID="2"/>
</Bookmarks>
<Loaded Value="True"/>
</Unit18>
<Unit19>
<Filename Value="../../../source/uCEFTypes.pas"/>
<EditorIndex Value="-1"/>
<TopLine Value="397"/>
<CursorPos X="18" Y="414"/>
<UsageCount Value="10"/>
</Unit10>
</Unit19>
<Unit20>
<Filename Value="../../../source/uCEFMiscFunctions.pas"/>
<EditorIndex Value="-1"/>
<TopLine Value="507"/>
<CursorPos X="3" Y="509"/>
<UsageCount Value="13"/>
</Unit20>
<Unit21>
<Filename Value="/usr/share/lazarus/2.0.10/lcl/controls.pp"/>
<UnitName Value="Controls"/>
<EditorIndex Value="-1"/>
<TopLine Value="1958"/>
<CursorPos X="3" Y="1981"/>
<UsageCount Value="14"/>
</Unit21>
<Unit22>
<Filename Value="/usr/share/lazarus/2.0.10/lcl/lcltype.pp"/>
<UnitName Value="LCLType"/>
<EditorIndex Value="-1"/>
<TopLine Value="79"/>
<CursorPos X="22" Y="89"/>
<UsageCount Value="9"/>
</Unit22>
<Unit23>
<Filename Value="/usr/share/fpcsrc/3.2.0/rtl/inc/systemh.inc"/>
<EditorIndex Value="-1"/>
<TopLine Value="312"/>
<CursorPos X="3" Y="339"/>
<UsageCount Value="9"/>
</Unit23>
<Unit24>
<Filename Value="/usr/share/fpcsrc/3.2.0/rtl/unix/aliasctp.inc"/>
<EditorIndex Value="-1"/>
<CursorPos X="3" Y="49"/>
<UsageCount Value="9"/>
</Unit24>
<Unit25>
<Filename Value="/usr/share/fpcsrc/3.2.0/rtl/unix/ctypes.inc"/>
<EditorIndex Value="-1"/>
<TopLine Value="13"/>
<CursorPos X="3" Y="55"/>
<UsageCount Value="9"/>
</Unit25>
<Unit26>
<Filename Value="/usr/share/fpcsrc/3.2.0/packages/gtk2/src/gtk+/gtk/gtkwidget.inc"/>
<EditorIndex Value="-1"/>
<TopLine Value="69"/>
<CursorPos X="4" Y="96"/>
<UsageCount Value="10"/>
</Unit26>
<Unit27>
<Filename Value="/usr/share/lazarus/2.0.10/lcl/interfaces/gtk2/gtk2def.pp"/>
<UnitName Value="Gtk2Def"/>
<EditorIndex Value="-1"/>
<UsageCount Value="9"/>
</Unit27>
<Unit28>
<Filename Value="/usr/share/fpcsrc/3.2.0/packages/gtk2/src/gtk2x11/gdk2x.pas"/>
<EditorIndex Value="-1"/>
<UsageCount Value="9"/>
</Unit28>
<Unit29>
<Filename Value="/usr/share/lazarus/2.0.10/lcl/interfaces/gtk2/gtk2extrah.inc"/>
<EditorIndex Value="-1"/>
<TopLine Value="32"/>
<CursorPos X="10" Y="59"/>
<UsageCount Value="10"/>
</Unit29>
<Unit30>
<Filename Value="/usr/share/lazarus/2.0.10/lcl/include/wincontrol.inc"/>
<EditorIndex Value="-1"/>
<TopLine Value="7104"/>
<CursorPos X="3" Y="7117"/>
<UsageCount Value="13"/>
</Unit30>
<Unit31>
<Filename Value="../../../source/uCEFLinkedWindowParent.pas"/>
<EditorIndex Value="1"/>
<TopLine Value="51"/>
<CursorPos X="91" Y="87"/>
<UsageCount Value="18"/>
<Loaded Value="True"/>
</Unit31>
<Unit32>
<Filename Value="../../../../fpCEF3/cef3lib.pas"/>
<EditorIndex Value="-1"/>
<TopLine Value="1101"/>
<CursorPos X="5" Y="1137"/>
<UsageCount Value="16"/>
</Unit32>
<Unit33>
<Filename Value="/usr/share/fpcsrc/3.2.0/packages/x11/src/xlib.pp"/>
<EditorIndex Value="-1"/>
<TopLine Value="1445"/>
<CursorPos X="10" Y="1467"/>
<UsageCount Value="10"/>
</Unit33>
<Unit34>
<Filename Value="../../../source/uCEFLibFunctions.pas"/>
<EditorIndex Value="-1"/>
<TopLine Value="300"/>
<CursorPos X="107" Y="315"/>
<UsageCount Value="9"/>
</Unit34>
<Unit35>
<Filename Value="../../../source/uCEFApplicationCore.pas"/>
<EditorIndex Value="-1"/>
<TopLine Value="2222"/>
<CursorPos X="3" Y="2227"/>
<UsageCount Value="9"/>
</Unit35>
<Unit36>
<Filename Value="../../../source/uCEFApplication.pas"/>
<EditorIndex Value="-1"/>
<TopLine Value="31"/>
<CursorPos X="21" Y="38"/>
<UsageCount Value="9"/>
</Unit36>
<Unit37>
<Filename Value="../../../source/uCEFInterfaces.pas"/>
<EditorIndex Value="-1"/>
<TopLine Value="441"/>
<CursorPos Y="484"/>
<UsageCount Value="16"/>
</Unit37>
<Unit38>
<Filename Value="../../../source/uCEFTask.pas"/>
<EditorIndex Value="-1"/>
<TopLine Value="777"/>
<CursorPos X="3" Y="794"/>
<UsageCount Value="15"/>
</Unit38>
<Unit39>
<Filename Value="../../../source/uCEFChromiumWindow.pas"/>
<EditorIndex Value="-1"/>
<TopLine Value="61"/>
<CursorPos X="47" Y="88"/>
<UsageCount Value="14"/>
</Unit39>
<Unit40>
<Filename Value="../../../../../Vídeos/4280/tests/cefclient/browser/root_window_gtk.cc"/>
<EditorIndex Value="-1"/>
<TopLine Value="516"/>
<CursorPos X="39" Y="551"/>
<UsageCount Value="15"/>
<Bookmarks Count="1">
<Item0 X="58" Y="524" ID="3"/>
</Bookmarks>
<DefaultSyntaxHighlighter Value="C++"/>
</Unit40>
<Unit41>
<Filename Value="../SimpleOSRBrowser/usimpleosrbrowser.pas"/>
<UnitName Value="uSimpleOSRBrowser"/>
<EditorIndex Value="-1"/>
<TopLine Value="242"/>
<CursorPos X="82" Y="277"/>
<UsageCount Value="15"/>
</Unit41>
<Unit42>
<Filename Value="/usr/share/lazarus/2.0.10/lcl/include/control.inc"/>
<EditorIndex Value="-1"/>
<TopLine Value="5777"/>
<CursorPos X="3" Y="5787"/>
<UsageCount Value="14"/>
</Unit42>
<Unit43>
<Filename Value="/usr/share/lazarus/2.0.10/components/lazutils/lazmethodlist.pas"/>
<UnitName Value="LazMethodList"/>
<EditorIndex Value="-1"/>
<TopLine Value="15"/>
<CursorPos X="15" Y="57"/>
<UsageCount Value="10"/>
</Unit43>
<Unit44>
<Filename Value="/usr/share/fpcsrc/3.2.0/packages/opengles/examples/es2example1.pas"/>
<EditorIndex Value="-1"/>
<TopLine Value="156"/>
<CursorPos X="75" Y="192"/>
<UsageCount Value="10"/>
</Unit44>
<Unit45>
<Filename Value="/usr/share/fpcsrc/3.2.0/packages/x11/src/x.pp"/>
<EditorIndex Value="-1"/>
<TopLine Value="266"/>
<CursorPos X="4" Y="293"/>
<UsageCount Value="9"/>
</Unit45>
<Unit46>
<Filename Value="/usr/share/fpcsrc/3.2.0/packages/x11/src/xatom.pp"/>
<EditorIndex Value="-1"/>
<CursorPos X="9" Y="18"/>
<UsageCount Value="9"/>
</Unit46>
<Unit47>
<Filename Value="/usr/share/fpcsrc/3.2.0/packages/fpgtk/src/fpgtk.pp"/>
<UnitName Value="FPgtk"/>
<EditorIndex Value="-1"/>
<TopLine Value="4153"/>
<CursorPos X="140" Y="4167"/>
<UsageCount Value="13"/>
</Unit47>
<Unit48>
<Filename Value="/usr/share/lazarus/2.0.10/lcl/interfaces/gtk2/gtk2widgetset.inc"/>
<EditorIndex Value="-1"/>
<TopLine Value="412"/>
<CursorPos X="181" Y="435"/>
<UsageCount Value="13"/>
</Unit48>
<Unit49>
<Filename Value="/usr/share/lazarus/2.0.10/lcl/interfaces/gtk2/gtk2proc.pp"/>
<UnitName Value="Gtk2Proc"/>
<EditorIndex Value="-1"/>
<TopLine Value="150"/>
<CursorPos X="10" Y="177"/>
<UsageCount Value="13"/>
</Unit49>
<Unit50>
<Filename Value="/usr/share/lazarus/2.0.10/lcl/interfaces/gtk2/gtk2callback.inc"/>
<EditorIndex Value="-1"/>
<TopLine Value="2433"/>
<CursorPos X="38" Y="2476"/>
<UsageCount Value="13"/>
</Unit50>
<Unit51>
<Filename Value="/usr/share/lazarus/2.0.10/lcl/interfaces/gtk2/gtk2proc.inc"/>
<EditorIndex Value="-1"/>
<TopLine Value="6707"/>
<CursorPos X="66" Y="6724"/>
<UsageCount Value="13"/>
<Bookmarks Count="1">
<Item0 X="66" Y="6724" ID="1"/>
</Bookmarks>
</Unit51>
<Unit52>
<Filename Value="/usr/share/lazarus/2.0.10/lcl/forms.pp"/>
<UnitName Value="Forms"/>
<EditorIndex Value="-1"/>
<TopLine Value="511"/>
<CursorPos X="24" Y="538"/>
<UsageCount Value="13"/>
</Unit52>
<Unit53>
<Filename Value="/usr/share/lazarus/2.0.10/lcl/include/customform.inc"/>
<EditorIndex Value="-1"/>
<TopLine Value="753"/>
<CursorPos X="3" Y="761"/>
<UsageCount Value="13"/>
</Unit53>
<Unit54>
<Filename Value="/usr/share/lazarus/2.0.10/lcl/include/application.inc"/>
<EditorIndex Value="-1"/>
<TopLine Value="2267"/>
<CursorPos Y="2285"/>
<UsageCount Value="10"/>
</Unit54>
</Units>
<JumpHistory Count="15" HistoryIndex="14">
<JumpHistory Count="30" HistoryIndex="29">
<Position1>
<Filename Value="usimplebrowser2.pas"/>
<Caret Line="211" Column="39" TopLine="201"/>
<Caret Line="212" TopLine="190"/>
</Position1>
<Position2>
<Filename Value="usimplebrowser2.pas"/>
<Caret Line="211" Column="7" TopLine="194"/>
<Caret Line="218" TopLine="190"/>
</Position2>
<Position3>
<Filename Value="usimplebrowser2.pas"/>
<Caret Line="216" Column="44" TopLine="194"/>
<Filename Value="../../../source/uCEFChromiumCore.pas"/>
<Caret Line="4735" Column="59" TopLine="4717"/>
</Position3>
<Position4>
<Filename Value="usimplebrowser2.pas"/>
<Caret Line="91" Column="15" TopLine="67"/>
<Filename Value="../../../source/uCEFChromiumCore.pas"/>
<Caret Line="649" TopLine="627"/>
</Position4>
<Position5>
<Filename Value="usimplebrowser2.pas"/>
<Caret Line="212" Column="32" TopLine="195"/>
<Filename Value="../../../source/uCEFChromiumCore.pas"/>
<Caret Line="2566" Column="39" TopLine="2552"/>
</Position5>
<Position6>
<Filename Value="usimplebrowser2.pas"/>
<Caret Line="212" Column="22" TopLine="195"/>
<Filename Value="../../../source/uCEFChromiumCore.pas"/>
<Caret Line="4764" Column="55" TopLine="4730"/>
</Position6>
<Position7>
<Filename Value="usimplebrowser2.pas"/>
<Caret Line="88" Column="15" TopLine="72"/>
<Filename Value="../../../source/uCEFChromiumCore.pas"/>
<Caret Line="818" TopLine="798"/>
</Position7>
<Position8>
<Filename Value="usimplebrowser2.pas"/>
<Caret Line="137" Column="3" TopLine="132"/>
<Filename Value="../../../source/uCEFChromiumCore.pas"/>
<Caret Line="4759" Column="5" TopLine="4733"/>
</Position8>
<Position9>
<Filename Value="usimplebrowser2.pas"/>
<Caret Line="136" TopLine="117"/>
<Filename Value="../../../source/uCEFChromiumCore.pas"/>
<Caret Line="441" TopLine="420"/>
</Position9>
<Position10>
<Filename Value="usimplebrowser2.pas"/>
<Caret Line="137" TopLine="117"/>
<Caret Line="214" Column="47" TopLine="187"/>
</Position10>
<Position11>
<Filename Value="usimplebrowser2.pas"/>
<Caret Line="138" TopLine="117"/>
<Caret Line="268" Column="61" TopLine="231"/>
</Position11>
<Position12>
<Filename Value="usimplebrowser2.pas"/>
<Caret Line="140" TopLine="117"/>
<Caret Line="91" TopLine="70"/>
</Position12>
<Position13>
<Filename Value="usimplebrowser2.pas"/>
<Caret Line="142" TopLine="117"/>
<Caret Line="211" TopLine="187"/>
</Position13>
<Position14>
<Filename Value="usimplebrowser2.pas"/>
<Caret Line="143" TopLine="117"/>
<Caret Line="265" Column="85" TopLine="229"/>
</Position14>
<Position15>
<Filename Value="usimplebrowser2.pas"/>
<Caret Line="144" TopLine="117"/>
<Caret Line="266" TopLine="229"/>
</Position15>
<Position16>
<Filename Value="usimplebrowser2.pas"/>
<Caret Line="219" Column="5" TopLine="193"/>
</Position16>
<Position17>
<Filename Value="usimplebrowser2.pas"/>
<Caret Line="119" Column="67" TopLine="36"/>
</Position17>
<Position18>
<Filename Value="usimplebrowser2.pas"/>
<Caret Line="85" Column="35" TopLine="70"/>
</Position18>
<Position19>
<Filename Value="usimplebrowser2.pas"/>
<Caret Line="63" Column="27" TopLine="53"/>
</Position19>
<Position20>
<Filename Value="../../../source/uCEFLinkedWindowParent.pas"/>
<Caret Line="170" Column="50" TopLine="53"/>
</Position20>
<Position21>
<Filename Value="../../../source/uCEFWinControl.pas"/>
<Caret Line="63" Column="3" TopLine="42"/>
</Position21>
<Position22>
<Filename Value="../../../source/uCEFWinControl.pas"/>
<Caret Line="66" Column="20" TopLine="42"/>
</Position22>
<Position23>
<Filename Value="../../../source/uCEFWinControl.pas"/>
<Caret Line="194" Column="19" TopLine="154"/>
</Position23>
<Position24>
<Filename Value="../../../source/uCEFWinControl.pas"/>
<Caret Line="73" Column="23" TopLine="51"/>
</Position24>
<Position25>
<Filename Value="../../../source/uCEFWinControl.pas"/>
<Caret Line="144" Column="61" TopLine="114"/>
</Position25>
<Position26>
<Filename Value="../../../source/uCEFWinControl.pas"/>
<Caret Line="195" Column="13" TopLine="154"/>
</Position26>
<Position27>
<Filename Value="../../../source/uCEFLinkedWindowParent.pas"/>
<Caret Line="154" Column="54" TopLine="131"/>
</Position27>
<Position28>
<Filename Value="../../../source/uCEFLinkedWindowParent.pas"/>
<Caret Line="73" Column="20" TopLine="58"/>
</Position28>
<Position29>
<Filename Value="../../../source/uCEFLinkedWindowParent.pas"/>
<Caret Line="176" Column="58" TopLine="151"/>
</Position29>
<Position30>
<Filename Value="usimplebrowser2.pas"/>
<Caret Line="216" Column="5" TopLine="197"/>
</Position30>
</JumpHistory>
<RunParams>
<FormatVersion Value="2"/>

View File

@@ -1,23 +1,16 @@
object Form1: TForm1
Left = 450
Left = 768
Height = 589
Top = 267
Top = 220
Width = 967
Caption = 'Initializing browser. Please wait...'
ClientHeight = 589
ClientWidth = 967
OnActivate = FormActivate
OnCloseQuery = FormCloseQuery
OnCreate = FormCreate
OnShow = FormShow
LCLVersion = '2.0.6.0'
object CEFWindowParent1: TCEFWindowParent
Left = 0
Height = 566
Top = 23
Width = 967
Align = alClient
TabOrder = 0
end
Position = poScreenCenter
LCLVersion = '2.0.10.0'
object AddressPnl: TPanel
Left = 0
Height = 23
@@ -27,7 +20,8 @@ object Form1: TForm1
BevelOuter = bvNone
ClientHeight = 23
ClientWidth = 967
TabOrder = 1
Enabled = False
TabOrder = 0
object GoBtn: TButton
Left = 932
Height = 23
@@ -48,19 +42,31 @@ object Form1: TForm1
Text = 'https://www.google.com'
end
end
object CEFLinkedWindowParent1: TCEFLinkedWindowParent
Left = 0
Height = 566
Top = 23
Width = 967
Align = alClient
TabStop = True
TabOrder = 1
OnEnter = CEFLinkedWindowParent1Enter
OnExit = CEFLinkedWindowParent1Exit
Chromium = Chromium1
end
object Chromium1: TChromium
OnBeforePopup = Chromium1BeforePopup
OnAfterCreated = Chromium1AfterCreated
OnBeforeClose = Chromium1BeforeClose
OnClose = Chromium1Close
OnOpenUrlFromTab = Chromium1OpenUrlFromTab
left = 56
top = 80
Left = 56
Top = 80
end
object Timer1: TTimer
Enabled = False
OnTimer = Timer1Timer
left = 56
top = 160
Left = 56
Top = 160
end
end

View File

@@ -42,9 +42,9 @@ unit uSimpleBrowser2;
interface
uses
Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ExtCtrls, StdCtrls,
Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ExtCtrls, StdCtrls, LMessages,
uCEFChromium, uCEFWindowParent, uCEFConstants, uCEFTypes, uCEFInterfaces,
uCEFChromiumEvents;
uCEFChromiumEvents, uCEFLinkedWindowParent;
type
@@ -52,30 +52,25 @@ type
TForm1 = class(TForm)
AddressEdt: TEdit;
CEFLinkedWindowParent1: TCEFLinkedWindowParent;
GoBtn: TButton;
CEFWindowParent1: TCEFWindowParent;
Chromium1: TChromium;
AddressPnl: TPanel;
Timer1: TTimer;
procedure Chromium1AfterCreated(Sender: TObject; const browser: ICefBrowser
);
procedure CEFLinkedWindowParent1Enter(Sender: TObject);
procedure CEFLinkedWindowParent1Exit(Sender: TObject);
procedure Chromium1AfterCreated(Sender: TObject; const browser: ICefBrowser);
procedure Chromium1BeforeClose(Sender: TObject; const browser: ICefBrowser);
procedure Chromium1BeforePopup(Sender: TObject; const browser: ICefBrowser;
const frame: ICefFrame; const targetUrl, targetFrameName: ustring;
targetDisposition: TCefWindowOpenDisposition; userGesture: Boolean;
const popupFeatures: TCefPopupFeatures; var windowInfo: TCefWindowInfo;
var client: ICefClient; var settings: TCefBrowserSettings;
var extra_info: ICefDictionaryValue; var noJavascriptAccess: Boolean;
var Result: Boolean);
procedure Chromium1Close(Sender: TObject; const browser: ICefBrowser;
var aAction: TCefCloseBrowserAction);
procedure Chromium1OpenUrlFromTab(Sender: TObject;
const browser: ICefBrowser; const frame: ICefFrame;
const targetUrl: ustring; targetDisposition: TCefWindowOpenDisposition;
userGesture: Boolean; out Result: Boolean);
procedure Chromium1Close(Sender: TObject; const browser: ICefBrowser; var aAction: TCefCloseBrowserAction);
procedure Chromium1BeforePopup(Sender: TObject; const browser: ICefBrowser; const frame: ICefFrame; const targetUrl, targetFrameName: ustring; targetDisposition: TCefWindowOpenDisposition; userGesture: Boolean; const popupFeatures: TCefPopupFeatures; var windowInfo: TCefWindowInfo; var client: ICefClient; var settings: TCefBrowserSettings; var extra_info: ICefDictionaryValue; var noJavascriptAccess: Boolean; var Result: Boolean);
procedure Chromium1OpenUrlFromTab(Sender: TObject; const browser: ICefBrowser; const frame: ICefFrame; const targetUrl: ustring; targetDisposition: TCefWindowOpenDisposition; userGesture: Boolean; out Result: Boolean);
procedure FormCreate(Sender: TObject);
procedure FormActivate(Sender: TObject);
procedure FormCloseQuery(Sender: TObject; var CanClose: boolean);
procedure FormCreate(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure GoBtnClick(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
private
@@ -85,10 +80,14 @@ type
FCanClose : boolean; // Set to True in TChromium.OnBeforeClose
FClosing : boolean; // Set to True in the CloseQuery event.
function SendCompMessage(aMsg : cardinal) : boolean;
// CEF needs to handle these messages to call TChromium.NotifyMoveOrResizeStarted
procedure WMMove(var Message: TLMMove); message LM_MOVE;
procedure WMSize(var Message: TLMSize); message LM_SIZE;
procedure WMWindowPosChanged(var Message: TLMWindowPosChanged); message LM_WINDOWPOSCHANGED;
procedure BrowserCreated;
procedure BrowserDestroyMsg(Data: PtrInt);
procedure SendCompMessage(aMsg : cardinal);
procedure BrowserCreatedMsg(Data: PtrInt);
procedure BrowserCloseFormMsg(Data: PtrInt);
public
@@ -115,12 +114,15 @@ implementation
// or the domain "google.com". If you don't live in the US, you'll be redirected to
// another domain which will take a little time too.
// This demo uses a TChromium and a TCEFWindowParent
// This demo uses a TChromium and a TCEFLinkedWindowParent
// We need to use TCEFLinkedWindowParent in Linux to update the browser
// visibility and size automatically.
// Destruction steps
// =================
// 1. FormCloseQuery sets CanClose to FALSE calls TChromium.CloseBrowser which triggers the TChromium.OnClose event.
// 2. TChromium.OnClose sends a CEFBROWSER_DESTROY message to destroy CEFWindowParent1 in the main thread, which triggers the TChromium.OnBeforeClose event.
// 2. TChromium.OnClose sets aAction to cbaClose to destroy the browser, which triggers the TChromium.OnBeforeClose event.
// 3. TChromium.OnBeforeClose sets FCanClose := True and sends CEF_BEFORECLOSE to close the form.
uses
@@ -130,56 +132,32 @@ uses
procedure CreateGlobalCEFApp;
var
TempHome, TempBinDir : ustring;
begin
TempHome := IncludeTrailingPathDelimiter(GetEnvironmentVariable('HOME'));
TempBinDir := TempHome + 'Lazarus/CEF4Delphi/bin';
GlobalCEFApp := TCefApplication.Create;
GlobalCEFApp.SetCurrentDir := True;
if DirectoryExists(TempBinDir) then
begin
GlobalCEFApp.FrameworkDirPath := TempBinDir;
GlobalCEFApp.ResourcesDirPath := TempBinDir;
GlobalCEFApp.LocalesDirPath := TempBinDir + '/locales';
end;
// Add a debug log in the BIN directory
GlobalCEFApp := TCefApplication.Create;
{
GlobalCEFApp.LogFile := 'cef.log';
GlobalCEFApp.LogSeverity := LOGSEVERITY_VERBOSE;
}
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
FCanClose := False;
FClosing := False;
end;
procedure TForm1.FormShow(Sender: TObject);
begin
Chromium1.DefaultURL := UTF8Decode(AddressEdt.Text);
// You *MUST* call CreateBrowser to create and initialize the browser.
// This will trigger the AfterCreated event when the browser is fully
// initialized and ready to receive commands.
// GlobalCEFApp.GlobalContextInitialized has to be TRUE before creating any browser
// If it's not initialized yet, we use a simple timer to create the browser later.
if not(Chromium1.CreateBrowser(CEFWindowParent1)) then Timer1.Enabled := True;
end;
procedure TForm1.GoBtnClick(Sender: TObject);
begin
// This will load the URL in the edit box
Chromium1.LoadURL(UTF8Decode(AddressEdt.Text));
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
Timer1.Enabled := False;
if not(Chromium1.CreateBrowser(CEFWindowParent1)) and not(Chromium1.Initialized) then
if not(Chromium1.CreateBrowser(CEFLinkedWindowParent1.Handle, CEFLinkedWindowParent1.BoundsRect)) and
not(Chromium1.Initialized) then
Timer1.Enabled := True;
end;
@@ -205,34 +183,7 @@ procedure TForm1.Chromium1BeforePopup(Sender: TObject;
begin
// For simplicity, this demo blocks all popup windows and new tabs
Result := (targetDisposition in [WOD_NEW_FOREGROUND_TAB, WOD_NEW_BACKGROUND_TAB, WOD_NEW_POPUP, WOD_NEW_WINDOW]);
end;
procedure TForm1.Chromium1Close(Sender: TObject; const browser: ICefBrowser;
var aAction: TCefCloseBrowserAction);
begin
SendCompMessage(CEF_DESTROY);
aAction := cbaDelay;
end;
procedure TForm1.Chromium1AfterCreated(Sender: TObject;
const browser: ICefBrowser);
begin
// Now the browser is fully initialized we can initialize the UI.
TThread.Queue(nil, @BrowserCreated);
end;
procedure TForm1.BrowserCreated;
begin
Caption := 'Simple Browser 2';
AddressPnl.Enabled := True;
end;
procedure TForm1.Chromium1BeforeClose(Sender: TObject;
const browser: ICefBrowser);
begin
FCanClose := True;
SendCompMessage(CEF_BEFORECLOSE);
end;
end;
procedure TForm1.Chromium1OpenUrlFromTab(Sender: TObject;
const browser: ICefBrowser; const frame: ICefFrame; const targetUrl: ustring;
@@ -243,9 +194,57 @@ begin
Result := (targetDisposition in [WOD_NEW_FOREGROUND_TAB, WOD_NEW_BACKGROUND_TAB, WOD_NEW_POPUP, WOD_NEW_WINDOW]);
end;
procedure TForm1.BrowserDestroyMsg(Data: PtrInt);
procedure TForm1.FormActivate(Sender: TObject);
begin
CEFWindowParent1.Free;
// You *MUST* call CreateBrowser to create and initialize the browser.
// This will trigger the AfterCreated event when the browser is fully
// initialized and ready to receive commands.
// GlobalCEFApp.GlobalContextInitialized has to be TRUE before creating any browser
// If it's not initialized yet, we use a simple timer to create the browser later.
// Linux needs a visible form to create a browser so we need to use the
// TForm.OnActivate event instead of the TForm.OnShow event
if not(Chromium1.Initialized) and
not(Chromium1.CreateBrowser(CEFLinkedWindowParent1.Handle, CEFLinkedWindowParent1.BoundsRect)) then
Timer1.Enabled := True;
end;
procedure TForm1.Chromium1Close(Sender: TObject; const browser: ICefBrowser; var aAction: TCefCloseBrowserAction);
begin
// continue closing the browser
aAction := cbaClose;
end;
procedure TForm1.Chromium1BeforeClose(Sender: TObject; const browser: ICefBrowser);
begin
// We must wait until all browsers trigger the TChromium.OnBeforeClose event
// in order to close the application safely or we will have shutdown issues.
FCanClose := True;
SendCompMessage(CEF_BEFORECLOSE);
end;
procedure TForm1.Chromium1AfterCreated(Sender: TObject; const browser: ICefBrowser);
begin
// Now the browser is fully initialized we can initialize the UI.
SendCompMessage(CEF_AFTERCREATED);
end;
procedure TForm1.CEFLinkedWindowParent1Enter(Sender: TObject);
begin
If not(csDesigning in ComponentState) then Chromium1.SetFocus(True);
end;
procedure TForm1.CEFLinkedWindowParent1Exit(Sender: TObject);
begin
if not(csDesigning in ComponentState) then Chromium1.SendCaptureLostEvent;
end;
procedure TForm1.BrowserCreatedMsg(Data: PtrInt);
begin
Caption := 'Simple Browser 2';
AddressPnl.Enabled := True;
end;
procedure TForm1.BrowserCloseFormMsg(Data: PtrInt);
@@ -253,13 +252,32 @@ begin
Close;
end;
function TForm1.SendCompMessage(aMsg : cardinal) : boolean;
procedure TForm1.SendCompMessage(aMsg : cardinal);
begin
case aMsg of
CEF_DESTROY : Application.QueueAsyncCall(@BrowserDestroyMsg, 0);
case aMsg of
CEF_AFTERCREATED : Application.QueueAsyncCall(@BrowserCreatedMsg, 0);
CEF_BEFORECLOSE : Application.QueueAsyncCall(@BrowserCloseFormMsg, 0);
end;
end;
procedure TForm1.WMMove(var Message: TLMMove);
begin
inherited;
Chromium1.NotifyMoveOrResizeStarted;
end;
procedure TForm1.WMSize(var Message: TLMSize);
begin
inherited;
Chromium1.NotifyMoveOrResizeStarted;
end;
procedure TForm1.WMWindowPosChanged(var Message: TLMWindowPosChanged);
begin
inherited;
Chromium1.NotifyMoveOrResizeStarted;
end;
end.

View File

@@ -20,9 +20,8 @@
<HasResources Value="True"/>
<ResourceBaseClass Value="Form"/>
<UnitName Value="uSimpleOSRBrowser"/>
<IsVisibleTab Value="True"/>
<TopLine Value="595"/>
<CursorPos Y="624"/>
<CursorPos X="53" Y="609"/>
<UsageCount Value="78"/>
<Bookmarks Count="2">
<Item0 X="47" Y="222" ID="2"/>
@@ -35,6 +34,7 @@
<Filename Value="interfaces.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="Interfaces"/>
<IsVisibleTab Value="True"/>
<EditorIndex Value="2"/>
<CursorPos X="40" Y="20"/>
<UsageCount Value="74"/>

View File

@@ -54,6 +54,7 @@ uses
{$ELSE}
{$IFDEF MSWINDOWS}Windows,{$ENDIF} Classes, {$IFDEF FPC}dynlibs,{$ENDIF}
{$ENDIF}
{$IFDEF LINUX}xlib,{$ENDIF}
uCEFTypes, uCEFInterfaces, uCEFBaseRefCounted, uCEFSchemeRegistrar;
const
@@ -251,6 +252,9 @@ type
function GetTotalSystemMemory : uint64;
function GetAvailableSystemMemory : uint64;
function GetSystemMemoryLoad : cardinal;
{$IFDEF LINUX}
function GetXDisplay : PXDisplay;
{$ENDIF}
function LoadCEFlibrary : boolean; virtual;
function Load_cef_app_capi_h : boolean;
@@ -494,6 +498,9 @@ type
property AvailableSystemMemory : uint64 read GetAvailableSystemMemory;
property SystemMemoryLoad : cardinal read GetSystemMemoryLoad;
property SupportedSchemes : TStringList read FSupportedSchemes;
{$IFDEF LINUX}
property XDisplay : PXDisplay read GetXDisplay;
{$ENDIF}
// ICefApp
property OnRegCustomSchemes : TOnRegisterCustomSchemesEvent read FOnRegisterCustomSchemes write FOnRegisterCustomSchemes;
@@ -2214,6 +2221,17 @@ begin
{$ENDIF}
end;
{$IFDEF LINUX}
function TCefApplicationCore.GetXDisplay : PXDisplay;
begin
// This property can only be called in the CEF UI thread.
if FLibLoaded then
Result := cef_get_xdisplay{$IFDEF FPC}(){$ENDIF}
else
Result := nil;
end;
{$ENDIF}
function TCefApplicationCore.LoadCEFlibrary : boolean;
var
TempOldDir, TempString : string;

View File

@@ -123,10 +123,11 @@ implementation
uses
{$IFDEF DELPHI16_UP}
System.SysUtils, System.Math;
System.SysUtils, System.Math,
{$ELSE}
SysUtils, Math;
SysUtils, Math,
{$ENDIF}
uCEFMiscFunctions;
{ TChromium }
@@ -295,7 +296,7 @@ function TChromium.CreateBrowser(const aBrowserParent : TWinControl;
const aContext : ICefRequestContext;
const aExtraInfo : ICefDictionaryValue) : boolean;
var
TempHandle : HWND;
TempHandle : TCefWindowHandle;
TempRect : TRect;
begin
if (aBrowserParent <> nil) then
@@ -305,8 +306,8 @@ begin
end
else
begin
TempHandle := 0;
TempRect := rect(0, 0, 0, 0);
InitializeWindowHandle(TempHandle);
TempRect := rect(0, 0, 0, 0);
end;
Result := inherited CreateBrowser(TempHandle, TempRect, aWindowName, aContext, aExtraInfo);

View File

@@ -435,6 +435,9 @@ type
function ExecuteSetZoomLevelTask(const aValue : double) : boolean;
function ExecuteSetZoomStepTask(aValue : byte) : boolean;
function ExecuteBrowserNavigationTask(aTask : TCefBrowserNavigation) : boolean;
function ExecuteUpdateSizeTask(aLeft, aTop, aWidth, aHeight : integer) : boolean;
function ExecuteSendCaptureLostEventTask : boolean;
function ExecuteUpdateXWindowVisibilityTask(aVisible : boolean) : boolean;
procedure UpdateHostZoomLevel(const aValue : double);
procedure UpdateHostZoomPct(const aValue : double);
@@ -639,6 +642,9 @@ type
procedure doMediaRouteCreateFinished(result: TCefMediaRouterCreateResult; const error: ustring; const route: ICefMediaRoute); virtual;
procedure doOnMediaSinkDeviceInfo(const ip_address: ustring; port: integer; const model_name: ustring); virtual;
procedure doBrowserNavigation(aTask : TCefBrowserNavigation); virtual;
procedure doUpdateSize(aLeft, aTop, aWidth, aHeight : integer); virtual;
procedure doSendCaptureLostEvent; virtual;
procedure doUpdateXWindowVisibility(aVisible : boolean); virtual;
function MustCreateAudioHandler : boolean; virtual;
function MustCreateDevToolsMessageObserver : boolean; virtual;
function MustCreateLoadHandler : boolean; virtual;
@@ -805,6 +811,11 @@ type
procedure ReplaceMisspelling(const aWord : ustring);
procedure AddWordToDictionary(const aWord : ustring);
{$IFDEF LINUX}
procedure UpdateBrowserSize(aLeft, aTop, aWidth, aHeight : integer);
procedure UpdateXWindowVisibility(aVisible : boolean);
{$ENDIF}
// ICefMediaRouter methods
function AddObserver(const observer: ICefMediaObserver): ICefRegistration;
function GetSource(const urn: ustring): ICefMediaSource;
@@ -1147,7 +1158,7 @@ uses
{$IFDEF DELPHI16_UP}
System.SysUtils, System.Math,
{$ELSE}
SysUtils, Math,
SysUtils, Math, {$IFDEF FPC}{$IFDEF LINUX}xlib, x, xatom,{$ENDIF}{$ENDIF}
{$ENDIF}
uCEFBrowser, uCEFValue, uCEFDictionaryValue, uCEFStringMultimap, uCEFFrame,
uCEFApplicationCore, uCEFProcessMessage, uCEFRequestContext,
@@ -2499,6 +2510,57 @@ begin
end;
end;
function TChromiumCore.ExecuteUpdateSizeTask(aLeft, aTop, aWidth, aHeight : integer) : boolean;
var
TempTask : ICefTask;
begin
Result := False;
try
if Initialized then
begin
TempTask := TCefUpdateSizeTask.Create(self, aLeft, aTop, aWidth, aHeight);
Result := CefPostTask(TID_UI, TempTask);
end;
finally
TempTask := nil;
end;
end;
function TChromiumCore.ExecuteSendCaptureLostEventTask : boolean;
var
TempTask : ICefTask;
begin
Result := False;
try
if Initialized then
begin
TempTask := TCefSendCaptureLostEventTask.Create(self);
Result := CefPostTask(TID_UI, TempTask);
end;
finally
TempTask := nil;
end;
end;
function TChromiumCore.ExecuteUpdateXWindowVisibilityTask(aVisible : boolean) : boolean;
var
TempTask : ICefTask;
begin
Result := False;
try
if Initialized then
begin
TempTask := TCefUpdateXWindowVisibilityTask.Create(self, aVisible);
Result := CefPostTask(TID_UI, TempTask);
end;
finally
TempTask := nil;
end;
end;
procedure TChromiumCore.GoBack;
begin
ExecuteBrowserNavigationTask(bnBack);
@@ -4576,6 +4638,110 @@ begin
end;
end;
procedure TChromiumCore.doUpdateSize(aLeft, aTop, aWidth, aHeight : integer);
{$IFDEF LINUX}
var
TempHandle : TCefWindowHandle;
TempChanges : TXWindowChanges;
TempXDisplay : PXDisplay;
{$ENDIF}
begin
{$IFDEF LINUX}
if (GlobalCEFApp <> nil) then
begin
TempXDisplay := GlobalCEFApp.XDisplay;
if (TempXDisplay <> nil) then
begin
TempHandle := WindowHandle;
if ValidCefWindowHandle(TempHandle) then
begin
TempChanges.x := aLeft;
TempChanges.y := aTop;
TempChanges.width := aWidth;
TempChanges.height := aHeight;
XConfigureWindow(TempXDisplay, TempHandle, CWX or CWY or CWHeight or CWWidth, @TempChanges);
end;
end;
end;
{$ENDIF}
end;
procedure TChromiumCore.doSendCaptureLostEvent;
{$IFDEF LINUX}
var
TempXDisplay : PXDisplay;
{$ENDIF}
begin
{$IFDEF LINUX}
if (GlobalCEFApp <> nil) then
begin
TempXDisplay := GlobalCEFApp.XDisplay;
if (TempXDisplay <> nil) then
XSetInputFocus(TempXDisplay, X.None, RevertToNone, CurrentTime);
end;
{$ENDIF}
if Initialized then
Browser.Host.SendCaptureLostEvent;
end;
procedure TChromiumCore.doUpdateXWindowVisibility(aVisible : boolean);
{$IFDEF LINUX}
var
TempXDisplay : PXDisplay;
TempHandle : TCefWindowHandle;
TempState : TAtom;
TempHidden : TAtom;
{$ENDIF}
begin
{$IFDEF LINUX}
if (GlobalCEFApp <> nil) then
begin
TempXDisplay := GlobalCEFApp.XDisplay;
if (TempXDisplay <> nil) then
begin
TempHandle := WindowHandle;
if ValidCefWindowHandle(TempHandle) then
begin
TempState := XInternAtom(TempXDisplay, '_NET_WM_STATE', False);
if aVisible then
XChangeProperty(TempXDisplay, TempHandle, TempState, XA_ATOM, 32, PropModeReplace, nil, 0)
else
begin
TempHidden := XInternAtom(TempXDisplay, '_NET_WM_STATE_HIDDEN', False);
XChangeProperty(TempXDisplay, TempHandle, TempState, XA_ATOM, 32, PropModeReplace, @TempHidden, 1);
end;
end;
end;
end;
{$ENDIF}
end;
{$IFDEF LINUX}
procedure TChromiumCore.UpdateBrowserSize(aLeft, aTop, aWidth, aHeight : integer);
begin
if CefCurrentlyOn(TID_UI) then
doUpdateSize(aLeft, aTop, aWidth, aHeight)
else
ExecuteUpdateSizeTask(aLeft, aTop, aWidth, aHeight);
end;
procedure TChromiumCore.UpdateXWindowVisibility(aVisible : boolean);
begin
if CefCurrentlyOn(TID_UI) then
doUpdateXWindowVisibility(aVisible)
else
ExecuteUpdateXWindowVisibilityTask(aVisible);
end;
{$ENDIF}
function TChromiumCore.MustCreateLoadHandler : boolean;
begin
Result := assigned(FOnLoadStart) or
@@ -6231,8 +6397,10 @@ end;
procedure TChromiumCore.SendCaptureLostEvent;
begin
if Initialized then
Browser.Host.SendCaptureLostEvent;
if CefCurrentlyOn(TID_UI) then
doSendCaptureLostEvent
else
ExecuteSendCaptureLostEventTask;
end;
procedure TChromiumCore.SetFocus(focus: Boolean);

View File

@@ -478,6 +478,9 @@ type
procedure doMediaRouteCreateFinished(result: TCefMediaRouterCreateResult; const error: ustring; const route: ICefMediaRoute);
procedure doOnMediaSinkDeviceInfo(const ip_address: ustring; port: integer; const model_name: ustring);
procedure doBrowserNavigation(aTask : TCefBrowserNavigation);
procedure doUpdateSize(aLeft, aTop, aWidth, aHeight : integer);
procedure doSendCaptureLostEvent;
procedure doUpdateXWindowVisibility(aVisible : boolean);
function MustCreateAudioHandler : boolean;
function MustCreateLoadHandler : boolean;
function MustCreateFocusHandler : boolean;

View File

@@ -54,7 +54,7 @@ uses
{$ELSE}
{$IFDEF MSWINDOWS}Windows,{$ENDIF} Math,
{$ENDIF}
uCEFTypes;
{$IFDEF LINUX}xlib,{$ENDIF} uCEFTypes;
var
// /include/capi/cef_app_capi.h

View File

@@ -54,9 +54,10 @@ uses
{$ELSE}
{$IFDEF MSWINDOWS}Windows,{$ENDIF} Classes, Forms, Controls, Graphics,
{$IFDEF FPC}
LCLProc, LCLType, LCLIntf, LResources, LMessages, InterfaceBase,
LCLProc, LCLType, LCLIntf, LResources, LMessages, InterfaceBase,
{$IFDEF LINUX}xlib, x,{$ENDIF}
{$ELSE}
Messages,
Messages,
{$ENDIF}
{$ENDIF}
uCEFWinControl, uCEFTypes, uCEFInterfaces, uCEFChromium;
@@ -66,7 +67,11 @@ type
TCEFLinkedWindowParent = class(TCEFWinControl)
protected
FChromium : TChromium;
{$IFDEF FPC}{$IFDEF LINUX}
procedure SetVisible(Value: Boolean); override;
procedure UpdateSize; override;
{$ENDIF}{$ENDIF}
procedure SetChromium(aValue : TChromium);
function GetChildWindowHandle : THandle; override;
@@ -84,14 +89,14 @@ type
{$IFDEF FPC}
procedure Register;
{$ENDIF}
implementation
uses
uCEFMiscFunctions, uCEFClient, uCEFConstants;
uCEFMiscFunctions, uCEFClient, uCEFConstants, uCEFLibFunctions,
uCEFApplication;
constructor TCEFLinkedWindowParent.Create(AOwner : TComponent);
begin
@@ -151,6 +156,31 @@ begin
if (Operation = opRemove) and (AComponent = FChromium) then FChromium := nil;
end;
{$IFDEF FPC}{$IFDEF LINUX}
procedure TCEFLinkedWindowParent.SetVisible(Value: Boolean);
var
TempChanged : boolean;
begin
TempChanged := (Visible <> Value);
inherited SetVisible(Value);
if not(csDesigning in ComponentState) and
TempChanged and
(FChromium <> nil) and
FChromium.Initialized then
FChromium.UpdateXWindowVisibility(Visible);
end;
procedure TCEFLinkedWindowParent.UpdateSize;
begin
if not(csDesigning in ComponentState) and
(FChromium <> nil) and
FChromium.Initialized then
FChromium.UpdateBrowserSize(Left, Top, Width, Height);
end;
{$ENDIF}{$ENDIF}
procedure TCEFLinkedWindowParent.SetChromium(aValue : TChromium);
begin
FChromium := aValue;

View File

@@ -61,7 +61,8 @@ uses
{$IFDEF DELPHI14_UP}Types, IOUtils,{$ENDIF} Classes, SysUtils, Math,
{$IFDEF FPC}LCLType,{$IFNDEF MSWINDOWS}InterfaceBase, Forms,{$ENDIF}{$ENDIF}
{$IFDEF LINUX}{$IFDEF FPC}{$IFDEF LCLGTK2}
ctypes, keysym, gdk2, gtk2proc, gtk2int, xf86keysym,
ctypes, keysym, gtk2, glib2, gdk2, gtk2proc, gtk2int, xf86keysym,
Gtk2Def, gdk2x, Gtk2Extra,
{$ENDIF}{$ENDIF}{$ENDIF}
{$ENDIF}
uCEFTypes, uCEFInterfaces, uCEFLibFunctions, uCEFResourceHandler,
@@ -761,7 +762,7 @@ begin
aWindowInfo.y := aRect.top;
aWindowInfo.width := aRect.right - aRect.left;
aWindowInfo.height := aRect.bottom - aRect.top;
aWindowInfo.parent_window := aParent;
aWindowInfo.parent_window := gdk_window_xwindow(PGtkWidget(aParent)^.window);
aWindowInfo.windowless_rendering_enabled := ord(False);
aWindowInfo.shared_texture_enabled := ord(False);
aWindowInfo.external_begin_frame_enabled := ord(False);
@@ -775,7 +776,7 @@ begin
aWindowInfo.y := 0;
aWindowInfo.width := 0;
aWindowInfo.height := 0;
aWindowInfo.parent_window := aParent;
aWindowInfo.parent_window := gdk_window_xwindow(PGtkWidget(aParent)^.window);
aWindowInfo.windowless_rendering_enabled := ord(False);
aWindowInfo.shared_texture_enabled := ord(False);
aWindowInfo.external_begin_frame_enabled := ord(False);

View File

@@ -219,6 +219,44 @@ type
destructor Destroy; override;
end;
TCefUpdateSizeTask = class(TCefTaskOwn)
protected
FEvents : Pointer;
FLeft : integer;
FTop : integer;
FWidth : integer;
FHeight : integer;
procedure Execute; override;
public
constructor Create(const aEvents : IChromiumEvents; aLeft, aTop, aWidth, aHeight : integer); reintroduce;
destructor Destroy; override;
end;
TCefSendCaptureLostEventTask = class(TCefTaskOwn)
protected
FEvents : Pointer;
procedure Execute; override;
public
constructor Create(const aEvents : IChromiumEvents); reintroduce;
destructor Destroy; override;
end;
TCefUpdateXWindowVisibilityTask = class(TCefTaskOwn)
protected
FEvents : pointer;
FVisible : boolean;
procedure Execute; override;
public
constructor Create(const aEvents : IChromiumEvents; aVisible : boolean); reintroduce;
destructor Destroy; override;
end;
implementation
@@ -682,4 +720,103 @@ begin
inherited Destroy;
end;
// TCefUpdateSizeTask
procedure TCefUpdateSizeTask.Execute;
begin
try
try
if (FEvents <> nil) then IChromiumEvents(FEvents).doUpdateSize(FLeft, FTop, FWidth, FHeight);
except
on e : exception do
if CustomExceptionHandler('TCefUpdateSizeTask.Execute', e) then raise;
end;
finally
FEvents := nil;
end;
end;
constructor TCefUpdateSizeTask.Create(const aEvents : IChromiumEvents; aLeft, aTop, aWidth, aHeight : integer);
begin
inherited Create;
FEvents := Pointer(aEvents);
FLeft := aLeft;
FTop := aTop;
FWidth := aWidth;
FHeight := aHeight;
end;
destructor TCefUpdateSizeTask.Destroy;
begin
FEvents := nil;
inherited Destroy;
end;
// TCefSendCaptureLostEventTask
procedure TCefSendCaptureLostEventTask.Execute;
begin
try
try
if (FEvents <> nil) then IChromiumEvents(FEvents).doSendCaptureLostEvent;
except
on e : exception do
if CustomExceptionHandler('TCefSendCaptureLostEventTask.Execute', e) then raise;
end;
finally
FEvents := nil;
end;
end;
constructor TCefSendCaptureLostEventTask.Create(const aEvents : IChromiumEvents);
begin
inherited Create;
FEvents := Pointer(aEvents);
end;
destructor TCefSendCaptureLostEventTask.Destroy;
begin
FEvents := nil;
inherited Destroy;
end;
// TCefUpdateXWindowVisibilityTask
procedure TCefUpdateXWindowVisibilityTask.Execute;
begin
try
try
if (FEvents <> nil) then IChromiumEvents(FEvents).doUpdateXWindowVisibility(FVisible);
except
on e : exception do
if CustomExceptionHandler('TCefUpdateXWindowVisibilityTask.Execute', e) then raise;
end;
finally
FEvents := nil;
end;
end;
constructor TCefUpdateXWindowVisibilityTask.Create(const aEvents : IChromiumEvents; aVisible : boolean);
begin
inherited Create;
FEvents := Pointer(aEvents);
FVisible := aVisible;
end;
destructor TCefUpdateXWindowVisibilityTask.Destroy;
begin
FEvents := nil;
inherited Destroy;
end;
end.

View File

@@ -250,9 +250,7 @@ type
PCefMediaSinkDeviceInfo = ^TCefMediaSinkDeviceInfo;
{$IFDEF LINUX}
PXEvent = Pointer;
TXDisplay = record end;
PXDisplay = ^TXDisplay;
PXEvent = Pointer;
{$ENDIF}

View File

@@ -70,7 +70,7 @@ type
function DestroyChildWindow : boolean;
procedure CreateHandle; override;
procedure InvalidateChildren;
procedure UpdateSize;
procedure UpdateSize; virtual;
property ChildWindowHandle : THandle read GetChildWindowHandle;
@@ -85,7 +85,9 @@ type
property Enabled;
property ShowHint;
property Hint;
property OnResize;
property OnResize;
property OnEnter;
property OnExit;
{$IFDEF DELPHI14_UP}
property Touch;
property OnGesture;
@@ -122,10 +124,13 @@ begin
end;
procedure TCEFWinControl.UpdateSize;
{$IFDEF MSWINDOWS}
var
TempRect : TRect;
TempHWND : THandle;
{$ENDIF}
begin
{$IFDEF MSWINDOWS}
TempHWND := ChildWindowHandle;
if (TempHWND = 0) then exit;
@@ -134,6 +139,7 @@ begin
SetWindowPos(TempHWND, 0,
0, 0, TempRect.right, TempRect.bottom,
SWP_NOZORDER);
{$ENDIF}
end;
function TCEFWinControl.TakeSnapshot(var aBitmap : TBitmap) : boolean;

View File

@@ -2,7 +2,7 @@
"UpdateLazPackages" : [
{
"ForceNotify" : true,
"InternalVersion" : 213,
"InternalVersion" : 214,
"Name" : "cef4delphi_lazarus.lpk",
"Version" : "87.1.12.0"
}