diff --git a/demos/Lazarus_Linux/MiniBrowser/MiniBrowser.lps b/demos/Lazarus_Linux/MiniBrowser/MiniBrowser.lps
index 93e53125..0c3bc472 100644
--- a/demos/Lazarus_Linux/MiniBrowser/MiniBrowser.lps
+++ b/demos/Lazarus_Linux/MiniBrowser/MiniBrowser.lps
@@ -7,7 +7,7 @@
-
+
@@ -20,7 +20,7 @@
-
+
@@ -70,33 +70,30 @@
-
+
-
-
+
-
-
+
-
@@ -107,144 +104,42 @@
-
+
-
-
+
-
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
-
-
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
-
+
diff --git a/demos/Lazarus_Linux/OSRExternalPumpBrowser/OSRExternalPumpBrowser.lps b/demos/Lazarus_Linux/OSRExternalPumpBrowser/OSRExternalPumpBrowser.lps
index 7b68d3fa..4baaaf03 100644
--- a/demos/Lazarus_Linux/OSRExternalPumpBrowser/OSRExternalPumpBrowser.lps
+++ b/demos/Lazarus_Linux/OSRExternalPumpBrowser/OSRExternalPumpBrowser.lps
@@ -3,15 +3,14 @@
-
+
-
+
-
-
+
@@ -21,12 +20,16 @@
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
@@ -37,7 +40,7 @@
-
+
@@ -126,25 +129,18 @@
-
-
-
+
+
+
-
-
-
-
-
-
-
-
-
-
+
+
+
@@ -202,8 +198,8 @@
-
-
+
+
@@ -403,8 +399,8 @@
-
-
+
+
@@ -447,9 +443,9 @@
-
-
-
+
+
+
@@ -581,9 +577,9 @@
-
-
-
+
+
+
@@ -799,20 +795,150 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
-
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/demos/Lazarus_Linux/OSRExternalPumpBrowser/uosrexternalpumpbrowser.lfm b/demos/Lazarus_Linux/OSRExternalPumpBrowser/uosrexternalpumpbrowser.lfm
index 2ea9777a..bb24072f 100644
--- a/demos/Lazarus_Linux/OSRExternalPumpBrowser/uosrexternalpumpbrowser.lfm
+++ b/demos/Lazarus_Linux/OSRExternalPumpBrowser/uosrexternalpumpbrowser.lfm
@@ -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
diff --git a/demos/Lazarus_Linux/OSRExternalPumpBrowser/uosrexternalpumpbrowser.pas b/demos/Lazarus_Linux/OSRExternalPumpBrowser/uosrexternalpumpbrowser.pas
index 76189ac2..e3fe939e 100644
--- a/demos/Lazarus_Linux/OSRExternalPumpBrowser/uosrexternalpumpbrowser.pas
+++ b/demos/Lazarus_Linux/OSRExternalPumpBrowser/uosrexternalpumpbrowser.pas
@@ -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.
diff --git a/demos/Lazarus_Linux/SimpleOSRBrowser/SimpleOSRBrowser.lps b/demos/Lazarus_Linux/SimpleOSRBrowser/SimpleOSRBrowser.lps
index 2857f6b6..2b7ebaf1 100644
--- a/demos/Lazarus_Linux/SimpleOSRBrowser/SimpleOSRBrowser.lps
+++ b/demos/Lazarus_Linux/SimpleOSRBrowser/SimpleOSRBrowser.lps
@@ -10,7 +10,7 @@
-
+
@@ -20,12 +20,12 @@
-
-
-
+
+
+
-
-
+
+
@@ -36,7 +36,7 @@
-
+
@@ -126,14 +126,14 @@
-
-
+
+
-
-
-
-
+
+
+
+
@@ -706,7 +706,7 @@
-
+
@@ -802,7 +802,88 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/demos/Lazarus_Linux/SimpleOSRBrowser/usimpleosrbrowser.lfm b/demos/Lazarus_Linux/SimpleOSRBrowser/usimpleosrbrowser.lfm
index 2ea9777a..c6655821 100644
--- a/demos/Lazarus_Linux/SimpleOSRBrowser/usimpleosrbrowser.lfm
+++ b/demos/Lazarus_Linux/SimpleOSRBrowser/usimpleosrbrowser.lfm
@@ -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
diff --git a/demos/Lazarus_Linux/SimpleOSRBrowser/usimpleosrbrowser.pas b/demos/Lazarus_Linux/SimpleOSRBrowser/usimpleosrbrowser.pas
index 7dc94931..60fd58ad 100644
--- a/demos/Lazarus_Linux/SimpleOSRBrowser/usimpleosrbrowser.pas
+++ b/demos/Lazarus_Linux/SimpleOSRBrowser/usimpleosrbrowser.pas
@@ -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.
diff --git a/demos/Lazarus_Windows/MiniBrowser/MiniBrowser.lps b/demos/Lazarus_Windows/MiniBrowser/MiniBrowser.lps
index cfdcce94..bff98626 100644
--- a/demos/Lazarus_Windows/MiniBrowser/MiniBrowser.lps
+++ b/demos/Lazarus_Windows/MiniBrowser/MiniBrowser.lps
@@ -23,7 +23,7 @@
-
+
diff --git a/source/uCEFBufferPanel.pas b/source/uCEFBufferPanel.pas
index ee7ccb8b..66ebacad 100644
--- a/source/uCEFBufferPanel.pas
+++ b/source/uCEFBufferPanel.pas
@@ -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;
diff --git a/update_CEF4Delphi.json b/update_CEF4Delphi.json
index f1666514..5dabdb85 100644
--- a/update_CEF4Delphi.json
+++ b/update_CEF4Delphi.json
@@ -2,7 +2,7 @@
"UpdateLazPackages" : [
{
"ForceNotify" : true,
- "InternalVersion" : 228,
+ "InternalVersion" : 229,
"Name" : "cef4delphi_lazarus.lpk",
"Version" : "87.1.13.0"
}