Closed ggarra13 closed 1 year ago
Feel free to raise this issue with the GLFW project.
I did. It seems it has been requested in the past.
I got this answer back:
PR https://github.com/glfw/glfw/pull/1958 added support for runtime platform selection, and this has been merged into main so you can select the platform using the GLFW_PLATFORM init hint with either GLFW_PLATFORM_X11 or GLFW_PLATFORM_WAYLAND in your case. Also see glfwPlatformSupported.
It seems we may need to upgrade glfw and add the GLFW_PLATFORM hint by checking an environment variable, like:
#ifdef __linux__
char* platform = getenv("GLFW_PLATFORM");
if (!platform)
platform = getenv("XDG_SESSION_TYPE");
int platform_hint = GLFW_PLATFORM_X11;
if (platform && strcmp(platform, "wayland") == 0)
{
platform_hint = GLFW_PLATFORM_WAYLAND;
}
if (glfwPlatformSupported(platform_hint) == GLFW_TRUE)
glfwWindowHint(GLFW_PLATFORM, platform_hint);
#endif
See PR #130 for an implementation.
Currently glfw3 is compiled with X11 support only. It can be compiled with Wayland support with the cmake setting -D GLFW_USE_WAYLAND=ON.
But it seems it cannot be compiled with support for both and switched at runtime with an environment variable like FLTK can.
This is problematic.