REVIEWED: GetWindowHandle(), avoid on SDL2 with Linux #6085
It generates conflicts with raylib Font symbol
This commit is contained in:
parent
0fb5c98293
commit
71643d8cda
1 changed files with 12 additions and 2 deletions
|
|
@ -56,7 +56,12 @@
|
||||||
#include "SDL3/SDL.h"
|
#include "SDL3/SDL.h"
|
||||||
#elif defined(USING_SDL2_PROJECT)
|
#elif defined(USING_SDL2_PROJECT)
|
||||||
#include "SDL2/SDL.h"
|
#include "SDL2/SDL.h"
|
||||||
#include "SDL2/SDL_syswm.h" // Required to get window handlers
|
#if !defined(__linux__)
|
||||||
|
// WARNING: On Linux this header includes Xlib.h that defines Font and
|
||||||
|
// conflicts with raylib Font, as it is only used on GetWindowHandle() and
|
||||||
|
// most users do not need that function, just commenting for that case
|
||||||
|
#include "SDL2/SDL_syswm.h" // Required to get window handlers
|
||||||
|
#endif
|
||||||
#else
|
#else
|
||||||
#include "SDL.h"
|
#include "SDL.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -955,13 +960,17 @@ void *GetWindowHandle(void)
|
||||||
#elif defined(__APPLE__)
|
#elif defined(__APPLE__)
|
||||||
handle = (void *)SDL_GetPointerProperty(props, SDL_PROP_WINDOW_COCOA_WINDOW_POINTER, NULL); // Type: NSWindow*
|
handle = (void *)SDL_GetPointerProperty(props, SDL_PROP_WINDOW_COCOA_WINDOW_POINTER, NULL); // Type: NSWindow*
|
||||||
#endif
|
#endif
|
||||||
#elif defined(USING_SDL2_PROJECT)
|
#elif defined(USING_SDL2_PROJECT) && !defined(__linux__)
|
||||||
|
// WARNING: On linux the inclusion of SDL_syswm.h also includes Xlib.h and
|
||||||
|
// generates a symbol conflict with raylib due to Font, as this function is not
|
||||||
|
// required by most users, just avoiding that use case
|
||||||
SDL_SysWMinfo wmInfo = { 0 };
|
SDL_SysWMinfo wmInfo = { 0 };
|
||||||
SDL_VERSION(&wmInfo.version);
|
SDL_VERSION(&wmInfo.version);
|
||||||
if (SDL_GetWindowWMInfo(platform.window, &wmInfo))
|
if (SDL_GetWindowWMInfo(platform.window, &wmInfo))
|
||||||
{
|
{
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
handle = (void *)wmInfo.info.win.window; // Type: HWND
|
handle = (void *)wmInfo.info.win.window; // Type: HWND
|
||||||
|
/*
|
||||||
#elif defined(__linux__)
|
#elif defined(__linux__)
|
||||||
if (wmInfo.subsystem == SDL_SYSWM_X11)
|
if (wmInfo.subsystem == SDL_SYSWM_X11)
|
||||||
{
|
{
|
||||||
|
|
@ -975,6 +984,7 @@ void *GetWindowHandle(void)
|
||||||
// NOTE: Alternative: wmInfo.info.wl.display
|
// NOTE: Alternative: wmInfo.info.wl.display
|
||||||
handle = (void *)wmInfo.info.wl.surface; // Type: struct wl_surface*
|
handle = (void *)wmInfo.info.wl.surface; // Type: struct wl_surface*
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
#elif defined(__APPLE__)
|
#elif defined(__APPLE__)
|
||||||
handle = (void *)wmInfo.info.cocoa.window; // Type: NSWindow*
|
handle = (void *)wmInfo.info.cocoa.window; // Type: NSWindow*
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue