From: Bentoo Overlay <noreply@bentoo>
Subject: [PATCH] Fix Wayland+Vulkan build: undef X11 CursorShape macro after vulkan include

When building with USE="vulkan wayland gui [tools]", two translation units
include the Vulkan rendering context driver header, which transitively pulls
in <vulkan/vulkan.h> with VK_USE_PLATFORM_XLIB_KHR set. That drags in
<X11/X.h>, which defines `CursorShape` as the macro `0`.

After PR #116976 (Decouple DisplayServer), CursorShape lives in
namespace DisplayServerEnums (and also InputClassEnums). References to
`DisplayServerEnums::CursorShape` / `InputClassEnums::CursorShape` later
in the same TU get mangled into `<namespace>::0` by the X11 macro,
producing:

  error: variable or field 'cursor_set_shape' declared void
  error: expected unqualified-id before numeric constant

The problem now occurs in BOTH:
  - platform/linuxbsd/wayland/display_server_wayland.cpp (since 4.4)
  - servers/display/display_server.cpp (new in 4.7 after the
    DisplayServer decoupling refactor moved CursorShape definitions
    to servers/display/display_server.h / DisplayServerEnums)

Undefining CursorShape inside display_server_enums.h is not enough because
that header is included BEFORE the vulkan include redefines the macro.

Fix: undef the macro in each .cpp itself, immediately after the RD/Vulkan
include block, so it stays gone for the rest of the translation unit.
Same trick is used by display_server_x11.h and display_server.h on the
Xlib side.

--- a/platform/linuxbsd/wayland/display_server_wayland.cpp
+++ b/platform/linuxbsd/wayland/display_server_wayland.cpp
@@ -55,6 +55,11 @@
 #endif

 #include "servers/rendering/renderer_rd/renderer_compositor_rd.h"
+
+// Xlib's <X11/X.h> (pulled in by vulkan.h when VK_USE_PLATFORM_XLIB_KHR is set)
+// defines CursorShape as a numeric macro (0) and clobbers references to
+// DisplayServerEnums::CursorShape later in this TU. Undef after the Vulkan block.
+#undef CursorShape
 #endif

 #ifdef GLES3_ENABLED
--- a/servers/display/display_server.cpp
+++ b/servers/display/display_server.cpp
@@ -58,6 +58,12 @@
 #if defined(METAL_ENABLED)
 #include "drivers/metal/rendering_context_driver_metal.h"
 #endif
+
+// Xlib's <X11/X.h> (pulled in by vulkan.h when VK_USE_PLATFORM_XLIB_KHR is set)
+// defines CursorShape as a numeric macro (0) and clobbers references to
+// DisplayServerEnums::CursorShape / InputClassEnums::CursorShape later in
+// this TU. Undef after the RD/Vulkan/D3D12/Metal include block.
+#undef CursorShape

 DisplayServer *DisplayServer::singleton = nullptr;

