mirror of
https://github.com/glfw/glfw.git
synced 2024-11-22 01:55:09 +00:00
parent
690a15f929
commit
14e653358b
@ -164,6 +164,7 @@ information on what to include when reporting a bug.
|
||||
- Added `GLFW_BUILD_X11` CMake option for enabling X11 support (#1958)
|
||||
- Added `GLFW_LIBRARY_TYPE` CMake variable for overriding the library type
|
||||
(#279,#1307,#1497,#1574,#1928)
|
||||
- Added support for `XDG_SESSION_TYPE` environment variable
|
||||
- Added `GLFW_PKG_CONFIG_REQUIRES_PRIVATE` and `GLFW_PKG_CONFIG_LIBS_PRIVATE` CMake
|
||||
variables exposing pkg-config dependencies (#1307)
|
||||
- Made joystick subsystem initialize at first use (#1284,#1646)
|
||||
|
@ -2199,6 +2199,13 @@ typedef struct GLFWallocator
|
||||
* application locale according to the current environment if that category is
|
||||
* still "C". This is because the "C" locale breaks Unicode text input.
|
||||
*
|
||||
* @remark __Wayland, X11:__ If the library was compiled with support for both
|
||||
* Wayland and X11, and the @ref GLFW_PLATFORM init hint is set to
|
||||
* `GLFW_ANY_PLATFORM`, the `XDG_SESSION_TYPE` environment variable affects
|
||||
* which platform is picked. If the environment variable is not set, or is set
|
||||
* to something other than `wayland` or `x11`, the regular detection mechanism
|
||||
* will be used instead.
|
||||
*
|
||||
* @thread_safety This function must only be called from the main thread.
|
||||
*
|
||||
* @sa @ref intro_init
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user