diff --git a/source/uCEFApplicationCore.pas b/source/uCEFApplicationCore.pas
index abd595a1..3a0bd33b 100644
--- a/source/uCEFApplicationCore.pas
+++ b/source/uCEFApplicationCore.pas
@@ -174,7 +174,8 @@ type
// Fields used during the CEF initialization
FWindowsSandboxInfo : pointer;
{$IFDEF LINUX}
- FArgCopy : TCEFArgCopy;
+ FArgCopy : TCEFArgCopy;
+ FDisplayServer : TCefLinuxDisplayServer;
{$ENDIF}
// Fields used by custom properties
@@ -403,6 +404,9 @@ type
{$IFDEF MACOSX}
function CheckMacOSVersion : boolean; virtual;
{$ENDIF}
+ {$IFDEF LINUX}
+ procedure ReadDisplayServer;
+ {$ENDIF}
function CheckOSVersion: boolean; virtual;
procedure ShowErrorMessageDlg(const aError : string); virtual;
function ParseProcessType : TCefProcessType;
@@ -1363,6 +1367,10 @@ type
/// Uses the following command line switch: --ozone-platform
///
property OzonePlatform : TCefOzonePlatform read FOzonePlatform write FOzonePlatform;
+ ///
+ /// Linux display server type.
+ ///
+ property DisplayServer : TCefLinuxDisplayServer read FDisplayServer;
{$ENDIF}
///
/// Ignores certificate-related errors.
@@ -2103,6 +2111,7 @@ begin
FPasswordStorage := psDefault;
FGTKVersion := gtkVersionDefault;
FOzonePlatform := ozpDefault;
+ FDisplayServer := ldsUnknown;
{$ENDIF}
// Fields used during the CEF initialization
@@ -2454,8 +2463,33 @@ begin
FCustomCommandLines := TStringList.Create;
FCustomCommandLineValues := TStringList.Create;
FComponentIDList := TCEFComponentIDList.Create;
+ {$IFDEF LINUX}
+ ReadDisplayServer;
+ {$ENDIF}
end;
+{$IFDEF LINUX}
+procedure TCefApplicationCore.ReadDisplayServer;
+{$IFDEF FPC}
+var
+ TempSession : AnsiString;
+{$ENDIF}
+begin
+ {$IFDEF FPC}
+ TempSession := GetEnvironmentVariable('XDG_SESSION_TYPE');
+
+ if (TempSession = 'wayland') then
+ FDisplayServer := ldsWayland
+ else
+ if (TempSession = 'x11') then
+ FDisplayServer := ldsX11
+ else
+ FDisplayServer := ldsUnknown;
+ {$ENDIF}
+ // TO-DO : Find a way to get read the value of an environment variable or the display server type in FMXLinux.
+end;
+{$ENDIF}
+
procedure TCefApplicationCore.AddCustomCommandLine(const aCommandLine, aValue : string);
begin
if (FCustomCommandLines <> nil) then FCustomCommandLines.Add(aCommandLine);
diff --git a/source/uCEFChromiumCore.pas b/source/uCEFChromiumCore.pas
index bba542d0..b8045854 100644
--- a/source/uCEFChromiumCore.pas
+++ b/source/uCEFChromiumCore.pas
@@ -5916,38 +5916,38 @@ var
TempParent : TCefWindowHandle;
{$ENDIF}
begin
- Result := nil;
-
try
- if (FXDisplay = nil) then
- begin
- {$IFDEF FPC}
- {$IFDEF LCLGTK2}
- TempParent := ParentFormHandle;
+ try
+ if (FXDisplay = nil) and (GlobalCEFApp.DisplayServer = ldsX11) then
+ begin
+ {$IFDEF FPC}
+ {$IFDEF LCLGTK2}
+ TempParent := ParentFormHandle;
- if ValidCefWindowHandle(TempParent) and
- (PGtkWidget(TempParent)^.Window <> nil) then
- FXDisplay := GDK_WINDOW_XDISPLAY(PGtkWidget(TempParent)^.Window);
+ if ValidCefWindowHandle(TempParent) and
+ (PGtkWidget(TempParent)^.Window <> nil) then
+ FXDisplay := GDK_WINDOW_XDISPLAY(PGtkWidget(TempParent)^.Window);
+ {$ENDIF}
+ {$IFDEF LCLGTK3}
+ FXDisplay := gdk_x11_get_default_xdisplay();
+ {$ENDIF}
+ {$IF DEFINED(LCLQT) OR DEFINED(LCLQT5)}
+ FXDisplay := QX11Info_display();
+ {$IFEND}
+ {$IFDEF LCLQT6}
+ FXDisplay := TQtWidgetSet(WidgetSet).x11Display;
+ {$ENDIF}
{$ENDIF}
- {$IFDEF LCLGTK3}
- FXDisplay := gdk_x11_get_default_xdisplay();
- {$ENDIF}
- {$IF DEFINED(LCLQT) OR DEFINED(LCLQT5)}
- FXDisplay := QX11Info_display();
- {$IFEND}
- {$IFDEF LCLQT6}
- FXDisplay := TQtWidgetSet(WidgetSet).x11Display;
- {$ENDIF}
- {$ENDIF}
- end;
-
+ end;
+ except
+ on e : exception do
+ if CustomExceptionHandler('TChromiumCore.GetXDisplay', e) then raise;
+ end;
+ finally
if (FXDisplay = nil) then
Result := FGlobalXDisplay
else
Result := FXDisplay;
- except
- on e : exception do
- if CustomExceptionHandler('TChromiumCore.GetXDisplay', e) then raise;
end;
end;
@@ -5955,8 +5955,7 @@ procedure TChromiumCore.ReadGlobalXDisplay;
begin
try
// GlobalCEFApp.XDisplay can only be called in the CEF UI thread.
- if (GlobalCEFApp <> nil) then
- FGlobalXDisplay := GlobalCEFApp.XDisplay;
+ FGlobalXDisplay := GlobalCEFApp.XDisplay;
except
on e : exception do
if CustomExceptionHandler('TChromiumCore.ReadGlobalXDisplay', e) then raise;
diff --git a/source/uCEFTypes.pas b/source/uCEFTypes.pas
index 4b607587..fe9d3c92 100644
--- a/source/uCEFTypes.pas
+++ b/source/uCEFTypes.pas
@@ -1485,6 +1485,11 @@ type
kDefault = 3
);
+ ///
+ /// Linux session type. Used to check whether the display server is Xorg or Wayland.
+ ///
+ TCefLinuxDisplayServer = (ldsX11, ldsWayland, ldsUnknown);
+
///
/// Used by TCEFFileDialogInfo.
///
diff --git a/update_CEF4Delphi.json b/update_CEF4Delphi.json
index b2e1eef8..372c2aa5 100644
--- a/update_CEF4Delphi.json
+++ b/update_CEF4Delphi.json
@@ -2,7 +2,7 @@
"UpdateLazPackages" : [
{
"ForceNotify" : true,
- "InternalVersion" : 797,
+ "InternalVersion" : 798,
"Name" : "cef4delphi_lazarus.lpk",
"Version" : "140.1.14"
}