diff --git a/README.md b/README.md index b24b7864..d77c7002 100644 --- a/README.md +++ b/README.md @@ -3,14 +3,14 @@ CEF4Delphi is an open source project created by Salvador Díaz Fau to embed Chro CEF4Delphi is based on DCEF3, made by Henri Gourvest. The original license of DCEF3 still applies to CEF4Delphi. Read the license terms in the first lines of any *.pas file. -CEF4Delphi uses CEF 88.2.1 which includes Chromium 88.0.4324.146. +CEF4Delphi uses CEF 88.2.4 which includes Chromium 88.0.4324.150. The CEF binaries used by CEF4Delphi are available for download at spotify : -* [Windows 32 bits](https://cef-builds.spotifycdn.com/cef_binary_88.2.1%2Bg0b18d0b%2Bchromium-88.0.4324.146_windows32.tar.bz2) -* [Windows 64 bits](https://cef-builds.spotifycdn.com/cef_binary_88.2.1%2Bg0b18d0b%2Bchromium-88.0.4324.146_windows64.tar.bz2) -* [Linux x86 32 bits](https://cef-builds.spotifycdn.com/cef_binary_88.2.1%2Bg0b18d0b%2Bchromium-88.0.4324.146_linux32.tar.bz2) -* [Linux x86 64 bits](https://cef-builds.spotifycdn.com/cef_binary_88.2.1%2Bg0b18d0b%2Bchromium-88.0.4324.146_linux64.tar.bz2) -* [Linux ARM 32 bits](https://cef-builds.spotifycdn.com/cef_binary_88.2.1%2Bg0b18d0b%2Bchromium-88.0.4324.146_linuxarm.tar.bz2) -* [Linux ARM 64 bits](https://cef-builds.spotifycdn.com/cef_binary_88.2.1%2Bg0b18d0b%2Bchromium-88.0.4324.146_linuxarm64.tar.bz2) +* [Windows 32 bits](https://cef-builds.spotifycdn.com/cef_binary_88.2.4%2Bgf3c4ca9%2Bchromium-88.0.4324.150_windows32.tar.bz2) +* [Windows 64 bits](https://cef-builds.spotifycdn.com/cef_binary_88.2.4%2Bgf3c4ca9%2Bchromium-88.0.4324.150_windows64.tar.bz2) +* [Linux x86 32 bits](https://cef-builds.spotifycdn.com/cef_binary_88.2.4%2Bgf3c4ca9%2Bchromium-88.0.4324.150_linux32.tar.bz2) +* [Linux x86 64 bits](https://cef-builds.spotifycdn.com/cef_binary_88.2.4%2Bgf3c4ca9%2Bchromium-88.0.4324.150_linux64.tar.bz2) +* [Linux ARM 32 bits](https://cef-builds.spotifycdn.com/cef_binary_88.2.4%2Bgf3c4ca9%2Bchromium-88.0.4324.150_linuxarm.tar.bz2) +* [Linux ARM 64 bits](https://cef-builds.spotifycdn.com/cef_binary_88.2.4%2Bgf3c4ca9%2Bchromium-88.0.4324.150_linuxarm64.tar.bz2) CEF4Delphi was developed and tested on Delphi 10.4.1 and it has been tested in Delphi 7, Delphi XE, Delphi 10, Delphi 10.2, Delphi 10.3 and Lazarus 2.0.10/FPC 3.2.0. CEF4Delphi includes VCL, FireMonkey (FMX) and Lazarus components. diff --git a/packages/cef4delphi_lazarus.lpk b/packages/cef4delphi_lazarus.lpk index f9fb2498..02e95069 100644 --- a/packages/cef4delphi_lazarus.lpk +++ b/packages/cef4delphi_lazarus.lpk @@ -21,7 +21,7 @@ - + diff --git a/source/uCEFApplicationCore.pas b/source/uCEFApplicationCore.pas index e8f11243..f36072d2 100644 --- a/source/uCEFApplicationCore.pas +++ b/source/uCEFApplicationCore.pas @@ -66,13 +66,13 @@ uses const CEF_SUPPORTED_VERSION_MAJOR = 88; CEF_SUPPORTED_VERSION_MINOR = 2; - CEF_SUPPORTED_VERSION_RELEASE = 1; + CEF_SUPPORTED_VERSION_RELEASE = 4; CEF_SUPPORTED_VERSION_BUILD = 0; CEF_CHROMEELF_VERSION_MAJOR = 88; CEF_CHROMEELF_VERSION_MINOR = 0; CEF_CHROMEELF_VERSION_RELEASE = 4324; - CEF_CHROMEELF_VERSION_BUILD = 146; + CEF_CHROMEELF_VERSION_BUILD = 150; {$IFDEF MSWINDOWS} LIBCEF_DLL = 'libcef.dll'; diff --git a/source/uCEFChromium.pas b/source/uCEFChromium.pas index 8eaa65dd..775d8976 100644 --- a/source/uCEFChromium.pas +++ b/source/uCEFChromium.pas @@ -190,14 +190,10 @@ begin end; function TChromium.GetParentFormHandle : TCefWindowHandle; -{$IFDEF MSWINDOWS} var TempForm : TCustomForm; -{$ENDIF} begin - Result := inherited GetParentFormHandle; - - {$IFDEF MSWINDOWS} + Result := inherited GetParentFormHandle; TempForm := GetParentForm; if (TempForm <> nil) and TempForm.HandleAllocated then @@ -207,7 +203,6 @@ begin (Application.MainForm <> nil) and Application.MainForm.HandleAllocated then Result := Application.MainForm.Handle; - {$ENDIF} end; procedure TChromium.MoveFormTo(const x, y: Integer); diff --git a/source/uCEFChromiumCore.pas b/source/uCEFChromiumCore.pas index 9c29cecf..4bf354e3 100644 --- a/source/uCEFChromiumCore.pas +++ b/source/uCEFChromiumCore.pas @@ -50,20 +50,22 @@ interface uses {$IFDEF DELPHI16_UP} - {$IFDEF MSWINDOWS}WinApi.Windows, WinApi.Messages, WinApi.ActiveX, WinApi.CommCtrl,{$ENDIF} - System.Classes, System.SyncObjs, System.Types, + {$IFDEF MSWINDOWS}WinApi.Windows, WinApi.Messages, WinApi.ActiveX, WinApi.CommCtrl,{$ENDIF} + System.Classes, System.SyncObjs, System.Types, {$ELSE} {$IFDEF MSWINDOWS}Windows, ActiveX, CommCtrl,{$ENDIF} Classes, {$IFDEF FPC} - LCLProc, LCLType, LCLIntf, LResources, LMessages, InterfaceBase, + LCLProc, LCLType, LCLIntf, LResources, LMessages, InterfaceBase, + {$IFDEF LINUX}xlib,{$ENDIF} {$ELSE} - Messages, + Messages, {$ENDIF} SyncObjs, {$ENDIF} uCEFTypes, uCEFInterfaces, uCEFLibFunctions, uCEFMiscFunctions, uCEFClient, uCEFConstants, uCEFTask, uCEFDomVisitor, uCEFChromiumEvents, {$IFDEF MSWINDOWS}uCEFDragAndDropMgr,{$ENDIF} + {$IFDEF LINUX}uCEFLinuxTypes,{$ENDIF} uCEFChromiumOptions, uCEFChromiumFontOptions, uCEFPDFPrintOptions, uCEFBrowserViewComponent; @@ -143,6 +145,10 @@ type FJavascriptEnabled : boolean; FLoadImagesAutomatically : boolean; + {$IFDEF LINUX} + FXDisplay : PXDisplay; + {$ENDIF} + {$IFDEF MSWINDOWS} FOldBrowserCompWndPrc : TFNWndProc; FOldWidgetCompWndPrc : TFNWndProc; @@ -356,6 +362,9 @@ type function GetBrowserById(aID : integer) : ICefBrowser; function GetBrowserCount : integer; function GetBrowserIdByIndex(aIndex : integer) : integer; + {$IFDEF LINUX} + function GetXDisplay : PXDisplay; + {$ENDIF} procedure SetDoNotTrack(aValue : boolean); procedure SetSendReferrer(aValue : boolean); @@ -436,9 +445,6 @@ type function ExecuteSetZoomLevelTask(const aValue : double) : boolean; function ExecuteSetZoomStepTask(aValue : byte) : boolean; function ExecuteBrowserNavigationTask(aTask : TCefBrowserNavigation) : boolean; - function ExecuteUpdateSizeTask(aLeft, aTop, aWidth, aHeight : integer) : boolean; - function ExecuteSendCaptureLostEventTask : boolean; - function ExecuteUpdateXWindowVisibilityTask(aVisible : boolean) : boolean; procedure UpdateHostZoomLevel(const aValue : double); procedure UpdateHostZoomPct(const aValue : double); @@ -643,9 +649,6 @@ type procedure doMediaRouteCreateFinished(result: TCefMediaRouterCreateResult; const error: ustring; const route: ICefMediaRoute); virtual; procedure doOnMediaSinkDeviceInfo(const ip_address: ustring; port: integer; const model_name: ustring); virtual; procedure doBrowserNavigation(aTask : TCefBrowserNavigation); virtual; - procedure doUpdateSize(aLeft, aTop, aWidth, aHeight : integer); virtual; - procedure doSendCaptureLostEvent; virtual; - procedure doUpdateXWindowVisibility(aVisible : boolean); virtual; function MustCreateAudioHandler : boolean; virtual; function MustCreateDevToolsMessageObserver : boolean; virtual; function MustCreateLoadHandler : boolean; virtual; @@ -906,6 +909,9 @@ type property QuicAllowed : boolean read FQuicAllowed write SetQuicAllowed; property JavascriptEnabled : boolean read FJavascriptEnabled write SetJavascriptEnabled; property LoadImagesAutomatically : boolean read FLoadImagesAutomatically write SetLoadImagesAutomatically; + {$IFDEF LINUX} + property XDisplay : PXDisplay read GetXDisplay; + {$ENDIF} property WebRTCIPHandlingPolicy : TCefWebRTCHandlingPolicy read FWebRTCIPHandlingPolicy write SetWebRTCIPHandlingPolicy; property WebRTCMultipleRoutes : TCefState read FWebRTCMultipleRoutes write SetWebRTCMultipleRoutes; @@ -1161,7 +1167,7 @@ uses {$IFDEF DELPHI16_UP} System.SysUtils, System.Math, {$ELSE} - SysUtils, Math, {$IFDEF FPC}{$IFDEF LINUX}xlib, x, xatom,{$ENDIF}{$ENDIF} + SysUtils, Math, {$IFDEF FPC}{$IFDEF LINUX}x, xatom, gdk2x, gtk2,{$ENDIF}{$ENDIF} {$ENDIF} uCEFBrowser, uCEFValue, uCEFDictionaryValue, uCEFStringMultimap, uCEFFrame, uCEFApplicationCore, uCEFProcessMessage, uCEFRequestContext, @@ -1220,6 +1226,9 @@ begin FQuicAllowed := True; FJavascriptEnabled := True; FLoadImagesAutomatically := True; + {$IFDEF LINUX} + FXDisplay := nil; + {$ENDIF} if (GlobalCEFApp <> nil) then FHyperlinkAuditing := GlobalCEFApp.HyperlinkAuditing @@ -2517,57 +2526,6 @@ begin end; end; -function TChromiumCore.ExecuteUpdateSizeTask(aLeft, aTop, aWidth, aHeight : integer) : boolean; -var - TempTask : ICefTask; -begin - Result := False; - - try - if Initialized then - begin - TempTask := TCefUpdateSizeTask.Create(self, aLeft, aTop, aWidth, aHeight); - Result := CefPostTask(TID_UI, TempTask); - end; - finally - TempTask := nil; - end; -end; - -function TChromiumCore.ExecuteSendCaptureLostEventTask : boolean; -var - TempTask : ICefTask; -begin - Result := False; - - try - if Initialized then - begin - TempTask := TCefSendCaptureLostEventTask.Create(self); - Result := CefPostTask(TID_UI, TempTask); - end; - finally - TempTask := nil; - end; -end; - -function TChromiumCore.ExecuteUpdateXWindowVisibilityTask(aVisible : boolean) : boolean; -var - TempTask : ICefTask; -begin - Result := False; - - try - if Initialized then - begin - TempTask := TCefUpdateXWindowVisibilityTask.Create(self, aVisible); - Result := CefPostTask(TID_UI, TempTask); - end; - finally - TempTask := nil; - end; -end; - procedure TChromiumCore.GoBack; begin ExecuteBrowserNavigationTask(bnBack); @@ -2765,6 +2723,32 @@ begin end; end; +{$IFDEF LINUX} +function TChromiumCore.GetXDisplay : PXDisplay; +{$IFDEF FPC} +var + TempParent : TCefWindowHandle; +{$ENDIF} +begin + if (FXDisplay = nil) then + begin + {$IFDEF FPC} + TempParent := ParentFormHandle; + + if ValidCefWindowHandle(TempParent) and + (PGtkWidget(TempParent)^.Window <> nil) then + FXDisplay := GDK_WINDOW_XDISPLAY(PGtkWidget(TempParent)^.Window); + {$ENDIF} + + // GlobalCEFApp.XDisplay can only be called in the CEF UI thread. + if (FXDisplay = nil) and (GlobalCEFApp <> nil) then + FXDisplay := GlobalCEFApp.XDisplay; + end; + + Result := FXDisplay; +end; +{$ENDIF} + function TChromiumCore.GetHasValidMainFrame : boolean; begin Result := Initialized and (Browser.MainFrame <> nil) and Browser.MainFrame.IsValid; @@ -4632,107 +4616,65 @@ begin end; end; -procedure TChromiumCore.doUpdateSize(aLeft, aTop, aWidth, aHeight : integer); -{$IFDEF LINUX}{$IFDEF FPC} +{$IFDEF LINUX} +procedure TChromiumCore.UpdateBrowserSize(aLeft, aTop, aWidth, aHeight : integer); +{$IFDEF FPC} var TempHandle : TCefWindowHandle; TempChanges : TXWindowChanges; TempXDisplay : PXDisplay; -{$ENDIF}{$ENDIF} +{$ENDIF} begin - {$IFDEF LINUX}{$IFDEF FPC} - if (GlobalCEFApp <> nil) then + {$IFDEF FPC} + TempHandle := WindowHandle; + + if ValidCefWindowHandle(TempHandle) then begin - TempXDisplay := GlobalCEFApp.XDisplay; + TempXDisplay := XDisplay; if (TempXDisplay <> nil) then begin - TempHandle := WindowHandle; + TempChanges.x := aLeft; + TempChanges.y := aTop; + TempChanges.width := aWidth; + TempChanges.height := aHeight; - if ValidCefWindowHandle(TempHandle) then - begin - TempChanges.x := aLeft; - TempChanges.y := aTop; - TempChanges.width := aWidth; - TempChanges.height := aHeight; - - XConfigureWindow(TempXDisplay, TempHandle, CWX or CWY or CWHeight or CWWidth, @TempChanges); - end; + XConfigureWindow(TempXDisplay, TempHandle, CWX or CWY or CWHeight or CWWidth, @TempChanges); end; end; - {$ENDIF}{$ENDIF} -end; - -procedure TChromiumCore.doSendCaptureLostEvent; -{$IFDEF LINUX}{$IFDEF FPC} -var - TempXDisplay : PXDisplay; -{$ENDIF}{$ENDIF} -begin - {$IFDEF LINUX}{$IFDEF FPC} - if (GlobalCEFApp <> nil) then - begin - TempXDisplay := GlobalCEFApp.XDisplay; - - if (TempXDisplay <> nil) then - XSetInputFocus(TempXDisplay, X.None, RevertToNone, CurrentTime); - end; - {$ENDIF}{$ENDIF} - - if Initialized then - Browser.Host.SendCaptureLostEvent; + {$ENDIF} end; -procedure TChromiumCore.doUpdateXWindowVisibility(aVisible : boolean); -{$IFDEF LINUX}{$IFDEF FPC} +procedure TChromiumCore.UpdateXWindowVisibility(aVisible : boolean); +{$IFDEF FPC} var TempXDisplay : PXDisplay; TempHandle : TCefWindowHandle; TempState : TAtom; TempHidden : TAtom; -{$ENDIF}{$ENDIF} +{$ENDIF} begin - {$IFDEF LINUX}{$IFDEF FPC} - if (GlobalCEFApp <> nil) then + {$IFDEF FPC} + TempHandle := WindowHandle; + + if ValidCefWindowHandle(TempHandle) then begin - TempXDisplay := GlobalCEFApp.XDisplay; + TempXDisplay := XDisplay; if (TempXDisplay <> nil) then - begin - TempHandle := WindowHandle; + begin + TempState := XInternAtom(TempXDisplay, '_NET_WM_STATE', False); - if ValidCefWindowHandle(TempHandle) then + if aVisible then + XChangeProperty(TempXDisplay, TempHandle, TempState, XA_ATOM, 32, PropModeReplace, nil, 0) + else begin - TempState := XInternAtom(TempXDisplay, '_NET_WM_STATE', False); - - if aVisible then - XChangeProperty(TempXDisplay, TempHandle, TempState, XA_ATOM, 32, PropModeReplace, nil, 0) - else - begin - TempHidden := XInternAtom(TempXDisplay, '_NET_WM_STATE_HIDDEN', False); - XChangeProperty(TempXDisplay, TempHandle, TempState, XA_ATOM, 32, PropModeReplace, @TempHidden, 1); - end; + TempHidden := XInternAtom(TempXDisplay, '_NET_WM_STATE_HIDDEN', False); + XChangeProperty(TempXDisplay, TempHandle, TempState, XA_ATOM, 32, PropModeReplace, @TempHidden, 1); end; end; end; - {$ENDIF}{$ENDIF} -end; - -{$IFDEF LINUX} -procedure TChromiumCore.UpdateBrowserSize(aLeft, aTop, aWidth, aHeight : integer); -begin - if CefCurrentlyOn(TID_UI) then - doUpdateSize(aLeft, aTop, aWidth, aHeight) - else - ExecuteUpdateSizeTask(aLeft, aTop, aWidth, aHeight); -end; - -procedure TChromiumCore.UpdateXWindowVisibility(aVisible : boolean); -begin - if CefCurrentlyOn(TID_UI) then - doUpdateXWindowVisibility(aVisible) - else - ExecuteUpdateXWindowVisibilityTask(aVisible); + {$ENDIF} end; {$ENDIF} @@ -6424,11 +6366,21 @@ begin end; procedure TChromiumCore.SendCaptureLostEvent; +{$IFDEF LINUX}{$IFDEF FPC} +var + TempXDisplay : PXDisplay; +{$ENDIF}{$ENDIF} begin - if CefCurrentlyOn(TID_UI) then - doSendCaptureLostEvent - else - ExecuteSendCaptureLostEventTask; + if not(Initialized) then exit; + + {$IFDEF LINUX}{$IFDEF FPC} + TempXDisplay := XDisplay; + + if (TempXDisplay <> nil) then + XSetInputFocus(TempXDisplay, X.None, RevertToNone, CurrentTime); + {$ENDIF}{$ENDIF} + + Browser.Host.SendCaptureLostEvent; end; procedure TChromiumCore.SetFocus(focus: Boolean); diff --git a/source/uCEFInterfaces.pas b/source/uCEFInterfaces.pas index 938bc309..f3797199 100644 --- a/source/uCEFInterfaces.pas +++ b/source/uCEFInterfaces.pas @@ -485,9 +485,6 @@ type procedure doMediaRouteCreateFinished(result: TCefMediaRouterCreateResult; const error: ustring; const route: ICefMediaRoute); procedure doOnMediaSinkDeviceInfo(const ip_address: ustring; port: integer; const model_name: ustring); procedure doBrowserNavigation(aTask : TCefBrowserNavigation); - procedure doUpdateSize(aLeft, aTop, aWidth, aHeight : integer); - procedure doSendCaptureLostEvent; - procedure doUpdateXWindowVisibility(aVisible : boolean); function MustCreateAudioHandler : boolean; function MustCreateLoadHandler : boolean; function MustCreateFocusHandler : boolean; diff --git a/source/uCEFTask.pas b/source/uCEFTask.pas index fd5ef5d7..26a98b1f 100644 --- a/source/uCEFTask.pas +++ b/source/uCEFTask.pas @@ -219,45 +219,6 @@ type destructor Destroy; override; end; - TCefUpdateSizeTask = class(TCefTaskOwn) - protected - FEvents : Pointer; - FLeft : integer; - FTop : integer; - FWidth : integer; - FHeight : integer; - - procedure Execute; override; - - public - constructor Create(const aEvents : IChromiumEvents; aLeft, aTop, aWidth, aHeight : integer); reintroduce; - destructor Destroy; override; - end; - - TCefSendCaptureLostEventTask = class(TCefTaskOwn) - protected - FEvents : Pointer; - - procedure Execute; override; - - public - constructor Create(const aEvents : IChromiumEvents); reintroduce; - destructor Destroy; override; - end; - - TCefUpdateXWindowVisibilityTask = class(TCefTaskOwn) - protected - FEvents : pointer; - FVisible : boolean; - - procedure Execute; override; - - public - constructor Create(const aEvents : IChromiumEvents; aVisible : boolean); reintroduce; - destructor Destroy; override; - end; - - implementation uses @@ -720,103 +681,4 @@ begin inherited Destroy; end; - -// TCefUpdateSizeTask - -procedure TCefUpdateSizeTask.Execute; -begin - try - try - if (FEvents <> nil) then IChromiumEvents(FEvents).doUpdateSize(FLeft, FTop, FWidth, FHeight); - except - on e : exception do - if CustomExceptionHandler('TCefUpdateSizeTask.Execute', e) then raise; - end; - finally - FEvents := nil; - end; -end; - -constructor TCefUpdateSizeTask.Create(const aEvents : IChromiumEvents; aLeft, aTop, aWidth, aHeight : integer); -begin - inherited Create; - - FEvents := Pointer(aEvents); - FLeft := aLeft; - FTop := aTop; - FWidth := aWidth; - FHeight := aHeight; -end; - -destructor TCefUpdateSizeTask.Destroy; -begin - FEvents := nil; - - inherited Destroy; -end; - - -// TCefSendCaptureLostEventTask - -procedure TCefSendCaptureLostEventTask.Execute; -begin - try - try - if (FEvents <> nil) then IChromiumEvents(FEvents).doSendCaptureLostEvent; - except - on e : exception do - if CustomExceptionHandler('TCefSendCaptureLostEventTask.Execute', e) then raise; - end; - finally - FEvents := nil; - end; -end; - -constructor TCefSendCaptureLostEventTask.Create(const aEvents : IChromiumEvents); -begin - inherited Create; - - FEvents := Pointer(aEvents); -end; - -destructor TCefSendCaptureLostEventTask.Destroy; -begin - FEvents := nil; - - inherited Destroy; -end; - - -// TCefUpdateXWindowVisibilityTask - -procedure TCefUpdateXWindowVisibilityTask.Execute; -begin - try - try - if (FEvents <> nil) then IChromiumEvents(FEvents).doUpdateXWindowVisibility(FVisible); - except - on e : exception do - if CustomExceptionHandler('TCefUpdateXWindowVisibilityTask.Execute', e) then raise; - end; - finally - FEvents := nil; - end; -end; - -constructor TCefUpdateXWindowVisibilityTask.Create(const aEvents : IChromiumEvents; aVisible : boolean); -begin - inherited Create; - - FEvents := Pointer(aEvents); - FVisible := aVisible; -end; - -destructor TCefUpdateXWindowVisibilityTask.Destroy; -begin - FEvents := nil; - - inherited Destroy; -end; - - end. diff --git a/update_CEF4Delphi.json b/update_CEF4Delphi.json index 739c4e49..dab43a16 100644 --- a/update_CEF4Delphi.json +++ b/update_CEF4Delphi.json @@ -2,9 +2,9 @@ "UpdateLazPackages" : [ { "ForceNotify" : true, - "InternalVersion" : 250, + "InternalVersion" : 251, "Name" : "cef4delphi_lazarus.lpk", - "Version" : "88.2.1.0" + "Version" : "88.2.4.0" } ], "UpdatePackageData" : {