diff --git a/engine/platform/dos/vid_dos.c b/engine/platform/dos/vid_dos.c index 19f82c20..9d1b5549 100644 --- a/engine/platform/dos/vid_dos.c +++ b/engine/platform/dos/vid_dos.c @@ -543,9 +543,12 @@ qboolean SW_CreateBuffer( int width, int height, uint *stride, uint *bpp, uint * return true; } -window_handle_t *R_GetWindowHandle( void ) +window_handle_t R_GetWindowHandle( void ) { - return NULL; + window_handle_t handle; + handle.type = REF_WINDOW_TYPE_NONE; + handle.handle = NULL; + return handle; } #endif diff --git a/engine/platform/linux/vid_fbdev.c b/engine/platform/linux/vid_fbdev.c index 0906bb1b..6b0c371f 100644 --- a/engine/platform/linux/vid_fbdev.c +++ b/engine/platform/linux/vid_fbdev.c @@ -246,9 +246,12 @@ qboolean SW_CreateBuffer( int width, int height, uint *stride, uint *bpp, uint * return true; } -window_handle_t *R_GetWindowHandle( void ) +window_handle_t R_GetWindowHandle( void ) { - return NULL; + window_handle_t handle; + handle.type = REF_WINDOW_TYPE_NONE; + handle.handle = NULL; + return handle; } #endif diff --git a/engine/platform/platform.h b/engine/platform/platform.h index e6a6e829..3ba8f8e7 100644 --- a/engine/platform/platform.h +++ b/engine/platform/platform.h @@ -314,6 +314,7 @@ typedef enum enum { + REF_WINDOW_TYPE_NONE = 0, // NULL REF_WINDOW_TYPE_WIN32 = 1, // HWND REF_WINDOW_TYPE_X11 = 2, // Display* REF_WINDOW_TYPE_WAYLAND = 3, // wl_display* @@ -344,7 +345,7 @@ void *SW_LockBuffer( void ); void SW_UnlockBuffer( void ); qboolean SW_CreateBuffer( int width, int height, uint *stride, uint *bpp, uint *r, uint *g, uint *b ); void Platform_Minimize_f( void ); -window_handle_t *R_GetWindowHandle( void ); +window_handle_t R_GetWindowHandle( void ); // // in_evdev.c diff --git a/engine/platform/sdl1/vid_sdl1.c b/engine/platform/sdl1/vid_sdl1.c index ddd8158e..40d88b97 100644 --- a/engine/platform/sdl1/vid_sdl1.c +++ b/engine/platform/sdl1/vid_sdl1.c @@ -513,9 +513,12 @@ qboolean VID_SetMode( void ) return true; } -window_handle_t *R_GetWindowHandle( void ) +window_handle_t R_GetWindowHandle( void ) { - return NULL; + window_handle_t handle; + handle.type = REF_WINDOW_TYPE_NONE; + handle.handle = NULL; + return handle; } /* diff --git a/engine/platform/sdl2/vid_sdl2.c b/engine/platform/sdl2/vid_sdl2.c index a962dfe3..9a6a346b 100644 --- a/engine/platform/sdl2/vid_sdl2.c +++ b/engine/platform/sdl2/vid_sdl2.c @@ -1165,30 +1165,33 @@ qboolean VID_SetMode( void ) return true; } -window_handle_t *R_GetWindowHandle( void ) +window_handle_t R_GetWindowHandle( void ) { + window_handle_t handle; + handle.type = REF_WINDOW_TYPE_NONE; + handle.handle = NULL; + SDL_SysWMinfo wmInfo; SDL_VERSION(&wmInfo.version); if (SDL_GetWindowWMInfo(host.hWnd, &wmInfo) != SDL_TRUE) { - return NULL; + return handle; } - window_handle_t *handle = malloc( sizeof( window_handle_t ) ); #if defined(SDL_VIDEO_DRIVER_WINDOWS) - handle->type = REF_WINDOW_TYPE_WIN32; - handle->handle = (void*)wmInfo.info.win.window; // HWND + handle.type = REF_WINDOW_TYPE_WIN32; + handle.handle = (void*)wmInfo.info.win.window; // HWND #elif defined(SDL_VIDEO_DRIVER_COCOA) - handle->type = REF_WINDOW_TYPE_MACOS; - handle->handle = (void*)wmInfo.info.cocoa.window; // NSWindow* + handle.type = REF_WINDOW_TYPE_MACOS; + handle.handle = (void*)wmInfo.info.cocoa.window; // NSWindow* #elif defined(SDL_VIDEO_DRIVER_X11) - handle->type = REF_WINDOW_TYPE_X11; - handle->handle = (void*)(uintptr_t)wmInfo.info.x11.window; // X11 Window + handle.type = REF_WINDOW_TYPE_X11; + handle.handle = (void*)(uintptr_t)wmInfo.info.x11.window; // X11 Window #elif defined(SDL_VIDEO_DRIVER_WAYLAND) - handle->type = REF_WINDOW_TYPE_WAYLAND; - handle->handle = (void*)wmInfo.info.wl.surface; // wl_surface* + handle.type = REF_WINDOW_TYPE_WAYLAND; + handle.handle = (void*)wmInfo.info.wl.surface; // wl_surface* #else - return NULL; + return handle; #endif return handle; diff --git a/engine/ref_api.h b/engine/ref_api.h index 6039fd68..2dd1f58c 100644 --- a/engine/ref_api.h +++ b/engine/ref_api.h @@ -470,7 +470,7 @@ typedef struct ref_api_s fs_api_t *fsapi; // for abstracting the engine's rendering - struct window_handle_t *(*R_GetWindowHandle)( void ); + struct window_handle_t (*R_GetWindowHandle)( void ); } ref_api_t; struct mip_s;