FIX: Wayland detection (fixes #2773)

This commit is contained in:
Alexander Koblov 2026-03-05 19:28:17 +03:00
commit 448e3d2d75
2 changed files with 18 additions and 4 deletions

View file

@ -28,7 +28,7 @@ var
implementation
uses
CTypes, SysUtils, Forms, Graphics, GraphUtil, qtobjects, qt6;
CTypes, SysUtils, Forms, Graphics, GraphUtil, qtobjects, qt6, DCStrUtils;
function setenv(const name, value: pchar; overwrite: cint): cint; cdecl; external clib;
@ -406,12 +406,26 @@ end;
function IsWayland: Boolean;
var
Index: Integer;
ASession: String;
APlatform: String;
begin
ASession:= LowerCase(GetEnvironmentVariable('XDG_SESSION_TYPE'));
APlatform:= LowerCase(GetEnvironmentVariable('QT_QPA_PLATFORM'));
Result:= (ASession = 'wayland') and ((APlatform = '') or (APlatform = 'wayland'));
Result:= (ASession = 'wayland');
if Result then
begin
for Index:= 1 to ParamCount do
begin
if ParamStr(Index) = '-platform' then
begin
APlatform:= ParamStr(Index + 1);
Result:= StrBegins(APlatform, 'wayland');
Exit;
end;
end;
APlatform:= LowerCase(GetEnvironmentVariable('QT_QPA_PLATFORM'));
Result:= (APlatform = '') or StrBegins(APlatform, 'wayland');
end;
end;
initialization

View file

@ -31,7 +31,7 @@ uses
procedure Initialize;
begin
if IsWayland then
if IsWayland and Assigned(QtWidgetSetEx) then
begin
WSControls.RegisterControl;
RegisterWSComponent(TControl, TQtWSControlEx);