You've already forked CEF4Delphi
mirror of
https://github.com/salvadordf/CEF4Delphi.git
synced 2025-11-23 21:34:53 +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:
@@ -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=""/>
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user