1
0
mirror of https://github.com/salvadordf/CEF4Delphi.git synced 2025-06-02 21:57:37 +02:00

Fixed OSRExternalPumpBrowser in Linux

Fixed SimpleOSRBrowser in Linux
Added the TBufferPanel.CopyOriginalBuffer property
Added the TBufferPanel.MustInitBuffer property
Added the TBufferPanel.OrigBuffer property
Added the TBufferPanel.OrigBufferWidth property
Added the TBufferPanel.OrigBufferHeight property
Renamed TBufferPanel.PopupBuffer to TBufferPanel.OrigPopupBuffer
Renamed TBufferPanel.PopupBufferWidth to TBufferPanel.OrigPopupBufferWidth
Renamed TBufferPanel.PopupBufferHeight to TBufferPanel.OrigPopupBufferHeight
Renamed TBufferPanel.PopupBufferBits to TBufferPanel.OrigPopupBufferBits
Renamed TBufferPanel.PopupScanlineSize to TBufferPanel.OrigPopupScanlineSize
Added the TBufferPanel.UpdateOrigBufferDimensions function
Added the TBufferPanel.UpdateOrigPopupBufferDimensions function
This commit is contained in:
Salvador Diaz Fau 2021-01-12 17:06:31 +01:00
parent 1fca56f298
commit 123f45ea08
10 changed files with 667 additions and 517 deletions

View File

@ -7,7 +7,7 @@
<Unit0> <Unit0>
<Filename Value="MiniBrowser.lpr"/> <Filename Value="MiniBrowser.lpr"/>
<IsPartOfProject Value="True"/> <IsPartOfProject Value="True"/>
<EditorIndex Value="6"/> <EditorIndex Value="1"/>
<TopLine Value="26"/> <TopLine Value="26"/>
<CursorPos X="62" Y="52"/> <CursorPos X="62" Y="52"/>
<UsageCount Value="22"/> <UsageCount Value="22"/>
@ -20,7 +20,7 @@
<HasResources Value="True"/> <HasResources Value="True"/>
<ResourceBaseClass Value="Form"/> <ResourceBaseClass Value="Form"/>
<IsVisibleTab Value="True"/> <IsVisibleTab Value="True"/>
<TopLine Value="183"/> <TopLine Value="187"/>
<CursorPos Y="352"/> <CursorPos Y="352"/>
<FoldState Value=" TJmA1{32 pjZlg1@4 pmOoL1{D1q"/> <FoldState Value=" TJmA1{32 pjZlg1@4 pmOoL1{D1q"/>
<UsageCount Value="22"/> <UsageCount Value="22"/>
@ -70,33 +70,30 @@
</Unit6> </Unit6>
<Unit7> <Unit7>
<Filename Value="../../../source/uCEFChromium.pas"/> <Filename Value="../../../source/uCEFChromium.pas"/>
<EditorIndex Value="5"/> <EditorIndex Value="-1"/>
<TopLine Value="130"/> <TopLine Value="130"/>
<CursorPos X="3" Y="146"/> <CursorPos X="3" Y="146"/>
<UsageCount Value="10"/> <UsageCount Value="10"/>
<Loaded Value="True"/>
</Unit7> </Unit7>
<Unit8> <Unit8>
<Filename Value="../../../source/uCEFMiscFunctions.pas"/> <Filename Value="../../../source/uCEFMiscFunctions.pas"/>
<EditorIndex Value="1"/> <EditorIndex Value="-1"/>
<TopLine Value="780"/> <TopLine Value="780"/>
<CursorPos X="70" Y="807"/> <CursorPos X="70" Y="807"/>
<UsageCount Value="10"/> <UsageCount Value="10"/>
<Bookmarks Count="1"> <Bookmarks Count="1">
<Item0 X="68" Y="793" ID="2"/> <Item0 X="68" Y="793" ID="2"/>
</Bookmarks> </Bookmarks>
<Loaded Value="True"/>
</Unit8> </Unit8>
<Unit9> <Unit9>
<Filename Value="../../../source/uCEFChromiumCore.pas"/> <Filename Value="../../../source/uCEFChromiumCore.pas"/>
<EditorIndex Value="3"/> <EditorIndex Value="-1"/>
<TopLine Value="1950"/> <TopLine Value="1950"/>
<CursorPos X="71" Y="1975"/> <CursorPos X="71" Y="1975"/>
<UsageCount Value="10"/> <UsageCount Value="10"/>
<Bookmarks Count="1"> <Bookmarks Count="1">
<Item0 X="56" Y="1966" ID="1"/> <Item0 X="56" Y="1966" ID="1"/>
</Bookmarks> </Bookmarks>
<Loaded Value="True"/>
</Unit9> </Unit9>
<Unit10> <Unit10>
<Filename Value="/usr/share/fpcsrc/3.2.0/packages/gtk2/src/gtk+/gtk/gtkwidget.inc"/> <Filename Value="/usr/share/fpcsrc/3.2.0/packages/gtk2/src/gtk+/gtk/gtkwidget.inc"/>
@ -107,144 +104,42 @@
</Unit10> </Unit10>
<Unit11> <Unit11>
<Filename Value="../../../source/uCEFTypes.pas"/> <Filename Value="../../../source/uCEFTypes.pas"/>
<EditorIndex Value="2"/> <EditorIndex Value="-1"/>
<TopLine Value="1228"/> <TopLine Value="1228"/>
<CursorPos X="53" Y="1251"/> <CursorPos X="53" Y="1251"/>
<UsageCount Value="10"/> <UsageCount Value="10"/>
<Loaded Value="True"/>
</Unit11> </Unit11>
<Unit12> <Unit12>
<Filename Value="../../../source/uCEFApplicationCore.pas"/> <Filename Value="../../../source/uCEFApplicationCore.pas"/>
<EditorIndex Value="4"/> <EditorIndex Value="-1"/>
<TopLine Value="220"/> <TopLine Value="220"/>
<UsageCount Value="10"/> <UsageCount Value="10"/>
<Loaded Value="True"/>
</Unit12> </Unit12>
</Units> </Units>
<OtherDefines Count="1"> <OtherDefines Count="1">
<Define0 Value="UseCThreads"/> <Define0 Value="UseCThreads"/>
</OtherDefines> </OtherDefines>
<JumpHistory Count="30" HistoryIndex="29"> <JumpHistory Count="5" HistoryIndex="4">
<Position1> <Position1>
<Filename Value="../../../source/uCEFMiscFunctions.pas"/>
<Caret Line="173" Column="11" TopLine="150"/>
</Position1>
<Position2>
<Filename Value="../../../source/uCEFMiscFunctions.pas"/>
<Caret Line="786" TopLine="767"/>
</Position2>
<Position3>
<Filename Value="../../../source/uCEFChromium.pas"/>
<Caret Line="142" Column="49" TopLine="121"/>
</Position3>
<Position4>
<Filename Value="../../../source/uCEFChromium.pas"/>
<Caret Line="148" Column="45" TopLine="121"/>
</Position4>
<Position5>
<Filename Value="../../../source/uCEFChromiumCore.pas"/>
<Caret Line="447" Column="17" TopLine="426"/>
</Position5>
<Position6>
<Filename Value="../../../source/uCEFChromiumCore.pas"/>
<Caret Line="1956" Column="3" TopLine="1950"/>
</Position6>
<Position7>
<Filename Value="../../../source/uCEFMiscFunctions.pas"/>
<Caret Line="173" Column="11" TopLine="150"/>
</Position7>
<Position8>
<Filename Value="../../../source/uCEFMiscFunctions.pas"/>
<Caret Line="790" Column="3" TopLine="786"/>
</Position8>
<Position9>
<Filename Value="../../../source/uCEFMiscFunctions.pas"/>
<Caret Line="772" Column="17" TopLine="749"/>
</Position9>
<Position10>
<Filename Value="uMiniBrowser.pas"/> <Filename Value="uMiniBrowser.pas"/>
<Caret Line="865" TopLine="829"/> <Caret Line="865" TopLine="829"/>
</Position10> </Position1>
<Position11> <Position2>
<Filename Value="uMiniBrowser.pas"/> <Filename Value="uMiniBrowser.pas"/>
<Caret Line="158" Column="15" TopLine="137"/> <Caret Line="158" Column="15" TopLine="137"/>
</Position11> </Position2>
<Position12> <Position3>
<Filename Value="uMiniBrowser.pas"/> <Filename Value="uMiniBrowser.pas"/>
<Caret Line="863" Column="3" TopLine="829"/> <Caret Line="863" Column="3" TopLine="829"/>
</Position12> </Position3>
<Position13> <Position4>
<Filename Value="../../../source/uCEFChromium.pas"/>
<Caret Line="76" Column="17" TopLine="53"/>
</Position13>
<Position14>
<Filename Value="../../../source/uCEFChromium.pas"/>
<Caret Line="157" Column="3" TopLine="146"/>
</Position14>
<Position15>
<Filename Value="../../../source/uCEFChromium.pas"/>
<Caret Line="70" Column="17" TopLine="47"/>
</Position15>
<Position16>
<Filename Value="../../../source/uCEFChromium.pas"/>
<Caret Line="146" Column="3" TopLine="133"/>
</Position16>
<Position17>
<Filename Value="../../../source/uCEFChromiumCore.pas"/>
<Caret Line="447" Column="17" TopLine="426"/>
</Position17>
<Position18>
<Filename Value="../../../source/uCEFChromiumCore.pas"/>
<Caret Line="1956" Column="3" TopLine="1950"/>
</Position18>
<Position19>
<Filename Value="../../../source/uCEFMiscFunctions.pas"/>
<Caret Line="173" Column="11" TopLine="150"/>
</Position19>
<Position20>
<Filename Value="uMiniBrowser.pas"/> <Filename Value="uMiniBrowser.pas"/>
<Caret Line="849" Column="74" TopLine="829"/> <Caret Line="849" Column="74" TopLine="829"/>
</Position20> </Position4>
<Position21> <Position5>
<Filename Value="../../../source/uCEFChromium.pas"/>
<Caret Line="76" Column="17" TopLine="53"/>
</Position21>
<Position22>
<Filename Value="../../../source/uCEFChromium.pas"/>
<Caret Line="157" Column="3" TopLine="140"/>
</Position22>
<Position23>
<Filename Value="../../../source/uCEFChromium.pas"/>
<Caret Line="70" Column="17" TopLine="48"/>
</Position23>
<Position24>
<Filename Value="../../../source/uCEFChromium.pas"/>
<Caret Line="146" Column="3" TopLine="130"/>
</Position24>
<Position25>
<Filename Value="../../../source/uCEFChromiumCore.pas"/>
<Caret Line="447" Column="17" TopLine="426"/>
</Position25>
<Position26>
<Filename Value="../../../source/uCEFChromiumCore.pas"/>
<Caret Line="1964" Column="66" TopLine="1950"/>
</Position26>
<Position27>
<Filename Value="../../../source/uCEFMiscFunctions.pas"/>
<Caret Line="173" Column="11" TopLine="150"/>
</Position27>
<Position28>
<Filename Value="../../../source/uCEFChromiumCore.pas"/>
<Caret Line="1964" Column="56" TopLine="1950"/>
</Position28>
<Position29>
<Filename Value="../../../source/uCEFMiscFunctions.pas"/>
<Caret Line="173" Column="11" TopLine="150"/>
</Position29>
<Position30>
<Filename Value="uMiniBrowser.pas"/> <Filename Value="uMiniBrowser.pas"/>
<Caret Line="222" Column="47" TopLine="210"/> <Caret Line="222" Column="47" TopLine="210"/>
</Position30> </Position5>
</JumpHistory> </JumpHistory>
<RunParams> <RunParams>
<FormatVersion Value="2"/> <FormatVersion Value="2"/>

View File

@ -3,15 +3,14 @@
<ProjectSession> <ProjectSession>
<Version Value="11"/> <Version Value="11"/>
<BuildModes Active="Default"/> <BuildModes Active="Default"/>
<Units Count="108"> <Units Count="112">
<Unit0> <Unit0>
<Filename Value="OSRExternalPumpBrowser.lpr"/> <Filename Value="OSRExternalPumpBrowser.lpr"/>
<IsPartOfProject Value="True"/> <IsPartOfProject Value="True"/>
<EditorIndex Value="1"/> <EditorIndex Value="-1"/>
<TopLine Value="30"/> <TopLine Value="30"/>
<CursorPos X="37" Y="51"/> <CursorPos X="37" Y="51"/>
<UsageCount Value="82"/> <UsageCount Value="90"/>
<Loaded Value="True"/>
</Unit0> </Unit0>
<Unit1> <Unit1>
<Filename Value="uosrexternalpumpbrowser.pas"/> <Filename Value="uosrexternalpumpbrowser.pas"/>
@ -21,12 +20,16 @@
<ResourceBaseClass Value="Form"/> <ResourceBaseClass Value="Form"/>
<UnitName Value="uOSRExternalPumpBrowser"/> <UnitName Value="uOSRExternalPumpBrowser"/>
<IsVisibleTab Value="True"/> <IsVisibleTab Value="True"/>
<TopLine Value="221"/> <TopLine Value="158"/>
<CursorPos X="43" Y="250"/> <CursorPos X="75" Y="192"/>
<UsageCount Value="82"/> <UsageCount Value="90"/>
<Bookmarks Count="2"> <Bookmarks Count="6">
<Item0 X="47" Y="222" ID="2"/> <Item0 Y="713" ID="2"/>
<Item1 X="76" Y="520" ID="6"/> <Item1 X="9" Y="603" ID="3"/>
<Item2 X="13" Y="316" ID="9"/>
<Item3 Y="690" ID="8"/>
<Item4 X="41" Y="280" ID="7"/>
<Item5 X="52" Y="189" ID="1"/>
</Bookmarks> </Bookmarks>
<Loaded Value="True"/> <Loaded Value="True"/>
<LoadedDesigner Value="True"/> <LoadedDesigner Value="True"/>
@ -37,7 +40,7 @@
<UnitName Value="Interfaces"/> <UnitName Value="Interfaces"/>
<EditorIndex Value="-1"/> <EditorIndex Value="-1"/>
<CursorPos X="40" Y="20"/> <CursorPos X="40" Y="20"/>
<UsageCount Value="78"/> <UsageCount Value="86"/>
</Unit2> </Unit2>
<Unit3> <Unit3>
<Filename Value="/usr/share/lazarus/2.0.6/lcl/lcltype.pp"/> <Filename Value="/usr/share/lazarus/2.0.6/lcl/lcltype.pp"/>
@ -126,25 +129,18 @@
</Unit14> </Unit14>
<Unit15> <Unit15>
<Filename Value="../../../source/uCEFBufferPanel.pas"/> <Filename Value="../../../source/uCEFBufferPanel.pas"/>
<EditorIndex Value="2"/> <EditorIndex Value="-1"/>
<TopLine Value="1043"/> <TopLine Value="469"/>
<CursorPos X="3" Y="71"/> <CursorPos X="3" Y="482"/>
<UsageCount Value="29"/> <UsageCount Value="29"/>
<Bookmarks Count="4">
<Item0 Y="1010" ID="9"/>
<Item1 X="63" Y="581" ID="8"/>
<Item2 X="5" Y="345" ID="7"/>
<Item3 X="5" Y="375" ID="1"/>
</Bookmarks>
<Loaded Value="True"/>
</Unit15> </Unit15>
<Unit16> <Unit16>
<Filename Value="/usr/share/lazarus/2.0.10/lcl/forms.pp"/> <Filename Value="/usr/share/lazarus/2.0.10/lcl/forms.pp"/>
<UnitName Value="Forms"/> <UnitName Value="Forms"/>
<EditorIndex Value="-1"/> <EditorIndex Value="-1"/>
<TopLine Value="684"/> <TopLine Value="1458"/>
<CursorPos X="31" Y="711"/> <CursorPos X="15" Y="1482"/>
<UsageCount Value="9"/> <UsageCount Value="10"/>
</Unit16> </Unit16>
<Unit17> <Unit17>
<Filename Value="../../../source/uCEFApplicationCore.pas"/> <Filename Value="../../../source/uCEFApplicationCore.pas"/>
@ -202,8 +198,8 @@
<Filename Value="/usr/share/lazarus/2.0.10/lcl/graphics.pp"/> <Filename Value="/usr/share/lazarus/2.0.10/lcl/graphics.pp"/>
<UnitName Value="Graphics"/> <UnitName Value="Graphics"/>
<EditorIndex Value="-1"/> <EditorIndex Value="-1"/>
<TopLine Value="1218"/> <TopLine Value="1068"/>
<CursorPos X="14" Y="1240"/> <CursorPos X="109" Y="1097"/>
<UsageCount Value="15"/> <UsageCount Value="15"/>
</Unit24> </Unit24>
<Unit25> <Unit25>
@ -403,8 +399,8 @@
<Unit52> <Unit52>
<Filename Value="../../../source/uCEFChromiumCore.pas"/> <Filename Value="../../../source/uCEFChromiumCore.pas"/>
<EditorIndex Value="-1"/> <EditorIndex Value="-1"/>
<TopLine Value="1122"/> <TopLine Value="6966"/>
<CursorPos Y="1147"/> <CursorPos X="78" Y="6355"/>
<UsageCount Value="10"/> <UsageCount Value="10"/>
</Unit52> </Unit52>
<Unit53> <Unit53>
@ -447,9 +443,9 @@
<Unit58> <Unit58>
<Filename Value="/usr/share/lazarus/2.0.10/lcl/include/application.inc"/> <Filename Value="/usr/share/lazarus/2.0.10/lcl/include/application.inc"/>
<EditorIndex Value="-1"/> <EditorIndex Value="-1"/>
<TopLine Value="230"/> <TopLine Value="2281"/>
<CursorPos X="3" Y="235"/> <CursorPos X="3" Y="2285"/>
<UsageCount Value="8"/> <UsageCount Value="10"/>
</Unit58> </Unit58>
<Unit59> <Unit59>
<Filename Value="/usr/share/lazarus/2.0.10/lcl/dialogs.pp"/> <Filename Value="/usr/share/lazarus/2.0.10/lcl/dialogs.pp"/>
@ -581,9 +577,9 @@
<Unit76> <Unit76>
<Filename Value="../../../source/uCEFTypes.pas"/> <Filename Value="../../../source/uCEFTypes.pas"/>
<EditorIndex Value="-1"/> <EditorIndex Value="-1"/>
<TopLine Value="1243"/> <TopLine Value="781"/>
<CursorPos X="9" Y="1271"/> <CursorPos X="3" Y="804"/>
<UsageCount Value="9"/> <UsageCount Value="10"/>
</Unit76> </Unit76>
<Unit77> <Unit77>
<Filename Value="/usr/share/fpcsrc/3.2.0/rtl/inc/objpash.inc"/> <Filename Value="/usr/share/fpcsrc/3.2.0/rtl/inc/objpash.inc"/>
@ -799,20 +795,150 @@
<CursorPos X="77" Y="127"/> <CursorPos X="77" Y="127"/>
<UsageCount Value="10"/> <UsageCount Value="10"/>
</Unit107> </Unit107>
<Unit108>
<Filename Value="../../Lazarus_Windows/OSRExternalPumpBrowser/uOSRExternalPumpBrowser.pas"/>
<EditorIndex Value="-1"/>
<TopLine Value="117"/>
<CursorPos X="73" Y="894"/>
<UsageCount Value="10"/>
</Unit108>
<Unit109>
<Filename Value="../../../source/uCEFChromiumOptions.pas"/>
<EditorIndex Value="-1"/>
<TopLine Value="77"/>
<CursorPos X="3" Y="60"/>
<UsageCount Value="10"/>
</Unit109>
<Unit110>
<Filename Value="../SimpleOSRBrowser/usimpleosrbrowser.pas"/>
<UnitName Value="uSimpleOSRBrowser"/>
<EditorIndex Value="-1"/>
<TopLine Value="772"/>
<CursorPos X="9" Y="817"/>
<UsageCount Value="10"/>
</Unit110>
<Unit111>
<Filename Value="../SimpleBrowser2/usimplebrowser2.pas"/>
<UnitName Value="uSimpleBrowser2"/>
<EditorIndex Value="-1"/>
<TopLine Value="16"/>
<CursorPos X="78" Y="45"/>
<UsageCount Value="10"/>
</Unit111>
</Units> </Units>
<OtherDefines Count="2"> <OtherDefines Count="2">
<Define0 Value="UseCthreads"/> <Define0 Value="UseCthreads"/>
<Define1 Value="EnabledGtkThreading"/> <Define1 Value="EnabledGtkThreading"/>
</OtherDefines> </OtherDefines>
<JumpHistory Count="2" HistoryIndex="1"> <JumpHistory Count="27" HistoryIndex="26">
<Position1> <Position1>
<Filename Value="uosrexternalpumpbrowser.pas"/> <Filename Value="uosrexternalpumpbrowser.pas"/>
<Caret Line="56" Column="63" TopLine="51"/> <Caret Line="506" TopLine="491"/>
</Position1> </Position1>
<Position2> <Position2>
<Filename Value="uosrexternalpumpbrowser.pas"/> <Filename Value="uosrexternalpumpbrowser.pas"/>
<Caret Line="234" TopLine="223"/> <Caret Line="740" TopLine="717"/>
</Position2> </Position2>
<Position3>
<Filename Value="uosrexternalpumpbrowser.pas"/>
<Caret Line="508" Column="3" TopLine="485"/>
</Position3>
<Position4>
<Filename Value="uosrexternalpumpbrowser.pas"/>
<Caret Line="733" Column="31" TopLine="720"/>
</Position4>
<Position5>
<Filename Value="uosrexternalpumpbrowser.pas"/>
<Caret Line="117" Column="15" TopLine="95"/>
</Position5>
<Position6>
<Filename Value="uosrexternalpumpbrowser.pas"/>
<Caret Line="743" Column="36" TopLine="719"/>
</Position6>
<Position7>
<Filename Value="uosrexternalpumpbrowser.pas"/>
<Caret Line="205" Column="73" TopLine="182"/>
</Position7>
<Position8>
<Filename Value="uosrexternalpumpbrowser.pas"/>
<Caret Line="409" TopLine="370"/>
</Position8>
<Position9>
<Filename Value="uosrexternalpumpbrowser.pas"/>
<Caret Line="725" TopLine="700"/>
</Position9>
<Position10>
<Filename Value="uosrexternalpumpbrowser.pas"/>
<Caret Line="724" TopLine="686"/>
</Position10>
<Position11>
<Filename Value="uosrexternalpumpbrowser.pas"/>
<Caret Line="762" Column="9" TopLine="717"/>
</Position11>
<Position12>
<Filename Value="uosrexternalpumpbrowser.pas"/>
<Caret Line="90" Column="45" TopLine="68"/>
</Position12>
<Position13>
<Filename Value="uosrexternalpumpbrowser.pas"/>
<Caret Line="309" Column="3" TopLine="297"/>
</Position13>
<Position14>
<Filename Value="uosrexternalpumpbrowser.pas"/>
<Caret Line="91" Column="24" TopLine="59"/>
</Position14>
<Position15>
<Filename Value="uosrexternalpumpbrowser.pas"/>
<Caret Line="696" Column="37" TopLine="691"/>
</Position15>
<Position16>
<Filename Value="uosrexternalpumpbrowser.pas"/>
<Caret Line="310" TopLine="286"/>
</Position16>
<Position17>
<Filename Value="uosrexternalpumpbrowser.pas"/>
<Caret Line="708" TopLine="682"/>
</Position17>
<Position18>
<Filename Value="uosrexternalpumpbrowser.pas"/>
<Caret Line="709" Column="22" TopLine="682"/>
</Position18>
<Position19>
<Filename Value="uosrexternalpumpbrowser.pas"/>
<Caret Line="706" Column="39" TopLine="682"/>
</Position19>
<Position20>
<Filename Value="uosrexternalpumpbrowser.pas"/>
<Caret Line="72" Column="32" TopLine="54"/>
</Position20>
<Position21>
<Filename Value="uosrexternalpumpbrowser.pas"/>
<Caret Line="117" Column="33" TopLine="92"/>
</Position21>
<Position22>
<Filename Value="uosrexternalpumpbrowser.pas"/>
<Caret Line="88" Column="22" TopLine="61"/>
</Position22>
<Position23>
<Filename Value="uosrexternalpumpbrowser.pas"/>
<Caret Line="328" Column="58" TopLine="308"/>
</Position23>
<Position24>
<Filename Value="uosrexternalpumpbrowser.pas"/>
<Caret Line="216" Column="77" TopLine="205"/>
</Position24>
<Position25>
<Filename Value="uosrexternalpumpbrowser.pas"/>
<Caret Line="87" Column="22" TopLine="60"/>
</Position25>
<Position26>
<Filename Value="uosrexternalpumpbrowser.pas"/>
<Caret Line="73" Column="13" TopLine="63"/>
</Position26>
<Position27>
<Filename Value="uosrexternalpumpbrowser.pas"/>
<Caret Line="410" Column="3" TopLine="406"/>
</Position27>
</JumpHistory> </JumpHistory>
<RunParams> <RunParams>
<FormatVersion Value="2"/> <FormatVersion Value="2"/>

View File

@ -2,10 +2,11 @@ object Form1: TForm1
Left = 518 Left = 518
Height = 630 Height = 630
Top = 252 Top = 252
Width = 1000 Width = 1001
Caption = ' Initializing browser. Please wait...' Caption = ' Initializing browser. Please wait...'
ClientHeight = 630 ClientHeight = 630
ClientWidth = 1000 ClientWidth = 1001
OnActivate = FormActivate
OnCloseQuery = FormCloseQuery OnCloseQuery = FormCloseQuery
OnCreate = FormCreate OnCreate = FormCreate
OnDestroy = FormDestroy OnDestroy = FormDestroy
@ -16,23 +17,23 @@ object Form1: TForm1
Left = 0 Left = 0
Height = 30 Height = 30
Top = 0 Top = 0
Width = 1000 Width = 1001
Align = alTop Align = alTop
ClientHeight = 30 ClientHeight = 30
ClientWidth = 1000 ClientWidth = 1001
TabOrder = 0 TabOrder = 0
object AddressEdt: TEdit object AddressEdt: TEdit
Left = 1 Left = 1
Height = 28 Height = 28
Top = 1 Top = 1
Width = 932 Width = 933
Align = alClient Align = alClient
OnEnter = AddressEdtEnter OnEnter = AddressEdtEnter
TabOrder = 0 TabOrder = 0
Text = 'https://www.google.com' Text = 'https://www.google.com'
end end
object Panel2: TPanel object Panel2: TPanel
Left = 933 Left = 934
Height = 28 Height = 28
Top = 1 Top = 1
Width = 66 Width = 66
@ -71,9 +72,11 @@ object Form1: TForm1
Left = 0 Left = 0
Height = 600 Height = 600
Top = 30 Top = 30
Width = 1000 Width = 1001
Align = alClient Align = alClient
Caption = 'Panel1' Caption = 'Panel1'
Color = clWhite
ParentColor = False
TabOrder = 1 TabOrder = 1
OnClick = Panel1Click OnClick = Panel1Click
OnEnter = Panel1Enter OnEnter = Panel1Enter

View File

@ -43,7 +43,7 @@ interface
uses uses
Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ExtCtrls, StdCtrls, Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ExtCtrls, StdCtrls,
LCLType, ComCtrls, Types, SyncObjs, LCLType, ComCtrls, Types, SyncObjs, LMessages,
uCEFChromium, uCEFTypes, uCEFInterfaces, uCEFConstants, uCEFBufferPanel, uCEFChromium, uCEFTypes, uCEFInterfaces, uCEFConstants, uCEFBufferPanel,
uCEFChromiumEvents; uCEFChromiumEvents;
@ -82,9 +82,10 @@ type
procedure Chromium1PopupSize(Sender: TObject; const browser: ICefBrowser; const rect: PCefRect); procedure Chromium1PopupSize(Sender: TObject; const browser: ICefBrowser; const rect: PCefRect);
procedure Chromium1Tooltip(Sender: TObject; const browser: ICefBrowser; var aText: ustring; out Result: Boolean); 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 FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject); procedure FormDestroy(Sender: TObject);
procedure FormActivate(Sender: TObject);
procedure FormCloseQuery(Sender: TObject; var CanClose: boolean);
procedure FormHide(Sender: TObject); procedure FormHide(Sender: TObject);
procedure FormShow(Sender: TObject); procedure FormShow(Sender: TObject);
@ -96,38 +97,25 @@ type
procedure AddressEdtEnter(Sender: TObject); procedure AddressEdtEnter(Sender: TObject);
private private
protected protected
FPopUpBitmap : TBitmap;
FPopUpRect : TRect; FPopUpRect : TRect;
FShowPopUp : boolean; FShowPopUp : boolean;
FResizing : boolean; FResizing : boolean;
FPendingResize : boolean; FPendingResize : boolean;
FCanClose : boolean; FCanClose : boolean;
FClosing : boolean; FClosing : boolean;
FFirstLoad : boolean;
FResizeCS : TCriticalSection; FResizeCS : TCriticalSection;
FBrowserCS : TCriticalSection;
FPanelCursor : TCursor;
FPanelHint : ustring;
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 getModifiers(Shift: TShiftState): TCefEventFlags;
function GetButton(Button: TMouseButton): TCefMouseButtonType; function GetButton(Button: TMouseButton): TCefMouseButtonType;
procedure DoResize; procedure DoResize;
procedure BrowserCreatedMsg(Data: PtrInt); // CEF needs to handle these messages to call TChromium.NotifyMoveOrResizeStarted
procedure BrowserCloseFormMsg(Data: PtrInt); procedure WMMove(var Message: TLMMove); message LM_MOVE;
procedure PendingResizeMsg(Data: PtrInt); procedure WMSize(var Message: TLMSize); message LM_SIZE;
procedure PendingInvalidateMsg(Data: PtrInt); procedure WMWindowPosChanged(var Message: TLMWindowPosChanged); message LM_WINDOWPOSCHANGED;
procedure PendingCursorUpdateMsg(Data: PtrInt);
procedure PendingHintUpdateMsg(Data: PtrInt);
property PanelCursor : TCursor read GetPanelCursor write SetPanelCursor;
property PanelHint : ustring read GetPanelHint write SetPanelHint;
public public
procedure SendCEFKeyEvent(const aCefEvent : TCefKeyEvent); procedure SendCEFKeyEvent(const aCefEvent : TCefKeyEvent);
@ -143,7 +131,7 @@ implementation
{$R *.lfm} {$R *.lfm}
// This is a simple CEF browser in "off-screen rendering" mode (a.k.a OSR mode) // This is a simple CEF browser in "off-screen rendering" mode (a.k.a OSR mode)
// with a different executable for the Chromium subprocesses and an external // with a different executable for the Chromium subprocesses and an external
// message pump // message pump
// Chromium needs the key press data available in the GDK signals // Chromium needs the key press data available in the GDK signals
@ -197,21 +185,16 @@ implementation
// to initialize and finalize the WidgetSet at the right time. // to initialize and finalize the WidgetSet at the right time.
// This is the destruction sequence in OSR mode : // This is the destruction sequence in OSR mode :
// 1- FormCloseQuery sets CanClose to the initial FCanClose value (False) and calls Chromium1.CloseBrowser(True). // 1- FormCloseQuery sets CanClose to the initial FCanClose value (False) and
// 2- Chromium1.CloseBrowser(True) will trigger chrmosr.OnClose and we have to // calls Chromium1.CloseBrowser(True) which will destroy the internal browser
// set "Result" to false and CEF will destroy the internal browser immediately. // immediately.
// 3- Chromium1.OnBeforeClose is triggered because the internal browser was destroyed. // 2- Chromium1.OnBeforeClose is triggered because the internal browser was
// FCanClose is set to True and calls SendCompMessage(CEF_BEFORECLOSE) to // destroyed. FCanClose is set to True and we can close the form safely.
// close the form asynchronously.
uses uses
Math, gtk2, glib2, gdk2, gtk2proc, gtk2int, Math, gtk2, glib2, gdk2, gtk2proc, gtk2int,
uCEFMiscFunctions, uCEFApplication, uCEFBitmapBitBuffer, uCEFWorkScheduler; uCEFMiscFunctions, uCEFApplication, uCEFBitmapBitBuffer, uCEFWorkScheduler;
const
CEF_UPDATE_CURSOR = $A0D;
CEF_UPDATE_HINT = $A0E;
procedure GlobalCEFApp_OnScheduleMessagePumpWork(const aDelayMS : int64); procedure GlobalCEFApp_OnScheduleMessagePumpWork(const aDelayMS : int64);
begin begin
if (GlobalCEFWorkScheduler <> nil) then if (GlobalCEFWorkScheduler <> nil) then
@ -291,7 +274,10 @@ end;
procedure TForm1.Chromium1AfterCreated(Sender: TObject; const browser: ICefBrowser); procedure TForm1.Chromium1AfterCreated(Sender: TObject; const browser: ICefBrowser);
begin begin
// Now the browser is fully initialized we can initialize the UI. // Now the browser is fully initialized we can initialize the UI.
SendCompMessage(CEF_AFTERCREATED); Caption := 'OSR External Pump Browser';
AddressPnl.Enabled := True;
Chromium1.NotifyMoveOrResizeStarted;
end; end;
procedure TForm1.AddressEdtEnter(Sender: TObject); procedure TForm1.AddressEdtEnter(Sender: TObject);
@ -304,6 +290,32 @@ begin
Panel1.SetFocus; Panel1.SetFocus;
end; end;
procedure TForm1.FormActivate(Sender: TObject);
begin
// 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) then
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);
if not(Chromium1.CreateBrowser) then Timer1.Enabled := True;
end;
end;
procedure TForm1.Panel1Enter(Sender: TObject); procedure TForm1.Panel1Enter(Sender: TObject);
begin begin
Chromium1.SendFocusEvent(True); Chromium1.SendFocusEvent(True);
@ -396,7 +408,7 @@ procedure TForm1.Chromium1BeforeClose(Sender: TObject;
const browser: ICefBrowser); const browser: ICefBrowser);
begin begin
FCanClose := True; FCanClose := True;
SendCompMessage(CEF_BEFORECLOSE); Close;
end; end;
procedure TForm1.Chromium1BeforePopup(Sender: TObject; procedure TForm1.Chromium1BeforePopup(Sender: TObject;
@ -416,10 +428,8 @@ procedure TForm1.Chromium1CursorChange(Sender: TObject;
cursorType: TCefCursorType; const customCursorInfo: PCefCursorInfo; cursorType: TCefCursorType; const customCursorInfo: PCefCursorInfo;
var aResult : boolean); var aResult : boolean);
begin begin
PanelCursor := CefCursorToWindowsCursor(cursorType); Panel1.Cursor := CefCursorToWindowsCursor(cursorType);
aResult := True; aResult := True;
SendCompMessage(CEF_UPDATE_CURSOR);
end; end;
procedure TForm1.Chromium1GetScreenInfo(Sender: TObject; procedure TForm1.Chromium1GetScreenInfo(Sender: TObject;
@ -493,7 +503,7 @@ var
TempWidth, TempHeight : integer; TempWidth, TempHeight : integer;
TempBufferBits : Pointer; TempBufferBits : Pointer;
TempForcedResize : boolean; TempForcedResize : boolean;
TempBitmap : TCEFBitmapBitBuffer; TempBitmap : TBitmap;
TempSrcRect : TRect; TempSrcRect : TRect;
begin begin
try try
@ -504,18 +514,41 @@ begin
begin begin
if (type_ = PET_POPUP) then if (type_ = PET_POPUP) then
begin begin
Panel1.UpdatePopupBufferDimensions(aWidth, aHeight); if (FPopUpBitmap = nil) then
begin
FPopUpBitmap := TBitmap.Create;
FPopUpBitmap.PixelFormat := pf32bit;
FPopUpBitmap.HandleType := bmDIB;
FPopUpBitmap.Width := aWidth;
FPopUpBitmap.Height := aHeight;
TempBitmap := Panel1.PopupBuffer; FPopUpBitmap.Canvas.Brush.Color := clWhite;
TempWidth := Panel1.PopupBufferWidth; FPopUpBitmap.Canvas.FillRect(rect(0, 0, aWidth, aHeight));
TempHeight := Panel1.PopupBufferHeight; end;
if (aWidth <> FPopUpBitmap.Width) or
(aHeight <> FPopUpBitmap.Height) then
begin
FPopUpBitmap.Width := aWidth;
FPopUpBitmap.Height := aHeight;
FPopUpBitmap.Canvas.Brush.Color := clWhite;
FPopUpBitmap.Canvas.FillRect(rect(0, 0, aWidth, aHeight));
end;
TempBitmap := FPopUpBitmap;
TempBitmap.BeginUpdate;
TempWidth := FPopUpBitmap.Width;
TempHeight := FPopUpBitmap.Height;
end end
else else
begin begin
TempForcedResize := Panel1.UpdateBufferDimensions(aWidth, aHeight) or TempForcedResize := Panel1.UpdateBufferDimensions(aWidth, aHeight) or not(Panel1.BufferIsResized(False));
not(Panel1.BufferIsResized(False));
TempBitmap := Panel1.Buffer; TempBitmap := Panel1.Buffer;
TempBitmap.BeginUpdate;
TempWidth := Panel1.BufferWidth; TempWidth := Panel1.BufferWidth;
TempHeight := Panel1.BufferHeight; TempHeight := Panel1.BufferHeight;
end; end;
@ -555,23 +588,24 @@ begin
inc(n); inc(n);
end; end;
if FShowPopup then TempBitmap.EndUpdate;
if FShowPopup and (FPopUpBitmap <> nil) then
begin begin
TempSrcRect := Rect(0, 0, TempSrcRect := Rect(0, 0,
FPopUpRect.Right - FPopUpRect.Left, min(FPopUpRect.Right - FPopUpRect.Left, FPopUpBitmap.Width),
FPopUpRect.Bottom - FPopUpRect.Top); min(FPopUpRect.Bottom - FPopUpRect.Top, FPopUpBitmap.Height));
Panel1.DrawPopupBuffer(TempSrcRect, FPopUpRect); Panel1.BufferDraw(FPopUpBitmap, TempSrcRect, FPopUpRect);
end; end;
Panel1.EndBufferDraw; Panel1.EndBufferDraw;
Panel1.InvalidatePanel;
SendCompMessage(CEF_PENDINGINVALIDATE);
if (type_ = PET_VIEW) then if (type_ = PET_VIEW) then
begin begin
if TempForcedResize or FPendingResize then if TempForcedResize or FPendingResize then
SendCompMessage(CEF_PENDINGRESIZE); TThread.Queue(nil, @DoResize);
FResizing := False; FResizing := False;
FPendingResize := False; FPendingResize := False;
@ -607,10 +641,9 @@ 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 begin
PanelHint := aText; Panel1.hint := aText;
Result := True; Panel1.ShowHint := (length(aText) > 0);
Result := True;
SendCompMessage(CEF_UPDATE_HINT);
end; end;
procedure TForm1.FormCloseQuery(Sender: TObject; var CanClose: boolean); procedure TForm1.FormCloseQuery(Sender: TObject; var CanClose: boolean);
@ -626,23 +659,24 @@ begin
end; end;
procedure TForm1.FormCreate(Sender: TObject); procedure TForm1.FormCreate(Sender: TObject);
begin begin
FPopUpBitmap := nil;
FPopUpRect := rect(0, 0, 0, 0); FPopUpRect := rect(0, 0, 0, 0);
FShowPopUp := False; FShowPopUp := False;
FResizing := False; FResizing := False;
FPendingResize := False; FPendingResize := False;
FCanClose := False; FCanClose := False;
FClosing := False; FClosing := False;
FFirstLoad := True;
FResizeCS := TCriticalSection.Create; FResizeCS := TCriticalSection.Create;
FBrowserCS := TCriticalSection.Create;
ConnectKeyPressReleaseEvents(PGtkWidget(Panel1.Handle)); ConnectKeyPressReleaseEvents(PGtkWidget(Panel1.Handle));
end; end;
procedure TForm1.FormDestroy(Sender: TObject); procedure TForm1.FormDestroy(Sender: TObject);
begin begin
if (FResizeCS <> nil) then FreeAndNil(FResizeCS); if (FPopUpBitmap <> nil) then FreeAndNil(FPopUpBitmap);
if (FBrowserCS <> nil) then FreeAndNil(FBrowserCS); if (FResizeCS <> nil) then FreeAndNil(FResizeCS);
end; end;
procedure TForm1.FormHide(Sender: TObject); procedure TForm1.FormHide(Sender: TObject);
@ -653,23 +687,8 @@ end;
procedure TForm1.FormShow(Sender: TObject); procedure TForm1.FormShow(Sender: TObject);
begin begin
if Chromium1.Initialized then Chromium1.WasHidden(False);
begin Chromium1.SendFocusEvent(True);
Chromium1.WasHidden(False);
Chromium1.SendFocusEvent(True);
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);
if not(Chromium1.CreateBrowser) then Timer1.Enabled := True;
end;
end; end;
procedure TForm1.GoBtnEnter(Sender: TObject); procedure TForm1.GoBtnEnter(Sender: TObject);
@ -691,50 +710,6 @@ begin
Timer1.Enabled := True; Timer1.Enabled := True;
end; end;
procedure TForm1.BrowserCreatedMsg(Data: PtrInt);
begin
Caption := 'Simple OSR Browser';
AddressPnl.Enabled := True;
end;
procedure TForm1.BrowserCloseFormMsg(Data: PtrInt);
begin
Close;
end;
procedure TForm1.PendingResizeMsg(Data: PtrInt);
begin
DoResize;
end;
procedure TForm1.PendingInvalidateMsg(Data: PtrInt);
begin
Panel1.Invalidate;
end;
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;
procedure TForm1.DoResize; procedure TForm1.DoResize;
begin begin
try try
@ -753,46 +728,24 @@ begin
finally finally
FResizeCS.Release; FResizeCS.Release;
end; end;
end;
function TForm1.GetPanelCursor : TCursor;
begin
try
FBrowserCS.Acquire;
Result := FPanelCursor;
finally
FBrowserCS.Release;
end;
end; end;
function TForm1.GetPanelHint : ustring; procedure TForm1.WMMove(var Message: TLMMove);
begin begin
try inherited;
FBrowserCS.Acquire; Chromium1.NotifyMoveOrResizeStarted;
Result := FPanelHint;
finally
FBrowserCS.Release;
end;
end; end;
procedure TForm1.SetPanelCursor(aValue : TCursor); procedure TForm1.WMSize(var Message: TLMSize);
begin begin
try inherited;
FBrowserCS.Acquire; Chromium1.NotifyMoveOrResizeStarted;
FPanelCursor := aValue;
finally
FBrowserCS.Release;
end;
end; end;
procedure TForm1.SetPanelHint(const aValue : ustring); procedure TForm1.WMWindowPosChanged(var Message: TLMWindowPosChanged);
begin begin
try inherited;
FBrowserCS.Acquire; Chromium1.NotifyMoveOrResizeStarted;
FPanelHint := aValue;
finally
FBrowserCS.Release;
end;
end; end;
end. end.

View File

@ -10,7 +10,7 @@
<EditorIndex Value="-1"/> <EditorIndex Value="-1"/>
<TopLine Value="29"/> <TopLine Value="29"/>
<CursorPos X="57" Y="58"/> <CursorPos X="57" Y="58"/>
<UsageCount Value="81"/> <UsageCount Value="83"/>
</Unit0> </Unit0>
<Unit1> <Unit1>
<Filename Value="usimpleosrbrowser.pas"/> <Filename Value="usimpleosrbrowser.pas"/>
@ -20,12 +20,12 @@
<ResourceBaseClass Value="Form"/> <ResourceBaseClass Value="Form"/>
<UnitName Value="uSimpleOSRBrowser"/> <UnitName Value="uSimpleOSRBrowser"/>
<IsVisibleTab Value="True"/> <IsVisibleTab Value="True"/>
<TopLine Value="55"/> <TopLine Value="187"/>
<CursorPos X="65" Y="96"/> <CursorPos X="72" Y="225"/>
<UsageCount Value="81"/> <UsageCount Value="83"/>
<Bookmarks Count="2"> <Bookmarks Count="2">
<Item0 X="47" Y="222" ID="2"/> <Item0 X="49" Y="223" ID="2"/>
<Item1 X="76" Y="501" ID="6"/> <Item1 X="80" Y="528" ID="6"/>
</Bookmarks> </Bookmarks>
<Loaded Value="True"/> <Loaded Value="True"/>
<LoadedDesigner Value="True"/> <LoadedDesigner Value="True"/>
@ -36,7 +36,7 @@
<UnitName Value="Interfaces"/> <UnitName Value="Interfaces"/>
<EditorIndex Value="-1"/> <EditorIndex Value="-1"/>
<CursorPos X="40" Y="20"/> <CursorPos X="40" Y="20"/>
<UsageCount Value="77"/> <UsageCount Value="79"/>
</Unit2> </Unit2>
<Unit3> <Unit3>
<Filename Value="/usr/share/lazarus/2.0.6/lcl/lcltype.pp"/> <Filename Value="/usr/share/lazarus/2.0.6/lcl/lcltype.pp"/>
@ -126,14 +126,14 @@
<Unit15> <Unit15>
<Filename Value="../../../source/uCEFBufferPanel.pas"/> <Filename Value="../../../source/uCEFBufferPanel.pas"/>
<EditorIndex Value="-1"/> <EditorIndex Value="-1"/>
<TopLine Value="111"/> <TopLine Value="1034"/>
<CursorPos X="17" Y="123"/> <CursorPos X="3" Y="1037"/>
<UsageCount Value="29"/> <UsageCount Value="29"/>
<Bookmarks Count="4"> <Bookmarks Count="4">
<Item0 Y="1010" ID="9"/> <Item0 Y="1036" ID="9"/>
<Item1 X="63" Y="581" ID="8"/> <Item1 X="63" Y="589" ID="8"/>
<Item2 X="5" Y="345" ID="7"/> <Item2 X="5" Y="350" ID="7"/>
<Item3 X="5" Y="375" ID="1"/> <Item3 X="5" Y="380" ID="1"/>
</Bookmarks> </Bookmarks>
</Unit15> </Unit15>
<Unit16> <Unit16>
@ -706,7 +706,7 @@
<Filename Value="../../../source/uCEFBitmapBitBuffer.pas"/> <Filename Value="../../../source/uCEFBitmapBitBuffer.pas"/>
<EditorIndex Value="-1"/> <EditorIndex Value="-1"/>
<TopLine Value="153"/> <TopLine Value="153"/>
<CursorPos X="58" Y="183"/> <CursorPos X="3" Y="172"/>
<UsageCount Value="13"/> <UsageCount Value="13"/>
</Unit94> </Unit94>
<Unit95> <Unit95>
@ -802,7 +802,88 @@
<Define0 Value="UseCthreads"/> <Define0 Value="UseCthreads"/>
<Define1 Value="EnabledGtkThreading"/> <Define1 Value="EnabledGtkThreading"/>
</OtherDefines> </OtherDefines>
<JumpHistory HistoryIndex="-1"/> <JumpHistory Count="20" HistoryIndex="19">
<Position1>
<Filename Value="usimpleosrbrowser.pas"/>
<Caret Line="56" Column="63" TopLine="51"/>
</Position1>
<Position2>
<Filename Value="usimpleosrbrowser.pas"/>
<Caret Line="634" Column="63" TopLine="619"/>
</Position2>
<Position3>
<Filename Value="usimpleosrbrowser.pas"/>
<Caret Line="80" Column="15" TopLine="64"/>
</Position3>
<Position4>
<Filename Value="usimpleosrbrowser.pas"/>
<Caret Line="501" Column="35" TopLine="478"/>
</Position4>
<Position5>
<Filename Value="usimpleosrbrowser.pas"/>
<Caret Line="512" Column="52" TopLine="478"/>
</Position5>
<Position6>
<Filename Value="usimpleosrbrowser.pas"/>
<Caret Line="514" Column="38" TopLine="497"/>
</Position6>
<Position7>
<Filename Value="usimpleosrbrowser.pas"/>
<Caret Line="506" Column="70" TopLine="497"/>
</Position7>
<Position8>
<Filename Value="usimpleosrbrowser.pas"/>
<Caret Line="558" Column="39" TopLine="536"/>
</Position8>
<Position9>
<Filename Value="usimpleosrbrowser.pas"/>
<Caret Line="569" Column="56" TopLine="475"/>
</Position9>
<Position10>
<Filename Value="usimpleosrbrowser.pas"/>
<Caret Line="469" Column="61" TopLine="460"/>
</Position10>
<Position11>
<Filename Value="usimpleosrbrowser.pas"/>
<Caret Line="89" Column="15" TopLine="56"/>
</Position11>
<Position12>
<Filename Value="usimpleosrbrowser.pas"/>
<Caret Line="663" Column="3" TopLine="660"/>
</Position12>
<Position13>
<Filename Value="usimpleosrbrowser.pas"/>
<Caret Line="309" Column="3" TopLine="280"/>
</Position13>
<Position14>
<Filename Value="usimpleosrbrowser.pas"/>
<Caret Line="90" Column="24" TopLine="45"/>
</Position14>
<Position15>
<Filename Value="usimpleosrbrowser.pas"/>
<Caret Line="679" Column="12" TopLine="661"/>
</Position15>
<Position16>
<Filename Value="usimpleosrbrowser.pas"/>
<Caret Line="85" Column="15" TopLine="68"/>
</Position16>
<Position17>
<Filename Value="usimpleosrbrowser.pas"/>
<Caret Line="319" Column="12" TopLine="306"/>
</Position17>
<Position18>
<Filename Value="usimpleosrbrowser.pas"/>
<Caret Line="90" Column="15" TopLine="63"/>
</Position18>
<Position19>
<Filename Value="usimpleosrbrowser.pas"/>
<Caret Line="675" TopLine="671"/>
</Position19>
<Position20>
<Filename Value="usimpleosrbrowser.pas"/>
<Caret Line="85" Column="15" TopLine="68"/>
</Position20>
</JumpHistory>
<RunParams> <RunParams>
<FormatVersion Value="2"/> <FormatVersion Value="2"/>
<Modes Count="0" ActiveMode=""/> <Modes Count="0" ActiveMode=""/>

View File

@ -6,6 +6,7 @@ object Form1: TForm1
Caption = ' Initializing browser. Please wait...' Caption = ' Initializing browser. Please wait...'
ClientHeight = 630 ClientHeight = 630
ClientWidth = 1000 ClientWidth = 1000
OnActivate = FormActivate
OnCloseQuery = FormCloseQuery OnCloseQuery = FormCloseQuery
OnCreate = FormCreate OnCreate = FormCreate
OnDestroy = FormDestroy OnDestroy = FormDestroy
@ -74,6 +75,8 @@ object Form1: TForm1
Width = 1000 Width = 1000
Align = alClient Align = alClient
Caption = 'Panel1' Caption = 'Panel1'
Color = clWhite
ParentColor = False
TabOrder = 1 TabOrder = 1
OnClick = Panel1Click OnClick = Panel1Click
OnEnter = Panel1Enter OnEnter = Panel1Enter

View File

@ -43,7 +43,7 @@ interface
uses uses
Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ExtCtrls, StdCtrls, Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ExtCtrls, StdCtrls,
LCLType, ComCtrls, Types, SyncObjs, LCLType, ComCtrls, Types, SyncObjs, LMessages,
uCEFChromium, uCEFTypes, uCEFInterfaces, uCEFConstants, uCEFBufferPanel, uCEFChromium, uCEFTypes, uCEFInterfaces, uCEFConstants, uCEFBufferPanel,
uCEFChromiumEvents; uCEFChromiumEvents;
@ -82,6 +82,7 @@ type
procedure Chromium1PopupSize(Sender: TObject; const browser: ICefBrowser; const rect: PCefRect); procedure Chromium1PopupSize(Sender: TObject; const browser: ICefBrowser; const rect: PCefRect);
procedure Chromium1Tooltip(Sender: TObject; const browser: ICefBrowser; var aText: ustring; out Result: Boolean); procedure Chromium1Tooltip(Sender: TObject; const browser: ICefBrowser; var aText: ustring; out Result: Boolean);
procedure FormActivate(Sender: TObject);
procedure FormCloseQuery(Sender: TObject; var CanClose: boolean); procedure FormCloseQuery(Sender: TObject; var CanClose: boolean);
procedure FormCreate(Sender: TObject); procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject); procedure FormDestroy(Sender: TObject);
@ -124,7 +125,12 @@ type
procedure PendingResizeMsg(Data: PtrInt); procedure PendingResizeMsg(Data: PtrInt);
procedure PendingInvalidateMsg(Data: PtrInt); procedure PendingInvalidateMsg(Data: PtrInt);
procedure PendingCursorUpdateMsg(Data: PtrInt); procedure PendingCursorUpdateMsg(Data: PtrInt);
procedure PendingHintUpdateMsg(Data: PtrInt); procedure PendingHintUpdateMsg(Data: PtrInt);
// 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;
property PanelCursor : TCursor read GetPanelCursor write SetPanelCursor; property PanelCursor : TCursor read GetPanelCursor write SetPanelCursor;
property PanelHint : ustring read GetPanelHint write SetPanelHint; property PanelHint : ustring read GetPanelHint write SetPanelHint;
@ -211,12 +217,12 @@ implementation
// to initialize and finalize the WidgetSet at the right time. // to initialize and finalize the WidgetSet at the right time.
// This is the destruction sequence in OSR mode : // This is the destruction sequence in OSR mode :
// 1- FormCloseQuery sets CanClose to the initial FCanClose value (False) and calls Chromium1.CloseBrowser(True). // 1- FormCloseQuery sets CanClose to the initial FCanClose value (False) and
// 2- Chromium1.CloseBrowser(True) will trigger chrmosr.OnClose and we have to // calls Chromium1.CloseBrowser(True) which will destroy the internal browser
// set "Result" to false and CEF will destroy the internal browser immediately. // immediately.
// 3- chrmosr.OnBeforeClose is triggered because the internal browser was destroyed. // 2- Chromium1.OnBeforeClose is triggered because the internal browser was
// FCanClose is set to True and calls SendCompMessage(CEF_BEFORECLOSE) to // destroyed. FCanClose is set to True and calls
// close the form asynchronously. // SendCompMessage(CEF_BEFORECLOSE) to close the form asynchronously.
uses uses
Math, gtk2, glib2, gdk2, gtk2proc, gtk2int, Math, gtk2, glib2, gdk2, gtk2proc, gtk2int,
@ -298,6 +304,32 @@ begin
Panel1.SetFocus; Panel1.SetFocus;
end; end;
procedure TForm1.FormActivate(Sender: TObject);
begin
// 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) then
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);
if not(Chromium1.CreateBrowser) then Timer1.Enabled := True;
end;
end;
procedure TForm1.Panel1Enter(Sender: TObject); procedure TForm1.Panel1Enter(Sender: TObject);
begin begin
Chromium1.SendFocusEvent(True); Chromium1.SendFocusEvent(True);
@ -498,20 +530,20 @@ begin
begin begin
if (type_ = PET_POPUP) then if (type_ = PET_POPUP) then
begin begin
Panel1.UpdatePopupBufferDimensions(aWidth, aHeight); Panel1.UpdateOrigPopupBufferDimensions(aWidth, aHeight);
TempBitmap := Panel1.PopupBuffer; TempBitmap := Panel1.OrigPopupBuffer;
TempWidth := Panel1.PopupBufferWidth; TempWidth := Panel1.OrigPopupBufferWidth;
TempHeight := Panel1.PopupBufferHeight; TempHeight := Panel1.OrigPopupBufferHeight;
end end
else else
begin begin
TempForcedResize := Panel1.UpdateBufferDimensions(aWidth, aHeight) or TempForcedResize := Panel1.UpdateOrigBufferDimensions(aWidth, aHeight) or
not(Panel1.BufferIsResized(False)); not(Panel1.BufferIsResized(False));
TempBitmap := Panel1.Buffer; TempBitmap := Panel1.OrigBuffer;
TempWidth := Panel1.BufferWidth; TempWidth := Panel1.OrigBufferWidth;
TempHeight := Panel1.BufferHeight; TempHeight := Panel1.OrigBufferHeight;
end; end;
SrcStride := aWidth * SizeOf(TRGBQuad); SrcStride := aWidth * SizeOf(TRGBQuad);
@ -555,7 +587,7 @@ begin
FPopUpRect.Right - FPopUpRect.Left, FPopUpRect.Right - FPopUpRect.Left,
FPopUpRect.Bottom - FPopUpRect.Top); FPopUpRect.Bottom - FPopUpRect.Top);
Panel1.DrawPopupBuffer(TempSrcRect, FPopUpRect); Panel1.DrawOrigPopupBuffer(TempSrcRect, FPopUpRect);
end; end;
Panel1.EndBufferDraw; Panel1.EndBufferDraw;
@ -630,6 +662,8 @@ begin
FResizeCS := TCriticalSection.Create; FResizeCS := TCriticalSection.Create;
FBrowserCS := TCriticalSection.Create; FBrowserCS := TCriticalSection.Create;
Panel1.CopyOriginalBuffer := True;
ConnectKeyPressReleaseEvents(PGtkWidget(Panel1.Handle)); ConnectKeyPressReleaseEvents(PGtkWidget(Panel1.Handle));
end; end;
@ -647,23 +681,8 @@ end;
procedure TForm1.FormShow(Sender: TObject); procedure TForm1.FormShow(Sender: TObject);
begin begin
if Chromium1.Initialized then Chromium1.WasHidden(False);
begin Chromium1.SendFocusEvent(True);
Chromium1.WasHidden(False);
Chromium1.SendFocusEvent(True);
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);
if not(Chromium1.CreateBrowser) then Timer1.Enabled := True;
end;
end; end;
procedure TForm1.GoBtnEnter(Sender: TObject); procedure TForm1.GoBtnEnter(Sender: TObject);
@ -689,6 +708,8 @@ procedure TForm1.BrowserCreatedMsg(Data: PtrInt);
begin begin
Caption := 'Simple OSR Browser'; Caption := 'Simple OSR Browser';
AddressPnl.Enabled := True; AddressPnl.Enabled := True;
Chromium1.NotifyMoveOrResizeStarted;
end; end;
procedure TForm1.BrowserCloseFormMsg(Data: PtrInt); procedure TForm1.BrowserCloseFormMsg(Data: PtrInt);
@ -787,6 +808,24 @@ begin
finally finally
FBrowserCS.Release; FBrowserCS.Release;
end; 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;
end. end.

View File

@ -23,7 +23,7 @@
<IsVisibleTab Value="True"/> <IsVisibleTab Value="True"/>
<EditorIndex Value="1"/> <EditorIndex Value="1"/>
<TopLine Value="823"/> <TopLine Value="823"/>
<CursorPos Y="825"/> <CursorPos X="45" Y="830"/>
<UsageCount Value="27"/> <UsageCount Value="27"/>
<Loaded Value="True"/> <Loaded Value="True"/>
<LoadedDesigner Value="True"/> <LoadedDesigner Value="True"/>

View File

@ -74,8 +74,13 @@ type
FTransparent : boolean; FTransparent : boolean;
FOnPaintParentBkg : TNotifyEvent; FOnPaintParentBkg : TNotifyEvent;
FForcedDeviceScaleFactor : single; FForcedDeviceScaleFactor : single;
{$IFDEF MSWINDOWS} FCopyOriginalBuffer : boolean;
FMustInitBuffer : boolean;
FBuffer : TBitmap; FBuffer : TBitmap;
FOrigBuffer : TCEFBitmapBitBuffer;
FOrigPopupBuffer : TCEFBitmapBitBuffer;
FOrigPopupScanlineSize : integer;
{$IFDEF MSWINDOWS}
FSyncObj : THandle; FSyncObj : THandle;
FIMEHandler : TCEFOSRIMEHandler; FIMEHandler : TCEFOSRIMEHandler;
FOnIMECancelComposition : TNotifyEvent; FOnIMECancelComposition : TNotifyEvent;
@ -86,11 +91,7 @@ type
FOnPointerUp : TOnHandledMessageEvent; FOnPointerUp : TOnHandledMessageEvent;
FOnPointerUpdate : TOnHandledMessageEvent; FOnPointerUpdate : TOnHandledMessageEvent;
{$ELSE} {$ELSE}
FBuffer : TCEFBitmapBitBuffer;
FPopupBuffer : TCEFBitmapBitBuffer;
FBitmap : TBitmap;
FSyncObj : TCriticalSection; FSyncObj : TCriticalSection;
FPopupScanlineSize : integer;
{$ENDIF} {$ENDIF}
procedure CreateSyncObj; procedure CreateSyncObj;
@ -100,16 +101,17 @@ type
function GetBufferBits : pointer; function GetBufferBits : pointer;
function GetBufferWidth : integer; function GetBufferWidth : integer;
function GetBufferHeight : integer; function GetBufferHeight : integer;
function GetOrigBufferWidth : integer;
function GetOrigBufferHeight : integer;
function GetScreenScale : single; virtual; function GetScreenScale : single; virtual;
function GetRealScreenScale(var aResultScale : single) : boolean; virtual; function GetRealScreenScale(var aResultScale : single) : boolean; virtual;
function GetOrigPopupBufferBits : pointer;
function GetOrigPopupBufferWidth : integer;
function GetOrigPopupBufferHeight : integer;
{$IFDEF MSWINDOWS} {$IFDEF MSWINDOWS}
function GetParentFormHandle : TCefWindowHandle; function GetParentFormHandle : TCefWindowHandle;
function GetParentForm : TCustomForm; function GetParentForm : TCustomForm;
{$ELSE}
function GetPopupBufferBits : pointer;
function GetPopupBufferWidth : integer;
function GetPopupBufferHeight : integer;
{$ENDIF} {$ENDIF}
procedure SetTransparent(aValue : boolean); procedure SetTransparent(aValue : boolean);
@ -142,14 +144,13 @@ type
procedure EndBufferDraw; procedure EndBufferDraw;
procedure BufferDraw(x, y : integer; const aBitmap : TBitmap); overload; procedure BufferDraw(x, y : integer; const aBitmap : TBitmap); overload;
procedure BufferDraw(const aBitmap : TBitmap; const aSrcRect, aDstRect : TRect); overload; procedure BufferDraw(const aBitmap : TBitmap; const aSrcRect, aDstRect : TRect); overload;
function UpdateBufferDimensions(aWidth, aHeight : integer) : boolean; function UpdateBufferDimensions(aWidth, aHeight : integer) : boolean;
function UpdateOrigBufferDimensions(aWidth, aHeight : integer) : boolean;
function UpdateOrigPopupBufferDimensions(aWidth, aHeight : integer) : boolean;
function BufferIsResized(aUseMutex : boolean = True) : boolean; function BufferIsResized(aUseMutex : boolean = True) : boolean;
procedure CreateIMEHandler; procedure CreateIMEHandler;
procedure ChangeCompositionRange(const selection_range : TCefRange; const character_bounds : TCefRectDynArray); procedure ChangeCompositionRange(const selection_range : TCefRange; const character_bounds : TCefRectDynArray);
{$IFNDEF MSWINDOWS} procedure DrawOrigPopupBuffer(const aSrcRect, aDstRect : TRect);
procedure DrawPopupBuffer(const aSrcRect, aDstRect : TRect);
function UpdatePopupBufferDimensions(aWidth, aHeight : integer) : boolean;
{$ENDIF}
property ScanlineSize : integer read FScanlineSize; property ScanlineSize : integer read FScanlineSize;
property BufferWidth : integer read GetBufferWidth; property BufferWidth : integer read GetBufferWidth;
@ -157,17 +158,21 @@ type
property BufferBits : pointer read GetBufferBits; property BufferBits : pointer read GetBufferBits;
property ScreenScale : single read GetScreenScale; property ScreenScale : single read GetScreenScale;
property ForcedDeviceScaleFactor : single read FForcedDeviceScaleFactor write FForcedDeviceScaleFactor; property ForcedDeviceScaleFactor : single read FForcedDeviceScaleFactor write FForcedDeviceScaleFactor;
{$IFDEF MSWINDOWS} property MustInitBuffer : boolean read FMustInitBuffer write FMustInitBuffer;
property Buffer : TBitmap read FBuffer; property Buffer : TBitmap read FBuffer;
property OrigBuffer : TCEFBitmapBitBuffer read FOrigBuffer;
property OrigBufferWidth : integer read GetOrigBufferWidth;
property OrigBufferHeight : integer read GetOrigBufferHeight;
property OrigPopupBuffer : TCEFBitmapBitBuffer read FOrigPopupBuffer;
property OrigPopupBufferWidth : integer read GetOrigPopupBufferWidth;
property OrigPopupBufferHeight : integer read GetOrigPopupBufferHeight;
property OrigPopupBufferBits : pointer read GetOrigPopupBufferBits;
property OrigPopupScanlineSize : integer read FOrigPopupScanlineSize;
{$IFDEF MSWINDOWS}
property ParentFormHandle : TCefWindowHandle read GetParentFormHandle; property ParentFormHandle : TCefWindowHandle read GetParentFormHandle;
property ParentForm : TCustomForm read GetParentForm; property ParentForm : TCustomForm read GetParentForm;
{$ELSE}
property Buffer : TCEFBitmapBitBuffer read FBuffer;
property PopupBuffer : TCEFBitmapBitBuffer read FPopupBuffer;
property PopupBufferWidth : integer read GetPopupBufferWidth;
property PopupBufferHeight : integer read GetPopupBufferHeight;
property PopupBufferBits : pointer read GetPopupBufferBits;
property PopupScanlineSize : integer read FPopupScanlineSize;
{$ENDIF} {$ENDIF}
property DockManager; property DockManager;
@ -185,7 +190,8 @@ type
{$ENDIF} {$ENDIF}
property OnPaintParentBkg : TNotifyEvent read FOnPaintParentBkg write FOnPaintParentBkg; property OnPaintParentBkg : TNotifyEvent read FOnPaintParentBkg write FOnPaintParentBkg;
property Transparent : boolean read FTransparent write SetTransparent default False; property Transparent : boolean read FTransparent write SetTransparent default False;
property CopyOriginalBuffer : boolean read FCopyOriginalBuffer write FCopyOriginalBuffer default False;
property Align; property Align;
property Alignment; property Alignment;
@ -295,10 +301,14 @@ constructor TBufferPanel.Create(AOwner: TComponent);
begin begin
inherited Create(AOwner); inherited Create(AOwner);
FBuffer := nil; FBuffer := nil;
FTransparent := False; FTransparent := False;
FOnPaintParentBkg := nil; FOnPaintParentBkg := nil;
FScanlineSize := 0; FScanlineSize := 0;
FCopyOriginalBuffer := False;
FOrigBuffer := nil;
FOrigPopupBuffer := nil;
FOrigPopupScanlineSize := 0;
if (GlobalCEFApp <> nil) and (GlobalCEFApp.ForcedDeviceScaleFactor <> 0) then if (GlobalCEFApp <> nil) and (GlobalCEFApp.ForcedDeviceScaleFactor <> 0) then
FForcedDeviceScaleFactor := GlobalCEFApp.ForcedDeviceScaleFactor FForcedDeviceScaleFactor := GlobalCEFApp.ForcedDeviceScaleFactor
@ -315,11 +325,10 @@ begin
FOnPointerDown := nil; FOnPointerDown := nil;
FOnPointerUp := nil; FOnPointerUp := nil;
FOnPointerUpdate := nil; FOnPointerUpdate := nil;
FMustInitBuffer := False;
{$ELSE} {$ELSE}
FSyncObj := nil; FSyncObj := nil;
FBitmap := nil; FMustInitBuffer := True;
FPopupBuffer := nil;
FPopupScanlineSize := 0;
{$ENDIF} {$ENDIF}
end; end;
@ -330,8 +339,6 @@ begin
{$IFDEF MSWINDOWS} {$IFDEF MSWINDOWS}
if (FIMEHandler <> nil) then FreeAndNil(FIMEHandler); if (FIMEHandler <> nil) then FreeAndNil(FIMEHandler);
{$ELSE}
if (FBitmap <> nil) then FreeAndNil(FBitmap);
{$ENDIF} {$ENDIF}
inherited Destroy; inherited Destroy;
@ -368,13 +375,12 @@ begin
{$ENDIF} {$ENDIF}
end; end;
{$IFNDEF MSWINDOWS} procedure TBufferPanel.DrawOrigPopupBuffer(const aSrcRect, aDstRect : TRect);
procedure TBufferPanel.DrawPopupBuffer(const aSrcRect, aDstRect : TRect);
var var
src_y, dst_y, TempWidth : integer; src_y, dst_y, TempWidth : integer;
src, dst : pointer; src, dst : PByte;
begin begin
if (FBuffer = nil) or (FPopupBuffer = nil) then exit; if (FOrigBuffer = nil) or (FOrigPopupBuffer = nil) then exit;
src_y := aSrcRect.Top; src_y := aSrcRect.Top;
dst_y := aDstRect.Top; dst_y := aDstRect.Top;
@ -382,17 +388,17 @@ begin
TempWidth := min(aSrcRect.Right - aSrcRect.Left + 1, TempWidth := min(aSrcRect.Right - aSrcRect.Left + 1,
aDstRect.Right - aDstRect.Left + 1); aDstRect.Right - aDstRect.Left + 1);
if (aSrcRect.Left + TempWidth >= FPopupBuffer.Width) then if (aSrcRect.Left + TempWidth >= FOrigPopupBuffer.Width) then
TempWidth := FPopupBuffer.Width - aSrcRect.Left; TempWidth := FOrigPopupBuffer.Width - aSrcRect.Left;
if (aDstRect.Left + TempWidth >= FBuffer.Width) then if (aDstRect.Left + TempWidth >= FOrigBuffer.Width) then
TempWidth := FBuffer.Width - aDstRect.Left; TempWidth := FOrigBuffer.Width - aDstRect.Left;
while (src_y <= aSrcRect.Bottom) and (src_y < FPopupBuffer.Height) and while (src_y <= aSrcRect.Bottom) and (src_y < FOrigPopupBuffer.Height) and
(dst_y <= aDstRect.Bottom) and (dst_y < FBuffer.Height) do (dst_y <= aDstRect.Bottom) and (dst_y < FOrigBuffer.Height) do
begin begin
src := FPopupBuffer.ScanLine[src_y]; src := FOrigPopupBuffer.ScanLine[src_y];
dst := FBuffer.ScanLine[dst_y]; dst := FOrigBuffer.ScanLine[dst_y];
if (aSrcRect.Left > 0) then if (aSrcRect.Left > 0) then
inc(src, aSrcRect.Left * SizeOf(TRGBQuad)); inc(src, aSrcRect.Left * SizeOf(TRGBQuad));
@ -406,7 +412,6 @@ begin
inc(dst_y); inc(dst_y);
end; end;
end; end;
{$ENDIF}
procedure TBufferPanel.CreateSyncObj; procedure TBufferPanel.CreateSyncObj;
begin begin
@ -434,10 +439,10 @@ procedure TBufferPanel.DestroyBuffer;
begin begin
if BeginBufferDraw then if BeginBufferDraw then
begin begin
if (FBuffer <> nil) then FreeAndNil(FBuffer); if (FBuffer <> nil) then FreeAndNil(FBuffer);
{$IFNDEF MSWINDOWS} if (FOrigBuffer <> nil) then FreeAndNil(FOrigBuffer);
if (FPopupBuffer <> nil) then FreeAndNil(FPopupBuffer); if (FOrigPopupBuffer <> nil) then FreeAndNil(FOrigPopupBuffer);
{$ENDIF}
EndBufferDraw; EndBufferDraw;
end; end;
end; end;
@ -446,19 +451,11 @@ function TBufferPanel.SaveBufferToFile(const aFilename : string) : boolean;
begin begin
Result := False; Result := False;
try try
{$IFDEF MSWINDOWS}
if (FBuffer <> nil) then if (FBuffer <> nil) then
begin begin
FBuffer.SaveToFile(aFilename); FBuffer.SaveToFile(aFilename);
Result := True; Result := True;
end; end;
{$ELSE}
if (FBitmap <> nil) then
begin
FBitmap.SaveToFile(aFilename);
Result := True;
end;
{$ENDIF}
except except
on e : exception do on e : exception do
if CustomExceptionHandler('TBufferPanel.SaveBufferToFile', e) then raise; if CustomExceptionHandler('TBufferPanel.SaveBufferToFile', e) then raise;
@ -514,15 +511,66 @@ function TBufferPanel.CopyBuffer : boolean;
var var
{$IFDEF MSWINDOWS} {$IFDEF MSWINDOWS}
TempFunction : TBlendFunction; TempFunction : TBlendFunction;
{$ELSE} {$ENDIF}
y : integer; y : integer;
src, dst : pointer; src, dst : pointer;
{$ENDIF}
begin begin
Result := False; Result := False;
if BeginBufferDraw then if BeginBufferDraw then
try try
if FCopyOriginalBuffer then
begin
if (FBuffer = nil) then
begin
FBuffer := TBitmap.Create;
FBuffer.PixelFormat := pf32bit;
FBuffer.HandleType := bmDIB;
FBuffer.Width := 1001;
FBuffer.Height := 600;
if FMustInitBuffer then
begin
FBuffer.Canvas.Brush.Color := clWhite;
FBuffer.Canvas.FillRect(rect(0, 0, FBuffer.Width, FBuffer.Height));
end;
end;
if (FOrigBuffer <> nil) and not(FOrigBuffer.Empty) then
begin
if (FBuffer.Width <> FOrigBuffer.Width) or
(FBuffer.Height <> FOrigBuffer.Height) then
begin
FBuffer.Width := FOrigBuffer.Width;
FBuffer.Height := FOrigBuffer.Height;
if FMustInitBuffer then
begin
FBuffer.Canvas.Brush.Color := clWhite;
FBuffer.Canvas.FillRect(rect(0, 0, FBuffer.Width, FBuffer.Height));
end;
end;
try
{$IFDEF FPC}
FBuffer.BeginUpdate;
{$ENDIF}
y := 0;
while (y < FBuffer.Height) do
begin
src := FOrigBuffer.ScanLine[y];
dst := FBuffer.ScanLine[y];
move(src^, dst^, FOrigBuffer.ScanLineSize);
inc(y);
end;
finally
{$IFDEF FPC}
FBuffer.EndUpdate;
{$ENDIF}
end;
end;
end;
if (FBuffer <> nil) and (FBuffer.Width <> 0) and (FBuffer.Height <> 0) then if (FBuffer <> nil) and (FBuffer.Width <> 0) and (FBuffer.Height <> 0) then
begin begin
{$IFDEF MSWINDOWS} {$IFDEF MSWINDOWS}
@ -550,39 +598,7 @@ begin
{$ELSE} {$ELSE}
try try
Canvas.Lock; Canvas.Lock;
Canvas.Draw(0, 0, FBuffer);
if (FBitmap = nil) then
begin
FBitmap := TBitmap.Create;
FBitmap.PixelFormat := pf32bit;
FBitmap.HandleType := bmDIB;
FBitmap.Width := 1001;
FBitmap.Height := 600;
FBitmap.Canvas.Brush.Color := clWhite;
FBitmap.Canvas.FillRect(0, 0, FBitmap.Width, FBitmap.Height);
end;
if (FBitmap.Width <> FBuffer.Width) or
(FBitmap.Height <> FBuffer.Height) then
begin
FBitmap.Width := FBuffer.Width;
FBitmap.Height := FBuffer.Height;
FBitmap.Canvas.Brush.Color := clWhite;
FBitmap.Canvas.FillRect(0, 0, FBitmap.Width, FBitmap.Height);
end;
FBitmap.BeginUpdate;
y := 0;
while (y < FBitmap.Height) do
begin
src := FBuffer.ScanLine[y];
dst := FBitmap.ScanLine[y];
move(src^, dst^, FBuffer.ScanLineSize);
inc(y);
end;
FBitmap.EndUpdate;
Canvas.Draw(0, 0, FBitmap);
Result := True; Result := True;
finally finally
Canvas.Unlock; Canvas.Unlock;
@ -792,14 +808,8 @@ end;
function TBufferPanel.GetBufferBits : pointer; function TBufferPanel.GetBufferBits : pointer;
begin begin
if (FBuffer <> nil) then if (FBuffer <> nil) and (FBuffer.Height <> 0) then
begin Result := FBuffer.Scanline[pred(FBuffer.Height)]
{$IFDEF MSWINDOWS}
Result := FBuffer.Scanline[pred(FBuffer.Height)];
{$ELSE}
Result := FBuffer.BufferBits;
{$ENDIF}
end
else else
Result := nil; Result := nil;
end; end;
@ -818,33 +828,47 @@ begin
Result := FBuffer.Height Result := FBuffer.Height
else else
Result := 0; Result := 0;
end;
function TBufferPanel.GetOrigBufferWidth : integer;
begin
if (FOrigBuffer <> nil) then
Result := FOrigBuffer.Width
else
Result := 0;
end; end;
{$IFNDEF MSWINDOWS} function TBufferPanel.GetOrigBufferHeight : integer;
function TBufferPanel.GetPopupBufferBits : pointer;
begin begin
if (FPopupBuffer <> nil) then if (FOrigBuffer <> nil) then
Result := FPopupBuffer.BufferBits Result := FOrigBuffer.Height
else
Result := 0;
end;
function TBufferPanel.GetOrigPopupBufferBits : pointer;
begin
if (FOrigPopupBuffer <> nil) then
Result := FOrigPopupBuffer.BufferBits
else else
Result := nil; Result := nil;
end; end;
function TBufferPanel.GetPopupBufferWidth : integer; function TBufferPanel.GetOrigPopupBufferWidth : integer;
begin begin
if (FPopupBuffer <> nil) then if (FOrigPopupBuffer <> nil) then
Result := FPopupBuffer.Width Result := FOrigPopupBuffer.Width
else else
Result := 0; Result := 0;
end; end;
function TBufferPanel.GetPopupBufferHeight : integer; function TBufferPanel.GetOrigPopupBufferHeight : integer;
begin begin
if (FPopupBuffer <> nil) then if (FOrigPopupBuffer <> nil) then
Result := FPopupBuffer.Height Result := FOrigPopupBuffer.Height
else else
Result := 0; Result := 0;
end; end;
{$ENDIF}
function TBufferPanel.GetRealScreenScale(var aResultScale : single) : boolean; function TBufferPanel.GetRealScreenScale(var aResultScale : single) : boolean;
var var
@ -967,16 +991,12 @@ end;
procedure TBufferPanel.BufferDraw(x, y : integer; const aBitmap : TBitmap); procedure TBufferPanel.BufferDraw(x, y : integer; const aBitmap : TBitmap);
begin begin
{$IFDEF MSWINDOWS}
if (FBuffer <> nil) then FBuffer.Canvas.Draw(x, y, aBitmap); if (FBuffer <> nil) then FBuffer.Canvas.Draw(x, y, aBitmap);
{$ENDIF}
end; end;
procedure TBufferPanel.BufferDraw(const aBitmap : TBitmap; const aSrcRect, aDstRect : TRect); procedure TBufferPanel.BufferDraw(const aBitmap : TBitmap; const aSrcRect, aDstRect : TRect);
begin begin
{$IFDEF MSWINDOWS}
if (FBuffer <> nil) then FBuffer.Canvas.CopyRect(aDstRect, aBitmap.Canvas, aSrcRect); if (FBuffer <> nil) then FBuffer.Canvas.CopyRect(aDstRect, aBitmap.Canvas, aSrcRect);
{$ENDIF}
end; end;
function TBufferPanel.UpdateBufferDimensions(aWidth, aHeight : integer) : boolean; function TBufferPanel.UpdateBufferDimensions(aWidth, aHeight : integer) : boolean;
@ -985,17 +1005,18 @@ begin
if (FBuffer = nil) then if (FBuffer = nil) then
begin begin
{$IFDEF MSWINDOWS}
FBuffer := TBitmap.Create; FBuffer := TBitmap.Create;
FBuffer.PixelFormat := pf32bit; FBuffer.PixelFormat := pf32bit;
FBuffer.HandleType := bmDIB; FBuffer.HandleType := bmDIB;
FBuffer.Width := aWidth; FBuffer.Width := aWidth;
FBuffer.Height := aHeight; FBuffer.Height := aHeight;
FScanlineSize := aWidth * SizeOf(TRGBQuad); FScanlineSize := aWidth * SizeOf(TRGBQuad);
{$ELSE}
FBuffer := TCEFBitmapBitBuffer.Create(aWidth, aHeight); if FMustInitBuffer then
FScanlineSize := FBuffer.ScanlineSize; begin
{$ENDIF} FBuffer.Canvas.Brush.Color := clWhite;
FBuffer.Canvas.FillRect(rect(0, 0, FBuffer.Width, FBuffer.Height));
end;
Result := True; Result := True;
end end
@ -1003,40 +1024,59 @@ begin
if (FBuffer.Width <> aWidth) or if (FBuffer.Width <> aWidth) or
(FBuffer.Height <> aHeight) then (FBuffer.Height <> aHeight) then
begin begin
{$IFDEF MSWINDOWS}
FBuffer.Width := aWidth; FBuffer.Width := aWidth;
FBuffer.Height := aHeight; FBuffer.Height := aHeight;
FScanlineSize := aWidth * SizeOf(TRGBQuad); FScanlineSize := aWidth * SizeOf(TRGBQuad);
{$ELSE}
FBuffer.UpdateSize(aWidth, aHeight); if FMustInitBuffer then
FScanlineSize := FBuffer.ScanlineSize; begin
{$ENDIF} FBuffer.Canvas.Brush.Color := clWhite;
FBuffer.Canvas.FillRect(rect(0, 0, FBuffer.Width, FBuffer.Height));
end;
Result := True; Result := True;
end; end;
end; end;
{$IFNDEF MSWINDOWS} function TBufferPanel.UpdateOrigBufferDimensions(aWidth, aHeight : integer) : boolean;
function TBufferPanel.UpdatePopupBufferDimensions(aWidth, aHeight : integer) : boolean;
begin begin
Result := False; Result := False;
if (FPopupBuffer = nil) then if (FOrigBuffer = nil) then
begin begin
FPopupBuffer := TCEFBitmapBitBuffer.Create(aWidth, aHeight); FOrigBuffer := TCEFBitmapBitBuffer.Create(aWidth, aHeight);
FPopupScanlineSize := FPopupBuffer.ScanlineSize; FScanlineSize := FOrigBuffer.ScanlineSize;
Result := True; Result := True;
end end
else else
if (FPopupBuffer.Width <> aWidth) or if (FOrigBuffer.Width <> aWidth) or
(FPopupBuffer.Height <> aHeight) then (FOrigBuffer.Height <> aHeight) then
begin begin
FPopupBuffer.UpdateSize(aWidth, aHeight); FOrigBuffer.UpdateSize(aWidth, aHeight);
FPopupScanlineSize := FPopupBuffer.ScanlineSize; FScanlineSize := FOrigBuffer.ScanlineSize;
Result := True; Result := True;
end;
end;
function TBufferPanel.UpdateOrigPopupBufferDimensions(aWidth, aHeight : integer) : boolean;
begin
Result := False;
if (FOrigPopupBuffer = nil) then
begin
FOrigPopupBuffer := TCEFBitmapBitBuffer.Create(aWidth, aHeight);
FOrigPopupScanlineSize := FOrigPopupBuffer.ScanlineSize;
Result := True;
end
else
if (FOrigPopupBuffer.Width <> aWidth) or
(FOrigPopupBuffer.Height <> aHeight) then
begin
FOrigPopupBuffer.UpdateSize(aWidth, aHeight);
FOrigPopupScanlineSize := FOrigPopupBuffer.ScanlineSize;
Result := True;
end; end;
end; end;
{$ENDIF}
function TBufferPanel.BufferIsResized(aUseMutex : boolean) : boolean; function TBufferPanel.BufferIsResized(aUseMutex : boolean) : boolean;
var var
@ -1052,9 +1092,14 @@ begin
if (TempScale = 1) then if (TempScale = 1) then
begin begin
Result := (FBuffer <> nil) and if FCopyOriginalBuffer then
(FBuffer.Width = Width) and Result := (FOrigBuffer <> nil) and
(FBuffer.Height = Height); (FOrigBuffer.Width = Width) and
(FOrigBuffer.Height = Height)
else
Result := (FBuffer <> nil) and
(FBuffer.Width = Width) and
(FBuffer.Height = Height);
end end
else else
begin begin
@ -1068,9 +1113,14 @@ begin
TempDevWidth := LogicalToDevice(TempLogWidth, TempScale); TempDevWidth := LogicalToDevice(TempLogWidth, TempScale);
TempDevHeight := LogicalToDevice(TempLogHeight, TempScale); TempDevHeight := LogicalToDevice(TempLogHeight, TempScale);
Result := (FBuffer <> nil) and if FCopyOriginalBuffer then
(FBuffer.Width = TempDevWidth) and Result := (FOrigBuffer <> nil) and
(FBuffer.Height = TempDevHeight); (FOrigBuffer.Width = TempDevWidth) and
(FOrigBuffer.Height = TempDevHeight)
else
Result := (FBuffer <> nil) and
(FBuffer.Width = TempDevWidth) and
(FBuffer.Height = TempDevHeight);
end; end;
if aUseMutex then EndBufferDraw; if aUseMutex then EndBufferDraw;

View File

@ -2,7 +2,7 @@
"UpdateLazPackages" : [ "UpdateLazPackages" : [
{ {
"ForceNotify" : true, "ForceNotify" : true,
"InternalVersion" : 228, "InternalVersion" : 229,
"Name" : "cef4delphi_lazarus.lpk", "Name" : "cef4delphi_lazarus.lpk",
"Version" : "87.1.13.0" "Version" : "87.1.13.0"
} }