1
0
mirror of https://github.com/salvadordf/CEF4Delphi.git synced 2025-05-23 21:50:21 +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>
<Filename Value="MiniBrowser.lpr"/>
<IsPartOfProject Value="True"/>
<EditorIndex Value="6"/>
<EditorIndex Value="1"/>
<TopLine Value="26"/>
<CursorPos X="62" Y="52"/>
<UsageCount Value="22"/>
@ -20,7 +20,7 @@
<HasResources Value="True"/>
<ResourceBaseClass Value="Form"/>
<IsVisibleTab Value="True"/>
<TopLine Value="183"/>
<TopLine Value="187"/>
<CursorPos Y="352"/>
<FoldState Value=" TJmA1{32 pjZlg1@4 pmOoL1{D1q"/>
<UsageCount Value="22"/>
@ -70,33 +70,30 @@
</Unit6>
<Unit7>
<Filename Value="../../../source/uCEFChromium.pas"/>
<EditorIndex Value="5"/>
<EditorIndex Value="-1"/>
<TopLine Value="130"/>
<CursorPos X="3" Y="146"/>
<UsageCount Value="10"/>
<Loaded Value="True"/>
</Unit7>
<Unit8>
<Filename Value="../../../source/uCEFMiscFunctions.pas"/>
<EditorIndex Value="1"/>
<EditorIndex Value="-1"/>
<TopLine Value="780"/>
<CursorPos X="70" Y="807"/>
<UsageCount Value="10"/>
<Bookmarks Count="1">
<Item0 X="68" Y="793" ID="2"/>
</Bookmarks>
<Loaded Value="True"/>
</Unit8>
<Unit9>
<Filename Value="../../../source/uCEFChromiumCore.pas"/>
<EditorIndex Value="3"/>
<EditorIndex Value="-1"/>
<TopLine Value="1950"/>
<CursorPos X="71" Y="1975"/>
<UsageCount Value="10"/>
<Bookmarks Count="1">
<Item0 X="56" Y="1966" ID="1"/>
</Bookmarks>
<Loaded Value="True"/>
</Unit9>
<Unit10>
<Filename Value="/usr/share/fpcsrc/3.2.0/packages/gtk2/src/gtk+/gtk/gtkwidget.inc"/>
@ -107,144 +104,42 @@
</Unit10>
<Unit11>
<Filename Value="../../../source/uCEFTypes.pas"/>
<EditorIndex Value="2"/>
<EditorIndex Value="-1"/>
<TopLine Value="1228"/>
<CursorPos X="53" Y="1251"/>
<UsageCount Value="10"/>
<Loaded Value="True"/>
</Unit11>
<Unit12>
<Filename Value="../../../source/uCEFApplicationCore.pas"/>
<EditorIndex Value="4"/>
<EditorIndex Value="-1"/>
<TopLine Value="220"/>
<UsageCount Value="10"/>
<Loaded Value="True"/>
</Unit12>
</Units>
<OtherDefines Count="1">
<Define0 Value="UseCThreads"/>
</OtherDefines>
<JumpHistory Count="30" HistoryIndex="29">
<JumpHistory Count="5" HistoryIndex="4">
<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"/>
<Caret Line="865" TopLine="829"/>
</Position10>
<Position11>
</Position1>
<Position2>
<Filename Value="uMiniBrowser.pas"/>
<Caret Line="158" Column="15" TopLine="137"/>
</Position11>
<Position12>
</Position2>
<Position3>
<Filename Value="uMiniBrowser.pas"/>
<Caret Line="863" Column="3" TopLine="829"/>
</Position12>
<Position13>
<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>
</Position3>
<Position4>
<Filename Value="uMiniBrowser.pas"/>
<Caret Line="849" Column="74" TopLine="829"/>
</Position20>
<Position21>
<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>
</Position4>
<Position5>
<Filename Value="uMiniBrowser.pas"/>
<Caret Line="222" Column="47" TopLine="210"/>
</Position30>
</Position5>
</JumpHistory>
<RunParams>
<FormatVersion Value="2"/>

View File

@ -3,15 +3,14 @@
<ProjectSession>
<Version Value="11"/>
<BuildModes Active="Default"/>
<Units Count="108">
<Units Count="112">
<Unit0>
<Filename Value="OSRExternalPumpBrowser.lpr"/>
<IsPartOfProject Value="True"/>
<EditorIndex Value="1"/>
<EditorIndex Value="-1"/>
<TopLine Value="30"/>
<CursorPos X="37" Y="51"/>
<UsageCount Value="82"/>
<Loaded Value="True"/>
<UsageCount Value="90"/>
</Unit0>
<Unit1>
<Filename Value="uosrexternalpumpbrowser.pas"/>
@ -21,12 +20,16 @@
<ResourceBaseClass Value="Form"/>
<UnitName Value="uOSRExternalPumpBrowser"/>
<IsVisibleTab Value="True"/>
<TopLine Value="221"/>
<CursorPos X="43" Y="250"/>
<UsageCount Value="82"/>
<Bookmarks Count="2">
<Item0 X="47" Y="222" ID="2"/>
<Item1 X="76" Y="520" ID="6"/>
<TopLine Value="158"/>
<CursorPos X="75" Y="192"/>
<UsageCount Value="90"/>
<Bookmarks Count="6">
<Item0 Y="713" ID="2"/>
<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>
<Loaded Value="True"/>
<LoadedDesigner Value="True"/>
@ -37,7 +40,7 @@
<UnitName Value="Interfaces"/>
<EditorIndex Value="-1"/>
<CursorPos X="40" Y="20"/>
<UsageCount Value="78"/>
<UsageCount Value="86"/>
</Unit2>
<Unit3>
<Filename Value="/usr/share/lazarus/2.0.6/lcl/lcltype.pp"/>
@ -126,25 +129,18 @@
</Unit14>
<Unit15>
<Filename Value="../../../source/uCEFBufferPanel.pas"/>
<EditorIndex Value="2"/>
<TopLine Value="1043"/>
<CursorPos X="3" Y="71"/>
<EditorIndex Value="-1"/>
<TopLine Value="469"/>
<CursorPos X="3" Y="482"/>
<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>
<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"/>
<TopLine Value="1458"/>
<CursorPos X="15" Y="1482"/>
<UsageCount Value="10"/>
</Unit16>
<Unit17>
<Filename Value="../../../source/uCEFApplicationCore.pas"/>
@ -202,8 +198,8 @@
<Filename Value="/usr/share/lazarus/2.0.10/lcl/graphics.pp"/>
<UnitName Value="Graphics"/>
<EditorIndex Value="-1"/>
<TopLine Value="1218"/>
<CursorPos X="14" Y="1240"/>
<TopLine Value="1068"/>
<CursorPos X="109" Y="1097"/>
<UsageCount Value="15"/>
</Unit24>
<Unit25>
@ -403,8 +399,8 @@
<Unit52>
<Filename Value="../../../source/uCEFChromiumCore.pas"/>
<EditorIndex Value="-1"/>
<TopLine Value="1122"/>
<CursorPos Y="1147"/>
<TopLine Value="6966"/>
<CursorPos X="78" Y="6355"/>
<UsageCount Value="10"/>
</Unit52>
<Unit53>
@ -447,9 +443,9 @@
<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"/>
<TopLine Value="2281"/>
<CursorPos X="3" Y="2285"/>
<UsageCount Value="10"/>
</Unit58>
<Unit59>
<Filename Value="/usr/share/lazarus/2.0.10/lcl/dialogs.pp"/>
@ -581,9 +577,9 @@
<Unit76>
<Filename Value="../../../source/uCEFTypes.pas"/>
<EditorIndex Value="-1"/>
<TopLine Value="1243"/>
<CursorPos X="9" Y="1271"/>
<UsageCount Value="9"/>
<TopLine Value="781"/>
<CursorPos X="3" Y="804"/>
<UsageCount Value="10"/>
</Unit76>
<Unit77>
<Filename Value="/usr/share/fpcsrc/3.2.0/rtl/inc/objpash.inc"/>
@ -799,20 +795,150 @@
<CursorPos X="77" Y="127"/>
<UsageCount Value="10"/>
</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>
<OtherDefines Count="2">
<Define0 Value="UseCthreads"/>
<Define1 Value="EnabledGtkThreading"/>
</OtherDefines>
<JumpHistory Count="2" HistoryIndex="1">
<JumpHistory Count="27" HistoryIndex="26">
<Position1>
<Filename Value="uosrexternalpumpbrowser.pas"/>
<Caret Line="56" Column="63" TopLine="51"/>
<Caret Line="506" TopLine="491"/>
</Position1>
<Position2>
<Filename Value="uosrexternalpumpbrowser.pas"/>
<Caret Line="234" TopLine="223"/>
<Caret Line="740" TopLine="717"/>
</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>
<RunParams>
<FormatVersion Value="2"/>

View File

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

View File

@ -43,7 +43,7 @@ interface
uses
Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ExtCtrls, StdCtrls,
LCLType, ComCtrls, Types, SyncObjs,
LCLType, ComCtrls, Types, SyncObjs, LMessages,
uCEFChromium, uCEFTypes, uCEFInterfaces, uCEFConstants, uCEFBufferPanel,
uCEFChromiumEvents;
@ -82,9 +82,10 @@ type
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 FormDestroy(Sender: TObject);
procedure FormActivate(Sender: TObject);
procedure FormCloseQuery(Sender: TObject; var CanClose: boolean);
procedure FormHide(Sender: TObject);
procedure FormShow(Sender: TObject);
@ -96,38 +97,25 @@ type
procedure AddressEdtEnter(Sender: TObject);
private
protected
protected
FPopUpBitmap : TBitmap;
FPopUpRect : TRect;
FShowPopUp : boolean;
FResizing : boolean;
FPendingResize : boolean;
FCanClose : boolean;
FClosing : boolean;
FFirstLoad : boolean;
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 GetButton(Button: TMouseButton): TCefMouseButtonType;
procedure DoResize;
procedure BrowserCreatedMsg(Data: PtrInt);
procedure BrowserCloseFormMsg(Data: PtrInt);
procedure PendingResizeMsg(Data: PtrInt);
procedure PendingInvalidateMsg(Data: PtrInt);
procedure PendingCursorUpdateMsg(Data: PtrInt);
procedure PendingHintUpdateMsg(Data: PtrInt);
property PanelCursor : TCursor read GetPanelCursor write SetPanelCursor;
property PanelHint : ustring read GetPanelHint write SetPanelHint;
// 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;
public
procedure SendCEFKeyEvent(const aCefEvent : TCefKeyEvent);
@ -143,7 +131,7 @@ implementation
{$R *.lfm}
// 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
// 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.
// 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- Chromium1.OnBeforeClose is triggered because the internal browser was destroyed.
// FCanClose is set to True and calls SendCompMessage(CEF_BEFORECLOSE) to
// close the form asynchronously.
// 1- FormCloseQuery sets CanClose to the initial FCanClose value (False) and
// calls Chromium1.CloseBrowser(True) which will destroy the internal browser
// immediately.
// 2- Chromium1.OnBeforeClose is triggered because the internal browser was
// destroyed. FCanClose is set to True and we can close the form safely.
uses
Math, gtk2, glib2, gdk2, gtk2proc, gtk2int,
uCEFMiscFunctions, uCEFApplication, uCEFBitmapBitBuffer, uCEFWorkScheduler;
const
CEF_UPDATE_CURSOR = $A0D;
CEF_UPDATE_HINT = $A0E;
procedure GlobalCEFApp_OnScheduleMessagePumpWork(const aDelayMS : int64);
begin
if (GlobalCEFWorkScheduler <> nil) then
@ -291,7 +274,10 @@ end;
procedure TForm1.Chromium1AfterCreated(Sender: TObject; const browser: ICefBrowser);
begin
// 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;
procedure TForm1.AddressEdtEnter(Sender: TObject);
@ -304,6 +290,32 @@ begin
Panel1.SetFocus;
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);
begin
Chromium1.SendFocusEvent(True);
@ -396,7 +408,7 @@ procedure TForm1.Chromium1BeforeClose(Sender: TObject;
const browser: ICefBrowser);
begin
FCanClose := True;
SendCompMessage(CEF_BEFORECLOSE);
Close;
end;
procedure TForm1.Chromium1BeforePopup(Sender: TObject;
@ -416,10 +428,8 @@ procedure TForm1.Chromium1CursorChange(Sender: TObject;
cursorType: TCefCursorType; const customCursorInfo: PCefCursorInfo;
var aResult : boolean);
begin
PanelCursor := CefCursorToWindowsCursor(cursorType);
aResult := True;
SendCompMessage(CEF_UPDATE_CURSOR);
Panel1.Cursor := CefCursorToWindowsCursor(cursorType);
aResult := True;
end;
procedure TForm1.Chromium1GetScreenInfo(Sender: TObject;
@ -493,7 +503,7 @@ var
TempWidth, TempHeight : integer;
TempBufferBits : Pointer;
TempForcedResize : boolean;
TempBitmap : TCEFBitmapBitBuffer;
TempBitmap : TBitmap;
TempSrcRect : TRect;
begin
try
@ -504,18 +514,41 @@ begin
begin
if (type_ = PET_POPUP) then
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;
TempWidth := Panel1.PopupBufferWidth;
TempHeight := Panel1.PopupBufferHeight;
FPopUpBitmap.Canvas.Brush.Color := clWhite;
FPopUpBitmap.Canvas.FillRect(rect(0, 0, aWidth, aHeight));
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
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;
@ -555,23 +588,24 @@ begin
inc(n);
end;
if FShowPopup then
TempBitmap.EndUpdate;
if FShowPopup and (FPopUpBitmap <> nil) then
begin
TempSrcRect := Rect(0, 0,
FPopUpRect.Right - FPopUpRect.Left,
FPopUpRect.Bottom - FPopUpRect.Top);
min(FPopUpRect.Right - FPopUpRect.Left, FPopUpBitmap.Width),
min(FPopUpRect.Bottom - FPopUpRect.Top, FPopUpBitmap.Height));
Panel1.DrawPopupBuffer(TempSrcRect, FPopUpRect);
Panel1.BufferDraw(FPopUpBitmap, TempSrcRect, FPopUpRect);
end;
Panel1.EndBufferDraw;
SendCompMessage(CEF_PENDINGINVALIDATE);
Panel1.InvalidatePanel;
if (type_ = PET_VIEW) then
begin
if TempForcedResize or FPendingResize then
SendCompMessage(CEF_PENDINGRESIZE);
TThread.Queue(nil, @DoResize);
FResizing := False;
FPendingResize := False;
@ -607,10 +641,9 @@ end;
procedure TForm1.Chromium1Tooltip(Sender: TObject; const browser: ICefBrowser; var aText: ustring; out Result: Boolean);
begin
PanelHint := aText;
Result := True;
SendCompMessage(CEF_UPDATE_HINT);
Panel1.hint := aText;
Panel1.ShowHint := (length(aText) > 0);
Result := True;
end;
procedure TForm1.FormCloseQuery(Sender: TObject; var CanClose: boolean);
@ -626,23 +659,24 @@ begin
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
begin
FPopUpBitmap := nil;
FPopUpRect := rect(0, 0, 0, 0);
FShowPopUp := False;
FResizing := False;
FPendingResize := False;
FCanClose := False;
FClosing := False;
FFirstLoad := True;
FResizeCS := TCriticalSection.Create;
FBrowserCS := TCriticalSection.Create;
ConnectKeyPressReleaseEvents(PGtkWidget(Panel1.Handle));
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
if (FResizeCS <> nil) then FreeAndNil(FResizeCS);
if (FBrowserCS <> nil) then FreeAndNil(FBrowserCS);
begin
if (FPopUpBitmap <> nil) then FreeAndNil(FPopUpBitmap);
if (FResizeCS <> nil) then FreeAndNil(FResizeCS);
end;
procedure TForm1.FormHide(Sender: TObject);
@ -653,23 +687,8 @@ end;
procedure TForm1.FormShow(Sender: TObject);
begin
if Chromium1.Initialized then
begin
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;
Chromium1.WasHidden(False);
Chromium1.SendFocusEvent(True);
end;
procedure TForm1.GoBtnEnter(Sender: TObject);
@ -691,50 +710,6 @@ begin
Timer1.Enabled := True;
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;
begin
try
@ -753,46 +728,24 @@ 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;
procedure TForm1.WMMove(var Message: TLMMove);
begin
try
FBrowserCS.Acquire;
Result := FPanelHint;
finally
FBrowserCS.Release;
end;
inherited;
Chromium1.NotifyMoveOrResizeStarted;
end;
procedure TForm1.SetPanelCursor(aValue : TCursor);
procedure TForm1.WMSize(var Message: TLMSize);
begin
try
FBrowserCS.Acquire;
FPanelCursor := aValue;
finally
FBrowserCS.Release;
end;
inherited;
Chromium1.NotifyMoveOrResizeStarted;
end;
procedure TForm1.SetPanelHint(const aValue : ustring);
procedure TForm1.WMWindowPosChanged(var Message: TLMWindowPosChanged);
begin
try
FBrowserCS.Acquire;
FPanelHint := aValue;
finally
FBrowserCS.Release;
end;
inherited;
Chromium1.NotifyMoveOrResizeStarted;
end;
end.

View File

@ -10,7 +10,7 @@
<EditorIndex Value="-1"/>
<TopLine Value="29"/>
<CursorPos X="57" Y="58"/>
<UsageCount Value="81"/>
<UsageCount Value="83"/>
</Unit0>
<Unit1>
<Filename Value="usimpleosrbrowser.pas"/>
@ -20,12 +20,12 @@
<ResourceBaseClass Value="Form"/>
<UnitName Value="uSimpleOSRBrowser"/>
<IsVisibleTab Value="True"/>
<TopLine Value="55"/>
<CursorPos X="65" Y="96"/>
<UsageCount Value="81"/>
<TopLine Value="187"/>
<CursorPos X="72" Y="225"/>
<UsageCount Value="83"/>
<Bookmarks Count="2">
<Item0 X="47" Y="222" ID="2"/>
<Item1 X="76" Y="501" ID="6"/>
<Item0 X="49" Y="223" ID="2"/>
<Item1 X="80" Y="528" ID="6"/>
</Bookmarks>
<Loaded Value="True"/>
<LoadedDesigner Value="True"/>
@ -36,7 +36,7 @@
<UnitName Value="Interfaces"/>
<EditorIndex Value="-1"/>
<CursorPos X="40" Y="20"/>
<UsageCount Value="77"/>
<UsageCount Value="79"/>
</Unit2>
<Unit3>
<Filename Value="/usr/share/lazarus/2.0.6/lcl/lcltype.pp"/>
@ -126,14 +126,14 @@
<Unit15>
<Filename Value="../../../source/uCEFBufferPanel.pas"/>
<EditorIndex Value="-1"/>
<TopLine Value="111"/>
<CursorPos X="17" Y="123"/>
<TopLine Value="1034"/>
<CursorPos X="3" Y="1037"/>
<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"/>
<Item0 Y="1036" ID="9"/>
<Item1 X="63" Y="589" ID="8"/>
<Item2 X="5" Y="350" ID="7"/>
<Item3 X="5" Y="380" ID="1"/>
</Bookmarks>
</Unit15>
<Unit16>
@ -706,7 +706,7 @@
<Filename Value="../../../source/uCEFBitmapBitBuffer.pas"/>
<EditorIndex Value="-1"/>
<TopLine Value="153"/>
<CursorPos X="58" Y="183"/>
<CursorPos X="3" Y="172"/>
<UsageCount Value="13"/>
</Unit94>
<Unit95>
@ -802,7 +802,88 @@
<Define0 Value="UseCthreads"/>
<Define1 Value="EnabledGtkThreading"/>
</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>
<FormatVersion Value="2"/>
<Modes Count="0" ActiveMode=""/>

View File

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

View File

@ -43,7 +43,7 @@ interface
uses
Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ExtCtrls, StdCtrls,
LCLType, ComCtrls, Types, SyncObjs,
LCLType, ComCtrls, Types, SyncObjs, LMessages,
uCEFChromium, uCEFTypes, uCEFInterfaces, uCEFConstants, uCEFBufferPanel,
uCEFChromiumEvents;
@ -82,6 +82,7 @@ type
procedure Chromium1PopupSize(Sender: TObject; const browser: ICefBrowser; const rect: PCefRect);
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 FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
@ -124,7 +125,12 @@ type
procedure PendingResizeMsg(Data: PtrInt);
procedure PendingInvalidateMsg(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 PanelHint : ustring read GetPanelHint write SetPanelHint;
@ -211,12 +217,12 @@ implementation
// 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.
// 1- FormCloseQuery sets CanClose to the initial FCanClose value (False) and
// calls Chromium1.CloseBrowser(True) which will destroy the internal browser
// immediately.
// 2- Chromium1.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, gtk2, glib2, gdk2, gtk2proc, gtk2int,
@ -298,6 +304,32 @@ begin
Panel1.SetFocus;
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);
begin
Chromium1.SendFocusEvent(True);
@ -498,20 +530,20 @@ begin
begin
if (type_ = PET_POPUP) then
begin
Panel1.UpdatePopupBufferDimensions(aWidth, aHeight);
Panel1.UpdateOrigPopupBufferDimensions(aWidth, aHeight);
TempBitmap := Panel1.PopupBuffer;
TempWidth := Panel1.PopupBufferWidth;
TempHeight := Panel1.PopupBufferHeight;
TempBitmap := Panel1.OrigPopupBuffer;
TempWidth := Panel1.OrigPopupBufferWidth;
TempHeight := Panel1.OrigPopupBufferHeight;
end
else
begin
TempForcedResize := Panel1.UpdateBufferDimensions(aWidth, aHeight) or
TempForcedResize := Panel1.UpdateOrigBufferDimensions(aWidth, aHeight) or
not(Panel1.BufferIsResized(False));
TempBitmap := Panel1.Buffer;
TempWidth := Panel1.BufferWidth;
TempHeight := Panel1.BufferHeight;
TempBitmap := Panel1.OrigBuffer;
TempWidth := Panel1.OrigBufferWidth;
TempHeight := Panel1.OrigBufferHeight;
end;
SrcStride := aWidth * SizeOf(TRGBQuad);
@ -555,7 +587,7 @@ begin
FPopUpRect.Right - FPopUpRect.Left,
FPopUpRect.Bottom - FPopUpRect.Top);
Panel1.DrawPopupBuffer(TempSrcRect, FPopUpRect);
Panel1.DrawOrigPopupBuffer(TempSrcRect, FPopUpRect);
end;
Panel1.EndBufferDraw;
@ -630,6 +662,8 @@ begin
FResizeCS := TCriticalSection.Create;
FBrowserCS := TCriticalSection.Create;
Panel1.CopyOriginalBuffer := True;
ConnectKeyPressReleaseEvents(PGtkWidget(Panel1.Handle));
end;
@ -647,23 +681,8 @@ end;
procedure TForm1.FormShow(Sender: TObject);
begin
if Chromium1.Initialized then
begin
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;
Chromium1.WasHidden(False);
Chromium1.SendFocusEvent(True);
end;
procedure TForm1.GoBtnEnter(Sender: TObject);
@ -689,6 +708,8 @@ procedure TForm1.BrowserCreatedMsg(Data: PtrInt);
begin
Caption := 'Simple OSR Browser';
AddressPnl.Enabled := True;
Chromium1.NotifyMoveOrResizeStarted;
end;
procedure TForm1.BrowserCloseFormMsg(Data: PtrInt);
@ -787,6 +808,24 @@ begin
finally
FBrowserCS.Release;
end;
end;
procedure TForm1.WMMove(var Message: TLMMove);
begin
inherited;
Chromium1.NotifyMoveOrResizeStarted;
end;
procedure TForm1.WMSize(var Message: TLMSize);
begin
inherited;
Chromium1.NotifyMoveOrResizeStarted;
end;
procedure TForm1.WMWindowPosChanged(var Message: TLMWindowPosChanged);
begin
inherited;
Chromium1.NotifyMoveOrResizeStarted;
end;
end.

View File

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

View File

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

View File

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