1
0
mirror of https://github.com/salvadordf/CEF4Delphi.git synced 2025-09-30 21:28:55 +02:00

Added code comments to GTKBrowser

Removed overloaded UseDefaultX11VisualForGtk
Removed overloaded FlushDisplay
Added Linux Mint 22.2 mention
This commit is contained in:
Salvador Díaz Fau
2025-09-09 17:36:08 +02:00
parent 491eba7bc5
commit 0a97240c4c
4 changed files with 38 additions and 22 deletions

View File

@@ -15,7 +15,7 @@ The CEF binaries used by CEF4Delphi are available for download at Spotify :
CEF4Delphi was developed and tested on Delphi 12.3 and it has been tested in Delphi 6, Delphi XE, Delphi 10, Delphi 11 and Lazarus 4.2/FPC 3.2.2. CEF4Delphi includes VCL, FireMonkey (FMX) and Lazarus components.
CEF4Delphi demos have been tested in Windows 10, Windows 11, Linux Mint 22.1 and Raspberry Pi OS.
CEF4Delphi demos have been tested in Windows 10, Windows 11, Linux Mint 22.2 and Raspberry Pi OS.
## Links
* [Installation instructions and more information about CEF4Delphi](https://www.briskbard.com/index.php?lang=en&pageid=cef)

View File

@@ -15,8 +15,6 @@ type
private
FCanClose : boolean;
FClosing : boolean;
FInitializing : boolean;
FLoading : boolean;
FWindow : PGtkWidget;
FChromium : TChromium;
@@ -63,6 +61,30 @@ function StartMainProcess: boolean;
implementation
// This demo is a rough and incomplete translation of the official cefclient
// application for GTK3.
// There are several missing features and pending issues. This demo was just
// used to test the CEF initialization in GTK3 using low level API functions in
// Lazarus.
// If you need to add a CEF browser to your GTK3 application then use the code
// in SimpleOSRBrowser.
// Trying to use the GTK3 WidgetSet in Lazarus to initialize CEF is not possible
// at this moment because:
// - GTK >3.15.1 uses an X11 visual optimized for GTK+'s OpenGL stuff which
// breaks CEF/Chromium.
// - It's necessary to call the UseDefaultX11VisualForGtk procedure before the
// GtkWindow is realized to use the default X11 visual.
// - TGtk3Window.CreateWidget (Gtk3Widgets.pas) realizes the window almost
// immediately after its creation.
// At this point we can only wait until the CEF/Chromium requirements change.
// Perhaps with Wayland support.
// Meanwhile GTK3 applications can use CEF browsers in OSR mode only.
var
MainAppEvent : TEventObject = nil;
@@ -151,8 +173,6 @@ begin
FCanClose := False;
FClosing := False;
FInitializing := True;
FLoading := False;
FWindow := nil;
FChromium := nil;
end;
@@ -195,6 +215,7 @@ procedure TMainWindow.Show;
begin
// Show the GTK window.
UseDefaultX11VisualForGtk(FWindow);
gtk_widget_show_all(FWindow);
// Flush the display to make sure the underlying X11 window gets created
@@ -235,13 +256,20 @@ end;
{%Region}
procedure TMainWindow.OnAfterCreated(Sender: TObject; const browser: ICefBrowser);
begin
TThread.Synchronize(nil, @DoAfterCreated);
if GlobalCEFApp.MultiThreadedMessageLoop then
TThread.Synchronize(nil, @DoAfterCreated)
else
DoAfterCreated;
end;
procedure TMainWindow.OnBeforeClose(Sender: TObject; const browser: ICefBrowser);
begin
FCanClose := True;
TThread.Synchronize(nil, @DoBeforeClose);
if GlobalCEFApp.MultiThreadedMessageLoop then
TThread.Synchronize(nil, @DoBeforeClose)
else
DoBeforeClose;
end;
procedure TMainWindow.OnBeforePopup(Sender: TObject;

View File

@@ -65,10 +65,8 @@ procedure gdk_set_allowed_backends(const backends: PGchar); cdecl; external 'lib
function gdk_x11_display_get_xdisplay(display: PGdkDisplay): PDisplay; cdecl; external 'libgdk-3.so.0';
function gdk_x11_screen_get_screen_number(screen: PGdkScreen): longint; cdecl; external 'libgdk-3.so.0';
function gdk_x11_visual_get_xvisual(visual: PGdkVisual): PVisual; cdecl; external 'libgdk-3.so.0';
procedure UseDefaultX11VisualForGtk(widget : PGtkWidget); overload;
procedure UseDefaultX11VisualForGtk(aHandle : TCefWindowHandle); overload;
procedure FlushDisplay(widget : PGtkWidget); overload;
procedure FlushDisplay(aHandle : TCefWindowHandle); overload;
procedure UseDefaultX11VisualForGtk(widget : PGtkWidget);
procedure FlushDisplay(widget : PGtkWidget);
{$ENDIF}
procedure ShowX11Message(const aMessage : string);
{$ENDIF}{$ENDIF}
@@ -735,11 +733,6 @@ begin
g_list_free(visuals);
end;
procedure UseDefaultX11VisualForGtk(aHandle : TCefWindowHandle);
begin
UseDefaultX11VisualForGtk(TGtk3Widget(aHandle).Widget);
end;
procedure FlushDisplay(widget : PGtkWidget);
var
gdk_window : PGdkWindow;
@@ -749,11 +742,6 @@ begin
display := gdk_window_get_display(gdk_window);
gdk_display_flush(display);
end;
procedure FlushDisplay(aHandle : TCefWindowHandle);
begin
FlushDisplay(TGtk3Widget(aHandle).Widget);
end;
{$ENDIF}
{$ENDIF}

View File

@@ -2,7 +2,7 @@
"UpdateLazPackages" : [
{
"ForceNotify" : true,
"InternalVersion" : 780,
"InternalVersion" : 781,
"Name" : "cef4delphi_lazarus.lpk",
"Version" : "139.0.38"
}