1
0
mirror of https://github.com/salvadordf/CEF4Delphi.git synced 2025-09-30 21:28:55 +02:00

Improved Linux support in Lazarus

- Fixed issue #255
- Changed GlobalCEFApp.DefaultEncoding property type to ustring
- Changed GlobalCEFApp.OverrideSpellCheckLang property type to ustring
This commit is contained in:
Salvador Diaz Fau
2020-12-28 18:11:27 +01:00
parent 7ec49e1f95
commit e7eae21105
21 changed files with 3957 additions and 638 deletions

View File

@@ -0,0 +1,30 @@
unit Interfaces;
{$mode objfpc}{$H+}
interface
{$IFDEF UNIX}{$IFNDEF DisableCWString}uses cwstring;{$ENDIF}{$ENDIF}
procedure CustomWidgetSetInitialization;
procedure CustomWidgetSetFinalization;
implementation
uses
{$IFNDEF EnableLibOverlay}
gtk2DisableLibOverlay,
{$ENDIF}
Gtk2Int, Forms;
procedure CustomWidgetSetInitialization;
begin
CreateWidgetset(TGtk2WidgetSet);
end;
procedure CustomWidgetSetFinalization;
begin
FreeWidgetSet;
end;
end.

View File

@@ -33,7 +33,7 @@
<PackageName Value="LCL"/>
</Item2>
</RequiredPackages>
<Units Count="2">
<Units Count="3">
<Unit0>
<Filename Value="SimpleOSRBrowser.lpr"/>
<IsPartOfProject Value="True"/>
@@ -46,6 +46,11 @@
<ResourceBaseClass Value="Form"/>
<UnitName Value="uSimpleOSRBrowser"/>
</Unit1>
<Unit2>
<Filename Value="interfaces.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="Interfaces"/>
</Unit2>
</Units>
</ProjectOptions>
<CompilerOptions>
@@ -66,6 +71,10 @@
</Linking>
<Other>
<CustomOptions Value="-dUseCthreads"/>
<OtherDefines Count="2">
<Define0 Value="UseCthreads"/>
<Define1 Value="EnabledGtkThreading"/>
</OtherDefines>
</Other>
</CompilerOptions>
<Debugging>

View File

@@ -42,8 +42,9 @@ program SimpleOSRBrowser;
uses
{$IFDEF UNIX}{$IFDEF UseCThreads}
cthreads,
cmem,
{$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, uSimpleOSRBrowser,
{ 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.Initialize;
Application.CreateForm(TForm1, Form1);
Application.Run;
CustomWidgetSetFinalization;
end;
DestroyGlobalCEFApp;

View File

@@ -3,15 +3,15 @@
<ProjectSession>
<Version Value="11"/>
<BuildModes Active="Default"/>
<Units Count="6">
<Units Count="101">
<Unit0>
<Filename Value="SimpleOSRBrowser.lpr"/>
<IsPartOfProject Value="True"/>
<EditorIndex Value="-1"/>
<WindowIndex Value="-1"/>
<TopLine Value="13"/>
<CursorPos X="8" Y="45"/>
<UsageCount Value="23"/>
<EditorIndex Value="1"/>
<TopLine Value="18"/>
<CursorPos X="57" Y="58"/>
<UsageCount Value="78"/>
<Loaded Value="True"/>
</Unit0>
<Unit1>
<Filename Value="usimpleosrbrowser.pas"/>
@@ -21,66 +21,877 @@
<ResourceBaseClass Value="Form"/>
<UnitName Value="uSimpleOSRBrowser"/>
<IsVisibleTab Value="True"/>
<TopLine Value="165"/>
<CursorPos X="32" Y="726"/>
<UsageCount Value="23"/>
<TopLine Value="595"/>
<CursorPos Y="624"/>
<UsageCount Value="78"/>
<Bookmarks Count="2">
<Item0 X="47" Y="222" ID="2"/>
<Item1 X="76" Y="501" ID="6"/>
</Bookmarks>
<Loaded Value="True"/>
<LoadedDesigner Value="True"/>
</Unit1>
<Unit2>
<Filename Value="interfaces.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="Interfaces"/>
<EditorIndex Value="2"/>
<CursorPos X="40" Y="20"/>
<UsageCount Value="74"/>
<Loaded Value="True"/>
</Unit2>
<Unit3>
<Filename Value="/usr/share/lazarus/2.0.6/lcl/lcltype.pp"/>
<UnitName Value="LCLType"/>
<EditorIndex Value="-1"/>
<TopLine Value="52"/>
<CursorPos X="3" Y="68"/>
<UsageCount Value="10"/>
</Unit2>
<Unit3>
<UsageCount Value="7"/>
</Unit3>
<Unit4>
<Filename Value="../../../../source/uCEFMiscFunctions.pas"/>
<EditorIndex Value="-1"/>
<TopLine Value="1889"/>
<CursorPos X="27" Y="1907"/>
<UsageCount Value="10"/>
</Unit3>
<Unit4>
<UsageCount Value="7"/>
</Unit4>
<Unit5>
<Filename Value="../../../../source/uCEFApplicationCore.pas"/>
<EditorIndex Value="-1"/>
<TopLine Value="432"/>
<CursorPos X="29" Y="445"/>
<UsageCount Value="10"/>
</Unit4>
<Unit5>
<UsageCount Value="7"/>
</Unit5>
<Unit6>
<Filename Value="/usr/share/fpcsrc/3.2.0/rtl/objpas/sysutils/finah.inc"/>
<EditorIndex Value="-1"/>
<CursorPos X="10" Y="33"/>
<TopLine Value="5"/>
<CursorPos X="10" Y="28"/>
<UsageCount Value="9"/>
</Unit6>
<Unit7>
<Filename Value="/usr/share/lazarus/2.0.10/lcl/interfaces/gtk2/interfaces.pas"/>
<UnitName Value="Interfaces"/>
<EditorIndex Value="-1"/>
<CursorPos X="26" Y="25"/>
<UsageCount Value="7"/>
</Unit7>
<Unit8>
<Filename Value="/usr/share/lazarus/2.0.10/lcl/interfaces/gtk2/gtk2disableliboverlay.pas"/>
<UnitName Value="gtk2DisableLibOverlay"/>
<EditorIndex Value="-1"/>
<UsageCount Value="7"/>
</Unit8>
<Unit9>
<Filename Value="/usr/share/lazarus/2.0.10/lcl/include/winapi.inc"/>
<EditorIndex Value="-1"/>
<TopLine Value="290"/>
<CursorPos X="3" Y="292"/>
<UsageCount Value="9"/>
</Unit9>
<Unit10>
<Filename Value="../../../source/uCEFMiscFunctions.pas"/>
<EditorIndex Value="-1"/>
<TopLine Value="184"/>
<CursorPos X="22" Y="211"/>
<UsageCount Value="15"/>
</Unit10>
<Unit11>
<Filename Value="/usr/share/lazarus/2.0.10/lcl/interfaces/gtk2/gtk2int.pas"/>
<UnitName Value="Gtk2Int"/>
<EditorIndex Value="-1"/>
<TopLine Value="295"/>
<CursorPos X="72" Y="304"/>
<UsageCount Value="10"/>
</Unit5>
</Unit11>
<Unit12>
<Filename Value="../../../source/uCEFChromium.pas"/>
<EditorIndex Value="-1"/>
<TopLine Value="62"/>
<CursorPos X="17" Y="86"/>
<UsageCount Value="8"/>
</Unit12>
<Unit13>
<Filename Value="../../../source/uCEFConstants.pas"/>
<EditorIndex Value="-1"/>
<TopLine Value="592"/>
<CursorPos X="70" Y="622"/>
<UsageCount Value="11"/>
</Unit13>
<Unit14>
<Filename Value="/usr/share/lazarus/2.0.10/lcl/include/rasterimage.inc"/>
<EditorIndex Value="-1"/>
<TopLine Value="744"/>
<CursorPos X="3" Y="748"/>
<UsageCount Value="11"/>
</Unit14>
<Unit15>
<Filename Value="../../../source/uCEFBufferPanel.pas"/>
<EditorIndex Value="-1"/>
<TopLine Value="363"/>
<CursorPos Y="381"/>
<UsageCount Value="28"/>
<Bookmarks Count="4">
<Item0 Y="997" ID="9"/>
<Item1 X="63" Y="579" ID="8"/>
<Item2 X="5" Y="345" ID="7"/>
<Item3 X="5" Y="375" ID="1"/>
</Bookmarks>
</Unit15>
<Unit16>
<Filename Value="/usr/share/lazarus/2.0.10/lcl/forms.pp"/>
<UnitName Value="Forms"/>
<EditorIndex Value="-1"/>
<TopLine Value="684"/>
<CursorPos X="31" Y="711"/>
<UsageCount Value="9"/>
</Unit16>
<Unit17>
<Filename Value="../../../source/uCEFApplicationCore.pas"/>
<EditorIndex Value="-1"/>
<TopLine Value="340"/>
<CursorPos X="40" Y="377"/>
<UsageCount Value="10"/>
<Bookmarks Count="1">
<Item0 X="3" Y="2235" ID="3"/>
</Bookmarks>
</Unit17>
<Unit18>
<Filename Value="../../../source/uCEFApplication.pas"/>
<EditorIndex Value="-1"/>
<UsageCount Value="9"/>
</Unit18>
<Unit19>
<Filename Value="/usr/share/fpcsrc/3.2.0/packages/fcl-base/src/syncobjs.pp"/>
<EditorIndex Value="-1"/>
<TopLine Value="122"/>
<CursorPos X="54" Y="146"/>
<UsageCount Value="10"/>
</Unit19>
<Unit20>
<Filename Value="/usr/share/fpcsrc/3.2.0/rtl/inc/threadh.inc"/>
<EditorIndex Value="-1"/>
<TopLine Value="117"/>
<CursorPos X="11" Y="149"/>
<UsageCount Value="10"/>
</Unit20>
<Unit21>
<Filename Value="/usr/share/fpcsrc/3.2.0/rtl/inc/thread.inc"/>
<EditorIndex Value="-1"/>
<TopLine Value="220"/>
<CursorPos X="3" Y="223"/>
<UsageCount Value="10"/>
</Unit21>
<Unit22>
<Filename Value="/usr/share/lazarus/2.0.10/lcl/controls.pp"/>
<UnitName Value="Controls"/>
<EditorIndex Value="-1"/>
<TopLine Value="1718"/>
<CursorPos X="29" Y="1745"/>
<UsageCount Value="16"/>
</Unit22>
<Unit23>
<Filename Value="/usr/share/lazarus/2.0.10/lcl/extctrls.pp"/>
<UnitName Value="ExtCtrls"/>
<EditorIndex Value="-1"/>
<TopLine Value="1025"/>
<CursorPos X="3" Y="1046"/>
<UsageCount Value="12"/>
</Unit23>
<Unit24>
<Filename Value="/usr/share/lazarus/2.0.10/lcl/graphics.pp"/>
<UnitName Value="Graphics"/>
<EditorIndex Value="-1"/>
<TopLine Value="1075"/>
<CursorPos X="15" Y="1083"/>
<UsageCount Value="14"/>
</Unit24>
<Unit25>
<Filename Value="/usr/share/lazarus/2.0.10/lcl/include/canvas.inc"/>
<EditorIndex Value="-1"/>
<TopLine Value="996"/>
<CursorPos X="3" Y="1004"/>
<UsageCount Value="9"/>
</Unit25>
<Unit26>
<Filename Value="/usr/share/fpcsrc/3.2.0/packages/fcl-image/src/fpcanvas.pp"/>
<UnitName Value="FPCanvas"/>
<EditorIndex Value="-1"/>
<TopLine Value="240"/>
<CursorPos X="15" Y="277"/>
<UsageCount Value="7"/>
</Unit26>
<Unit27>
<Filename Value="/usr/share/fpcsrc/3.2.0/packages/fcl-image/src/fpcanvas.inc"/>
<EditorIndex Value="-1"/>
<TopLine Value="575"/>
<CursorPos X="3" Y="578"/>
<UsageCount Value="7"/>
</Unit27>
<Unit28>
<Filename Value="../../../../../.cache/.fr-A0S8PI/gtk2_thread/unit1.pas"/>
<UnitName Value="Unit1"/>
<EditorIndex Value="-1"/>
<TopLine Value="72"/>
<UsageCount Value="7"/>
</Unit28>
<Unit29>
<Filename Value="/usr/share/lazarus/2.0.10/lcl/lclproc.pas"/>
<UnitName Value="LCLProc"/>
<EditorIndex Value="-1"/>
<UsageCount Value="7"/>
</Unit29>
<Unit30>
<Filename Value="/usr/share/lazarus/2.0.10/ide/lazarus.pp"/>
<UnitName Value="Lazarus"/>
<EditorIndex Value="-1"/>
<TopLine Value="124"/>
<CursorPos Y="165"/>
<UsageCount Value="7"/>
</Unit30>
<Unit31>
<Filename Value="/usr/share/lazarus/2.0.10/lcl/include/custombitmap.inc"/>
<EditorIndex Value="-1"/>
<TopLine Value="51"/>
<CursorPos X="3" Y="62"/>
<UsageCount Value="7"/>
</Unit31>
<Unit32>
<Filename Value="/usr/share/lazarus/2.0.10/components/lazutils/graphtype.pp"/>
<UnitName Value="GraphType"/>
<EditorIndex Value="-1"/>
<TopLine Value="185"/>
<CursorPos X="3" Y="197"/>
<UsageCount Value="12"/>
</Unit32>
<Unit33>
<Filename Value="/usr/share/fpcsrc/3.2.0/rtl/inc/systemh.inc"/>
<EditorIndex Value="-1"/>
<TopLine Value="1494"/>
<CursorPos X="19" Y="1526"/>
<UsageCount Value="8"/>
</Unit33>
<Unit34>
<Filename Value="../../../../../Descargas/bgrabitmap-master/bgrabitmap/bgralclbitmap.pas"/>
<UnitName Value="BGRALCLBitmap"/>
<EditorIndex Value="-1"/>
<CursorPos X="123" Y="18"/>
<UsageCount Value="7"/>
</Unit34>
<Unit35>
<Filename Value="/usr/share/lazarus/2.0.10/lcl/interfacebase.pp"/>
<UnitName Value="InterfaceBase"/>
<EditorIndex Value="-1"/>
<TopLine Value="113"/>
<CursorPos X="3" Y="122"/>
<UsageCount Value="10"/>
</Unit35>
<Unit36>
<Filename Value="/usr/share/lazarus/2.0.10/lcl/include/lclintf.inc"/>
<EditorIndex Value="-1"/>
<TopLine Value="450"/>
<CursorPos Y="474"/>
<UsageCount Value="7"/>
</Unit36>
<Unit37>
<Filename Value="/usr/share/lazarus/2.0.10/lcl/interfaces/gtk2/gtk2winapi.inc"/>
<EditorIndex Value="-1"/>
<TopLine Value="7097"/>
<CursorPos X="15" Y="7124"/>
<UsageCount Value="9"/>
</Unit37>
<Unit38>
<Filename Value="/usr/share/lazarus/2.0.10/lcl/interfaces/gtk2/gtk2widgetset.inc"/>
<EditorIndex Value="-1"/>
<TopLine Value="1359"/>
<CursorPos X="31" Y="1401"/>
<UsageCount Value="12"/>
</Unit38>
<Unit39>
<Filename Value="/usr/share/lazarus/2.0.10/lcl/interfaces/gtk2/gtk2devicecontext.inc"/>
<EditorIndex Value="-1"/>
<TopLine Value="759"/>
<CursorPos X="3" Y="767"/>
<UsageCount Value="9"/>
</Unit39>
<Unit40>
<Filename Value="/usr/share/lazarus/2.0.10/lcl/include/graphic.inc"/>
<EditorIndex Value="-1"/>
<TopLine Value="124"/>
<CursorPos X="30" Y="130"/>
<UsageCount Value="11"/>
</Unit40>
<Unit41>
<Filename Value="/usr/share/lazarus/2.0.10/lcl/include/fpimagebitmap.inc"/>
<EditorIndex Value="-1"/>
<TopLine Value="140"/>
<CursorPos X="3" Y="165"/>
<UsageCount Value="11"/>
</Unit41>
<Unit42>
<Filename Value="/usr/share/lazarus/2.0.10/lcl/intfgraphics.pas"/>
<UnitName Value="IntfGraphics"/>
<EditorIndex Value="-1"/>
<TopLine Value="3644"/>
<CursorPos X="3" Y="3649"/>
<UsageCount Value="11"/>
</Unit42>
<Unit43>
<Filename Value="/usr/share/lazarus/2.0.10/lcl/include/control.inc"/>
<EditorIndex Value="-1"/>
<TopLine Value="3393"/>
<CursorPos X="3" Y="3399"/>
<UsageCount Value="11"/>
</Unit43>
<Unit44>
<Filename Value="/usr/share/lazarus/2.0.10/lcl/include/monitor.inc"/>
<EditorIndex Value="-1"/>
<TopLine Value="26"/>
<CursorPos Y="34"/>
<UsageCount Value="8"/>
</Unit44>
<Unit45>
<Filename Value="/usr/share/lazarus/2.0.10/lcl/include/winapih.inc"/>
<EditorIndex Value="-1"/>
<TopLine Value="76"/>
<CursorPos X="10" Y="103"/>
<UsageCount Value="9"/>
</Unit45>
<Unit46>
<Filename Value="/usr/share/lazarus/2.0.10/lcl/include/screen.inc"/>
<EditorIndex Value="-1"/>
<TopLine Value="797"/>
<CursorPos X="3" Y="801"/>
<UsageCount Value="8"/>
</Unit46>
<Unit47>
<Filename Value="/usr/share/lazarus/2.0.10/lcl/include/customdesigncontrol.inc"/>
<EditorIndex Value="-1"/>
<TopLine Value="61"/>
<CursorPos X="3" Y="74"/>
<UsageCount Value="8"/>
</Unit47>
<Unit48>
<Filename Value="/usr/share/lazarus/2.0.10/lcl/include/font.inc"/>
<EditorIndex Value="-1"/>
<TopLine Value="610"/>
<CursorPos X="3" Y="622"/>
<UsageCount Value="8"/>
</Unit48>
<Unit49>
<Filename Value="/usr/share/lazarus/2.0.10/lcl/lcltype.pp"/>
<UnitName Value="LCLType"/>
<EditorIndex Value="-1"/>
<TopLine Value="1293"/>
<CursorPos X="3" Y="1320"/>
<UsageCount Value="9"/>
</Unit49>
<Unit50>
<Filename Value="/usr/share/lazarus/2.0.10/lcl/include/customimage.inc"/>
<EditorIndex Value="-1"/>
<TopLine Value="242"/>
<CursorPos X="3" Y="251"/>
<UsageCount Value="8"/>
</Unit50>
<Unit51>
<Filename Value="/usr/share/fpcsrc/3.2.0/rtl/objpas/classes/classesh.inc"/>
<EditorIndex Value="-1"/>
<TopLine Value="2234"/>
<CursorPos X="3" Y="2263"/>
<UsageCount Value="9"/>
</Unit51>
<Unit52>
<Filename Value="../../../source/uCEFChromiumCore.pas"/>
<EditorIndex Value="-1"/>
<TopLine Value="1122"/>
<CursorPos Y="1147"/>
<UsageCount Value="10"/>
</Unit52>
<Unit53>
<Filename Value="/usr/share/lazarus/2.0.10/lcl/include/wincontrol.inc"/>
<EditorIndex Value="-1"/>
<TopLine Value="7177"/>
<CursorPos Y="7204"/>
<UsageCount Value="13"/>
</Unit53>
<Unit54>
<Filename Value="/usr/share/fpcsrc/3.2.0/rtl/inc/objpas.inc"/>
<EditorIndex Value="-1"/>
<TopLine Value="618"/>
<CursorPos Y="638"/>
<UsageCount Value="12"/>
</Unit54>
<Unit55>
<Filename Value="/usr/share/lazarus/2.0.10/lcl/lmessages.pp"/>
<UnitName Value="LMessages"/>
<EditorIndex Value="-1"/>
<TopLine Value="294"/>
<CursorPos X="3" Y="308"/>
<UsageCount Value="9"/>
</Unit55>
<Unit56>
<Filename Value="/usr/share/lazarus/2.0.10/lcl/lclmessageglue.pas"/>
<UnitName Value="LCLMessageGlue"/>
<EditorIndex Value="-1"/>
<TopLine Value="88"/>
<CursorPos X="3" Y="92"/>
<UsageCount Value="9"/>
</Unit56>
<Unit57>
<Filename Value="../../Delphi_VCL/SimpleOSRBrowser/uSimpleOSRBrowser.pas"/>
<EditorIndex Value="-1"/>
<TopLine Value="262"/>
<CursorPos X="3" Y="267"/>
<UsageCount Value="11"/>
</Unit57>
<Unit58>
<Filename Value="/usr/share/lazarus/2.0.10/lcl/include/application.inc"/>
<EditorIndex Value="-1"/>
<TopLine Value="230"/>
<CursorPos X="3" Y="235"/>
<UsageCount Value="8"/>
</Unit58>
<Unit59>
<Filename Value="/usr/share/lazarus/2.0.10/lcl/dialogs.pp"/>
<UnitName Value="Dialogs"/>
<EditorIndex Value="-1"/>
<TopLine Value="846"/>
<CursorPos X="10" Y="848"/>
<UsageCount Value="8"/>
</Unit59>
<Unit60>
<Filename Value="/usr/share/lazarus/2.0.10/lcl/interfaces/gtk3/gtk3bindings/lazgio2.pas"/>
<UnitName Value="LazGio2"/>
<EditorIndex Value="-1"/>
<TopLine Value="1299"/>
<CursorPos X="18" Y="1336"/>
<UsageCount Value="8"/>
</Unit60>
<Unit61>
<Filename Value="/usr/share/fpcsrc/3.2.0/rtl/objpas/sysutils/fina.inc"/>
<EditorIndex Value="-1"/>
<TopLine Value="134"/>
<CursorPos Y="141"/>
<UsageCount Value="9"/>
</Unit61>
<Unit62>
<Filename Value="../../../source/uCEFLibFunctions.pas"/>
<EditorIndex Value="-1"/>
<TopLine Value="60"/>
<CursorPos X="3" Y="113"/>
<UsageCount Value="9"/>
</Unit62>
<Unit63>
<Filename Value="/usr/share/fpcsrc/3.2.0/tests/bench/shootout/src/chameneos.pp"/>
<EditorIndex Value="-1"/>
<CursorPos X="39" Y="31"/>
<UsageCount Value="9"/>
</Unit63>
<Unit64>
<Filename Value="../../Lazarus_Windows/SimpleOSRBrowser/usimplelazosrbrowser.pas"/>
<EditorIndex Value="-1"/>
<TopLine Value="973"/>
<CursorPos X="131" Y="1002"/>
<UsageCount Value="8"/>
</Unit64>
<Unit65>
<Filename Value="/usr/share/lazarus/2.0.10/lcl/interfaces/gtk/gtkwidgetset.inc"/>
<EditorIndex Value="-1"/>
<TopLine Value="133"/>
<CursorPos X="11" Y="179"/>
<UsageCount Value="10"/>
</Unit65>
<Unit66>
<Filename Value="/usr/share/lazarus/2.0.10/lcl/interfaces/gtk/gtkproc.pp"/>
<UnitName Value="GTKProc"/>
<EditorIndex Value="-1"/>
<TopLine Value="99"/>
<CursorPos X="10" Y="126"/>
<UsageCount Value="10"/>
</Unit66>
<Unit67>
<Filename Value="/usr/share/lazarus/2.0.10/lcl/interfaces/gtk/gtkcallback.inc"/>
<EditorIndex Value="-1"/>
<TopLine Value="878"/>
<CursorPos Y="880"/>
<UsageCount Value="10"/>
</Unit67>
<Unit68>
<Filename Value="/usr/share/lazarus/2.0.10/lcl/interfaces/gtk/gtkproc.inc"/>
<EditorIndex Value="-1"/>
<TopLine Value="1935"/>
<CursorPos Y="2265"/>
<UsageCount Value="10"/>
</Unit68>
<Unit69>
<Filename Value="/usr/share/lazarus/2.0.10/lcl/interfaces/gtk2/gtk2proc.inc"/>
<EditorIndex Value="-1"/>
<TopLine Value="8852"/>
<CursorPos X="37" Y="8887"/>
<UsageCount Value="11"/>
<Bookmarks Count="2">
<Item0 X="91" Y="1895" ID="1"/>
<Item1 X="42" Y="2240" ID="2"/>
</Bookmarks>
</Unit69>
<Unit70>
<Filename Value="/usr/share/lazarus/2.0.10/lcl/interfaces/gtk2/gtk2proc.pp"/>
<UnitName Value="Gtk2Proc"/>
<EditorIndex Value="-1"/>
<TopLine Value="697"/>
<CursorPos X="11" Y="724"/>
<UsageCount Value="12"/>
</Unit70>
<Unit71>
<Filename Value="/usr/share/fpcsrc/3.2.0/packages/gtk1/src/gdk/gdktypes.pp"/>
<EditorIndex Value="-1"/>
<TopLine Value="903"/>
<CursorPos X="6" Y="930"/>
<UsageCount Value="10"/>
</Unit71>
<Unit72>
<Filename Value="/usr/share/lazarus/2.0.10/lcl/interfaces/gtk2/gtk2callback.inc"/>
<EditorIndex Value="-1"/>
<TopLine Value="760"/>
<CursorPos Y="768"/>
<UsageCount Value="11"/>
</Unit72>
<Unit73>
<Filename Value="../../../../test-0006/ucefgdkconstants.pas"/>
<UnitName Value="uCEFGDKConstants"/>
<EditorIndex Value="-1"/>
<CursorPos X="22" Y="8"/>
<UsageCount Value="9"/>
</Unit73>
<Unit74>
<Filename Value="../../../../test-0006/ucefgdkmiscfunctions.pas"/>
<UnitName Value="uCEFGDKMiscFunctions"/>
<EditorIndex Value="-1"/>
<CursorPos X="22" Y="8"/>
<UsageCount Value="9"/>
</Unit74>
<Unit75>
<Filename Value="../../../../test-0006/unit1.pas"/>
<UnitName Value="Unit1"/>
<EditorIndex Value="-1"/>
<TopLine Value="24"/>
<CursorPos X="3" Y="38"/>
<UsageCount Value="9"/>
</Unit75>
<Unit76>
<Filename Value="../../../source/uCEFTypes.pas"/>
<EditorIndex Value="-1"/>
<TopLine Value="1243"/>
<CursorPos X="9" Y="1271"/>
<UsageCount Value="9"/>
</Unit76>
<Unit77>
<Filename Value="/usr/share/fpcsrc/3.2.0/rtl/inc/objpash.inc"/>
<EditorIndex Value="-1"/>
<TopLine Value="179"/>
<CursorPos X="23" Y="206"/>
<UsageCount Value="9"/>
</Unit77>
<Unit78>
<Filename Value="/usr/share/fpcsrc/3.2.0/packages/libc/src/pthread.inc"/>
<EditorIndex Value="-1"/>
<CursorPos X="68"/>
<UsageCount Value="10"/>
</Unit78>
<Unit79>
<Filename Value="/usr/share/fpcsrc/3.2.0/packages/libc/src/pthreadh.inc"/>
<EditorIndex Value="-1"/>
<TopLine Value="74"/>
<CursorPos X="10" Y="102"/>
<UsageCount Value="9"/>
</Unit79>
<Unit80>
<Filename Value="/usr/share/fpcsrc/3.2.0/rtl/unix/cthreads.pp"/>
<EditorIndex Value="-1"/>
<TopLine Value="347"/>
<CursorPos X="14" Y="642"/>
<UsageCount Value="9"/>
</Unit80>
<Unit81>
<Filename Value="/usr/share/fpcsrc/3.2.0/rtl/linux/pthread.inc"/>
<EditorIndex Value="-1"/>
<TopLine Value="279"/>
<CursorPos X="11" Y="306"/>
<UsageCount Value="9"/>
</Unit81>
<Unit82>
<Filename Value="/usr/share/fpcsrc/3.2.0/packages/libmicrohttpd/examples/event_and_thread.pp"/>
<EditorIndex Value="-1"/>
<TopLine Value="3"/>
<CursorPos X="62" Y="48"/>
<UsageCount Value="10"/>
</Unit82>
<Unit83>
<Filename Value="/usr/share/fpcsrc/3.2.0/rtl/linux/sysosh.inc"/>
<EditorIndex Value="-1"/>
<CursorPos X="14" Y="26"/>
<UsageCount Value="10"/>
</Unit83>
<Unit84>
<Filename Value="/usr/share/lazarus/2.0.10/lcl/lclintf.pas"/>
<UnitName Value="LCLIntf"/>
<EditorIndex Value="-1"/>
<TopLine Value="198"/>
<UsageCount Value="9"/>
</Unit84>
<Unit85>
<Filename Value="/usr/share/lazarus/2.0.10/lcl/interfaces/gtk2/gtk2def.pp"/>
<UnitName Value="Gtk2Def"/>
<EditorIndex Value="-1"/>
<TopLine Value="366"/>
<CursorPos X="14" Y="394"/>
<UsageCount Value="9"/>
</Unit85>
<Unit86>
<Filename Value="/usr/share/fpcsrc/3.2.0/packages/gtk2/src/gtk+/gdk/gdk2.pas"/>
<EditorIndex Value="-1"/>
<TopLine Value="162"/>
<CursorPos X="11" Y="189"/>
<UsageCount Value="9"/>
</Unit86>
<Unit87>
<Filename Value="/usr/share/fpcsrc/3.2.0/packages/gtk2/src/glib/gthread.inc"/>
<EditorIndex Value="-1"/>
<TopLine Value="91"/>
<CursorPos X="11" Y="119"/>
<UsageCount Value="9"/>
</Unit87>
<Unit88>
<Filename Value="/usr/share/fpcsrc/3.2.0/packages/gtk2/src/glib/glib2.pas"/>
<EditorIndex Value="-1"/>
<TopLine Value="158"/>
<CursorPos X="11" Y="186"/>
<UsageCount Value="9"/>
</Unit88>
<Unit89>
<Filename Value="/usr/share/lazarus/2.0.10/components/lazutils/laztracer.pas"/>
<UnitName Value="LazTracer"/>
<EditorIndex Value="-1"/>
<TopLine Value="3"/>
<CursorPos Y="50"/>
<UsageCount Value="9"/>
</Unit89>
<Unit90>
<Filename Value="/usr/share/lazarus/2.0.10/lcl/interfaces/gtk2/gtk2defines.inc"/>
<EditorIndex Value="-1"/>
<TopLine Value="47"/>
<CursorPos X="10" Y="93"/>
<UsageCount Value="9"/>
</Unit90>
<Unit91>
<Filename Value="/usr/share/lazarus/2.0.10/lcl/interfaces/gtk/gtkdefines.inc"/>
<EditorIndex Value="-1"/>
<TopLine Value="44"/>
<CursorPos X="10" Y="96"/>
<UsageCount Value="9"/>
</Unit91>
<Unit92>
<Filename Value="/usr/share/lazarus/2.0.10/lcl/interfaces/gtk/gtkwinapi.inc"/>
<EditorIndex Value="-1"/>
<TopLine Value="7515"/>
<CursorPos X="15" Y="7542"/>
<UsageCount Value="9"/>
</Unit92>
<Unit93>
<Filename Value="/usr/share/lazarus/2.0.10/lcl/include/bitmapcanvas.inc"/>
<EditorIndex Value="-1"/>
<TopLine Value="7"/>
<CursorPos X="57" Y="31"/>
<UsageCount Value="9"/>
</Unit93>
<Unit94>
<Filename Value="../../../source/uCEFBitmapBitBuffer.pas"/>
<EditorIndex Value="-1"/>
<TopLine Value="110"/>
<CursorPos X="29" Y="126"/>
<UsageCount Value="13"/>
</Unit94>
<Unit95>
<Filename Value="/usr/share/lazarus/2.0.10/components/lazutils/LazLoggerIntf.inc"/>
<EditorIndex Value="-1"/>
<CursorPos X="11" Y="3"/>
<UsageCount Value="9"/>
</Unit95>
<Unit96>
<Filename Value="/usr/share/lazarus/2.0.10/components/lazutils/LazLoggerImpl.inc"/>
<EditorIndex Value="-1"/>
<TopLine Value="16"/>
<CursorPos X="3" Y="18"/>
<UsageCount Value="9"/>
</Unit96>
<Unit97>
<Filename Value="/usr/share/lazarus/2.0.10/components/lazutils/lazloggerbase.pas"/>
<UnitName Value="LazLoggerBase"/>
<EditorIndex Value="-1"/>
<TopLine Value="666"/>
<CursorPos X="134" Y="689"/>
<UsageCount Value="9"/>
</Unit97>
<Unit98>
<Filename Value="/usr/share/lazarus/2.0.10/test/lazutils/testlazloggercase.pas"/>
<UnitName Value="TestLazLoggerCase"/>
<EditorIndex Value="-1"/>
<TopLine Value="13"/>
<CursorPos X="55" Y="47"/>
<UsageCount Value="9"/>
</Unit98>
<Unit99>
<Filename Value="/usr/share/lazarus/2.0.10/lcl/include/customform.inc"/>
<EditorIndex Value="-1"/>
<TopLine Value="2389"/>
<CursorPos X="3" Y="2393"/>
<UsageCount Value="9"/>
</Unit99>
<Unit100>
<Filename Value="/usr/share/lazarus/2.0.10/components/lazutils/maps.pp"/>
<UnitName Value="Maps"/>
<EditorIndex Value="-1"/>
<TopLine Value="323"/>
<CursorPos Y="357"/>
<UsageCount Value="11"/>
</Unit100>
</Units>
<JumpHistory Count="5" HistoryIndex="4">
<OtherDefines Count="2">
<Define0 Value="UseCthreads"/>
<Define1 Value="EnabledGtkThreading"/>
</OtherDefines>
<JumpHistory Count="30" HistoryIndex="29">
<Position1>
<Filename Value="usimpleosrbrowser.pas"/>
<Caret Line="137" Column="44" TopLine="124"/>
<Caret Line="535" Column="58" TopLine="488"/>
</Position1>
<Position2>
<Filename Value="usimpleosrbrowser.pas"/>
<Caret Line="138" Column="30" TopLine="124"/>
<Caret Line="543" Column="51" TopLine="496"/>
</Position2>
<Position3>
<Filename Value="usimpleosrbrowser.pas"/>
<Caret Line="389" Column="18" TopLine="360"/>
<Caret Line="75" Column="32" TopLine="56"/>
</Position3>
<Position4>
<Filename Value="usimpleosrbrowser.pas"/>
<Caret Line="575" Column="48" TopLine="555"/>
<Caret Line="320" Column="3" TopLine="314"/>
</Position4>
<Position5>
<Filename Value="usimpleosrbrowser.pas"/>
<Caret Line="581" Column="30" TopLine="555"/>
<Caret Line="75" Column="15" TopLine="48"/>
</Position5>
<Position6>
<Filename Value="usimpleosrbrowser.pas"/>
<Caret Line="320" Column="3" TopLine="315"/>
</Position6>
<Position7>
<Filename Value="usimpleosrbrowser.pas"/>
<Caret Line="83" Column="28" TopLine="75"/>
</Position7>
<Position8>
<Filename Value="usimpleosrbrowser.pas"/>
<Caret Line="511" Column="3" TopLine="508"/>
</Position8>
<Position9>
<Filename Value="usimpleosrbrowser.pas"/>
<Caret Line="112" Column="23" TopLine="87"/>
</Position9>
<Position10>
<Filename Value="usimpleosrbrowser.pas"/>
<Caret Line="618" Column="3" TopLine="593"/>
</Position10>
<Position11>
<Filename Value="usimpleosrbrowser.pas"/>
<Caret Line="112" Column="29" TopLine="97"/>
</Position11>
<Position12>
<Filename Value="usimpleosrbrowser.pas"/>
<Caret Line="628" Column="84" TopLine="597"/>
</Position12>
<Position13>
<Filename Value="usimpleosrbrowser.pas"/>
<Caret Line="120" Column="31" TopLine="94"/>
</Position13>
<Position14>
<Filename Value="usimpleosrbrowser.pas"/>
<Caret Line="669" Column="24" TopLine="620"/>
</Position14>
<Position15>
<Filename Value="usimpleosrbrowser.pas"/>
<Caret Line="112" Column="25" TopLine="84"/>
</Position15>
<Position16>
<Filename Value="usimpleosrbrowser.pas"/>
<Caret Line="479" Column="50" TopLine="447"/>
</Position16>
<Position17>
<Filename Value="usimpleosrbrowser.pas"/>
<Caret Line="75" Column="15" TopLine="52"/>
</Position17>
<Position18>
<Filename Value="usimpleosrbrowser.pas"/>
<Caret Line="338" Column="59" TopLine="318"/>
</Position18>
<Position19>
<Filename Value="usimpleosrbrowser.pas"/>
<Caret Line="75" Column="31" TopLine="51"/>
</Position19>
<Position20>
<Filename Value="usimpleosrbrowser.pas"/>
<Caret Line="341" Column="3" TopLine="332"/>
</Position20>
<Position21>
<Filename Value="usimpleosrbrowser.pas"/>
<Caret Line="83" Column="15" TopLine="49"/>
</Position21>
<Position22>
<Filename Value="usimpleosrbrowser.pas"/>
<Caret Line="552" Column="57" TopLine="524"/>
</Position22>
<Position23>
<Filename Value="usimpleosrbrowser.pas"/>
<Caret Line="118" Column="30" TopLine="88"/>
</Position23>
<Position24>
<Filename Value="usimpleosrbrowser.pas"/>
<Caret Line="73" Column="31" TopLine="71"/>
</Position24>
<Position25>
<Filename Value="SimpleOSRBrowser.lpr"/>
<Caret Line="58" Column="57" TopLine="18"/>
</Position25>
<Position26>
<Filename Value="usimpleosrbrowser.pas"/>
<Caret Line="101" Column="55" TopLine="81"/>
</Position26>
<Position27>
<Filename Value="usimpleosrbrowser.pas"/>
<Caret Line="625" Column="10" TopLine="578"/>
</Position27>
<Position28>
<Filename Value="usimpleosrbrowser.pas"/>
<Caret Line="100" Column="12" TopLine="74"/>
</Position28>
<Position29>
<Filename Value="usimpleosrbrowser.pas"/>
<Caret Line="625" Column="10" TopLine="578"/>
</Position29>
<Position30>
<Filename Value="usimpleosrbrowser.pas"/>
<Caret Line="100" TopLine="74"/>
</Position30>
</JumpHistory>
<RunParams>
<FormatVersion Value="2"/>
<Modes Count="0" ActiveMode=""/>
</RunParams>
</ProjectSession>
<Debugging>
<Watches Count="1">
<Item1>
<Expression Value="width"/>
</Item1>
</Watches>
</Debugging>
</CONFIG>

View File

@@ -0,0 +1,30 @@
unit Interfaces;
{$mode objfpc}{$H+}
interface
{$IFDEF UNIX}{$IFNDEF DisableCWString}uses cwstring;{$ENDIF}{$ENDIF}
procedure CustomWidgetSetInitialization;
procedure CustomWidgetSetFinalization;
implementation
uses
{$IFNDEF EnableLibOverlay}
gtk2DisableLibOverlay,
{$ENDIF}
Gtk2Int, Forms;
procedure CustomWidgetSetInitialization;
begin
CreateWidgetset(TGtk2WidgetSet);
end;
procedure CustomWidgetSetFinalization;
begin
FreeWidgetSet;
end;
end.

View File

@@ -1,55 +1,78 @@
object Form1: TForm1
Left = 393
Height = 622
Top = 250
Width = 972
Left = 518
Height = 630
Top = 252
Width = 1000
Caption = ' Initializing browser. Please wait...'
ClientHeight = 622
ClientWidth = 972
ClientHeight = 630
ClientWidth = 1000
OnCloseQuery = FormCloseQuery
OnCreate = FormCreate
OnDestroy = FormDestroy
OnHide = FormHide
OnShow = FormShow
LCLVersion = '2.0.6.0'
LCLVersion = '2.0.10.0'
object AddressPnl: TPanel
Left = 0
Height = 21
Height = 30
Top = 0
Width = 972
Width = 1000
Align = alTop
ClientHeight = 21
ClientWidth = 972
ClientHeight = 30
ClientWidth = 1000
TabOrder = 0
object GoBtn: TButton
Left = 940
Height = 19
Top = 1
Width = 31
Align = alRight
Caption = 'Go'
OnClick = GoBtnClick
OnEnter = GoBtnEnter
TabOrder = 0
end
object AddressEdt: TEdit
Left = 1
Height = 19
Height = 28
Top = 1
Width = 939
Width = 932
Align = alClient
OnEnter = AddressEdtEnter
TabOrder = 0
Text = 'https://www.google.com'
end
object Panel2: TPanel
Left = 933
Height = 28
Top = 1
Width = 66
Align = alRight
ClientHeight = 28
ClientWidth = 66
TabOrder = 1
Text = 'AddressEdt'
object GoBtn: TButton
Left = 1
Height = 26
Top = 1
Width = 31
Align = alLeft
Caption = 'Go'
OnClick = GoBtnClick
OnEnter = GoBtnEnter
TabOrder = 0
end
object SnapshotBtn: TButton
Left = 34
Height = 26
Top = 1
Width = 31
Align = alRight
Caption = 'µ'
Font.Height = -24
Font.Name = 'Webdings'
OnClick = SnapshotBtnClick
OnEnter = GoBtnEnter
ParentFont = False
TabOrder = 1
end
end
end
object Panel1: TBufferPanel
Left = 0
Height = 601
Top = 21
Width = 972
Height = 600
Top = 30
Width = 1000
Align = alClient
OnUTF8KeyPress = Panel1UTF8KeyPress
Caption = 'Panel1'
TabOrder = 1
OnClick = Panel1Click
@@ -59,12 +82,11 @@ object Form1: TForm1
OnMouseMove = Panel1MouseMove
OnMouseUp = Panel1MouseUp
OnMouseWheel = Panel1MouseWheel
OnKeyDown = Panel1KeyDown
OnKeyUp = Panel1KeyUp
OnResize = Panel1Resize
end
object Chromium1: TChromium
OnTooltip = Chromium1Tooltip
OnCursorChange = Chromium1CursorChange
OnBeforePopup = Chromium1BeforePopup
OnAfterCreated = Chromium1AfterCreated
OnBeforeClose = Chromium1BeforeClose
@@ -75,14 +97,20 @@ object Form1: TForm1
OnPopupShow = Chromium1PopupShow
OnPopupSize = Chromium1PopupSize
OnPaint = Chromium1Paint
OnCursorChange = Chromium1CursorChange
left = 48
top = 72
Left = 48
Top = 72
end
object Timer1: TTimer
Enabled = False
OnTimer = Timer1Timer
left = 48
top = 144
Left = 48
Top = 144
end
object SaveDialog1: TSaveDialog
Title = 'Save screenshot bitmap as'
DefaultExt = '.bmp'
Filter = 'Bitmap file|*.bmp'
Left = 48
Top = 216
end
end

View File

@@ -43,109 +43,94 @@ interface
uses
Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ExtCtrls, StdCtrls,
LCLType, Types, SyncObjs,
LCLType, ComCtrls, Types, SyncObjs,
uCEFChromium, uCEFTypes, uCEFInterfaces, uCEFConstants, uCEFBufferPanel,
uCEFChromiumEvents;
type
{ TForm1 }
TForm1 = class(TForm)
AddressEdt: TEdit;
SaveDialog1: TSaveDialog;
SnapshotBtn: TButton;
GoBtn: TButton;
Panel1: TBufferPanel;
Chromium1: TChromium;
GoBtn: TButton;
AddressPnl: TPanel;
Panel2: TPanel;
Timer1: TTimer;
procedure AddressEdtEnter(Sender: TObject);
procedure Panel1Click(Sender: TObject);
procedure Panel1Enter(Sender: TObject);
procedure Panel1Exit(Sender: TObject);
procedure Panel1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure Panel1KeyUp(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure Panel1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure Panel1MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
procedure Panel1MouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure Panel1MouseWheel(Sender: TObject; Shift: TShiftState;
WheelDelta: Integer; MousePos: TPoint; var Handled: Boolean);
procedure Panel1MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
procedure Panel1MouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
procedure Panel1MouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
procedure Panel1MouseWheel(Sender: TObject; Shift: TShiftState; WheelDelta: Integer; MousePos: TPoint; var Handled: Boolean);
procedure Panel1Resize(Sender: TObject);
procedure Panel1UTF8KeyPress(Sender: TObject; var UTF8Key: TUTF8Char);
procedure Chromium1AfterCreated(Sender: TObject; const browser: ICefBrowser
);
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 Chromium1CursorChange(Sender: TObject;
const browser: ICefBrowser; cursor_: TCefCursorHandle;
cursorType: TCefCursorType; const customCursorInfo: PCefCursorInfo;
var aResult : boolean);
procedure Chromium1GetScreenInfo(Sender: TObject;
const browser: ICefBrowser; var screenInfo: TCefScreenInfo; out
Result: Boolean);
procedure Chromium1GetScreenPoint(Sender: TObject;
const browser: ICefBrowser; viewX, viewY: Integer; var screenX,
screenY: Integer; out Result: Boolean);
procedure Chromium1GetViewRect(Sender: TObject; const browser: ICefBrowser;
var rect: TCefRect);
procedure Chromium1OpenUrlFromTab(Sender: TObject;
const browser: ICefBrowser; const frame: ICefFrame;
const targetUrl: ustring; targetDisposition: TCefWindowOpenDisposition;
userGesture: Boolean; out Result: Boolean);
procedure Chromium1Paint(Sender: TObject; const browser: ICefBrowser;
type_: TCefPaintElementType; dirtyRectsCount: NativeUInt;
const dirtyRects: PCefRectArray; const buffer: Pointer; aWidth,
aHeight: Integer);
procedure Chromium1PopupShow(Sender: TObject; const browser: ICefBrowser;
aShow: Boolean);
procedure Chromium1PopupSize(Sender: TObject; const browser: ICefBrowser;
const rect: PCefRect);
procedure Chromium1Tooltip(Sender: TObject; const browser: ICefBrowser;
var aText: ustring; out Result: Boolean);
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 Chromium1CursorChange(Sender: TObject; const browser: ICefBrowser; cursor_: TCefCursorHandle; cursorType: TCefCursorType; const customCursorInfo: PCefCursorInfo; var aResult : boolean);
procedure Chromium1GetScreenInfo(Sender: TObject; const browser: ICefBrowser; var screenInfo: TCefScreenInfo; out Result: Boolean);
procedure Chromium1GetScreenPoint(Sender: TObject; const browser: ICefBrowser; viewX, viewY: Integer; var screenX, screenY: Integer; out Result: Boolean);
procedure Chromium1GetViewRect(Sender: TObject; const browser: ICefBrowser; var rect: TCefRect);
procedure Chromium1OpenUrlFromTab(Sender: TObject; const browser: ICefBrowser; const frame: ICefFrame; const targetUrl: ustring; targetDisposition: TCefWindowOpenDisposition; userGesture: Boolean; out Result: Boolean);
procedure Chromium1Paint(Sender: TObject; const browser: ICefBrowser; type_: TCefPaintElementType; dirtyRectsCount: NativeUInt; const dirtyRects: PCefRectArray; const buffer: Pointer; aWidth, aHeight: Integer);
procedure Chromium1PopupShow(Sender: TObject; const browser: ICefBrowser; aShow: Boolean);
procedure Chromium1PopupSize(Sender: TObject; const browser: ICefBrowser; const rect: PCefRect);
procedure Chromium1Tooltip(Sender: TObject; const browser: ICefBrowser; var aText: ustring; out Result: Boolean);
procedure FormCloseQuery(Sender: TObject; var CanClose: boolean);
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure FormHide(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure GoBtnClick(Sender: TObject);
procedure GoBtnEnter(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
procedure SnapshotBtnClick(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
procedure AddressEdtEnter(Sender: TObject);
private
protected
FbFirst : boolean;
FPopUpBitmap : TBitmap;
FPopUpRect : TRect;
FShowPopUp : boolean;
FResizing : boolean;
FPendingResize : boolean;
FCanClose : boolean;
FClosing : boolean;
FResizeCS : TCriticalSection;
FDeviceBounds : TCefRectDynArray;
FSelectedRange : TCefRange;
FResizeCS : TCriticalSection;
FBrowserCS : TCriticalSection;
FPanelCursor : TCursor;
FPanelHint : ustring;
function SendCompMessage(aMsg : cardinal) : boolean;
function GetPanelCursor : TCursor;
function GetPanelHint : ustring;
procedure SetPanelCursor(aValue : TCursor);
procedure SetPanelHint(const aValue : ustring);
procedure SendCompMessage(aMsg : cardinal);
function getModifiers(Shift: TShiftState): TCefEventFlags;
function GetButton(Button: TMouseButton): TCefMouseButtonType;
procedure DoResize;
procedure BrowserCreated;
procedure BrowserCreatedMsg(Data: PtrInt);
procedure BrowserCloseFormMsg(Data: PtrInt);
procedure PendingResizeMsg(Data: PtrInt);
procedure PendingInvalidateMsg(Data: PtrInt);
public
procedure PendingCursorUpdateMsg(Data: PtrInt);
procedure PendingHintUpdateMsg(Data: PtrInt);
property PanelCursor : TCursor read GetPanelCursor write SetPanelCursor;
property PanelHint : ustring read GetPanelHint write SetPanelHint;
public
procedure SendCEFKeyEvent(const aCefEvent : TCefKeyEvent);
end;
var
@@ -157,36 +142,136 @@ implementation
{$R *.lfm}
// This is a simple CEF browser in "off-screen rendering" mode (a.k.a OSR mode)
// It uses the default CEF configuration with a multithreaded message loop and
// that means that the TChromium events are executed in a CEF thread.
// GTK is not thread safe so we have to save all the information given in the
// TChromium events and use it later in the main application thread. We use
// critical sections to protect all that information.
// For example, the browser updates the mouse cursor in the
// TChromium.OnCursorChange event so we have to save the cursor in FPanelCursor
// and use Application.QueueAsyncCall to update the Panel1.Cursor value in the
// main application thread.
// The raw bitmap information given in the TChromium.OnPaint event also needs to
// be stored in a TCEFBitmapBitBuffer class instead of a simple TBitmap to avoid
// issues with GTK.
// Chromium needs the key press data available in the GDK signals
// "key-press-event" and "key-release-event" but Lazarus doesn't expose that
// information so we have to call g_signal_connect to receive that information
// in the GTKKeyPress function.
// Chromium renders the web contents asynchronously. It uses multiple processes
// and threads which makes it complicated to keep the correct browser size.
// In one hand you have the main application thread where the form is resized by
// the user. On the other hand, Chromium renders the contents asynchronously
// with the last browser size available, which may have changed by the time
// Chromium renders the page.
// For this reason we need to keep checking the real size and call
// TChromium.WasResized when we detect that Chromium has an incorrect size.
// TChromium.WasResized triggers the TChromium.OnGetViewRect event to let CEF
// read the current browser size and then it triggers TChromium.OnPaint when the
// contents are finally rendered.
// TChromium.WasResized --> (time passes) --> TChromium.OnGetViewRect --> (time passes) --> TChromium.OnPaint
// You have to assume that the real browser size can change between those calls
// and events.
// This demo uses a couple of fields called "FResizing" and "FPendingResize" to
// reduce the number of TChromium.WasResized calls.
// FResizing is set to True before the TChromium.WasResized call and it's set to
// False at the end of the TChromium.OnPaint event.
// FPendingResize is set to True when the browser changed its size while
// FResizing was True. The FPendingResize value is checked at the end of
// TChromium.OnPaint to check the browser size again because it changed while
// Chromium was rendering the page.
// The TChromium.OnPaint event in the demo also calls
// TBufferPanel.UpdateBufferDimensions and TBufferPanel.BufferIsResized to check
// the width and height of the buffer parameter, and the internal buffer size in
// the TBufferPanel component.
// Lazarus usually initializes the GTK WidgetSet in the initialization section
// of the "Interfaces" unit which is included in the LPR file. This causes
// initialization problems in CEF and we need to call "CreateWidgetset" after
// the GlobalCEFApp.StartMainProcess call.
// Lazarus shows a warning if we remove the "Interfaces" unit from the LPR file
// so we created a custom unit with the same name that includes two procedures
// to initialize and finalize the WidgetSet at the right time.
// This is the destruction sequence in OSR mode :
// 1- FormCloseQuery sets CanClose to the initial FCanClose value (False) and calls Chromium1.CloseBrowser(True).
// 2- Chromium1.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 calls SendCompMessage(CEF_BEFORECLOSE) to
// close the form asynchronously.
uses
Math,
uCEFMiscFunctions, uCEFApplication;
Math, gtk2, glib2, gdk2, gtk2proc, gtk2int,
uCEFMiscFunctions, uCEFApplication, uCEFBitmapBitBuffer;
const
CEF_UPDATE_CURSOR = $A0D;
CEF_UPDATE_HINT = $A0E;
procedure CreateGlobalCEFApp;
var
TempHome, TempBinDir : ustring;
begin
TempHome := IncludeTrailingPathDelimiter(GetEnvironmentVariable('HOME'));
TempBinDir := TempHome + 'Lazarus/CEF4Delphi/bin';
GlobalCEFApp := TCefApplication.Create;
GlobalCEFApp.WindowlessRenderingEnabled := True;
GlobalCEFApp.EnableHighDPISupport := True;
GlobalCEFApp.SetCurrentDir := True;
GlobalCEFApp.BackgroundColor := CefColorSetARGB($FF, $FF, $FF, $FF);
if DirectoryExists(TempBinDir) then
//GlobalCEFApp.LogFile := 'debug.log';
//GlobalCEFApp.LogSeverity := LOGSEVERITY_INFO;
end;
function GTKKeyPress(Widget: PGtkWidget; Event: PGdkEventKey; Data: gPointer) : GBoolean; cdecl;
var
TempCefEvent : TCefKeyEvent;
begin
GdkEventKeyToCEFKeyEvent(Event, TempCefEvent);
if (Event^._type = GDK_KEY_PRESS) then
begin
GlobalCEFApp.FrameworkDirPath := TempBinDir;
GlobalCEFApp.ResourcesDirPath := TempBinDir;
GlobalCEFApp.LocalesDirPath := TempBinDir + '/locales';
TempCefEvent.kind := KEYEVENT_RAWKEYDOWN;
Form1.SendCEFKeyEvent(TempCefEvent);
TempCefEvent.kind := KEYEVENT_CHAR;
Form1.SendCEFKeyEvent(TempCefEvent);
end
else
begin
TempCefEvent.kind := KEYEVENT_KEYUP;
Form1.SendCEFKeyEvent(TempCefEvent);
end;
// Add a debug log in the BIN directory
GlobalCEFApp.LogFile := 'cef.log';
GlobalCEFApp.LogSeverity := LOGSEVERITY_VERBOSE;
Result := True;
end;
procedure ConnectKeyPressReleaseEvents(const aWidget : PGtkWidget);
begin
g_signal_connect(aWidget, 'key-press-event', TGTKSignalFunc(@GTKKeyPress), nil);
g_signal_connect(aWidget, 'key-release-event', TGTKSignalFunc(@GTKKeyPress), nil);
end;
{ TForm1 }
procedure TForm1.SendCEFKeyEvent(const aCefEvent : TCefKeyEvent);
begin
Chromium1.SendKeyEvent(@aCefEvent);
end;
procedure TForm1.GoBtnClick(Sender: TObject);
begin
FResizeCS.Acquire;
@@ -197,37 +282,10 @@ begin
Chromium1.LoadURL(AddressEdt.Text);
end;
procedure TForm1.Chromium1AfterCreated(Sender: TObject;
const browser: ICefBrowser);
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.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);
Chromium1.SendKeyEvent(@TempKeyEvent);
end;
end;
SendCompMessage(CEF_AFTERCREATED);
end;
procedure TForm1.AddressEdtEnter(Sender: TObject);
@@ -250,64 +308,19 @@ begin
Chromium1.SendFocusEvent(False);
end;
procedure TForm1.Panel1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
var
TempKeyEvent : TCefKeyEvent;
begin
if (Key <> 0) and (Chromium1 <> 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);
Chromium1.SendKeyEvent(@TempKeyEvent);
if (Key in [VK_LEFT, VK_RIGHT, VK_UP, VK_DOWN, VK_TAB]) then Key := 0;
end;
end;
procedure TForm1.Panel1KeyUp(Sender: TObject; var Key: Word;
Shift: TShiftState);
var
TempKeyEvent : TCefKeyEvent;
begin
if (Key <> 0) and (Chromium1 <> 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);
Chromium1.SendKeyEvent(@TempKeyEvent);
end;
end;
procedure TForm1.Panel1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
var
TempEvent : TCefMouseEvent;
TempTime : integer;
begin
if (GlobalCEFApp <> nil) and (Chromium1 <> nil) then
begin
Panel1.SetFocus;
Panel1.SetFocus;
TempEvent.x := X;
TempEvent.y := Y;
TempEvent.modifiers := getModifiers(Shift);
DeviceToLogical(TempEvent, GlobalCEFApp.DeviceScaleFactor);
Chromium1.SendMouseClickEvent(@TempEvent, GetButton(Button), False, 1);
end;
TempEvent.x := X;
TempEvent.y := Y;
TempEvent.modifiers := getModifiers(Shift);
DeviceToLogical(TempEvent, Panel1.ScreenScale);
Chromium1.SendMouseClickEvent(@TempEvent, GetButton(Button), False, 1);
end;
procedure TForm1.Panel1MouseMove(Sender: TObject; Shift: TShiftState; X,
@@ -316,14 +329,11 @@ var
TempEvent : TCefMouseEvent;
TempTime : integer;
begin
if (GlobalCEFApp <> nil) and (Chromium1 <> nil) then
begin
TempEvent.x := x;
TempEvent.y := y;
TempEvent.modifiers := getModifiers(Shift);
DeviceToLogical(TempEvent, GlobalCEFApp.DeviceScaleFactor);
Chromium1.SendMouseMoveEvent(@TempEvent, False);
end;
TempEvent.x := x;
TempEvent.y := y;
TempEvent.modifiers := getModifiers(Shift);
DeviceToLogical(TempEvent, Panel1.ScreenScale);
Chromium1.SendMouseMoveEvent(@TempEvent, False);
end;
procedure TForm1.Panel1MouseUp(Sender: TObject; Button: TMouseButton;
@@ -331,14 +341,11 @@ procedure TForm1.Panel1MouseUp(Sender: TObject; Button: TMouseButton;
var
TempEvent : TCefMouseEvent;
begin
if (GlobalCEFApp <> nil) and (Chromium1 <> nil) then
begin
TempEvent.x := X;
TempEvent.y := Y;
TempEvent.modifiers := getModifiers(Shift);
DeviceToLogical(TempEvent, GlobalCEFApp.DeviceScaleFactor);
Chromium1.SendMouseClickEvent(@TempEvent, GetButton(Button), True, 1);
end;
TempEvent.x := X;
TempEvent.y := Y;
TempEvent.modifiers := getModifiers(Shift);
DeviceToLogical(TempEvent, Panel1.ScreenScale);
Chromium1.SendMouseClickEvent(@TempEvent, GetButton(Button), True, 1);
end;
procedure TForm1.Panel1MouseWheel(Sender: TObject; Shift: TShiftState;
@@ -346,14 +353,11 @@ procedure TForm1.Panel1MouseWheel(Sender: TObject; Shift: TShiftState;
var
TempEvent : TCefMouseEvent;
begin
if (GlobalCEFApp <> nil) and (Chromium1 <> nil) then
begin
TempEvent.x := MousePos.x;
TempEvent.y := MousePos.y;
TempEvent.modifiers := getModifiers(Shift);
DeviceToLogical(TempEvent, GlobalCEFApp.DeviceScaleFactor);
Chromium1.SendMouseWheelEvent(@TempEvent, 0, WheelDelta);
end;
TempEvent.x := MousePos.x;
TempEvent.y := MousePos.y;
TempEvent.modifiers := getModifiers(Shift);
DeviceToLogical(TempEvent, Panel1.ScreenScale);
Chromium1.SendMouseWheelEvent(@TempEvent, 0, WheelDelta);
end;
procedure TForm1.Panel1Resize(Sender: TObject);
@@ -406,34 +410,33 @@ procedure TForm1.Chromium1CursorChange(Sender: TObject;
cursorType: TCefCursorType; const customCursorInfo: PCefCursorInfo;
var aResult : boolean);
begin
Panel1.Cursor := CefCursorToWindowsCursor(cursorType);
aResult := True;
PanelCursor := CefCursorToWindowsCursor(cursorType);
aResult := True;
SendCompMessage(CEF_UPDATE_CURSOR);
end;
procedure TForm1.Chromium1GetScreenInfo(Sender: TObject;
const browser: ICefBrowser; var screenInfo: TCefScreenInfo; out
Result: Boolean);
var
TempRect : TCEFRect;
begin
if (GlobalCEFApp <> nil) then
begin
TempRect.x := 0;
TempRect.y := 0;
TempRect.width := DeviceToLogical(Panel1.Width, GlobalCEFApp.DeviceScaleFactor);
TempRect.height := DeviceToLogical(Panel1.Height, GlobalCEFApp.DeviceScaleFactor);
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 := GlobalCEFApp.DeviceScaleFactor;
screenInfo.depth := 0;
screenInfo.depth_per_component := 0;
screenInfo.is_monochrome := Ord(False);
screenInfo.rect := TempRect;
screenInfo.available_rect := TempRect;
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
else
Result := False;
Result := True;
end;
procedure TForm1.Chromium1GetScreenPoint(Sender: TObject;
@@ -441,30 +444,27 @@ procedure TForm1.Chromium1GetScreenPoint(Sender: TObject;
screenY: Integer; out Result: Boolean);
var
TempScreenPt, TempViewPt : TPoint;
TempScale : single;
begin
if (GlobalCEFApp <> nil) then
begin
TempViewPt.x := LogicalToDevice(viewX, GlobalCEFApp.DeviceScaleFactor);
TempViewPt.y := LogicalToDevice(viewY, GlobalCEFApp.DeviceScaleFactor);
TempScreenPt := Panel1.ClientToScreen(TempViewPt);
screenX := TempScreenPt.x;
screenY := TempScreenPt.y;
Result := True;
end
else
Result := False;
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 TForm1.Chromium1GetViewRect(Sender: TObject;
const browser: ICefBrowser; var rect: TCefRect);
begin
if (GlobalCEFApp <> nil) then
begin
rect.x := 0;
rect.y := 0;
rect.width := DeviceToLogical(Panel1.Width, GlobalCEFApp.DeviceScaleFactor);
rect.height := DeviceToLogical(Panel1.Height, GlobalCEFApp.DeviceScaleFactor);
end;
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 TForm1.Chromium1OpenUrlFromTab(Sender: TObject;
@@ -487,7 +487,8 @@ var
TempWidth, TempHeight : integer;
TempBufferBits : Pointer;
TempForcedResize : boolean;
TempBitmap : TBitmap;
TempBitmap : TCEFBitmapBitBuffer;
TempSrcRect : TRect;
begin
try
FResizeCS.Acquire;
@@ -497,87 +498,73 @@ begin
begin
if (type_ = PET_POPUP) then
begin
if (FPopUpBitmap = nil) or
(aWidth <> FPopUpBitmap.Width) or
(aHeight <> FPopUpBitmap.Height) then
begin
if (FPopUpBitmap <> nil) then FPopUpBitmap.Free;
Panel1.UpdatePopupBufferDimensions(aWidth, aHeight);
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;
TempBitmap := Panel1.PopupBuffer;
TempWidth := Panel1.PopupBufferWidth;
TempHeight := Panel1.PopupBufferHeight;
end
else
begin
TempForcedResize := Panel1.UpdateBufferDimensions(aWidth, aHeight) or not(Panel1.BufferIsResized(False));
TempForcedResize := Panel1.UpdateBufferDimensions(aWidth, aHeight) or
not(Panel1.BufferIsResized(False));
TempBitmap := Panel1.Buffer;
TempBitmap.BeginUpdate;
TempWidth := Panel1.BufferWidth;
TempHeight := Panel1.BufferHeight;
end;
if (TempBufferBits <> nil) then
SrcStride := aWidth * SizeOf(TRGBQuad);
n := 0;
while (n < dirtyRectsCount) do
begin
SrcStride := aWidth * SizeOf(TRGBQuad);
n := 0;
while (n < dirtyRectsCount) do
if (dirtyRects^[n].x >= 0) and (dirtyRects^[n].y >= 0) then
begin
if (dirtyRects^[n].x >= 0) and (dirtyRects^[n].y >= 0) then
TempLineSize := min(dirtyRects^[n].width, TempWidth - dirtyRects^[n].x) * SizeOf(TRGBQuad);
if (TempLineSize > 0) then
begin
TempLineSize := min(dirtyRects^[n].width, TempWidth - dirtyRects^[n].x) * SizeOf(TRGBQuad);
TempSrcOffset := ((dirtyRects^[n].y * aWidth) + dirtyRects^[n].x) * SizeOf(TRGBQuad);
TempDstOffset := (dirtyRects^[n].x * SizeOf(TRGBQuad));
if (TempLineSize > 0) then
src := @PByte(buffer)[TempSrcOffset];
i := 0;
j := min(dirtyRects^[n].height, TempHeight - dirtyRects^[n].y);
while (i < j) do
begin
TempSrcOffset := ((dirtyRects^[n].y * aWidth) + dirtyRects^[n].x) * SizeOf(TRGBQuad);
TempDstOffset := (dirtyRects^[n].x * SizeOf(TRGBQuad));
TempBufferBits := TempBitmap.Scanline[dirtyRects^[n].y + i];
dst := @PByte(TempBufferBits)[TempDstOffset];
src := @PByte(buffer)[TempSrcOffset];
Move(src^, dst^, TempLineSize);
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;
Inc(src, SrcStride);
inc(i);
end;
end;
inc(n);
end;
TempBitmap.EndUpdate;
inc(n);
end;
if FShowPopup and (FPopUpBitmap <> nil) then
Panel1.BufferDraw(FPopUpRect.Left, FPopUpRect.Top, FPopUpBitmap);
if FShowPopup then
begin
TempSrcRect := Rect(0, 0,
FPopUpRect.Right - FPopUpRect.Left,
FPopUpRect.Bottom - FPopUpRect.Top);
Panel1.DrawPopupBuffer(TempSrcRect, FPopUpRect);
end;
Panel1.EndBufferDraw;
if HandleAllocated then SendCompMessage(CEF_PENDINGINVALIDATE);
SendCompMessage(CEF_PENDINGINVALIDATE);
if (type_ = PET_VIEW) then
begin
if (TempForcedResize or FPendingResize) and
HandleAllocated then
if TempForcedResize or FPendingResize then
SendCompMessage(CEF_PENDINGRESIZE);
FResizing := False;
@@ -589,8 +576,7 @@ begin
end;
end;
procedure TForm1.Chromium1PopupShow(Sender: TObject;
const browser: ICefBrowser; aShow: Boolean);
procedure TForm1.Chromium1PopupShow(Sender: TObject; const browser: ICefBrowser; aShow: Boolean);
begin
if aShow then
FShowPopUp := True
@@ -603,26 +589,22 @@ begin
end;
end;
procedure TForm1.Chromium1PopupSize(Sender: TObject;
const browser: ICefBrowser; const rect: PCefRect);
procedure TForm1.Chromium1PopupSize(Sender: TObject; const browser: ICefBrowser; const rect: PCefRect);
begin
if (GlobalCEFApp <> nil) then
begin
LogicalToDevice(rect^, GlobalCEFApp.DeviceScaleFactor);
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;
FPopUpRect.Left := rect^.x;
FPopUpRect.Top := rect^.y;
FPopUpRect.Right := rect^.x + rect^.width - 1;
FPopUpRect.Bottom := rect^.y + rect^.height - 1;
end;
procedure TForm1.Chromium1Tooltip(Sender: TObject; const browser: ICefBrowser;
var aText: ustring; out Result: Boolean);
procedure TForm1.Chromium1Tooltip(Sender: TObject; const browser: ICefBrowser; var aText: ustring; out Result: Boolean);
begin
Panel1.hint := aText;
Panel1.ShowHint := (length(aText) > 0);
Result := True;
PanelHint := aText;
Result := True;
SendCompMessage(CEF_UPDATE_HINT);
end;
procedure TForm1.FormCloseQuery(Sender: TObject; var CanClose: boolean);
@@ -639,31 +621,22 @@ end;
procedure TForm1.FormCreate(Sender: TObject);
begin
FbFirst := False;
FPopUpBitmap := nil;
FPopUpRect := rect(0, 0, 0, 0);
FShowPopUp := False;
FResizing := False;
FPendingResize := False;
FCanClose := False;
FClosing := False;
FDeviceBounds := nil;
FResizeCS := TCriticalSection.Create;
FBrowserCS := TCriticalSection.Create;
FSelectedRange.from := 0;
FSelectedRange.to_ := 0;
ConnectKeyPressReleaseEvents(PGtkWidget(Panel1.Handle));
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
if (FPopUpBitmap <> nil) then FreeAndNil(FPopUpBitmap);
if (FResizeCS <> nil) then FreeAndNil(FResizeCS);
if (FDeviceBounds <> nil) then
begin
Finalize(FDeviceBounds);
FDeviceBounds := nil;
end;
if (FResizeCS <> nil) then FreeAndNil(FResizeCS);
if (FBrowserCS <> nil) then FreeAndNil(FBrowserCS);
end;
procedure TForm1.FormHide(Sender: TObject);
@@ -681,11 +654,15 @@ begin
end
else
begin
// We have to update the DeviceScaleFactor here to get the scale of the
// monitor where the main application form is located.
GlobalCEFApp.UpdateDeviceScaleFactor;
// opaque white background color
Chromium1.Options.BackgroundColor := CefColorSetARGB($FF, $FF, $FF, $FF);
Chromium1.DefaultURL := UTF8Decode(AddressEdt.Text);
Chromium1.DefaultURL := UTF8Decode(AddressEdt.Text);
if not(Chromium1.CreateBrowser(nil, '')) then Timer1.Enabled := True;
if not(Chromium1.CreateBrowser) then Timer1.Enabled := True;
end;
end;
@@ -694,15 +671,21 @@ begin
Chromium1.SendFocusEvent(False);
end;
procedure TForm1.SnapshotBtnClick(Sender: TObject);
begin
if SaveDialog1.Execute then
Panel1.SaveToFile(SaveDialog1.FileName);
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
Timer1.Enabled := False;
if not(Chromium1.CreateBrowser(nil, '')) and not(Chromium1.Initialized) then
if not(Chromium1.CreateBrowser) and not(Chromium1.Initialized) then
Timer1.Enabled := True;
end;
procedure TForm1.BrowserCreated;
procedure TForm1.BrowserCreatedMsg(Data: PtrInt);
begin
Caption := 'Simple OSR Browser';
AddressPnl.Enabled := True;
@@ -723,12 +706,26 @@ begin
Panel1.Invalidate;
end;
function TForm1.SendCompMessage(aMsg : cardinal) : boolean;
procedure TForm1.PendingCursorUpdateMsg(Data: PtrInt);
begin
Panel1.Cursor := PanelCursor;
end;
procedure TForm1.PendingHintUpdateMsg(Data: PtrInt);
begin
Panel1.hint := PanelHint;
Panel1.ShowHint := (length(Panel1.hint) > 0);
end;
procedure TForm1.SendCompMessage(aMsg : cardinal);
begin
case aMsg of
CEF_AFTERCREATED : Application.QueueAsyncCall(@BrowserCreatedMsg, 0);
CEF_BEFORECLOSE : Application.QueueAsyncCall(@BrowserCloseFormMsg, 0);
CEF_PENDINGRESIZE : Application.QueueAsyncCall(@PendingResizeMsg, 0);
CEF_PENDINGINVALIDATE : Application.QueueAsyncCall(@PendingInvalidateMsg, 0);
CEF_UPDATE_CURSOR : Application.QueueAsyncCall(@PendingCursorUpdateMsg, 0);
CEF_UPDATE_HINT : Application.QueueAsyncCall(@PendingHintUpdateMsg, 0);
end;
end;
@@ -750,6 +747,46 @@ begin
finally
FResizeCS.Release;
end;
end;
function TForm1.GetPanelCursor : TCursor;
begin
try
FBrowserCS.Acquire;
Result := FPanelCursor;
finally
FBrowserCS.Release;
end;
end;
function TForm1.GetPanelHint : ustring;
begin
try
FBrowserCS.Acquire;
Result := FPanelHint;
finally
FBrowserCS.Release;
end;
end;
procedure TForm1.SetPanelCursor(aValue : TCursor);
begin
try
FBrowserCS.Acquire;
FPanelCursor := aValue;
finally
FBrowserCS.Release;
end;
end;
procedure TForm1.SetPanelHint(const aValue : ustring);
begin
try
FBrowserCS.Acquire;
FPanelHint := aValue;
finally
FBrowserCS.Release;
end;
end;
end.

View File

@@ -8,6 +8,7 @@
<Unit0>
<Filename Value="SimpleOSRBrowser.lpr"/>
<IsPartOfProject Value="True"/>
<IsVisibleTab Value="True"/>
<TopLine Value="38"/>
<CursorPos X="11" Y="46"/>
<UsageCount Value="20"/>
@@ -36,10 +37,9 @@
<ComponentName Value="Form1"/>
<HasResources Value="True"/>
<ResourceBaseClass Value="Form"/>
<IsVisibleTab Value="True"/>
<EditorIndex Value="1"/>
<TopLine Value="804"/>
<CursorPos X="70" Y="818"/>
<TopLine Value="803"/>
<CursorPos X="72" Y="824"/>
<UsageCount Value="42"/>
<Bookmarks Count="2">
<Item0 X="40" Y="302" ID="4"/>