Use XWayland for Atlas if needed

GlCanvas currently doesn't support runtime selection of GDK backend [1].

Therefore to run Atlas under Wayland wxWidgets needs to be built with
GLCANVAS_EGL which is usually not the case to support X11 at the same
time.

Check if the EGL backend is available and if not and running under
Wayland force use of XWayland with the GLX backend.

[1] https://github.com/wxWidgets/wxWidgets/issues/22325

Closes: #6939
Signed-off-by: Ralph Sennhauser <ralph.sennhauser@gmail.com>
This commit is contained in:
Ralph Sennhauser 2024-10-06 08:28:39 +02:00
parent 0716d23aa4
commit b5d08a4833

View file

@ -139,6 +139,19 @@ ATLASDLLIMPEXP void Atlas_StartWindow(const wchar_t* type)
{
fprintf(stderr, "Error enabling thread-safety via XInitThreads\n");
}
#if defined(wxUSE_GLCANVAS_EGL) && wxUSE_GLCANVAS_EGL == 0
// The glcanvas is currently either built with support for GLX or EGL, if
// built with GLX support on Wayland we need to use XWayland.
// https://github.com/wxWidgets/wxWidgets/issues/22325
const wxString xdgSessionType{wxGetenv("XDG_SESSION_TYPE")};
const wxString waylandDisplay{wxGetenv("WAYLAND_DISPLAY")};
if (xdgSessionType == "wayland" || waylandDisplay.Contains("wayland"))
{
// GTK has an API to set allowed backends but would require to add it
// as a direct dependency, so just force it using an envvar.
wxSetEnv("GDK_BACKEND", "x11");
}
#endif
#endif
int argc = 1;
char atlas[] = "atlas";