Start program with x11 backend
Posted: Mon Apr 25, 2022 12:21 pm
Since not everything runs under Wayland (default of Ubuntu 22.04), such as OpenGLGadget (gl_area not supported) or engine3d, you can change the gdk_backend to x11 for the application.
Also for the problem with the window sizes of PB. (Or use Workaround Wayland)
Update v1.01.2
Also for the problem with the window sizes of PB. (Or use Workaround Wayland)
Update v1.01.2
Code: Select all
;-TOP by mk-soft, v1.01.2, 25.04.2022
Procedure StartProgramX11(Program.s, Parameters.s, WorkingDirectory.s = "", Exit = #False)
Protected r1, SessionType.s, GdkBackend.s
SessionType = GetEnvironmentVariable("XDG_SESSION_TYPE")
GdkBackend = GetEnvironmentVariable("GDK_BACKEND")
If SessionType <> "x11"
If GdkBackend <> "x11"
SetEnvironmentVariable("GDK_BACKEND", "x11")
EndIf
EndIf
r1 = RunProgram(Program, Parameters, WorkingDirectory)
If Exit
End
EndIf
ProcedureReturn r1
EndProcedure
CompilerIf #PB_Compiler_IsMainFile
Global dx, dy, info.s
If GetEnvironmentVariable("XDG_SESSION_TYPE") <> "x11"
If ProgramParameter(0) <> "x11"
StartProgramX11(ProgramFilename(), "x11" , "", #True)
EndIf
EndIf
info = "XDG_SESSION_TYPE: " + GetEnvironmentVariable("XDG_SESSION_TYPE") + #LF$
info + "GDK_BACKEND: " + GetEnvironmentVariable("GDK_BACKEND")
If OpenWindow(0, 100, 100, 400, 300, "GDK Backend X11", #PB_Window_SystemMenu)
dx = WindowWidth(0)
dy = WindowHeight(0)
TextGadget(0, 10, 10, dx - 20, dy - 60, info)
ButtonGadget(1, 10, dy - 50, 120, 30, "Button")
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
Break
EndSelect
ForEver
EndIf
CompilerEndIf