|
|
|
|
@ -56,12 +56,13 @@
|
|
|
|
|
#include "SDL3/SDL.h"
|
|
|
|
|
#elif defined(USING_SDL2_PROJECT)
|
|
|
|
|
#include "SDL2/SDL.h"
|
|
|
|
|
#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
|
|
|
|
|
|
|
|
|
|
// WARNING: On Linux, this header includes Xlib.h, which defines Font
|
|
|
|
|
// To prevent a conflict with raylib's own Font type, we temporarily
|
|
|
|
|
// rename it to FontX11
|
|
|
|
|
#define Font FontX11
|
|
|
|
|
#include "SDL2/SDL_syswm.h" // Required to get window handlers
|
|
|
|
|
#undef Font
|
|
|
|
|
#else
|
|
|
|
|
#include "SDL.h"
|
|
|
|
|
#endif
|
|
|
|
|
@ -469,12 +470,11 @@ bool WindowShouldClose(void)
|
|
|
|
|
void ToggleFullscreen(void)
|
|
|
|
|
{
|
|
|
|
|
const int monitor = SDL_GetWindowDisplayIndex(platform.window);
|
|
|
|
|
const int monitorCount = SDL_GetNumVideoDisplays();
|
|
|
|
|
|
|
|
|
|
#if defined(USING_VERSION_SDL3) // SDL3 Migration: Monitor is an id instead of index now, returns 0 on failure
|
|
|
|
|
if (SDL_GetDisplayProperties(monitor) != 0) // Returns 0 on failure, so a value other than zero indicates that the monitor id is valid
|
|
|
|
|
#else
|
|
|
|
|
if ((monitor >= 0) && (monitor < monitorCount))
|
|
|
|
|
if ((monitor >= 0) && (monitor < SDL_GetNumVideoDisplays()))
|
|
|
|
|
#endif
|
|
|
|
|
{
|
|
|
|
|
if (FLAG_IS_SET(CORE.Window.flags, FLAG_FULLSCREEN_MODE))
|
|
|
|
|
@ -495,12 +495,11 @@ void ToggleFullscreen(void)
|
|
|
|
|
void ToggleBorderlessWindowed(void)
|
|
|
|
|
{
|
|
|
|
|
const int monitor = SDL_GetWindowDisplayIndex(platform.window);
|
|
|
|
|
const int monitorCount = SDL_GetNumVideoDisplays();
|
|
|
|
|
|
|
|
|
|
#if defined(USING_VERSION_SDL3) // SDL3 Migration: Monitor is an id instead of index now, returns 0 on failure
|
|
|
|
|
if (SDL_GetDisplayProperties(monitor) != 0) // Returns 0 on failure, so a value other than zero indicates that the monitor id is valid
|
|
|
|
|
#else
|
|
|
|
|
if ((monitor >= 0) && (monitor < monitorCount))
|
|
|
|
|
if ((monitor >= 0) && (monitor < SDL_GetNumVideoDisplays()))
|
|
|
|
|
#endif
|
|
|
|
|
{
|
|
|
|
|
if (FLAG_IS_SET(CORE.Window.flags, FLAG_BORDERLESS_WINDOWED_MODE))
|
|
|
|
|
@ -552,12 +551,11 @@ void SetWindowState(unsigned int flags)
|
|
|
|
|
if (FLAG_IS_SET(flags, FLAG_FULLSCREEN_MODE))
|
|
|
|
|
{
|
|
|
|
|
const int monitor = SDL_GetWindowDisplayIndex(platform.window);
|
|
|
|
|
const int monitorCount = SDL_GetNumVideoDisplays();
|
|
|
|
|
|
|
|
|
|
#if defined(USING_VERSION_SDL3) // SDL3 Migration: Monitor is an id instead of index now, returns 0 on failure
|
|
|
|
|
if (SDL_GetDisplayProperties(monitor) != 0) // Returns 0 on failure, so a value other than zero indicates that the monitor id is valid
|
|
|
|
|
#else
|
|
|
|
|
if ((monitor >= 0) && (monitor < monitorCount))
|
|
|
|
|
if ((monitor >= 0) && (monitor < SDL_GetNumVideoDisplays()))
|
|
|
|
|
#endif
|
|
|
|
|
{
|
|
|
|
|
SDL_SetWindowFullscreen(platform.window, SDL_WINDOW_FULLSCREEN);
|
|
|
|
|
@ -614,12 +612,11 @@ void SetWindowState(unsigned int flags)
|
|
|
|
|
if (FLAG_IS_SET(flags, FLAG_BORDERLESS_WINDOWED_MODE))
|
|
|
|
|
{
|
|
|
|
|
const int monitor = SDL_GetWindowDisplayIndex(platform.window);
|
|
|
|
|
const int monitorCount = SDL_GetNumVideoDisplays();
|
|
|
|
|
|
|
|
|
|
#if defined(USING_VERSION_SDL3) // SDL3 Migration: Monitor is an id instead of index now, returns 0 on failure
|
|
|
|
|
if (SDL_GetDisplayProperties(monitor) != 0) // Returns 0 on failure, so a value other than zero indicates that the monitor id is valid
|
|
|
|
|
#else
|
|
|
|
|
if ((monitor >= 0) && (monitor < monitorCount))
|
|
|
|
|
if ((monitor >= 0) && (monitor < SDL_GetNumVideoDisplays()))
|
|
|
|
|
#endif
|
|
|
|
|
{
|
|
|
|
|
SDL_SetWindowFullscreen(platform.window, SDL_WINDOW_FULLSCREEN_DESKTOP);
|
|
|
|
|
@ -836,11 +833,10 @@ void SetWindowPosition(int x, int y)
|
|
|
|
|
// Set monitor for the current window
|
|
|
|
|
void SetWindowMonitor(int monitor)
|
|
|
|
|
{
|
|
|
|
|
const int monitorCount = SDL_GetNumVideoDisplays();
|
|
|
|
|
#if defined(USING_VERSION_SDL3) // SDL3 Migration: Monitor is an id instead of index now, returns 0 on failure
|
|
|
|
|
if (SDL_GetDisplayProperties(monitor) != 0) // Returns 0 on failure, so a value other than zero indicates that the monitor id is valid
|
|
|
|
|
#else
|
|
|
|
|
if ((monitor >= 0) && (monitor < monitorCount))
|
|
|
|
|
if ((monitor >= 0) && (monitor < SDL_GetNumVideoDisplays()))
|
|
|
|
|
#endif
|
|
|
|
|
{
|
|
|
|
|
// NOTE 1: SDL started supporting moving exclusive fullscreen windows between displays on SDL3,
|
|
|
|
|
@ -960,17 +956,13 @@ void *GetWindowHandle(void)
|
|
|
|
|
#elif defined(__APPLE__)
|
|
|
|
|
handle = (void *)SDL_GetPointerProperty(props, SDL_PROP_WINDOW_COCOA_WINDOW_POINTER, NULL); // Type: NSWindow*
|
|
|
|
|
#endif
|
|
|
|
|
#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
|
|
|
|
|
#elif defined(USING_SDL2_PROJECT)
|
|
|
|
|
SDL_SysWMinfo wmInfo = { 0 };
|
|
|
|
|
SDL_VERSION(&wmInfo.version);
|
|
|
|
|
if (SDL_GetWindowWMInfo(platform.window, &wmInfo))
|
|
|
|
|
{
|
|
|
|
|
#if defined(_WIN32)
|
|
|
|
|
handle = (void *)wmInfo.info.win.window; // Type: HWND
|
|
|
|
|
/*
|
|
|
|
|
#elif defined(__linux__)
|
|
|
|
|
if (wmInfo.subsystem == SDL_SYSWM_X11)
|
|
|
|
|
{
|
|
|
|
|
@ -984,7 +976,6 @@ void *GetWindowHandle(void)
|
|
|
|
|
// NOTE: Alternative: wmInfo.info.wl.display
|
|
|
|
|
handle = (void *)wmInfo.info.wl.surface; // Type: struct wl_surface*
|
|
|
|
|
}
|
|
|
|
|
*/
|
|
|
|
|
#elif defined(__APPLE__)
|
|
|
|
|
handle = (void *)wmInfo.info.cocoa.window; // Type: NSWindow*
|
|
|
|
|
#endif
|
|
|
|
|
@ -997,32 +988,23 @@ void *GetWindowHandle(void)
|
|
|
|
|
// Get number of monitors
|
|
|
|
|
int GetMonitorCount(void)
|
|
|
|
|
{
|
|
|
|
|
int monitorCount = 0;
|
|
|
|
|
|
|
|
|
|
monitorCount = SDL_GetNumVideoDisplays();
|
|
|
|
|
|
|
|
|
|
return monitorCount;
|
|
|
|
|
return SDL_GetNumVideoDisplays();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Get current monitor where window is placed
|
|
|
|
|
int GetCurrentMonitor(void)
|
|
|
|
|
{
|
|
|
|
|
int currentMonitor = 0;
|
|
|
|
|
|
|
|
|
|
// Be aware that this returns an ID in SDL3 and a Index in SDL2
|
|
|
|
|
currentMonitor = SDL_GetWindowDisplayIndex(platform.window);
|
|
|
|
|
|
|
|
|
|
return currentMonitor;
|
|
|
|
|
return SDL_GetWindowDisplayIndex(platform.window);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Get selected monitor position
|
|
|
|
|
Vector2 GetMonitorPosition(int monitor)
|
|
|
|
|
{
|
|
|
|
|
const int monitorCount = SDL_GetNumVideoDisplays();
|
|
|
|
|
#if defined(USING_VERSION_SDL3) // SDL3 Migration: Monitor is an id instead of index now, returns 0 on failure
|
|
|
|
|
if (SDL_GetDisplayProperties(monitor) != 0) // Returns 0 on failure, so a value other than zero indicates that the monitor id is valid
|
|
|
|
|
#else
|
|
|
|
|
if ((monitor >= 0) && (monitor < monitorCount))
|
|
|
|
|
if ((monitor >= 0) && (monitor < SDL_GetNumVideoDisplays()))
|
|
|
|
|
#endif
|
|
|
|
|
{
|
|
|
|
|
SDL_Rect displayBounds;
|
|
|
|
|
@ -1046,11 +1028,10 @@ int GetMonitorWidth(int monitor)
|
|
|
|
|
{
|
|
|
|
|
int width = 0;
|
|
|
|
|
|
|
|
|
|
const int monitorCount = SDL_GetNumVideoDisplays();
|
|
|
|
|
#if defined(USING_VERSION_SDL3) // SDL3 Migration: Monitor is an id instead of index now, returns 0 on failure
|
|
|
|
|
if (SDL_GetDisplayProperties(monitor) != 0) // Returns 0 on failure, so a value other than zero indicates that the monitor id is valid
|
|
|
|
|
#else
|
|
|
|
|
if ((monitor >= 0) && (monitor < monitorCount))
|
|
|
|
|
if ((monitor >= 0) && (monitor < SDL_GetNumVideoDisplays()))
|
|
|
|
|
#endif
|
|
|
|
|
{
|
|
|
|
|
SDL_DisplayMode mode;
|
|
|
|
|
@ -1067,11 +1048,10 @@ int GetMonitorHeight(int monitor)
|
|
|
|
|
{
|
|
|
|
|
int height = 0;
|
|
|
|
|
|
|
|
|
|
const int monitorCount = SDL_GetNumVideoDisplays();
|
|
|
|
|
#if defined(USING_VERSION_SDL3) // SDL3 Migration: Monitor is an id instead of index now, returns 0 on failure
|
|
|
|
|
if (SDL_GetDisplayProperties(monitor) != 0) // Returns 0 on failure, so a value other than zero indicates that the monitor id is valid
|
|
|
|
|
#else
|
|
|
|
|
if ((monitor >= 0) && (monitor < monitorCount))
|
|
|
|
|
if ((monitor >= 0) && (monitor < SDL_GetNumVideoDisplays()))
|
|
|
|
|
#endif
|
|
|
|
|
{
|
|
|
|
|
SDL_DisplayMode mode;
|
|
|
|
|
@ -1088,11 +1068,10 @@ int GetMonitorPhysicalWidth(int monitor)
|
|
|
|
|
{
|
|
|
|
|
int width = 0;
|
|
|
|
|
|
|
|
|
|
const int monitorCount = SDL_GetNumVideoDisplays();
|
|
|
|
|
#if defined(USING_VERSION_SDL3) // SDL3 Migration: Monitor is an id instead of index now, returns 0 on failure
|
|
|
|
|
if (SDL_GetDisplayProperties(monitor) != 0) // Returns 0 on failure, so a value other than zero indicates that the monitor id is valid
|
|
|
|
|
#else
|
|
|
|
|
if ((monitor >= 0) && (monitor < monitorCount))
|
|
|
|
|
if ((monitor >= 0) && (monitor < SDL_GetNumVideoDisplays()))
|
|
|
|
|
#endif
|
|
|
|
|
{
|
|
|
|
|
float ddpi = 0.0f;
|
|
|
|
|
@ -1112,11 +1091,10 @@ int GetMonitorPhysicalHeight(int monitor)
|
|
|
|
|
{
|
|
|
|
|
int height = 0;
|
|
|
|
|
|
|
|
|
|
const int monitorCount = SDL_GetNumVideoDisplays();
|
|
|
|
|
#if defined(USING_VERSION_SDL3) // SDL3 Migration: Monitor is an id instead of index now, returns 0 on failure
|
|
|
|
|
if (SDL_GetDisplayProperties(monitor) != 0) // Returns 0 on failure, so a value other than zero indicates that the monitor id is valid
|
|
|
|
|
#else
|
|
|
|
|
if ((monitor >= 0) && (monitor < monitorCount))
|
|
|
|
|
if ((monitor >= 0) && (monitor < SDL_GetNumVideoDisplays()))
|
|
|
|
|
#endif
|
|
|
|
|
{
|
|
|
|
|
float ddpi = 0.0f;
|
|
|
|
|
@ -1136,11 +1114,10 @@ int GetMonitorRefreshRate(int monitor)
|
|
|
|
|
{
|
|
|
|
|
int refresh = 0;
|
|
|
|
|
|
|
|
|
|
const int monitorCount = SDL_GetNumVideoDisplays();
|
|
|
|
|
#if defined(USING_VERSION_SDL3) // SDL3 Migration: Monitor is an id instead of index now, returns 0 on failure
|
|
|
|
|
if (SDL_GetDisplayProperties(monitor) != 0) // Returns 0 on failure, so a value other than zero indicates that the monitor id is valid
|
|
|
|
|
#else
|
|
|
|
|
if ((monitor >= 0) && (monitor < monitorCount))
|
|
|
|
|
if ((monitor >= 0) && (monitor < SDL_GetNumVideoDisplays()))
|
|
|
|
|
#endif
|
|
|
|
|
{
|
|
|
|
|
SDL_DisplayMode mode;
|
|
|
|
|
@ -1155,12 +1132,10 @@ int GetMonitorRefreshRate(int monitor)
|
|
|
|
|
// Get the human-readable, UTF-8 encoded name of the selected monitor
|
|
|
|
|
const char *GetMonitorName(int monitor)
|
|
|
|
|
{
|
|
|
|
|
const int monitorCount = SDL_GetNumVideoDisplays();
|
|
|
|
|
|
|
|
|
|
#if defined(USING_VERSION_SDL3) // SDL3 Migration: Monitor is an id instead of index now, returns 0 on failure
|
|
|
|
|
if (SDL_GetDisplayProperties(monitor) != 0) // Returns 0 on failure, so a value other than zero indicates that the monitor id is valid
|
|
|
|
|
#else
|
|
|
|
|
if ((monitor >= 0) && (monitor < monitorCount))
|
|
|
|
|
if ((monitor >= 0) && (monitor < SDL_GetNumVideoDisplays()))
|
|
|
|
|
#endif
|
|
|
|
|
{
|
|
|
|
|
return SDL_GetDisplayName(monitor);
|
|
|
|
|
|