mirror of
https://github.com/glfw/glfw.git
synced 2026-08-28 21:25:53 +02:00
@@ -27,6 +27,9 @@
|
||||
|
||||
#include "internal.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
// These construct a string literal from individual numeric constants
|
||||
#define _GLFW_CONCAT_VERSION(m, n, r) #m "." #n "." #r
|
||||
#define _GLFW_MAKE_VERSION(m, n, r) _GLFW_CONCAT_VERSION(m, n, r)
|
||||
@@ -80,6 +83,22 @@ GLFWbool _glfwSelectPlatform(int desiredID, _GLFWplatform* platform)
|
||||
return GLFW_FALSE;
|
||||
}
|
||||
|
||||
#if defined(_GLFW_WAYLAND) && defined(_GLFW_X11)
|
||||
if (desiredID == GLFW_ANY_PLATFORM)
|
||||
{
|
||||
const char* const session = getenv("XDG_SESSION_TYPE");
|
||||
if (session)
|
||||
{
|
||||
// Only follow XDG_SESSION_TYPE if it is set correctly and the
|
||||
// environment looks plausble; otherwise fall back to detection
|
||||
if (strcmp(session, "wayland") == 0 && getenv("WAYLAND_DISPLAY"))
|
||||
desiredID = GLFW_PLATFORM_WAYLAND;
|
||||
else if (strcmp(session, "x11") == 0 && getenv("DISPLAY"))
|
||||
desiredID = GLFW_PLATFORM_X11;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (desiredID == GLFW_ANY_PLATFORM)
|
||||
{
|
||||
// If there is exactly one platform available for auto-selection, let it emit the
|
||||
|
||||
Reference in New Issue
Block a user