Skip to content

Update GLFW backend X11 and WL detection - #8969

Closed
oktonion wants to merge 1 commit into
ocornut:masterfrom
oktonion:master
Closed

oktonion wants to merge 1 commit into
ocornut:masterfrom
oktonion:master

Conversation

@oktonion

Copy link
Copy Markdown

Quick fix for recently added GLFW ...EXPOSE_NATIVE... defines to access internals of X11 and Wayland platforms (bad design decision in the first place but whatever).

Just check for if not windows or apple and !defined(__EMSCRIPTEN__) is not enough to assume that platform has X11 or Wayland.
PR adds checks for unix or linux OS defines to ensure back-end may access GLFW internals for these platforms.

@ocornut

ocornut commented Sep 29, 2025

Copy link
Copy Markdown
Owner

Thank you! Could you clarify which platform/sdk you are using where the assumption was not correct?

@ocornut

ocornut commented Sep 29, 2025

Copy link
Copy Markdown
Owner

Does it work if you replace the code with:

#elif !defined(__EMSCRIPTEN__) && GLFW_HAS_X11_OR_WAYLAND

@oktonion

Copy link
Copy Markdown
Author

Does it work if you replace the code with:

#elif !defined(__EMSCRIPTEN__) && GLFW_HAS_X11_OR_WAYLAND

Obviously it will not work because GLFW_HAS_X11_OR_WAYLAND define starts at 158 line and checks are at 120 line.

If we'll rearrange defines so

...
#if defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__DragonFly__)
#define GLFW_HAS_X11_OR_WAYLAND 1
#else
#define GLFW_HAS_X11_OR_WAYLAND 0
#endif
...
// GLFW
#include <GLFW/glfw3.h>
#ifdef _WIN32
#undef APIENTRY
#ifndef GLFW_EXPOSE_NATIVE_WIN32    // for glfwGetWin32Window()
#define GLFW_EXPOSE_NATIVE_WIN32
...
#elif !defined(__EMSCRIPTEN__) && GLFW_HAS_X11_OR_WAYLAND 
#ifndef GLFW_EXPOSE_NATIVE_X11      // for glfwGetX11Window() on Freedesktop (Linux, BSD, etc.)
#define GLFW_EXPOSE_NATIVE_X11
#endif
#ifndef GLFW_EXPOSE_NATIVE_WAYLAND
#define GLFW_EXPOSE_NATIVE_WAYLAND
#endif
#include <GLFW/glfw3native.h>
#endif
...
#if !GLFW_HAS_X11_OR_WAYLAND
    return false;
#elif GLFW_HAS_GETPLATFORM
...

then yes.

P.S. Also I don't know why misleading comment like // for glfwGetX11Window() on Freedesktop (Linux, BSD, etc.) exists as there is zero usage of glfwGetX11Window function. However there is glfwGetX11Display function call so maybe it is typo or smth.

@ocornut

ocornut commented Sep 29, 2025

Copy link
Copy Markdown
Owner

Thanks, I'll push the fix soon.

P.S. Also I don't know why misleading comment like // for glfwGetX11Window() on Freedesktop (Linux, BSD, etc.) exists as there is zero usage of glfwGetX11Window function. However there is glfwGetX11Display function call so maybe it is typo or smth.

The glfwGetX11Window() is used in docking branch hence the confusion, I'll tweak the comments accordingly.

ocornut added a commit that referenced this pull request Sep 29, 2025
@ocornut ocornut closed this Sep 29, 2025
ocornut added a commit that referenced this pull request Oct 20, 2025
Intrets pushed a commit to Intrets/imgui that referenced this pull request Jan 1, 2026
ocornut added a commit that referenced this pull request Feb 10, 2026
…LFW_DISABLE_WAYLAND automatically if headers are not available. (#9225)

Amend/fix 10d0162 for system without X11/Wayland headers. (#8921, #8920, #8969)
brentfpage pushed a commit to brentfpage/imgui that referenced this pull request Feb 24, 2026
…LFW_DISABLE_WAYLAND automatically if headers are not available. (ocornut#9225)

Amend/fix 10d0162 for system without X11/Wayland headers. (ocornut#8921, ocornut#8920, ocornut#8969)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

⌂ 换网址