Displays are now referenced by instance ID instead of index

This commit is contained in:
Sam Lantinga 2023-01-29 13:30:55 -08:00
parent 758c0dd6d8
commit 22c69bccdf
157 changed files with 1620 additions and 1589 deletions

View file

@ -1993,12 +1993,12 @@ typedef SDL_GameControllerButtonBind, SDL_GamepadBinding;
@@
@@
- SDL_GetPointDisplayIndex
+ SDL_GetDisplayIndexForPoint
+ SDL_GetDisplayForPoint
(...)
@@
@@
- SDL_GetRectDisplayIndex
+ SDL_GetDisplayIndexForRect
+ SDL_GetDisplayForRect
(...)
@ depends on rule_init_noparachute @
expression e;
@ -2354,3 +2354,8 @@ SDL_DisplayMode e;
- e.h
+ e.screen_h
)
@@
@@
- SDL_GetWindowDisplayIndex
+ SDL_GetDisplayForWindow
(...)

View file

@ -444,7 +444,7 @@ The following functions have been removed:
* SDL_JoystickGetDeviceVendor() - replaced with SDL_GetJoystickInstanceVendor()
* SDL_JoystickNameForIndex() - replaced with SDL_GetJoystickInstanceName()
* SDL_JoystickPathForIndex() - replaced with SDL_GetJoystickInstancePath()
* SDL_NumJoysticks - replaced with SDL_GetJoysticks()
* SDL_NumJoysticks() - replaced with SDL_GetJoysticks()
## SDL_keyboard.h
@ -958,6 +958,28 @@ SDL_GetRevisionNumber() has been removed from the API, it always returned 0 in S
SDL_VideoInit() and SDL_VideoQuit() have been removed. Instead you can call SDL_InitSubSytem() and SDL_QuitSubSytem() with SDL_INIT_VIDEO, which will properly refcount the subsystems. You can choose a specific audio driver using SDL_VIDEO_DRIVER hint.
Rather than iterating over displays using display index, there is a new function SDL_GetDisplays() to get the current list of displays, and functions which used to take a display index now take SDL_DisplayID, with an invalid ID being 0.
```c
{
if (SDL_InitSubSystem(SDL_INIT_VIDEO) == 0) {
int i, num_displays;
SDL_DisplayID *displays = SDL_GetDisplays(&num_displays);
if (displays) {
for (i = 0; i < num_displays; ++i) {
SDL_DisplayID instance_id = displays[i];
const char *name = SDL_GetDisplayName(instance_id);
SDL_Log("Display %" SDL_PRIu32 ": %s\n", instance_id, name ? name : "Unknown");
}
SDL_free(displays);
}
SDL_QuitSubSystem(SDL_INIT_VIDEO);
}
}
```
The SDL_WINDOWPOS_UNDEFINED_DISPLAY() and SDL_WINDOWPOS_CENTERED_DISPLAY() macros take a display ID instead of display index. The display ID 0 has a special meaning in this case, and is used to indicate the primary display.
The SDL_WINDOW_SHOWN flag has been removed. Windows are shown by default and can be created hidden by using the SDL_WINDOW_HIDDEN flag.
The SDL_WINDOW_ALLOW_HIGHDPI flag has been removed. Windows are automatically high DPI aware and their coordinates are in screen space, which may differ from physical pixels on displays using display scaling.
@ -982,8 +1004,12 @@ SDL_GL_GetDrawableSize() has been removed. SDL_GetWindowSizeInPixels() can be us
The following functions have been renamed:
* SDL_GetDisplayDPI() => SDL_GetDisplayPhysicalDPI()
* SDL_GetPointDisplayIndex() => SDL_GetDisplayIndexForPoint()
* SDL_GetRectDisplayIndex() => SDL_GetDisplayIndexForRect()
* SDL_GetPointDisplayIndex() => SDL_GetDisplayForPoint()
* SDL_GetRectDisplayIndex() => SDL_GetDisplayForRect()
* SDL_GetWindowDisplayIndex() => SDL_GetDisplayForWindow()
The following functions have been removed:
* SDL_GetNumVideoDisplays() - replaced with SDL_GetDisplays()
SDL_Window id type is named SDL_WindowID

View file

@ -341,7 +341,7 @@ int main(int argc, char **argv)
if (SDL_Init(SDL_INIT_VIDEO) != 0) {
return 1;
} else if (SDL_GetCurrentDisplayMode(0, &mode) != 0) {
} else if (SDL_GetCurrentDisplayMode(SDL_GetPrimaryDisplay(), &mode) != 0) {
return 1;
} else if (SDL_CreateWindowAndRenderer(mode.w, mode.h, SDL_WINDOW_FULLSCREEN_EXCLUSIVE, &window, &renderer) != 0) {
return 1;

View file

@ -215,7 +215,7 @@ typedef struct SDL_DisplayEvent
{
Uint32 type; /**< ::SDL_DISPLAYEVENT_* */
Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */
Uint32 display; /**< The associated display index */
SDL_DisplayID displayID;/**< The associated display */
Sint32 data1; /**< event dependent data */
} SDL_DisplayEvent;

View file

@ -413,8 +413,9 @@
/* ##SDL_video.h */
#define SDL_GetDisplayDPI SDL_GetDisplayPhysicalDPI
#define SDL_GetPointDisplayIndex SDL_GetDisplayIndexForPoint
#define SDL_GetRectDisplayIndex SDL_GetDisplayIndexForRect
#define SDL_GetPointDisplayIndex SDL_GetDisplayForPoint
#define SDL_GetRectDisplayIndex SDL_GetDisplayForRect
#define SDL_GetWindowDisplayIndex SDL_GetDisplayForWindow
#define SDL_WINDOW_FULLSCREEN SDL_WINDOW_FULLSCREEN_EXCLUSIVE
#define SDL_WINDOW_INPUT_GRABBED SDL_WINDOW_MOUSE_GRABBED
@ -795,8 +796,9 @@
/* ##SDL_video.h */
#define SDL_GetDisplayDPI SDL_GetDisplayDPI_renamed_SDL_GetDisplayPhysicalDPI
#define SDL_GetPointDisplayIndex SDL_GetPointDisplayIndex_renamed_SDL_GetDisplayIndexForPoint
#define SDL_GetRectDisplayIndex SDL_GetRectDisplayIndex_renamed_SDL_GetDisplayIndexForRect
#define SDL_GetPointDisplayIndex SDL_GetPointDisplayIndex_renamed_SDL_GetDisplayForPoint
#define SDL_GetRectDisplayIndex SDL_GetRectDisplayIndex_renamed_SDL_GetDisplayForRect
#define SDL_GetWindowDisplayIndex SDL_GetWindowDisplayIndex_renamed_SDL_GetDisplayForWindow
#define SDL_WINDOW_FULLSCREEN SDL_WINDOW_FULLSCREEN_renamed_SDL_WINDOW_FULLSCREEN_EXCLUSIVE
#define SDL_WINDOW_INPUT_GRABBED SDL_WINDOW_INPUT_GRABBED_renamed_SDL_WINDOW_MOUSE_GRABBED

View file

@ -60,19 +60,18 @@ extern DECLSPEC void SDLCALL SDL_SetWindowsMessageHook(SDL_WindowsMessageHook ca
#if defined(__WIN32__) || defined(__WINGDK__)
/**
* Get the D3D9 adapter index that matches the specified display index.
* Get the D3D9 adapter index that matches the specified display.
*
* The returned adapter index can be passed to `IDirect3D9::CreateDevice` and
* controls on which monitor a full screen application will appear.
*
* \param displayIndex the display index for which to get the D3D9 adapter
* index
* \param displayID the instance of the display to query
* \returns the D3D9 adapter index on success or a negative error code on
* failure; call SDL_GetError() for more information.
*
* \since This function is available since SDL 3.0.0.
*/
extern DECLSPEC int SDLCALL SDL_Direct3D9GetAdapterIndex( int displayIndex );
extern DECLSPEC int SDLCALL SDL_Direct3D9GetAdapterIndex(SDL_DisplayID displayID);
typedef struct IDirect3DDevice9 IDirect3DDevice9;
@ -131,16 +130,13 @@ extern DECLSPEC ID3D12Device* SDLCALL SDL_RenderGetD3D12Device(SDL_Renderer* ren
#if defined(__WIN32__) || defined(__WINGDK__)
/**
* Get the DXGI Adapter and Output indices for the specified display index.
* Get the DXGI Adapter and Output indices for the specified display.
*
* The DXGI Adapter and Output indices can be passed to `EnumAdapters` and
* `EnumOutputs` respectively to get the objects required to create a DX10 or
* DX11 device and swap chain.
*
* Before SDL 2.0.4 this function did not return a value. Since SDL 2.0.4 it
* returns an SDL_bool.
*
* \param displayIndex the display index for which to get both indices
* \param displayID the instance of the display to query
* \param adapterIndex a pointer to be filled in with the adapter index
* \param outputIndex a pointer to be filled in with the output index
* \returns SDL_TRUE on success or SDL_FALSE on failure; call SDL_GetError()
@ -148,7 +144,7 @@ extern DECLSPEC ID3D12Device* SDLCALL SDL_RenderGetD3D12Device(SDL_Renderer* ren
*
* \since This function is available since SDL 3.0.0.
*/
extern DECLSPEC SDL_bool SDLCALL SDL_DXGIGetOutputInfo( int displayIndex, int *adapterIndex, int *outputIndex );
extern DECLSPEC SDL_bool SDLCALL SDL_DXGIGetOutputInfo(SDL_DisplayID displayID, int *adapterIndex, int *outputIndex);
#endif /* defined(__WIN32__) || defined(__WINGDK__) */

View file

@ -40,6 +40,7 @@ extern "C" {
#endif
typedef Uint32 SDL_DisplayID;
typedef Uint32 SDL_WindowID;
/**
@ -300,53 +301,61 @@ extern DECLSPEC const char *SDLCALL SDL_GetVideoDriver(int index);
extern DECLSPEC const char *SDLCALL SDL_GetCurrentVideoDriver(void);
/**
* Get the number of available video displays.
* Get a list of currently connected displays.
*
* \returns a number >= 1 or a negative error code on failure; call
* SDL_GetError() for more information.
* \param count a pointer filled in with the number of displays returned
* \returns a 0 terminated array of display instance IDs which should be
* freed with SDL_free(), or NULL on error; call SDL_GetError() for
* more details.
*
* \since This function is available since SDL 3.0.0.
*/
extern DECLSPEC SDL_DisplayID *SDLCALL SDL_GetDisplays(int *count);
/**
* Return the primary display.
*
* \returns the instance ID of the primary display on success or 0 on failure; call SDL_GetError() for more information.
*
* \since This function is available since SDL 3.0.0.
*
* \sa SDL_GetDisplayBounds
* \sa SDL_GetDisplays
*/
extern DECLSPEC int SDLCALL SDL_GetNumVideoDisplays(void);
extern DECLSPEC SDL_DisplayID SDLCALL SDL_GetPrimaryDisplay(void);
/**
* Get the name of a display in UTF-8 encoding.
*
* \param displayIndex the index of display from which the name should be
* queried
* \returns the name of a display or NULL for an invalid display index or
* failure; call SDL_GetError() for more information.
* \param displayID the instance ID of the display to query
* \returns the name of a display or NULL on failure; call SDL_GetError() for more information.
*
* \since This function is available since SDL 3.0.0.
*
* \sa SDL_GetNumVideoDisplays
* \sa SDL_GetDisplays
*/
extern DECLSPEC const char *SDLCALL SDL_GetDisplayName(int displayIndex);
extern DECLSPEC const char *SDLCALL SDL_GetDisplayName(SDL_DisplayID displayID);
/**
* Get the desktop area represented by a display, in screen coordinates.
*
* The primary display (`displayIndex` zero) is always located at 0,0.
* The primary display is always located at (0,0).
*
* \param displayIndex the index of the display to query
* \param displayID the instance ID of the display to query
* \param rect the SDL_Rect structure filled in with the display bounds
* \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information.
*
* \since This function is available since SDL 3.0.0.
*
* \sa SDL_GetNumVideoDisplays
* \sa SDL_GetDisplayUsableBounds
* \sa SDL_GetDisplays
*/
extern DECLSPEC int SDLCALL SDL_GetDisplayBounds(int displayIndex, SDL_Rect *rect);
extern DECLSPEC int SDLCALL SDL_GetDisplayBounds(SDL_DisplayID displayID, SDL_Rect *rect);
/**
* Get the usable desktop area represented by a display, in screen
* coordinates.
*
* The primary display (`displayIndex` zero) is always located at 0,0.
*
* This is the same area as SDL_GetDisplayBounds() reports, but with portions
* reserved by the system removed. For example, on Apple's macOS, this
* subtracts the area occupied by the menu bar and dock.
@ -355,13 +364,7 @@ extern DECLSPEC int SDLCALL SDL_GetDisplayBounds(int displayIndex, SDL_Rect *rec
* so these are good guidelines for the maximum space available to a
* non-fullscreen window.
*
* The parameter `rect` is ignored if it is NULL.
*
* This function also returns -1 if the parameter `displayIndex` is out of
* range.
*
* \param displayIndex the index of the display to query the usable bounds
* from
* \param displayID the instance ID of the display to query
* \param rect the SDL_Rect structure filled in with the display bounds
* \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information.
@ -369,9 +372,9 @@ extern DECLSPEC int SDLCALL SDL_GetDisplayBounds(int displayIndex, SDL_Rect *rec
* \since This function is available since SDL 3.0.0.
*
* \sa SDL_GetDisplayBounds
* \sa SDL_GetNumVideoDisplays
* \sa SDL_GetDisplays
*/
extern DECLSPEC int SDLCALL SDL_GetDisplayUsableBounds(int displayIndex, SDL_Rect *rect);
extern DECLSPEC int SDLCALL SDL_GetDisplayUsableBounds(SDL_DisplayID displayID, SDL_Rect *rect);
/**
* Get the dots/pixels-per-inch for a display.
@ -379,9 +382,6 @@ extern DECLSPEC int SDLCALL SDL_GetDisplayUsableBounds(int displayIndex, SDL_Rec
* Diagonal, horizontal and vertical DPI can all be optionally returned if the
* appropriate parameter is non-NULL.
*
* A failure of this function usually means that either no DPI information is
* available or the `displayIndex` is out of range.
*
* **WARNING**: This reports the DPI that the hardware reports, and it is not
* always reliable! It is almost always better to use SDL_GetWindowSize() to
* find the window size, which might be in logical points instead of pixels,
@ -390,8 +390,7 @@ extern DECLSPEC int SDLCALL SDL_GetDisplayUsableBounds(int displayIndex, SDL_Rec
* will be rethinking how high-dpi details should be managed in SDL3 to make
* things more consistent, reliable, and clear.
*
* \param displayIndex the index of the display from which DPI information
* should be queried
* \param displayID the instance ID of the display to query
* \param ddpi a pointer filled in with the diagonal DPI of the display; may
* be NULL
* \param hdpi a pointer filled in with the horizontal DPI of the display; may
@ -403,53 +402,51 @@ extern DECLSPEC int SDLCALL SDL_GetDisplayUsableBounds(int displayIndex, SDL_Rec
*
* \since This function is available since SDL 3.0.0.
*
* \sa SDL_GetNumVideoDisplays
* \sa SDL_GetDisplays
*/
extern DECLSPEC int SDLCALL SDL_GetDisplayPhysicalDPI(int displayIndex, float *ddpi, float *hdpi, float *vdpi);
extern DECLSPEC int SDLCALL SDL_GetDisplayPhysicalDPI(SDL_DisplayID displayID, float *ddpi, float *hdpi, float *vdpi);
/**
* Get the orientation of a display.
*
* \param displayIndex the index of the display to query
* \param displayID the instance ID of the display to query
* \returns The SDL_DisplayOrientation enum value of the display, or
* `SDL_ORIENTATION_UNKNOWN` if it isn't available.
*
* \since This function is available since SDL 3.0.0.
*
* \sa SDL_GetNumVideoDisplays
* \sa SDL_GetDisplays
*/
extern DECLSPEC SDL_DisplayOrientation SDLCALL SDL_GetDisplayOrientation(int displayIndex);
extern DECLSPEC SDL_DisplayOrientation SDLCALL SDL_GetDisplayOrientation(SDL_DisplayID displayID);
/**
* Get the number of available display modes.
*
* The `displayIndex` needs to be in the range from 0 to
* SDL_GetNumVideoDisplays() - 1.
*
* \param displayIndex the index of the display to query
* \param displayID the instance ID of the display to query
* \returns a number >= 1 on success or a negative error code on failure; call
* SDL_GetError() for more information.
*
* \since This function is available since SDL 3.0.0.
*
* \sa SDL_GetDisplayMode
* \sa SDL_GetNumVideoDisplays
* \sa SDL_GetDisplays
*/
extern DECLSPEC int SDLCALL SDL_GetNumDisplayModes(int displayIndex);
extern DECLSPEC int SDLCALL SDL_GetNumDisplayModes(SDL_DisplayID displayID);
/**
* Get information about a specific display mode.
*
* The display modes are sorted in this priority:
*
* - width -> largest to smallest
* - height -> largest to smallest
* - display_scale -> smallest to largest
* - screen_w -> largest to smallest
* - screen_h -> largest to smallest
* - pixel_w -> largest to smallest
* - pixel_h -> largest to smallest
* - bits per pixel -> more colors to fewer colors
* - packed pixel layout -> largest to smallest
* - refresh rate -> highest to lowest
*
* \param displayIndex the index of the display to query
* \param displayID the instance ID of the display to query
* \param modeIndex the index of the display mode to query
* \param mode an SDL_DisplayMode structure filled in with the mode at
* `modeIndex`
@ -460,7 +457,7 @@ extern DECLSPEC int SDLCALL SDL_GetNumDisplayModes(int displayIndex);
*
* \sa SDL_GetNumDisplayModes
*/
extern DECLSPEC int SDLCALL SDL_GetDisplayMode(int displayIndex, int modeIndex, SDL_DisplayMode *mode);
extern DECLSPEC int SDLCALL SDL_GetDisplayMode(SDL_DisplayID displayID, int modeIndex, SDL_DisplayMode *mode);
/**
* Get information about the desktop's display mode.
@ -470,7 +467,7 @@ extern DECLSPEC int SDLCALL SDL_GetDisplayMode(int displayIndex, int modeIndex,
* function will return the previous native display mode, and not the current
* display mode.
*
* \param displayIndex the index of the display to query
* \param displayID the instance ID of the display to query
* \param mode an SDL_DisplayMode structure filled in with the current display
* mode
* \returns 0 on success or a negative error code on failure; call
@ -482,7 +479,7 @@ extern DECLSPEC int SDLCALL SDL_GetDisplayMode(int displayIndex, int modeIndex,
* \sa SDL_GetDisplayMode
* \sa SDL_SetWindowDisplayMode
*/
extern DECLSPEC int SDLCALL SDL_GetDesktopDisplayMode(int displayIndex, SDL_DisplayMode *mode);
extern DECLSPEC int SDLCALL SDL_GetDesktopDisplayMode(SDL_DisplayID displayID, SDL_DisplayMode *mode);
/**
* Get information about the current display mode.
@ -492,7 +489,7 @@ extern DECLSPEC int SDLCALL SDL_GetDesktopDisplayMode(int displayIndex, SDL_Disp
* function will return the current display mode, and not the previous native
* display mode.
*
* \param displayIndex the index of the display to query
* \param displayID the instance ID of the display to query
* \param mode an SDL_DisplayMode structure filled in with the current display
* mode
* \returns 0 on success or a negative error code on failure; call
@ -502,11 +499,10 @@ extern DECLSPEC int SDLCALL SDL_GetDesktopDisplayMode(int displayIndex, SDL_Disp
*
* \sa SDL_GetDesktopDisplayMode
* \sa SDL_GetDisplayMode
* \sa SDL_GetNumVideoDisplays
* \sa SDL_GetDisplays
* \sa SDL_SetWindowDisplayMode
*/
extern DECLSPEC int SDLCALL SDL_GetCurrentDisplayMode(int displayIndex, SDL_DisplayMode *mode);
extern DECLSPEC int SDLCALL SDL_GetCurrentDisplayMode(SDL_DisplayID displayID, SDL_DisplayMode *mode);
/**
* Get the closest match to the requested display mode.
@ -518,9 +514,9 @@ extern DECLSPEC int SDLCALL SDL_GetCurrentDisplayMode(int displayIndex, SDL_Disp
* and finally checking the refresh rate. If all the available modes are too
* small, then NULL is returned.
*
* \param displayIndex the index of the display to query
* \param displayID the instance ID of the display to query
* \param mode an SDL_DisplayMode structure containing the desired display
* mode
* mode, should be zero initialized
* \param closest an SDL_DisplayMode structure filled in with the closest
* match of the available display modes
* \returns the passed in value `closest` or NULL if no matching video mode
@ -531,51 +527,48 @@ extern DECLSPEC int SDLCALL SDL_GetCurrentDisplayMode(int displayIndex, SDL_Disp
* \sa SDL_GetDisplayMode
* \sa SDL_GetNumDisplayModes
*/
extern DECLSPEC SDL_DisplayMode *SDLCALL SDL_GetClosestDisplayMode(int displayIndex, const SDL_DisplayMode *mode, SDL_DisplayMode *closest);
extern DECLSPEC SDL_DisplayMode *SDLCALL SDL_GetClosestDisplayMode(SDL_DisplayID displayID, const SDL_DisplayMode *mode, SDL_DisplayMode *closest);
/**
* Get the index of the display containing a point
* Get the display containing a point
*
* \param point the point to query
* \returns the index of the display containing the point or a negative error
* code on failure; call SDL_GetError() for more information.
* \returns the instance ID of the display containing the point or 0 on failure; call SDL_GetError() for more information.
*
* \since This function is available since SDL 3.0.0.
*
* \sa SDL_GetDisplayBounds
* \sa SDL_GetNumVideoDisplays
* \sa SDL_GetDisplays
*/
extern DECLSPEC int SDLCALL SDL_GetDisplayIndexForPoint(const SDL_Point *point);
extern DECLSPEC SDL_DisplayID SDLCALL SDL_GetDisplayForPoint(const SDL_Point *point);
/**
* Get the index of the display primarily containing a rect
* Get the display primarily containing a rect
*
* \param rect the rect to query
* \returns the index of the display entirely containing the rect or closest
* to the center of the rect on success or a negative error code on
* failure; call SDL_GetError() for more information.
* \returns the instance ID of the display entirely containing the rect or closest
* to the center of the rect on success or 0 on failure; call SDL_GetError() for more information.
*
* \since This function is available since SDL 3.0.0.
*
* \sa SDL_GetDisplayBounds
* \sa SDL_GetNumVideoDisplays
* \sa SDL_GetDisplays
*/
extern DECLSPEC int SDLCALL SDL_GetDisplayIndexForRect(const SDL_Rect *rect);
extern DECLSPEC SDL_DisplayID SDLCALL SDL_GetDisplayForRect(const SDL_Rect *rect);
/**
* Get the index of the display associated with a window.
* Get the display associated with a window.
*
* \param window the window to query
* \returns the index of the display containing the center of the window on
* success or a negative error code on failure; call SDL_GetError()
* for more information.
* \returns the instance ID of the display containing the center of the window on
* success or 0 on failure; call SDL_GetError() for more information.
*
* \since This function is available since SDL 3.0.0.
*
* \sa SDL_GetDisplayBounds
* \sa SDL_GetNumVideoDisplays
* \sa SDL_GetDisplays
*/
extern DECLSPEC int SDLCALL SDL_GetWindowDisplayIndex(SDL_Window *window);
extern DECLSPEC SDL_DisplayID SDLCALL SDL_GetDisplayForWindow(SDL_Window *window);
/**
* Set the display mode to use when a window is visible at fullscreen.

View file

@ -901,7 +901,7 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeOrientationChanged)(
displayOrientation = (SDL_DisplayOrientation)orientation;
if (Android_Window) {
SDL_VideoDisplay *display = SDL_GetDisplay(0);
SDL_VideoDisplay *display = SDL_GetVideoDisplay(SDL_GetPrimaryDisplay());
SDL_SendDisplayEvent(display, SDL_EVENT_DISPLAY_ORIENTATION, orientation);
}
@ -1034,7 +1034,7 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeSurfaceCreated)(JNIEnv *env, j
SDL_LockMutex(Android_ActivityMutex);
if (Android_Window) {
SDL_WindowData *data = (SDL_WindowData *)Android_Window->driverdata;
SDL_WindowData *data = Android_Window->driverdata;
data->native_window = Android_JNI_GetNativeWindow();
if (data->native_window == NULL) {
@ -1053,7 +1053,7 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeSurfaceChanged)(JNIEnv *env, j
#if SDL_VIDEO_OPENGL_EGL
if (Android_Window) {
SDL_VideoDevice *_this = SDL_GetVideoDevice();
SDL_WindowData *data = (SDL_WindowData *)Android_Window->driverdata;
SDL_WindowData *data = Android_Window->driverdata;
/* If the surface has been previously destroyed by onNativeSurfaceDestroyed, recreate it here */
if (data->egl_surface == EGL_NO_SURFACE) {
@ -1078,7 +1078,7 @@ retry:
if (Android_Window) {
SDL_VideoDevice *_this = SDL_GetVideoDevice();
SDL_WindowData *data = (SDL_WindowData *)Android_Window->driverdata;
SDL_WindowData *data = Android_Window->driverdata;
/* Wait for Main thread being paused and context un-activated to release 'egl_surface' */
if (!data->backup_done) {

View file

@ -432,16 +432,15 @@ void SDL_SetWindowsMessageHook(SDL_WindowsMessageHook callback, void *userdata)
#endif /* __WIN32__ || __GDK__ */
#if defined(__WIN32__) || defined(__WINGDK__)
int SDL_Direct3D9GetAdapterIndex(int displayIndex)
int SDL_Direct3D9GetAdapterIndex(SDL_DisplayID displayID)
{
(void)displayIndex;
(void)displayID;
return 0; /* D3DADAPTER_DEFAULT */
}
SDL_bool
SDL_DXGIGetOutputInfo(int displayIndex, int *adapterIndex, int *outputIndex)
SDL_bool SDL_DXGIGetOutputInfo(SDL_DisplayID displayID, int *adapterIndex, int *outputIndex)
{
(void)displayIndex;
(void)displayID;
if (adapterIndex) {
*adapterIndex = -1;
}

View file

@ -114,7 +114,7 @@ static void WINRT_ProcessWindowSizeChange() // TODO: Pass an SDL_Window-identify
if (coreWindow) {
if (WINRT_GlobalSDLWindow) {
SDL_Window *window = WINRT_GlobalSDLWindow;
SDL_WindowData *data = (SDL_WindowData *)window->driverdata;
SDL_WindowData *data = window->driverdata;
int x = (int)SDL_lroundf(data->coreWindow->Bounds.Left);
int y = (int)SDL_lroundf(data->coreWindow->Bounds.Top);
@ -234,7 +234,7 @@ void SDL_WinRTApp::OnOrientationChanged(Object ^ sender)
// TODO, WinRT: do more extensive research into why orientation changes on Win 8.x don't need D3D changes, or if they might, in some cases
SDL_Window *window = WINRT_GlobalSDLWindow;
if (window) {
SDL_WindowData *data = (SDL_WindowData *)window->driverdata;
SDL_WindowData *data = window->driverdata;
int w = (int)SDL_floorf(data->coreWindow->Bounds.Width);
int h = (int)SDL_floorf(data->coreWindow->Bounds.Height);
SDL_SendWindowEvent(WINRT_GlobalSDLWindow, SDL_EVENT_WINDOW_RESIZED, w, h);

View file

@ -164,8 +164,8 @@ SDL3_0.0.0 {
SDL_GetDesktopDisplayMode;
SDL_GetDisplayBounds;
SDL_GetDisplayPhysicalDPI;
SDL_GetDisplayIndexForPoint;
SDL_GetDisplayIndexForRect;
SDL_GetDisplayForPoint;
SDL_GetDisplayForRect;
SDL_GetDisplayMode;
SDL_GetDisplayName;
SDL_GetDisplayOrientation;
@ -268,7 +268,6 @@ SDL3_0.0.0 {
SDL_GetNumRenderDrivers;
SDL_GetNumTouchDevices;
SDL_GetNumTouchFingers;
SDL_GetNumVideoDisplays;
SDL_GetNumVideoDrivers;
SDL_GetOriginalMemoryFunctions;
SDL_GetPerformanceCounter;
@ -348,7 +347,7 @@ SDL3_0.0.0 {
SDL_GetVideoDriver;
SDL_GetWindowBordersSize;
SDL_GetWindowData;
SDL_GetWindowDisplayIndex;
SDL_GetDisplayForWindow;
SDL_GetWindowDisplayMode;
SDL_GetWindowFlags;
SDL_GetWindowFromID;
@ -839,6 +838,8 @@ SDL3_0.0.0 {
SDL_aligned_alloc;
SDL_aligned_free;
SDL_ConvertAudioSamples;
SDL_GetDisplays;
SDL_GetPrimaryDisplay;
# extra symbols go here (don't modify this line)
local: *;
};

View file

@ -189,8 +189,8 @@
#define SDL_GetDesktopDisplayMode SDL_GetDesktopDisplayMode_REAL
#define SDL_GetDisplayBounds SDL_GetDisplayBounds_REAL
#define SDL_GetDisplayPhysicalDPI SDL_GetDisplayPhysicalDPI_REAL
#define SDL_GetDisplayIndexForPoint SDL_GetDisplayIndexForPoint_REAL
#define SDL_GetDisplayIndexForRect SDL_GetDisplayIndexForRect_REAL
#define SDL_GetDisplayForPoint SDL_GetDisplayForPoint_REAL
#define SDL_GetDisplayForRect SDL_GetDisplayForRect_REAL
#define SDL_GetDisplayMode SDL_GetDisplayMode_REAL
#define SDL_GetDisplayName SDL_GetDisplayName_REAL
#define SDL_GetDisplayOrientation SDL_GetDisplayOrientation_REAL
@ -293,7 +293,6 @@
#define SDL_GetNumRenderDrivers SDL_GetNumRenderDrivers_REAL
#define SDL_GetNumTouchDevices SDL_GetNumTouchDevices_REAL
#define SDL_GetNumTouchFingers SDL_GetNumTouchFingers_REAL
#define SDL_GetNumVideoDisplays SDL_GetNumVideoDisplays_REAL
#define SDL_GetNumVideoDrivers SDL_GetNumVideoDrivers_REAL
#define SDL_GetOriginalMemoryFunctions SDL_GetOriginalMemoryFunctions_REAL
#define SDL_GetPerformanceCounter SDL_GetPerformanceCounter_REAL
@ -373,7 +372,7 @@
#define SDL_GetVideoDriver SDL_GetVideoDriver_REAL
#define SDL_GetWindowBordersSize SDL_GetWindowBordersSize_REAL
#define SDL_GetWindowData SDL_GetWindowData_REAL
#define SDL_GetWindowDisplayIndex SDL_GetWindowDisplayIndex_REAL
#define SDL_GetDisplayForWindow SDL_GetDisplayForWindow_REAL
#define SDL_GetWindowDisplayMode SDL_GetWindowDisplayMode_REAL
#define SDL_GetWindowFlags SDL_GetWindowFlags_REAL
#define SDL_GetWindowFromID SDL_GetWindowFromID_REAL
@ -866,3 +865,5 @@
#define SDL_aligned_alloc SDL_aligned_alloc_REAL
#define SDL_aligned_free SDL_aligned_free_REAL
#define SDL_ConvertAudioSamples SDL_ConvertAudioSamples_REAL
#define SDL_GetDisplays SDL_GetDisplays_REAL
#define SDL_GetPrimaryDisplay SDL_GetPrimaryDisplay_REAL

View file

@ -72,8 +72,8 @@ SDL_DYNAPI_PROC(void,SDL_UnregisterApp,(void),(),)
#endif
#if defined(__WIN32__) || defined(__WINGDK__)
SDL_DYNAPI_PROC(SDL_bool,SDL_DXGIGetOutputInfo,(int a, int *b, int *c),(a,b,c),return)
SDL_DYNAPI_PROC(int,SDL_Direct3D9GetAdapterIndex,(int a),(a),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_DXGIGetOutputInfo,(SDL_DisplayID a, int *b, int *c),(a,b,c),return)
SDL_DYNAPI_PROC(int,SDL_Direct3D9GetAdapterIndex,(SDL_DisplayID a),(a),return)
SDL_DYNAPI_PROC(ID3D11Device*,SDL_GetRenderD3D11Device,(SDL_Renderer *a),(a),return)
SDL_DYNAPI_PROC(IDirect3DDevice9*,SDL_GetRenderD3D9Device,(SDL_Renderer *a),(a),return)
#endif
@ -252,23 +252,23 @@ SDL_DYNAPI_PROC(char*,SDL_GetBasePath,(void),(),return)
SDL_DYNAPI_PROC(int,SDL_GetCPUCacheLineSize,(void),(),return)
SDL_DYNAPI_PROC(int,SDL_GetCPUCount,(void),(),return)
SDL_DYNAPI_PROC(char*,SDL_GetClipboardText,(void),(),return)
SDL_DYNAPI_PROC(SDL_DisplayMode*,SDL_GetClosestDisplayMode,(int a, const SDL_DisplayMode *b, SDL_DisplayMode *c),(a,b,c),return)
SDL_DYNAPI_PROC(SDL_DisplayMode*,SDL_GetClosestDisplayMode,(SDL_DisplayID a, const SDL_DisplayMode *b, SDL_DisplayMode *c),(a,b,c),return)
SDL_DYNAPI_PROC(const char*,SDL_GetCurrentAudioDriver,(void),(),return)
SDL_DYNAPI_PROC(int,SDL_GetCurrentDisplayMode,(int a, SDL_DisplayMode *b),(a,b),return)
SDL_DYNAPI_PROC(int,SDL_GetCurrentDisplayMode,(SDL_DisplayID a, SDL_DisplayMode *b),(a,b),return)
SDL_DYNAPI_PROC(const char*,SDL_GetCurrentVideoDriver,(void),(),return)
SDL_DYNAPI_PROC(SDL_Cursor*,SDL_GetCursor,(void),(),return)
SDL_DYNAPI_PROC(SDL_AssertionHandler,SDL_GetDefaultAssertionHandler,(void),(),return)
SDL_DYNAPI_PROC(int,SDL_GetDefaultAudioInfo,(char **a, SDL_AudioSpec *b, int c),(a,b,c),return)
SDL_DYNAPI_PROC(SDL_Cursor*,SDL_GetDefaultCursor,(void),(),return)
SDL_DYNAPI_PROC(int,SDL_GetDesktopDisplayMode,(int a, SDL_DisplayMode *b),(a,b),return)
SDL_DYNAPI_PROC(int,SDL_GetDisplayBounds,(int a, SDL_Rect *b),(a,b),return)
SDL_DYNAPI_PROC(int,SDL_GetDisplayPhysicalDPI,(int a, float *b, float *c, float *d),(a,b,c,d),return)
SDL_DYNAPI_PROC(int,SDL_GetDisplayIndexForPoint,(const SDL_Point *a),(a),return)
SDL_DYNAPI_PROC(int,SDL_GetDisplayIndexForRect,(const SDL_Rect *a),(a),return)
SDL_DYNAPI_PROC(int,SDL_GetDisplayMode,(int a, int b, SDL_DisplayMode *c),(a,b,c),return)
SDL_DYNAPI_PROC(const char*,SDL_GetDisplayName,(int a),(a),return)
SDL_DYNAPI_PROC(SDL_DisplayOrientation,SDL_GetDisplayOrientation,(int a),(a),return)
SDL_DYNAPI_PROC(int,SDL_GetDisplayUsableBounds,(int a, SDL_Rect *b),(a,b),return)
SDL_DYNAPI_PROC(int,SDL_GetDesktopDisplayMode,(SDL_DisplayID a, SDL_DisplayMode *b),(a,b),return)
SDL_DYNAPI_PROC(int,SDL_GetDisplayBounds,(SDL_DisplayID a, SDL_Rect *b),(a,b),return)
SDL_DYNAPI_PROC(int,SDL_GetDisplayPhysicalDPI,(SDL_DisplayID a, float *b, float *c, float *d),(a,b,c,d),return)
SDL_DYNAPI_PROC(SDL_DisplayID,SDL_GetDisplayForPoint,(const SDL_Point *a),(a),return)
SDL_DYNAPI_PROC(SDL_DisplayID,SDL_GetDisplayForRect,(const SDL_Rect *a),(a),return)
SDL_DYNAPI_PROC(int,SDL_GetDisplayMode,(SDL_DisplayID a, int b, SDL_DisplayMode *c),(a,b,c),return)
SDL_DYNAPI_PROC(const char*,SDL_GetDisplayName,(SDL_DisplayID a),(a),return)
SDL_DYNAPI_PROC(SDL_DisplayOrientation,SDL_GetDisplayOrientation,(SDL_DisplayID a),(a),return)
SDL_DYNAPI_PROC(int,SDL_GetDisplayUsableBounds,(SDL_DisplayID a, SDL_Rect *b),(a,b),return)
SDL_DYNAPI_PROC(const char*,SDL_GetError,(void),(),return)
SDL_DYNAPI_PROC(char*,SDL_GetErrorMsg,(char *a, int b),(a,b),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_GetEventFilter,(SDL_EventFilter *a, void **b),(a,b),return)
@ -359,7 +359,7 @@ SDL_DYNAPI_PROC(Uint32,SDL_GetMouseState,(float *a, float *b),(a,b),return)
SDL_DYNAPI_PROC(int,SDL_GetNumAllocations,(void),(),return)
SDL_DYNAPI_PROC(int,SDL_GetNumAudioDevices,(int a),(a),return)
SDL_DYNAPI_PROC(int,SDL_GetNumAudioDrivers,(void),(),return)
SDL_DYNAPI_PROC(int,SDL_GetNumDisplayModes,(int a),(a),return)
SDL_DYNAPI_PROC(int,SDL_GetNumDisplayModes,(SDL_DisplayID a),(a),return)
SDL_DYNAPI_PROC(int,SDL_GetNumGamepadMappings,(void),(),return)
SDL_DYNAPI_PROC(int,SDL_GetNumJoystickAxes,(SDL_Joystick *a),(a),return)
SDL_DYNAPI_PROC(int,SDL_GetNumJoystickButtons,(SDL_Joystick *a),(a),return)
@ -367,7 +367,6 @@ SDL_DYNAPI_PROC(int,SDL_GetNumJoystickHats,(SDL_Joystick *a),(a),return)
SDL_DYNAPI_PROC(int,SDL_GetNumRenderDrivers,(void),(),return)
SDL_DYNAPI_PROC(int,SDL_GetNumTouchDevices,(void),(),return)
SDL_DYNAPI_PROC(int,SDL_GetNumTouchFingers,(SDL_TouchID a),(a),return)
SDL_DYNAPI_PROC(int,SDL_GetNumVideoDisplays,(void),(),return)
SDL_DYNAPI_PROC(int,SDL_GetNumVideoDrivers,(void),(),return)
SDL_DYNAPI_PROC(void,SDL_GetOriginalMemoryFunctions,(SDL_malloc_func *a, SDL_calloc_func *b, SDL_realloc_func *c, SDL_free_func *d),(a,b,c,d),)
SDL_DYNAPI_PROC(Uint64,SDL_GetPerformanceCounter,(void),(),return)
@ -445,7 +444,7 @@ SDL_DYNAPI_PROC(void,SDL_GetVersion,(SDL_version *a),(a),)
SDL_DYNAPI_PROC(const char*,SDL_GetVideoDriver,(int a),(a),return)
SDL_DYNAPI_PROC(int,SDL_GetWindowBordersSize,(SDL_Window *a, int *b, int *c, int *d, int *e),(a,b,c,d,e),return)
SDL_DYNAPI_PROC(void*,SDL_GetWindowData,(SDL_Window *a, const char *b),(a,b),return)
SDL_DYNAPI_PROC(int,SDL_GetWindowDisplayIndex,(SDL_Window *a),(a),return)
SDL_DYNAPI_PROC(SDL_DisplayID,SDL_GetDisplayForWindow,(SDL_Window *a),(a),return)
SDL_DYNAPI_PROC(int,SDL_GetWindowDisplayMode,(SDL_Window *a, SDL_DisplayMode *b),(a,b),return)
SDL_DYNAPI_PROC(Uint32,SDL_GetWindowFlags,(SDL_Window *a),(a),return)
SDL_DYNAPI_PROC(SDL_Window*,SDL_GetWindowFromID,(Uint32 a),(a),return)
@ -911,3 +910,5 @@ SDL_DYNAPI_PROC(void,SDL_PlayAudioDevice,(SDL_AudioDeviceID a),(a),)
SDL_DYNAPI_PROC(void*,SDL_aligned_alloc,(size_t a, size_t b),(a,b),return)
SDL_DYNAPI_PROC(void,SDL_aligned_free,(void *a),(a),)
SDL_DYNAPI_PROC(int,SDL_ConvertAudioSamples,(SDL_AudioFormat a, Uint8 b, int c, int d, Uint8 *e, SDL_AudioFormat f, Uint8 g, int h, int *i, Uint8 **j),(a,b,c,d,e,f,g,h,i,j),return)
SDL_DYNAPI_PROC(SDL_DisplayID*,SDL_GetDisplays,(int *a),(a),return)
SDL_DYNAPI_PROC(SDL_DisplayID,SDL_GetPrimaryDisplay,(void),(),return)

View file

@ -48,7 +48,7 @@ int SDL_SendDisplayEvent(SDL_VideoDisplay *display, SDL_EventType displayevent,
SDL_Event event;
event.type = displayevent;
event.common.timestamp = 0;
event.display.display = SDL_GetIndexOfDisplay(display);
event.display.displayID = display->id;
event.display.data1 = data1;
posted = (SDL_PushEvent(&event) > 0);
}

View file

@ -217,7 +217,7 @@ static void SDL_LogEvent(const SDL_Event *event)
case x: \
SDL_strlcpy(name, #x, sizeof(name)); \
(void)SDL_snprintf(details, sizeof(details), " (timestamp=%u display=%u event=%s data1=%d)", \
(uint)event->display.timestamp, (uint)event->display.display, name, (int)event->display.data1); \
(uint)event->display.timestamp, (uint)event->display.displayID, name, (int)event->display.data1); \
break
SDL_DISPLAYEVENT_CASE(SDL_EVENT_DISPLAY_ORIENTATION);
SDL_DISPLAYEVENT_CASE(SDL_EVENT_DISPLAY_CONNECTED);

View file

@ -141,10 +141,10 @@ int SDL_SendWindowEvent(SDL_Window *window, SDL_EventType windowevent,
window->flags &= ~SDL_WINDOW_INPUT_FOCUS;
break;
case SDL_EVENT_WINDOW_DISPLAY_CHANGED:
if (data1 < 0 || data1 == window->display_index) {
if (data1 == 0 || (SDL_DisplayID)data1 == window->displayID) {
return 0;
}
window->display_index = data1;
window->displayID = (SDL_DisplayID)data1;
break;
default:
break;

View file

@ -915,15 +915,15 @@ static SDL_RenderLineMethod SDL_GetRenderLineMethod()
static void SDL_CalculateSimulatedVSyncInterval(SDL_Renderer *renderer, SDL_Window *window)
{
int display_index = SDL_GetWindowDisplayIndex(window);
SDL_DisplayID displayID = SDL_GetDisplayForWindow(window);
SDL_DisplayMode mode;
float refresh_rate;
int num, den;
if (display_index < 0) {
display_index = 0;
if (displayID == 0) {
displayID = SDL_GetPrimaryDisplay();
}
if (SDL_GetDesktopDisplayMode(display_index, &mode) == 0 && mode.refresh_rate > 0.0f) {
if (SDL_GetDesktopDisplayMode(displayID, &mode) == 0 && mode.refresh_rate > 0.0f) {
refresh_rate = mode.refresh_rate;
} else {
/* Pick a good default refresh rate */

View file

@ -1557,7 +1557,7 @@ D3D_CreateRenderer(SDL_Window *window, Uint32 flags)
Uint32 window_flags;
int w, h;
SDL_DisplayMode fullscreen_mode;
int displayIndex;
SDL_DisplayID displayID;
if (SDL_GetWindowWMInfo(window, &windowinfo, SDL_SYSWM_CURRENT_VERSION) < 0 ||
windowinfo.subsystem != SDL_SYSWM_WINDOWS) {
@ -1639,8 +1639,8 @@ D3D_CreateRenderer(SDL_Window *window, Uint32 flags)
}
/* Get the adapter for the display that the window is on */
displayIndex = SDL_GetWindowDisplayIndex(window);
data->adapter = SDL_Direct3D9GetAdapterIndex(displayIndex);
displayID = SDL_GetDisplayForWindow(window);
data->adapter = SDL_Direct3D9GetAdapterIndex(displayID);
IDirect3D9_GetDeviceCaps(data->d3d, data->adapter, D3DDEVTYPE_HAL, &caps);

View file

@ -1099,6 +1099,7 @@ SDLTest_CommonInit(SDLTest_CommonState *state)
}
if (state->verbose & VERBOSE_MODES) {
SDL_DisplayID *displays;
SDL_Rect bounds, usablebounds;
float hdpi = 0;
float vdpi = 0;
@ -1109,24 +1110,25 @@ SDLTest_CommonInit(SDLTest_CommonState *state)
int adapterIndex = 0;
int outputIndex = 0;
#endif
n = SDL_GetNumVideoDisplays();
displays = SDL_GetDisplays(&n);
SDL_Log("Number of displays: %d\n", n);
for (i = 0; i < n; ++i) {
SDL_Log("Display %d: %s\n", i, SDL_GetDisplayName(i));
SDL_DisplayID displayID = displays[i];
SDL_Log("Display %" SDL_PRIu32 ": %s\n", displayID, SDL_GetDisplayName(displayID));
SDL_zero(bounds);
SDL_GetDisplayBounds(i, &bounds);
SDL_GetDisplayBounds(displayID, &bounds);
SDL_zero(usablebounds);
SDL_GetDisplayUsableBounds(i, &usablebounds);
SDL_GetDisplayUsableBounds(displayID, &usablebounds);
SDL_GetDisplayPhysicalDPI(i, NULL, &hdpi, &vdpi);
SDL_GetDisplayPhysicalDPI(displayID, NULL, &hdpi, &vdpi);
SDL_Log("Bounds: %dx%d at %d,%d\n", bounds.w, bounds.h, bounds.x, bounds.y);
SDL_Log("Usable bounds: %dx%d at %d,%d\n", usablebounds.w, usablebounds.h, usablebounds.x, usablebounds.y);
SDL_Log("DPI: %gx%g\n", hdpi, vdpi);
SDL_GetDesktopDisplayMode(i, &mode);
SDL_GetDesktopDisplayMode(displayID, &mode);
SDL_GetMasksForPixelFormatEnum(mode.format, &bpp, &Rmask, &Gmask,
&Bmask, &Amask);
SDL_Log(" Current mode: %dx%d@%gHz, %d%% scale, %d bits-per-pixel (%s)\n",
@ -1142,13 +1144,13 @@ SDLTest_CommonInit(SDLTest_CommonState *state)
}
/* Print available fullscreen video modes */
m = SDL_GetNumDisplayModes(i);
m = SDL_GetNumDisplayModes(displayID);
if (m == 0) {
SDL_Log("No available fullscreen video modes\n");
} else {
SDL_Log(" Fullscreen video modes:\n");
for (j = 0; j < m; ++j) {
SDL_GetDisplayMode(i, j, &mode);
SDL_GetDisplayMode(displayID, j, &mode);
SDL_GetMasksForPixelFormatEnum(mode.format, &bpp, &Rmask,
&Gmask, &Bmask, &Amask);
SDL_Log(" Mode %d: %dx%d@%gHz, %d%% scale, %d bits-per-pixel (%s)\n",
@ -1170,14 +1172,15 @@ SDLTest_CommonInit(SDLTest_CommonState *state)
#if SDL_VIDEO_DRIVER_WINDOWS && !defined(__XBOXONE__) && !defined(__XBOXSERIES__)
/* Print the D3D9 adapter index */
adapterIndex = SDL_Direct3D9GetAdapterIndex(i);
adapterIndex = SDL_Direct3D9GetAdapterIndex(displayID);
SDL_Log("D3D9 Adapter Index: %d", adapterIndex);
/* Print the DXGI adapter and output indices */
SDL_DXGIGetOutputInfo(i, &adapterIndex, &outputIndex);
SDL_DXGIGetOutputInfo(displayID, &adapterIndex, &outputIndex);
SDL_Log("DXGI Adapter Index: %d Output Index: %d", adapterIndex, outputIndex);
#endif
}
SDL_free(displays);
}
if (state->verbose & VERBOSE_RENDER) {
@ -1236,7 +1239,14 @@ SDLTest_CommonInit(SDLTest_CommonState *state)
/* !!! FIXME: hack to make --usable-bounds work for now. */
if ((r.x == -1) && (r.y == -1) && (r.w == -1) && (r.h == -1)) {
SDL_GetDisplayUsableBounds(state->display, &r);
int num_displays;
SDL_DisplayID *displays = SDL_GetDisplays(&num_displays);
if (displays && state->display < num_displays) {
SDL_GetDisplayUsableBounds(displays[state->display], &r);
} else {
SDL_GetDisplayUsableBounds(SDL_GetPrimaryDisplay(), &r);
}
SDL_free(displays);
}
if (state->num_windows > 1) {
@ -1421,19 +1431,19 @@ static void SDLTest_PrintEvent(SDL_Event *event)
switch (event->type) {
case SDL_EVENT_DISPLAY_CONNECTED:
SDL_Log("SDL EVENT: Display %" SDL_PRIu32 " connected",
event->display.display);
event->display.displayID);
break;
case SDL_EVENT_DISPLAY_MOVED:
SDL_Log("SDL EVENT: Display %" SDL_PRIu32 " changed position",
event->display.display);
event->display.displayID);
break;
case SDL_EVENT_DISPLAY_ORIENTATION:
SDL_Log("SDL EVENT: Display %" SDL_PRIu32 " changed orientation to %s",
event->display.display, DisplayOrientationName(event->display.data1));
event->display.displayID, DisplayOrientationName(event->display.data1));
break;
case SDL_EVENT_DISPLAY_DISCONNECTED:
SDL_Log("SDL EVENT: Display %" SDL_PRIu32 " disconnected",
event->display.display);
event->display.displayID);
break;
case SDL_EVENT_WINDOW_SHOWN:
SDL_Log("SDL EVENT: Window %" SDL_PRIu32 " shown", event->window.windowID);
@ -1720,14 +1730,17 @@ static void SDLTest_ScreenShot(SDL_Renderer *renderer)
static void FullscreenTo(int index, int windowId)
{
int num_displays;
SDL_DisplayID *displays;
SDL_Window *window;
Uint32 flags;
struct SDL_Rect rect = { 0, 0, 0, 0 };
SDL_Window *window = SDL_GetWindowFromID(windowId);
if (window == NULL) {
return;
}
SDL_GetDisplayBounds(index, &rect);
displays = SDL_GetDisplays(&num_displays);
if (displays && index < num_displays) {
window = SDL_GetWindowFromID(windowId);
if (window) {
SDL_GetDisplayBounds(displays[index], &rect);
flags = SDL_GetWindowFlags(window);
if ((flags & SDL_WINDOW_FULLSCREEN_MASK) != 0) {
@ -1738,6 +1751,9 @@ static void FullscreenTo(int index, int windowId)
SDL_SetWindowPosition(window, rect.x, rect.y);
SDL_SetWindowFullscreen(window, SDL_WINDOW_FULLSCREEN_EXCLUSIVE);
}
}
SDL_free(displays);
}
void SDLTest_CommonEvent(SDLTest_CommonState *state, SDL_Event *event, int *done)
{
@ -1831,21 +1847,32 @@ void SDLTest_CommonEvent(SDLTest_CommonState *state, SDL_Event *event, int *done
/* Alt-Up/Down/Left/Right switches between displays */
SDL_Window *window = SDL_GetWindowFromID(event->key.windowID);
if (window) {
int currentIndex = SDL_GetWindowDisplayIndex(window);
int numDisplays = SDL_GetNumVideoDisplays();
int num_displays;
SDL_DisplayID *displays = SDL_GetDisplays(&num_displays);
if (displays) {
SDL_DisplayID displayID = SDL_GetDisplayForWindow(window);
int current_index = -1;
if (currentIndex >= 0 && numDisplays >= 1) {
int dest;
if (event->key.keysym.sym == SDLK_UP || event->key.keysym.sym == SDLK_LEFT) {
dest = (currentIndex + numDisplays - 1) % numDisplays;
} else {
dest = (currentIndex + numDisplays + 1) % numDisplays;
for (i = 0; i < num_displays; ++i) {
if (displayID == displays[i]) {
current_index = i;
break;
}
SDL_Log("Centering on display %d\n", dest);
}
if (current_index >= 0) {
SDL_DisplayID dest;
if (event->key.keysym.sym == SDLK_UP || event->key.keysym.sym == SDLK_LEFT) {
dest = displays[(current_index + num_displays - 1) % num_displays];
} else {
dest = displays[(current_index + num_displays + 1) % num_displays];
}
SDL_Log("Centering on display (%" SDL_PRIu32 ")\n", dest);
SDL_SetWindowPosition(window,
SDL_WINDOWPOS_CENTERED_DISPLAY(dest),
SDL_WINDOWPOS_CENTERED_DISPLAY(dest));
}
SDL_free(displays);
}
}
}
if (withShift) {
@ -2169,7 +2196,7 @@ void SDLTest_CommonDrawWindowInfo(SDL_Renderer *renderer, SDL_Window *window, fl
float ddpi, hdpi, vdpi;
float scaleX, scaleY;
Uint32 flags;
const int windowDisplayIndex = SDL_GetWindowDisplayIndex(window);
SDL_DisplayID windowDisplayID = SDL_GetDisplayForWindow(window);
SDL_RendererInfo info;
/* Video */
@ -2259,36 +2286,36 @@ void SDLTest_CommonDrawWindowInfo(SDL_Renderer *renderer, SDL_Window *window, fl
SDL_SetRenderDrawColor(renderer, 170, 170, 170, 255);
(void)SDL_snprintf(text, sizeof text, "SDL_GetWindowDisplayIndex: %d", windowDisplayIndex);
(void)SDL_snprintf(text, sizeof text, "SDL_GetDisplayForWindow: %" SDL_PRIu32 "", windowDisplayID);
SDLTest_DrawString(renderer, 0.0f, textY, text);
textY += lineHeight;
(void)SDL_snprintf(text, sizeof text, "SDL_GetDisplayName: %s", SDL_GetDisplayName(windowDisplayIndex));
(void)SDL_snprintf(text, sizeof text, "SDL_GetDisplayName: %s", SDL_GetDisplayName(windowDisplayID));
SDLTest_DrawString(renderer, 0.0f, textY, text);
textY += lineHeight;
if (0 == SDL_GetDisplayBounds(windowDisplayIndex, &rect)) {
if (0 == SDL_GetDisplayBounds(windowDisplayID, &rect)) {
(void)SDL_snprintf(text, sizeof text, "SDL_GetDisplayBounds: %d,%d, %dx%d",
rect.x, rect.y, rect.w, rect.h);
SDLTest_DrawString(renderer, 0.0f, textY, text);
textY += lineHeight;
}
if (0 == SDL_GetCurrentDisplayMode(windowDisplayIndex, &mode)) {
if (0 == SDL_GetCurrentDisplayMode(windowDisplayID, &mode)) {
(void)SDL_snprintf(text, sizeof text, "SDL_GetCurrentDisplayMode: %dx%d@%gHz %d%% scale, (%s)",
mode.pixel_w, mode.pixel_h, mode.refresh_rate, (int)(mode.display_scale * 100.0f), SDL_GetPixelFormatName(mode.format));
SDLTest_DrawString(renderer, 0.0f, textY, text);
textY += lineHeight;
}
if (0 == SDL_GetDesktopDisplayMode(windowDisplayIndex, &mode)) {
if (0 == SDL_GetDesktopDisplayMode(windowDisplayID, &mode)) {
(void)SDL_snprintf(text, sizeof text, "SDL_GetDesktopDisplayMode: %dx%d@%gHz %d%% scale, (%s)",
mode.pixel_w, mode.pixel_h, mode.refresh_rate, (int)(mode.display_scale * 100.0f), SDL_GetPixelFormatName(mode.format));
SDLTest_DrawString(renderer, 0.0f, textY, text);
textY += lineHeight;
}
if (0 == SDL_GetDisplayPhysicalDPI(windowDisplayIndex, &ddpi, &hdpi, &vdpi)) {
if (0 == SDL_GetDisplayPhysicalDPI(windowDisplayID, &ddpi, &hdpi, &vdpi)) {
(void)SDL_snprintf(text, sizeof text, "SDL_GetDisplayPhysicalDPI: ddpi: %g, hdpi: %g, vdpi: %g",
ddpi, hdpi, vdpi);
SDLTest_DrawString(renderer, 0.0f, textY, text);
@ -2296,7 +2323,7 @@ void SDLTest_CommonDrawWindowInfo(SDL_Renderer *renderer, SDL_Window *window, fl
}
(void)SDL_snprintf(text, sizeof text, "SDL_GetDisplayOrientation: ");
SDLTest_PrintDisplayOrientation(text, sizeof text, SDL_GetDisplayOrientation(windowDisplayIndex));
SDLTest_PrintDisplayOrientation(text, sizeof text, SDL_GetDisplayOrientation(windowDisplayID));
SDLTest_DrawString(renderer, 0.0f, textY, text);
textY += lineHeight;

View file

@ -148,24 +148,21 @@ extern int SDL_EGL_SetErrorEx(const char *message, const char *eglFunctionName,
/* A few of useful macros */
#define SDL_EGL_SwapWindow_impl(BACKEND) \
int \
BACKEND##_GLES_SwapWindow(_THIS, SDL_Window *window) \
int BACKEND##_GLES_SwapWindow(_THIS, SDL_Window *window) \
{ \
return SDL_EGL_SwapBuffers(_this, ((SDL_WindowData *)window->driverdata)->egl_surface); \
return SDL_EGL_SwapBuffers(_this, window->driverdata->egl_surface); \
}
#define SDL_EGL_MakeCurrent_impl(BACKEND) \
int \
BACKEND##_GLES_MakeCurrent(_THIS, SDL_Window *window, SDL_GLContext context) \
int BACKEND##_GLES_MakeCurrent(_THIS, SDL_Window *window, SDL_GLContext context) \
{ \
return SDL_EGL_MakeCurrent(_this, window ? ((SDL_WindowData *)window->driverdata)->egl_surface : EGL_NO_SURFACE, context); \
return SDL_EGL_MakeCurrent(_this, window ? window->driverdata->egl_surface : EGL_NO_SURFACE, context); \
}
#define SDL_EGL_CreateContext_impl(BACKEND) \
SDL_GLContext \
BACKEND##_GLES_CreateContext(_THIS, SDL_Window *window) \
SDL_GLContext BACKEND##_GLES_CreateContext(_THIS, SDL_Window *window) \
{ \
return SDL_EGL_CreateContext(_this, ((SDL_WindowData *)window->driverdata)->egl_surface); \
return SDL_EGL_CreateContext(_this, window->driverdata->egl_surface); \
}
#endif /* SDL_VIDEO_OPENGL_EGL */

View file

@ -273,32 +273,24 @@ int SDL_SetWindowShape(SDL_Window *window, SDL_Surface *shape, SDL_WindowShapeMo
result = _this->shape_driver.SetWindowShape(window->shaper, shape, shape_mode);
window->shaper->hasshape = SDL_TRUE;
if (window->shaper->userx != 0 && window->shaper->usery != 0) {
SDL_DisplayID displayID = 0;
int x = window->shaper->userx;
int y = window->shaper->usery;
if (SDL_WINDOWPOS_ISUNDEFINED(x) || SDL_WINDOWPOS_ISUNDEFINED(y) ||
SDL_WINDOWPOS_ISCENTERED(x) || SDL_WINDOWPOS_ISCENTERED(y)) {
int displayIndex;
if (!displayID) {
displayID = SDL_GetDisplayForWindowCoordinate(x);
}
if (!displayID) {
displayID = SDL_GetDisplayForWindowCoordinate(y);
}
if (displayID) {
SDL_Rect bounds;
SDL_GetDisplayBounds(displayID, &bounds);
if (SDL_WINDOWPOS_ISUNDEFINED(x) || SDL_WINDOWPOS_ISCENTERED(x)) {
displayIndex = (x & 0xFFFF);
if (displayIndex >= _this->num_displays) {
displayIndex = 0;
}
} else {
displayIndex = (y & 0xFFFF);
if (displayIndex >= _this->num_displays) {
displayIndex = 0;
}
}
SDL_GetDisplayBounds(displayIndex, &bounds);
if (SDL_WINDOWPOS_ISUNDEFINED(x) || SDL_WINDOWPOS_ISCENTERED(x)) {
window->x = bounds.x + (bounds.w - window->w) / 2;
x = bounds.x + (bounds.w - window->w) / 2;
}
if (SDL_WINDOWPOS_ISUNDEFINED(y) || SDL_WINDOWPOS_ISCENTERED(y)) {
window->y = bounds.y + (bounds.h - window->h) / 2;
y = bounds.y + (bounds.h - window->h) / 2;
}
}
SDL_SetWindowPosition(window, x, y);

View file

@ -31,6 +31,34 @@ typedef struct SDL_WindowShaper SDL_WindowShaper;
typedef struct SDL_ShapeDriver SDL_ShapeDriver;
typedef struct SDL_VideoDisplay SDL_VideoDisplay;
typedef struct SDL_VideoDevice SDL_VideoDevice;
#if defined(SDL_VIDEO_DRIVER_COCOA)
#ifdef __OBJC__
@class SDL_VideoData;
@class SDL_WindowData;
#else
typedef struct _SDL_VideoData SDL_VideoData;
typedef struct _SDL_WindowData SDL_WindowData;
#endif
typedef struct SDL_DisplayData SDL_DisplayData;
typedef struct SDL_DisplayModeData SDL_DisplayModeData;
#elif defined(SDL_VIDEO_DRIVER_UIKIT)
#ifdef __OBJC__
@class SDL_VideoData;
@class SDL_WindowData;
@class SDL_DisplayData;
@class SDL_DisplayModeData;
#else
typedef struct _SDL_VideoData SDL_VideoData;
typedef struct _SDL_WindowData SDL_WindowData;
typedef struct _SDL_DisplayData SDL_DisplayData;
typedef struct _SDL_DisplayModeData SDL_DisplayModeData;
#endif
#else
typedef struct SDL_VideoData SDL_VideoData;
typedef struct SDL_DisplayData SDL_DisplayData;
typedef struct SDL_DisplayModeData SDL_DisplayModeData;
typedef struct SDL_WindowData SDL_WindowData;
#endif /* SDL_VIDEO_DRIVER_COCOA || SDL_VIDEO_DRIVER_UIKIT */
/* Define the SDL window-shaper structure */
struct SDL_WindowShaper
@ -79,7 +107,7 @@ struct SDL_Window
int last_pixel_w, last_pixel_h;
Uint32 flags;
Uint32 last_fullscreen_flags;
Uint32 display_index;
SDL_DisplayID displayID;
/* Stored position and size for windowed mode */
SDL_Rect windowed;
@ -104,7 +132,7 @@ struct SDL_Window
SDL_WindowUserData *data;
void *driverdata;
SDL_WindowData *driverdata;
SDL_Window *prev;
SDL_Window *next;
@ -120,6 +148,7 @@ struct SDL_Window
*/
struct SDL_VideoDisplay
{
SDL_DisplayID id;
char *name;
int max_display_modes;
int num_display_modes;
@ -132,7 +161,7 @@ struct SDL_VideoDisplay
SDL_VideoDevice *device;
void *driverdata;
SDL_DisplayData *driverdata;
};
/* Forward declaration */
@ -240,7 +269,7 @@ struct SDL_VideoDevice
void (*SetWindowAlwaysOnTop)(_THIS, SDL_Window *window, SDL_bool on_top);
void (*SetWindowFullscreen)(_THIS, SDL_Window *window, SDL_VideoDisplay *display, SDL_bool fullscreen);
void *(*GetWindowICCProfile)(_THIS, SDL_Window *window, size_t *size);
int (*GetWindowDisplayIndex)(_THIS, SDL_Window *window);
SDL_DisplayID (*GetDisplayForWindow)(_THIS, SDL_Window *window);
void (*SetWindowMouseRect)(_THIS, SDL_Window *window);
void (*SetWindowMouseGrab)(_THIS, SDL_Window *window, SDL_bool grabbed);
void (*SetWindowKeyboardGrab)(_THIS, SDL_Window *window, SDL_bool grabbed);
@ -422,7 +451,7 @@ struct SDL_VideoDevice
/* * * */
/* Data private to this driver */
void *driverdata;
SDL_VideoData *driverdata;
struct SDL_GLDriverData *gl_data;
#if SDL_VIDEO_OPENGL_EGL
@ -473,18 +502,20 @@ extern VideoBootStrap NGAGE_bootstrap;
/* Use SDL_OnVideoThread() sparingly, to avoid regressions in use cases that currently happen to work */
extern SDL_bool SDL_OnVideoThread(void);
extern SDL_VideoDevice *SDL_GetVideoDevice(void);
extern int SDL_AddBasicVideoDisplay(const SDL_DisplayMode *desktop_mode);
extern int SDL_AddVideoDisplay(const SDL_VideoDisplay *display, SDL_bool send_event);
extern void SDL_DelVideoDisplay(int index);
extern SDL_bool SDL_IsVideoContextExternal(void);
extern SDL_DisplayID SDL_AddBasicVideoDisplay(const SDL_DisplayMode *desktop_mode);
extern SDL_DisplayID SDL_AddVideoDisplay(const SDL_VideoDisplay *display, SDL_bool send_event);
extern void SDL_DelVideoDisplay(SDL_DisplayID display);
extern SDL_bool SDL_AddDisplayMode(SDL_VideoDisplay *display, const SDL_DisplayMode *mode);
extern void SDL_SetCurrentDisplayMode(SDL_VideoDisplay *display, const SDL_DisplayMode *mode);
extern void SDL_SetDesktopDisplayMode(SDL_VideoDisplay *display, const SDL_DisplayMode *mode);
extern void SDL_ResetDisplayModes(int displayIndex);
extern int SDL_GetIndexOfDisplay(SDL_VideoDisplay *display);
extern SDL_VideoDisplay *SDL_GetDisplay(int displayIndex);
extern SDL_VideoDisplay *SDL_GetDisplayForWindow(SDL_Window *window);
extern void *SDL_GetDisplayDriverData(int displayIndex);
extern SDL_bool SDL_IsVideoContextExternal(void);
extern void SDL_ResetDisplayModes(SDL_VideoDisplay *display);
extern SDL_VideoDisplay *SDL_GetVideoDisplay(SDL_DisplayID display);
extern SDL_VideoDisplay *SDL_GetVideoDisplayForWindow(SDL_Window *window);
extern int SDL_GetDisplayIndex(SDL_DisplayID displayID);
extern SDL_DisplayData *SDL_GetDisplayDriverData(SDL_DisplayID display);
extern SDL_DisplayData *SDL_GetDisplayDriverDataForWindow(SDL_Window *window);
extern SDL_DisplayID SDL_GetDisplayForWindowCoordinate(int coordinate);
extern int SDL_GetMessageBoxCount(void);
extern void SDL_GL_DeduceMaxSupportedESProfile(int *major, int *minor);
@ -515,8 +546,6 @@ extern float SDL_ComputeDiagonalDPI(int hpix, int vpix, float hinches, float vin
extern void SDL_ToggleDragAndDropSupport(void);
extern int SDL_GetDisplayIndexForPoint(const SDL_Point *point);
/* This has been moved out of the public API, but is still available for now */
#define SDL_WINDOW_ALLOW_HIGHDPI 0x00002000

View file

@ -140,16 +140,10 @@ static VideoBootStrap *bootstrap[] = {
return retval; \
}
#define CHECK_DISPLAY_INDEX(displayIndex, retval) \
if (!_this) { \
SDL_UninitializedVideo(); \
#define CHECK_DISPLAY_MAGIC(display, retval) \
if (!display) { \
return retval; \
} \
if ((displayIndex) < 0 || (displayIndex) >= _this->num_displays) { \
SDL_SetError("displayIndex must be in the range 0 - %d", \
_this->num_displays - 1); \
return retval; \
}
#if defined(__MACOS__) && defined(SDL_VIDEO_DRIVER_COCOA)
/* Support for macOS fullscreen spaces */
@ -578,6 +572,11 @@ SDL_VideoDevice *SDL_GetVideoDevice(void)
return _this;
}
SDL_bool SDL_IsVideoContextExternal(void)
{
return SDL_GetHintBoolean(SDL_HINT_VIDEO_EXTERNAL_CONTEXT, SDL_FALSE);
}
SDL_bool SDL_OnVideoThread()
{
return (_this && SDL_ThreadID() == _this->thread) ? SDL_TRUE : SDL_FALSE;
@ -617,7 +616,7 @@ static void SDL_FinalizeDisplayMode(SDL_DisplayMode *mode)
}
}
int SDL_AddBasicVideoDisplay(const SDL_DisplayMode *desktop_mode)
SDL_DisplayID SDL_AddBasicVideoDisplay(const SDL_DisplayMode *desktop_mode)
{
SDL_VideoDisplay display;
@ -631,17 +630,18 @@ int SDL_AddBasicVideoDisplay(const SDL_DisplayMode *desktop_mode)
return SDL_AddVideoDisplay(&display, SDL_FALSE);
}
int SDL_AddVideoDisplay(const SDL_VideoDisplay *display, SDL_bool send_event)
SDL_DisplayID SDL_AddVideoDisplay(const SDL_VideoDisplay *display, SDL_bool send_event)
{
SDL_VideoDisplay *displays;
int index = -1;
SDL_DisplayID id = 0;
int index;
displays =
SDL_realloc(_this->displays,
(_this->num_displays + 1) * sizeof(*displays));
displays = (SDL_VideoDisplay *)SDL_realloc(_this->displays, (_this->num_displays + 1) * sizeof(*displays));
if (displays) {
id = _this->next_object_id++;
index = _this->num_displays++;
displays[index] = *display;
displays[index].id = id;
displays[index].device = _this;
_this->displays = displays;
@ -663,78 +663,131 @@ int SDL_AddVideoDisplay(const SDL_VideoDisplay *display, SDL_bool send_event)
} else {
SDL_OutOfMemory();
}
return index;
return id;
}
void SDL_DelVideoDisplay(int index)
void SDL_DelVideoDisplay(SDL_DisplayID displayID)
{
if (index < 0 || index >= _this->num_displays) {
SDL_VideoDisplay *display;
int display_index = SDL_GetDisplayIndex(displayID);
if (display_index < 0) {
return;
}
SDL_SendDisplayEvent(&_this->displays[index], SDL_EVENT_DISPLAY_DISCONNECTED, 0);
display = &_this->displays[display_index];
if (index < (_this->num_displays - 1)) {
SDL_free(_this->displays[index].driverdata);
SDL_memmove(&_this->displays[index], &_this->displays[index + 1], (_this->num_displays - index - 1) * sizeof(_this->displays[index]));
SDL_SendDisplayEvent(display, SDL_EVENT_DISPLAY_DISCONNECTED, 0);
if (display->driverdata) {
SDL_free(display->driverdata);
}
if (display_index < (_this->num_displays - 1)) {
SDL_memmove(&_this->displays[display_index], &_this->displays[display_index + 1], (_this->num_displays - display_index - 1) * sizeof(_this->displays[display_index]));
}
--_this->num_displays;
}
int SDL_GetNumVideoDisplays(void)
SDL_DisplayID *SDL_GetDisplays(int *count)
{
if (_this == NULL) {
int i;
SDL_DisplayID *displays;
displays = (SDL_DisplayID *)SDL_malloc((_this->num_displays + 1) * sizeof(*displays));
if (displays) {
if (count) {
*count = _this->num_displays;
}
for (i = 0; i < _this->num_displays; ++i) {
displays[i] = _this->displays[i].id;
}
displays[i] = 0;
} else {
if (count) {
*count = 0;
}
SDL_OutOfMemory();
}
return displays;
}
SDL_VideoDisplay *SDL_GetVideoDisplay(SDL_DisplayID displayID)
{
int display_index;
display_index = SDL_GetDisplayIndex(displayID);
if (display_index < 0) {
return NULL;
}
return &_this->displays[display_index];
}
SDL_VideoDisplay *SDL_GetVideoDisplayForWindow(SDL_Window *window)
{
return SDL_GetVideoDisplay(SDL_GetDisplayForWindow(window));
}
SDL_DisplayID SDL_GetPrimaryDisplay(void)
{
if (!_this || _this->num_displays == 0) {
SDL_UninitializedVideo();
return 0;
}
return _this->num_displays;
return _this->displays[0].id;
}
int SDL_GetIndexOfDisplay(SDL_VideoDisplay *display)
int SDL_GetDisplayIndex(SDL_DisplayID displayID)
{
int displayIndex;
int display_index;
for (displayIndex = 0; displayIndex < _this->num_displays; ++displayIndex) {
if (display == &_this->displays[displayIndex]) {
return displayIndex;
}
if (!_this) {
SDL_UninitializedVideo();
return -1;
}
/* Couldn't find the display, just use index 0 */
return 0;
for (display_index = 0; display_index < _this->num_displays; ++display_index) {
if (displayID == _this->displays[display_index].id) {
return display_index;
}
}
SDL_SetError("Invalid display");
return -1;
}
void *SDL_GetDisplayDriverData(int displayIndex)
SDL_DisplayData *SDL_GetDisplayDriverData(SDL_DisplayID displayID)
{
CHECK_DISPLAY_INDEX(displayIndex, NULL);
SDL_VideoDisplay *display = SDL_GetVideoDisplay(displayID);
return _this->displays[displayIndex].driverdata;
CHECK_DISPLAY_MAGIC(display, NULL);
return display->driverdata;
}
SDL_bool SDL_IsVideoContextExternal(void)
SDL_DisplayData *SDL_GetDisplayDriverDataForWindow(SDL_Window *window)
{
return SDL_GetHintBoolean(SDL_HINT_VIDEO_EXTERNAL_CONTEXT, SDL_FALSE);
return SDL_GetDisplayDriverData(SDL_GetDisplayForWindow(window));
}
const char *SDL_GetDisplayName(int displayIndex)
const char *SDL_GetDisplayName(SDL_DisplayID displayID)
{
CHECK_DISPLAY_INDEX(displayIndex, NULL);
SDL_VideoDisplay *display = SDL_GetVideoDisplay(displayID);
return _this->displays[displayIndex].name;
CHECK_DISPLAY_MAGIC(display, NULL);
return display->name;
}
int SDL_GetDisplayBounds(int displayIndex, SDL_Rect *rect)
int SDL_GetDisplayBounds(SDL_DisplayID displayID, SDL_Rect *rect)
{
SDL_VideoDisplay *display;
SDL_VideoDisplay *display = SDL_GetVideoDisplay(displayID);
CHECK_DISPLAY_INDEX(displayIndex, -1);
CHECK_DISPLAY_MAGIC(display, -1);
if (rect == NULL) {
return SDL_InvalidParamError("rect");
}
display = &_this->displays[displayIndex];
if (_this->GetDisplayBounds) {
if (_this->GetDisplayBounds(_this, display, rect) == 0) {
return 0;
@ -742,11 +795,11 @@ int SDL_GetDisplayBounds(int displayIndex, SDL_Rect *rect)
}
/* Assume that the displays are left to right */
if (displayIndex == 0) {
if (displayID == SDL_GetPrimaryDisplay()) {
rect->x = 0;
rect->y = 0;
} else {
SDL_GetDisplayBounds(displayIndex - 1, rect);
SDL_GetDisplayBounds(_this->displays[SDL_GetDisplayIndex(displayID) - 1].id, rect);
rect->x += rect->w;
}
rect->w = display->current_mode.screen_w;
@ -760,19 +813,17 @@ static int ParseDisplayUsableBoundsHint(SDL_Rect *rect)
return hint && (SDL_sscanf(hint, "%d,%d,%d,%d", &rect->x, &rect->y, &rect->w, &rect->h) == 4);
}
int SDL_GetDisplayUsableBounds(int displayIndex, SDL_Rect *rect)
int SDL_GetDisplayUsableBounds(SDL_DisplayID displayID, SDL_Rect *rect)
{
SDL_VideoDisplay *display;
SDL_VideoDisplay *display = SDL_GetVideoDisplay(displayID);
CHECK_DISPLAY_INDEX(displayIndex, -1);
CHECK_DISPLAY_MAGIC(display, -1);
if (rect == NULL) {
return SDL_InvalidParamError("rect");
}
display = &_this->displays[displayIndex];
if ((displayIndex == 0) && ParseDisplayUsableBoundsHint(rect)) {
if (displayID == SDL_GetPrimaryDisplay() && ParseDisplayUsableBoundsHint(rect)) {
return 0;
}
@ -783,35 +834,32 @@ int SDL_GetDisplayUsableBounds(int displayIndex, SDL_Rect *rect)
}
/* Oh well, just give the entire display bounds. */
return SDL_GetDisplayBounds(displayIndex, rect);
return SDL_GetDisplayBounds(displayID, rect);
}
int SDL_GetDisplayPhysicalDPI(int displayIndex, float *ddpi, float *hdpi, float *vdpi)
int SDL_GetDisplayPhysicalDPI(SDL_DisplayID displayID, float *ddpi, float *hdpi, float *vdpi)
{
SDL_VideoDisplay *display;
SDL_VideoDisplay *display = SDL_GetVideoDisplay(displayID);
CHECK_DISPLAY_INDEX(displayIndex, -1);
display = &_this->displays[displayIndex];
CHECK_DISPLAY_MAGIC(display, -1);
if (_this->GetDisplayPhysicalDPI) {
if (_this->GetDisplayPhysicalDPI(_this, display, ddpi, hdpi, vdpi) == 0) {
if (_this->GetDisplayPhysicalDPI(_this, display, ddpi, hdpi, vdpi) < 0) {
return -1;
} else {
return 0;
}
} else {
return SDL_Unsupported();
}
return -1;
}
SDL_DisplayOrientation SDL_GetDisplayOrientation(int displayIndex)
SDL_DisplayOrientation SDL_GetDisplayOrientation(SDL_DisplayID displayID)
{
SDL_VideoDisplay *display;
SDL_VideoDisplay *display = SDL_GetVideoDisplay(displayID);
CHECK_DISPLAY_INDEX(displayIndex, SDL_ORIENTATION_UNKNOWN);
CHECK_DISPLAY_MAGIC(display, SDL_ORIENTATION_UNKNOWN);
display = &_this->displays[displayIndex];
return display->orientation;
}
@ -861,31 +909,10 @@ void SDL_SetDesktopDisplayMode(SDL_VideoDisplay *display, const SDL_DisplayMode
SDL_FinalizeDisplayMode(&display->desktop_mode);
}
static int SDL_GetNumDisplayModesForDisplay(SDL_VideoDisplay *display)
void SDL_ResetDisplayModes(SDL_VideoDisplay *display)
{
if (!display->num_display_modes && _this->GetDisplayModes) {
_this->GetDisplayModes(_this, display);
SDL_qsort(display->display_modes, display->num_display_modes,
sizeof(SDL_DisplayMode), cmpmodes);
}
return display->num_display_modes;
}
int SDL_GetNumDisplayModes(int displayIndex)
{
CHECK_DISPLAY_INDEX(displayIndex, -1);
return SDL_GetNumDisplayModesForDisplay(&_this->displays[displayIndex]);
}
void SDL_ResetDisplayModes(int displayIndex)
{
SDL_VideoDisplay *display;
int i;
CHECK_DISPLAY_INDEX(displayIndex, );
display = &_this->displays[displayIndex];
for (i = display->num_display_modes; i--;) {
SDL_free(display->display_modes[i].driverdata);
display->display_modes[i].driverdata = NULL;
@ -896,13 +923,31 @@ void SDL_ResetDisplayModes(int displayIndex)
display->max_display_modes = 0;
}
int SDL_GetDisplayMode(int displayIndex, int index, SDL_DisplayMode *mode)
static int SDL_GetNumDisplayModesForDisplay(SDL_VideoDisplay *display)
{
SDL_VideoDisplay *display;
if (!display->num_display_modes && _this->GetDisplayModes) {
_this->GetDisplayModes(_this, display);
SDL_qsort(display->display_modes, display->num_display_modes,
sizeof(SDL_DisplayMode), cmpmodes);
}
return display->num_display_modes;
}
CHECK_DISPLAY_INDEX(displayIndex, -1);
int SDL_GetNumDisplayModes(SDL_DisplayID displayID)
{
SDL_VideoDisplay *display = SDL_GetVideoDisplay(displayID);
CHECK_DISPLAY_MAGIC(display, -1);
return SDL_GetNumDisplayModesForDisplay(display);
}
int SDL_GetDisplayMode(SDL_DisplayID displayID, int index, SDL_DisplayMode *mode)
{
SDL_VideoDisplay *display = SDL_GetVideoDisplay(displayID);
CHECK_DISPLAY_MAGIC(display, -1);
display = &_this->displays[displayIndex];
if (index < 0 || index >= SDL_GetNumDisplayModesForDisplay(display)) {
return SDL_SetError("index must be in the range of 0 - %d", SDL_GetNumDisplayModesForDisplay(display) - 1);
}
@ -912,26 +957,24 @@ int SDL_GetDisplayMode(int displayIndex, int index, SDL_DisplayMode *mode)
return 0;
}
int SDL_GetDesktopDisplayMode(int displayIndex, SDL_DisplayMode *mode)
int SDL_GetDesktopDisplayMode(SDL_DisplayID displayID, SDL_DisplayMode *mode)
{
SDL_VideoDisplay *display;
SDL_VideoDisplay *display = SDL_GetVideoDisplay(displayID);
CHECK_DISPLAY_INDEX(displayIndex, -1);
CHECK_DISPLAY_MAGIC(display, -1);
display = &_this->displays[displayIndex];
if (mode) {
*mode = display->desktop_mode;
}
return 0;
}
int SDL_GetCurrentDisplayMode(int displayIndex, SDL_DisplayMode *mode)
int SDL_GetCurrentDisplayMode(SDL_DisplayID displayID, SDL_DisplayMode *mode)
{
SDL_VideoDisplay *display;
SDL_VideoDisplay *display = SDL_GetVideoDisplay(displayID);
CHECK_DISPLAY_INDEX(displayIndex, -1);
CHECK_DISPLAY_MAGIC(display, -1);
display = &_this->displays[displayIndex];
if (mode) {
*mode = display->current_mode;
}
@ -1058,13 +1101,12 @@ static SDL_DisplayMode *SDL_GetClosestDisplayModeForDisplay(SDL_VideoDisplay *di
return NULL;
}
SDL_DisplayMode *SDL_GetClosestDisplayMode(int displayIndex, const SDL_DisplayMode *mode, SDL_DisplayMode *closest)
SDL_DisplayMode *SDL_GetClosestDisplayMode(SDL_DisplayID displayID, const SDL_DisplayMode *mode, SDL_DisplayMode *closest)
{
SDL_VideoDisplay *display;
SDL_VideoDisplay *display = SDL_GetVideoDisplay(displayID);
CHECK_DISPLAY_INDEX(displayIndex, NULL);
CHECK_DISPLAY_MAGIC(display, NULL);
display = &_this->displays[displayIndex];
return SDL_GetClosestDisplayModeForDisplay(display, mode, closest);
}
@ -1132,13 +1174,6 @@ static int SDL_SetDisplayModeForDisplay(SDL_VideoDisplay *display, const SDL_Dis
return 0;
}
SDL_VideoDisplay *SDL_GetDisplay(int displayIndex)
{
CHECK_DISPLAY_INDEX(displayIndex, NULL);
return &_this->displays[displayIndex];
}
/**
* If x, y are outside of rect, snaps them to the closest point inside rect
* (between rect->x, rect->y, inclusive, and rect->x + w, rect->y + h, exclusive)
@ -1161,10 +1196,10 @@ static void SDL_GetClosestPointOnRect(const SDL_Rect *rect, SDL_Point *point)
}
}
static int GetDisplayIndexForRect(int x, int y, int w, int h)
static SDL_DisplayID GetDisplayForRect(int x, int y, int w, int h)
{
int i, dist;
int closest = -1;
SDL_DisplayID closest = 0;
int closest_dist = 0x7FFFFFFF;
SDL_Point closest_point_on_display;
SDL_Point delta;
@ -1174,8 +1209,9 @@ static int GetDisplayIndexForRect(int x, int y, int w, int h)
if (_this) {
for (i = 0; i < _this->num_displays; ++i) {
SDL_VideoDisplay *display = &_this->displays[i];
SDL_Rect display_rect;
SDL_GetDisplayBounds(i, &display_rect);
SDL_GetDisplayBounds(display->id, &display_rect);
/* Check if the window is fully enclosed */
if (SDL_GetRectEnclosingPoints(&center, 1, &display_rect, NULL)) {
@ -1190,75 +1226,82 @@ static int GetDisplayIndexForRect(int x, int y, int w, int h)
delta.y = center.y - closest_point_on_display.y;
dist = (delta.x * delta.x + delta.y * delta.y);
if (dist < closest_dist) {
closest = i;
closest = display->id;
closest_dist = dist;
}
}
}
if (closest < 0) {
if (closest == 0) {
SDL_SetError("Couldn't find any displays");
}
return closest;
}
int SDL_GetDisplayIndexForPoint(const SDL_Point *point)
SDL_DisplayID SDL_GetDisplayForPoint(const SDL_Point *point)
{
return GetDisplayIndexForRect(point->x, point->y, 1, 1);
return GetDisplayForRect(point->x, point->y, 1, 1);
}
int SDL_GetDisplayIndexForRect(const SDL_Rect *rect)
SDL_DisplayID SDL_GetDisplayForRect(const SDL_Rect *rect)
{
return GetDisplayIndexForRect(rect->x, rect->y, rect->w, rect->h);
return GetDisplayForRect(rect->x, rect->y, rect->w, rect->h);
}
int SDL_GetWindowDisplayIndex(SDL_Window *window)
SDL_DisplayID SDL_GetDisplayForWindowCoordinate(int coordinate)
{
int displayIndex = -1;
SDL_DisplayID displayID = 0;
CHECK_WINDOW_MAGIC(window, -1);
if (_this->GetWindowDisplayIndex) {
displayIndex = _this->GetWindowDisplayIndex(_this, window);
if (SDL_WINDOWPOS_ISUNDEFINED(coordinate) ||
SDL_WINDOWPOS_ISCENTERED(coordinate)) {
displayID = (coordinate & 0xFFFF);
if (SDL_GetDisplayIndex(displayID) < 0) {
displayID = SDL_GetPrimaryDisplay();
}
}
return displayID;
}
SDL_DisplayID SDL_GetDisplayForWindow(SDL_Window *window)
{
SDL_DisplayID displayID = 0;
CHECK_WINDOW_MAGIC(window, 0);
if (_this->GetDisplayForWindow) {
displayID = _this->GetDisplayForWindow(_this, window);
}
/* A backend implementation may fail to get a display index for the window
* (for example if the window is off-screen), but other code may expect it
* to succeed in that situation, so we fall back to a generic position-
* based implementation in that case. */
if (displayIndex >= 0) {
return displayIndex;
} else {
int i;
if (SDL_WINDOWPOS_ISUNDEFINED(window->x) ||
SDL_WINDOWPOS_ISCENTERED(window->x)) {
displayIndex = (window->x & 0xFFFF);
if (displayIndex >= _this->num_displays) {
displayIndex = 0;
if (!displayID) {
displayID = SDL_GetDisplayForWindowCoordinate(window->x);
}
return displayIndex;
}
if (SDL_WINDOWPOS_ISUNDEFINED(window->y) ||
SDL_WINDOWPOS_ISCENTERED(window->y)) {
displayIndex = (window->y & 0xFFFF);
if (displayIndex >= _this->num_displays) {
displayIndex = 0;
}
return displayIndex;
if (!displayID) {
displayID = SDL_GetDisplayForWindowCoordinate(window->y);
}
if (!displayID) {
int i, display_index;
displayIndex = GetDisplayIndexForRect(window->x, window->y, window->w, window->h);
displayID = GetDisplayForRect(window->x, window->y, window->w, window->h);
if (!displayID) {
/* Use the primary display for a window if we can't find it anywhere else */
displayID = SDL_GetPrimaryDisplay();
}
display_index = SDL_GetDisplayIndex(displayID);
/* Find the display containing the window if fullscreen */
for (i = 0; i < _this->num_displays; ++i) {
SDL_VideoDisplay *display = &_this->displays[i];
if (display->fullscreen_window == window) {
if (displayIndex != i) {
if (displayIndex < 0) {
displayIndex = i;
if (display_index != i) {
if (display_index < 0) {
display_index = i;
} else {
SDL_VideoDisplay *new_display = &_this->displays[displayIndex];
SDL_VideoDisplay *new_display = &_this->displays[display_index];
/* The window was moved to a different display */
if (new_display->fullscreen_window != NULL) {
@ -1272,18 +1315,9 @@ int SDL_GetWindowDisplayIndex(SDL_Window *window)
break;
}
}
return displayIndex;
}
}
SDL_VideoDisplay *SDL_GetDisplayForWindow(SDL_Window *window)
{
int displayIndex = SDL_GetWindowDisplayIndex(window);
if (displayIndex >= 0) {
return &_this->displays[displayIndex];
} else {
return NULL;
}
return displayID;
}
int SDL_SetWindowDisplayMode(SDL_Window *window, const SDL_DisplayMode *mode)
@ -1299,7 +1333,7 @@ int SDL_SetWindowDisplayMode(SDL_Window *window, const SDL_DisplayMode *mode)
if (SDL_WINDOW_FULLSCREEN_VISIBLE(window) && (window->flags & SDL_WINDOW_FULLSCREEN_EXCLUSIVE) != 0) {
SDL_DisplayMode fullscreen_mode;
if (SDL_GetWindowDisplayMode(window, &fullscreen_mode) == 0) {
if (SDL_SetDisplayModeForDisplay(SDL_GetDisplayForWindow(window), &fullscreen_mode) == 0) {
if (SDL_SetDisplayModeForDisplay(SDL_GetVideoDisplayForWindow(window), &fullscreen_mode) == 0) {
#ifndef __ANDROID__
/* Android may not resize the window to exactly what our fullscreen mode is, especially on
* windowed Android environments like the Chromebook or Samsung DeX. Given this, we shouldn't
@ -1316,7 +1350,6 @@ int SDL_SetWindowDisplayMode(SDL_Window *window, const SDL_DisplayMode *mode)
int SDL_GetWindowDisplayMode(SDL_Window *window, SDL_DisplayMode *mode)
{
SDL_DisplayMode fullscreen_mode;
SDL_VideoDisplay *display;
CHECK_WINDOW_MAGIC(window, -1);
@ -1325,6 +1358,14 @@ int SDL_GetWindowDisplayMode(SDL_Window *window, SDL_DisplayMode *mode)
return SDL_InvalidParamError("mode");
}
display = SDL_GetVideoDisplayForWindow(window);
/* if in desktop size mode, just return the size of the desktop */
if ((window->flags & SDL_WINDOW_FULLSCREEN_DESKTOP) != 0) {
*mode = display->desktop_mode;
} else {
SDL_DisplayMode fullscreen_mode;
fullscreen_mode = window->fullscreen_mode;
if (!fullscreen_mode.screen_w) {
fullscreen_mode.screen_w = window->windowed.w;
@ -1332,21 +1373,11 @@ int SDL_GetWindowDisplayMode(SDL_Window *window, SDL_DisplayMode *mode)
if (!fullscreen_mode.screen_h) {
fullscreen_mode.screen_h = window->windowed.h;
}
display = SDL_GetDisplayForWindow(window);
/* if in desktop size mode, just return the size of the desktop */
if ((window->flags & SDL_WINDOW_FULLSCREEN_DESKTOP) != 0) {
fullscreen_mode = display->desktop_mode;
} else if (!SDL_GetClosestDisplayModeForDisplay(SDL_GetDisplayForWindow(window),
&fullscreen_mode,
&fullscreen_mode)) {
if (SDL_GetClosestDisplayModeForDisplay(display, &fullscreen_mode, mode) == NULL) {
SDL_zerop(mode);
return SDL_SetError("Couldn't find display mode match");
}
*mode = fullscreen_mode;
}
return 0;
}
@ -1365,7 +1396,7 @@ Uint32 SDL_GetWindowPixelFormat(SDL_Window *window)
CHECK_WINDOW_MAGIC(window, SDL_PIXELFORMAT_UNKNOWN);
display = SDL_GetDisplayForWindow(window);
display = SDL_GetVideoDisplayForWindow(window);
return display->current_mode.format;
}
@ -1415,7 +1446,7 @@ static int SDL_UpdateFullscreenMode(SDL_Window *window, SDL_bool fullscreen)
} else if (fullscreen &&
(window->last_fullscreen_flags & SDL_WINDOW_FULLSCREEN_EXCLUSIVE) != 0 &&
(window->flags & SDL_WINDOW_FULLSCREEN_DESKTOP) != 0) {
display = SDL_GetDisplayForWindow(window);
display = SDL_GetVideoDisplayForWindow(window);
SDL_SetDisplayModeForDisplay(display, NULL);
if (_this->SetWindowFullscreen) {
_this->SetWindowFullscreen(_this, window, display, SDL_FALSE);
@ -1456,7 +1487,7 @@ static int SDL_UpdateFullscreenMode(SDL_Window *window, SDL_bool fullscreen)
}
#endif
display = SDL_GetDisplayForWindow(window);
display = SDL_GetVideoDisplayForWindow(window);
if (fullscreen) {
/* Hide any other fullscreen windows */
@ -1480,7 +1511,7 @@ static int SDL_UpdateFullscreenMode(SDL_Window *window, SDL_bool fullscreen)
if (other == window) {
setDisplayMode = fullscreen;
} else if (SDL_WINDOW_FULLSCREEN_VISIBLE(other) &&
SDL_GetDisplayForWindow(other) == display) {
SDL_GetVideoDisplayForWindow(other) == display) {
setDisplayMode = SDL_TRUE;
}
@ -1733,12 +1764,10 @@ SDL_Window *SDL_CreateWindow(const char *title, int x, int y, int w, int h, Uint
window->h = h;
if (SDL_WINDOWPOS_ISUNDEFINED(x) || SDL_WINDOWPOS_ISUNDEFINED(y) ||
SDL_WINDOWPOS_ISCENTERED(x) || SDL_WINDOWPOS_ISCENTERED(y)) {
SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
int displayIndex;
SDL_VideoDisplay *display = SDL_GetVideoDisplayForWindow(window);
SDL_Rect bounds;
displayIndex = SDL_GetIndexOfDisplay(display);
SDL_GetDisplayBounds(displayIndex, &bounds);
SDL_GetDisplayBounds(display->id, &bounds);
if (SDL_WINDOWPOS_ISUNDEFINED(x) || SDL_WINDOWPOS_ISCENTERED(x)) {
window->x = bounds.x + (bounds.w - w) / 2;
}
@ -1752,12 +1781,10 @@ SDL_Window *SDL_CreateWindow(const char *title, int x, int y, int w, int h, Uint
window->windowed.h = window->h;
if (flags & SDL_WINDOW_FULLSCREEN_MASK) {
SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
int displayIndex;
SDL_VideoDisplay *display = SDL_GetVideoDisplayForWindow(window);
SDL_Rect bounds;
displayIndex = SDL_GetIndexOfDisplay(display);
SDL_GetDisplayBounds(displayIndex, &bounds);
SDL_GetDisplayBounds(display->id, &bounds);
/* for real fullscreen we might switch the resolution, so get width and height
* from closest supported mode and use that instead of current resolution
@ -1785,7 +1812,7 @@ SDL_Window *SDL_CreateWindow(const char *title, int x, int y, int w, int h, Uint
window->opacity = 1.0f;
window->next = _this->windows;
window->is_destroying = SDL_FALSE;
window->display_index = SDL_GetWindowDisplayIndex(window);
window->displayID = SDL_GetDisplayForWindow(window);
if (_this->windows) {
_this->windows->prev = window;
@ -1891,7 +1918,7 @@ SDL_Window *SDL_CreateWindowFrom(const void *data)
return NULL;
}
window->display_index = SDL_GetWindowDisplayIndex(window);
window->displayID = SDL_GetDisplayForWindow(window);
PrepareDragAndDropSupport(window);
return window;
@ -2186,15 +2213,18 @@ void SDL_SetWindowPosition(SDL_Window *window, int x, int y)
CHECK_WINDOW_MAGIC(window, );
if (SDL_WINDOWPOS_ISCENTERED(x) || SDL_WINDOWPOS_ISCENTERED(y)) {
int displayIndex = (x & 0xFFFF);
SDL_DisplayID displayID = 0;
SDL_Rect bounds;
if (displayIndex >= _this->num_displays) {
displayIndex = 0;
if (!displayID) {
displayID = SDL_GetDisplayForWindowCoordinate(x);
}
if (!displayID) {
displayID = SDL_GetDisplayForWindowCoordinate(y);
}
SDL_zero(bounds);
SDL_GetDisplayBounds(displayIndex, &bounds);
SDL_GetDisplayBounds(displayID, &bounds);
if (SDL_WINDOWPOS_ISCENTERED(x)) {
x = bounds.x + (bounds.w - window->windowed.w) / 2;
}
@ -2230,7 +2260,7 @@ void SDL_GetWindowPosition(SDL_Window *window, int *x, int *y)
/* Fullscreen windows are always at their display's origin */
if ((window->flags & SDL_WINDOW_FULLSCREEN_MASK) != 0) {
int displayIndex;
SDL_DisplayID displayID;
if (x) {
*x = 0;
@ -2241,13 +2271,13 @@ void SDL_GetWindowPosition(SDL_Window *window, int *x, int *y)
/* Find the window's monitor and update to the
monitor offset. */
displayIndex = SDL_GetWindowDisplayIndex(window);
if (displayIndex >= 0) {
displayID = SDL_GetDisplayForWindow(window);
if (displayID != 0) {
SDL_Rect bounds;
SDL_zero(bounds);
SDL_GetDisplayBounds(displayIndex, &bounds);
SDL_GetDisplayBounds(displayID, &bounds);
if (x) {
*x = bounds.x;
}
@ -2415,7 +2445,7 @@ void SDL_GetWindowSizeInPixels(SDL_Window *window, int *w, int *h)
if (_this->GetWindowSizeInPixels) {
_this->GetWindowSizeInPixels(_this, window, w, h);
} else {
SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
SDL_VideoDisplay *display = SDL_GetVideoDisplayForWindow(window);
SDL_GetWindowSize(window, w, h);
@ -2999,10 +3029,10 @@ void SDL_OnWindowHidden(SDL_Window *window)
void SDL_CheckWindowDisplayChanged(SDL_Window *window)
{
int display_index;
SDL_DisplayID displayID;
display_index = SDL_GetWindowDisplayIndex(window);
SDL_SendWindowEvent(window, SDL_EVENT_WINDOW_DISPLAY_CHANGED, display_index, 0);
displayID = SDL_GetDisplayForWindow(window);
SDL_SendWindowEvent(window, SDL_EVENT_WINDOW_DISPLAY_CHANGED, (int)displayID, 0);
}
void SDL_OnWindowDisplayChanged(SDL_Window *window)
@ -3026,7 +3056,7 @@ void SDL_OnWindowDisplayChanged(SDL_Window *window)
* emulated mode dimensions since the window is just being scaled.
*/
if (!ModeSwitchingEmulated(_this) &&
SDL_GetDisplayBounds(window->display_index, &rect) == 0) {
SDL_GetDisplayBounds(window->displayID, &rect) == 0) {
int old_w = window->w;
int old_h = window->h;
window->x = rect.x;
@ -3238,7 +3268,7 @@ void SDL_DestroyWindow(SDL_Window *window)
_this->DestroyWindow(_this, window);
}
display = SDL_GetDisplayForWindow(window);
display = SDL_GetVideoDisplayForWindow(window);
if (display->fullscreen_window == window) {
display->fullscreen_window = NULL;
}
@ -3330,7 +3360,7 @@ void SDL_VideoQuit(void)
for (i = 0; i < _this->num_displays; ++i) {
SDL_VideoDisplay *display = &_this->displays[i];
SDL_ResetDisplayModes(i);
SDL_ResetDisplayModes(display);
SDL_free(display->desktop_mode.driverdata);
display->desktop_mode.driverdata = NULL;
SDL_free(display->driverdata);

View file

@ -72,7 +72,7 @@ static void android_egl_context_restore(SDL_Window *window)
{
if (window) {
SDL_Event event;
SDL_WindowData *data = (SDL_WindowData *)window->driverdata;
SDL_WindowData *data = window->driverdata;
if (SDL_GL_MakeCurrent(window, (SDL_GLContext)data->egl_context) < 0) {
/* The context is no longer valid, create a new one */
data->egl_context = (EGLContext)SDL_GL_CreateContext(window);
@ -89,7 +89,7 @@ static void android_egl_context_backup(SDL_Window *window)
{
if (window) {
/* Keep a copy of the EGL Context so we can try to restore it when we resume */
SDL_WindowData *data = (SDL_WindowData *)window->driverdata;
SDL_WindowData *data = window->driverdata;
data->egl_context = SDL_GL_GetCurrentContext();
/* We need to do this so the EGLSurface can be freed */
SDL_GL_MakeCurrent(window, NULL);
@ -107,7 +107,7 @@ static void android_egl_context_backup(SDL_Window *window)
void Android_PumpEvents_Blocking(_THIS)
{
SDL_VideoData *videodata = (SDL_VideoData *)_this->driverdata;
SDL_VideoData *videodata = _this->driverdata;
if (videodata->isPaused) {
SDL_bool isContextExternal = SDL_IsVideoContextExternal();
@ -182,7 +182,7 @@ void Android_PumpEvents_Blocking(_THIS)
void Android_PumpEvents_NonBlocking(_THIS)
{
SDL_VideoData *videodata = (SDL_VideoData *)_this->driverdata;
SDL_VideoData *videodata = _this->driverdata;
static int backup_context = 0;
if (videodata->isPaused) {

View file

@ -38,7 +38,7 @@
int Android_GLES_MakeCurrent(_THIS, SDL_Window *window, SDL_GLContext context)
{
if (window && context) {
return SDL_EGL_MakeCurrent(_this, ((SDL_WindowData *)window->driverdata)->egl_surface, context);
return SDL_EGL_MakeCurrent(_this, window->driverdata->egl_surface, context);
} else {
return SDL_EGL_MakeCurrent(_this, NULL, NULL);
}
@ -51,7 +51,7 @@ Android_GLES_CreateContext(_THIS, SDL_Window *window)
Android_ActivityMutex_Lock_Running();
ret = SDL_EGL_CreateContext(_this, ((SDL_WindowData *)window->driverdata)->egl_surface);
ret = SDL_EGL_CreateContext(_this, window->driverdata->egl_surface);
SDL_UnlockMutex(Android_ActivityMutex);
@ -71,7 +71,7 @@ int Android_GLES_SwapWindow(_THIS, SDL_Window *window)
/*_this->egl_data->eglWaitNative(EGL_CORE_NATIVE_ENGINE);
_this->egl_data->eglWaitGL();*/
retval = SDL_EGL_SwapBuffers(_this, ((SDL_WindowData *)window->driverdata)->egl_surface);
retval = SDL_EGL_SwapBuffers(_this, window->driverdata->egl_surface);
SDL_UnlockMutex(Android_ActivityMutex);

View file

@ -350,7 +350,7 @@ Android_IsScreenKeyboardShown(_THIS, SDL_Window *window)
void Android_StartTextInput(_THIS)
{
SDL_VideoData *videodata = (SDL_VideoData *)_this->driverdata;
SDL_VideoData *videodata = _this->driverdata;
Android_JNI_ShowTextInput(&videodata->textRect);
}
@ -361,7 +361,7 @@ void Android_StopTextInput(_THIS)
void Android_SetTextInputRect(_THIS, const SDL_Rect *rect)
{
SDL_VideoData *videodata = (SDL_VideoData *)_this->driverdata;
SDL_VideoData *videodata = _this->driverdata;
if (rect == NULL) {
SDL_InvalidParamError("rect");

View file

@ -169,8 +169,8 @@ VideoBootStrap Android_bootstrap = {
int Android_VideoInit(_THIS)
{
SDL_VideoData *videodata = (SDL_VideoData *)_this->driverdata;
int display_index;
SDL_VideoData *videodata = _this->driverdata;
SDL_DisplayID displayID;
SDL_VideoDisplay *display;
SDL_DisplayMode mode;
@ -186,11 +186,11 @@ int Android_VideoInit(_THIS)
mode.refresh_rate = Android_ScreenRate;
mode.driverdata = NULL;
display_index = SDL_AddBasicVideoDisplay(&mode);
if (display_index < 0) {
displayID = SDL_AddBasicVideoDisplay(&mode);
if (displayID == 0) {
return -1;
}
display = SDL_GetDisplay(display_index);
display = SDL_GetVideoDisplay(displayID);
display->orientation = Android_JNI_GetDisplayOrientation();
SDL_AddDisplayMode(&_this->displays[0], &mode);
@ -291,7 +291,7 @@ void Android_SendResize(SDL_Window *window)
/* Force the current mode to match the resize otherwise the SDL_EVENT_WINDOW_RESTORED event
* will fall back to the old mode */
int w, h;
SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
SDL_VideoDisplay *display = SDL_GetVideoDisplayForWindow(window);
SDL_DisplayMode current_mode;
current_mode.format = Android_ScreenFormat;

View file

@ -32,13 +32,13 @@ extern void Android_SendResize(SDL_Window *window);
/* Private display data */
typedef struct SDL_VideoData
struct SDL_VideoData
{
SDL_Rect textRect;
int isPaused;
int isPausing;
int pauseAudio;
} SDL_VideoData;
};
extern int Android_SurfaceWidth;
extern int Android_SurfaceHeight;

View file

@ -130,7 +130,7 @@ SDL_bool Android_Vulkan_CreateSurface(_THIS,
VkInstance instance,
VkSurfaceKHR *surface)
{
SDL_WindowData *windowData = (SDL_WindowData *)window->driverdata;
SDL_WindowData *windowData = window->driverdata;
PFN_vkGetInstanceProcAddr vkGetInstanceProcAddr =
(PFN_vkGetInstanceProcAddr)_this->vulkan_config.vkGetInstanceProcAddr;
PFN_vkCreateAndroidSurfaceKHR vkCreateAndroidSurfaceKHR =

View file

@ -128,7 +128,7 @@ void Android_SetWindowFullscreen(_THIS, SDL_Window *window, SDL_VideoDisplay *di
goto endfunction;
}
data = (SDL_WindowData *)window->driverdata;
data = window->driverdata;
if (data == NULL || !data->native_window) {
if (data && !data->native_window) {
SDL_SetError("Missing native window");
@ -175,7 +175,7 @@ void Android_DestroyWindow(_THIS, SDL_Window *window)
Android_Window = NULL;
if (window->driverdata) {
SDL_WindowData *data = (SDL_WindowData *)window->driverdata;
SDL_WindowData *data = window->driverdata;
#if SDL_VIDEO_OPENGL_EGL
if (data->egl_surface != EGL_NO_SURFACE) {
@ -196,7 +196,7 @@ void Android_DestroyWindow(_THIS, SDL_Window *window)
int Android_GetWindowWMInfo(_THIS, SDL_Window *window, SDL_SysWMinfo *info)
{
SDL_WindowData *data = (SDL_WindowData *)window->driverdata;
SDL_WindowData *data = window->driverdata;
info->subsystem = SDL_SYSWM_ANDROID;
info->info.android.window = data->native_window;

View file

@ -36,7 +36,7 @@ extern void Android_DestroyWindow(_THIS, SDL_Window *window);
extern int Android_GetWindowWMInfo(_THIS, SDL_Window *window, struct SDL_SysWMinfo *info);
extern SDL_Window *Android_Window;
typedef struct
struct SDL_WindowData
{
#if SDL_VIDEO_OPENGL_EGL
EGLSurface egl_surface;
@ -45,6 +45,6 @@ typedef struct
SDL_bool backup_done;
ANativeWindow *native_window;
} SDL_WindowData;
};
#endif /* SDL_androidwindow_h_ */

View file

@ -28,7 +28,7 @@
int Cocoa_SetClipboardText(_THIS, const char *text)
{
@autoreleasepool {
SDL_VideoData *data = (__bridge SDL_VideoData *)_this->driverdata;
SDL_VideoData *data = _this->driverdata;
NSPasteboard *pasteboard;
NSString *format = NSPasteboardTypeString;
NSString *nsstr = [NSString stringWithUTF8String:text];

View file

@ -35,7 +35,7 @@ static SDL_Window *FindSDLWindowForNSWindow(NSWindow *win)
SDL_VideoDevice *device = SDL_GetVideoDevice();
if (device && device->windows) {
for (sdlwindow = device->windows; sdlwindow; sdlwindow = sdlwindow->next) {
NSWindow *nswindow = ((__bridge SDL_WindowData *)sdlwindow->driverdata).nswindow;
NSWindow *nswindow = sdlwindow->driverdata.nswindow;
if (win == nswindow) {
return sdlwindow;
}
@ -557,7 +557,7 @@ void Cocoa_SendWakeupEvent(_THIS, SDL_Window *window)
location:NSMakePoint(0, 0)
modifierFlags:0
timestamp:0.0
windowNumber:((__bridge SDL_WindowData *)window->driverdata).window_number
windowNumber:window->driverdata.window_number
context:nil
subtype:0
data1:0
@ -570,7 +570,7 @@ void Cocoa_SendWakeupEvent(_THIS, SDL_Window *window)
void Cocoa_SuspendScreenSaver(_THIS)
{
@autoreleasepool {
SDL_VideoData *data = (__bridge SDL_VideoData *)_this->driverdata;
SDL_VideoData *data = _this->driverdata;
if (data.screensaver_assertion) {
IOPMAssertionRelease(data.screensaver_assertion);

View file

@ -294,7 +294,7 @@ cleanup:
void Cocoa_InitKeyboard(_THIS)
{
SDL_VideoData *data = (__bridge SDL_VideoData *)_this->driverdata;
SDL_VideoData *data = _this->driverdata;
UpdateKeymap(data, SDL_FALSE);
@ -314,11 +314,11 @@ void Cocoa_StartTextInput(_THIS)
{
@autoreleasepool {
NSView *parentView;
SDL_VideoData *data = (__bridge SDL_VideoData *)_this->driverdata;
SDL_VideoData *data = _this->driverdata;
SDL_Window *window = SDL_GetKeyboardFocus();
NSWindow *nswindow = nil;
if (window) {
nswindow = ((__bridge SDL_WindowData *)window->driverdata).nswindow;
nswindow = window->driverdata.nswindow;
}
parentView = [nswindow contentView];
@ -345,7 +345,7 @@ void Cocoa_StartTextInput(_THIS)
void Cocoa_StopTextInput(_THIS)
{
@autoreleasepool {
SDL_VideoData *data = (__bridge SDL_VideoData *)_this->driverdata;
SDL_VideoData *data = _this->driverdata;
if (data && data.fieldEdit) {
[data.fieldEdit removeFromSuperview];
@ -356,7 +356,7 @@ void Cocoa_StopTextInput(_THIS)
void Cocoa_SetTextInputRect(_THIS, const SDL_Rect *rect)
{
SDL_VideoData *data = (__bridge SDL_VideoData *)_this->driverdata;
SDL_VideoData *data = _this->driverdata;
if (!rect) {
SDL_InvalidParamError("rect");
@ -370,7 +370,7 @@ void Cocoa_HandleKeyEvent(_THIS, NSEvent *event)
{
unsigned short scancode;
SDL_Scancode code;
SDL_VideoData *data = _this ? ((__bridge SDL_VideoData *)_this->driverdata) : nil;
SDL_VideoData *data = _this ? _this->driverdata : nil;
if (!data) {
return; /* can happen when returning from fullscreen Space on shutdown */
}

View file

@ -42,7 +42,7 @@
/* Retain the NSWindow because we'll show the alert later on the main thread */
if (window) {
nswindow = ((__bridge SDL_WindowData *)window->driverdata).nswindow;
nswindow = window->driverdata.nswindow;
} else {
nswindow = nil;
}

View file

@ -133,7 +133,7 @@ SDL_MetalView
Cocoa_Metal_CreateView(_THIS, SDL_Window *window)
{
@autoreleasepool {
SDL_WindowData *data = (__bridge SDL_WindowData *)window->driverdata;
SDL_WindowData *data = window->driverdata;
NSView *view = data.nswindow.contentView;
BOOL highDPI = (window->flags & SDL_WINDOW_ALLOW_HIGHDPI) != 0;
Uint32 windowID = SDL_GetWindowID(window);

View file

@ -23,15 +23,15 @@
#ifndef SDL_cocoamodes_h_
#define SDL_cocoamodes_h_
typedef struct
struct SDL_DisplayData
{
CGDirectDisplayID display;
} SDL_DisplayData;
};
typedef struct
struct SDL_DisplayModeData
{
CFMutableArrayRef modes;
} SDL_DisplayModeData;
};
extern void Cocoa_InitModes(_THIS);
extern int Cocoa_GetDisplayBounds(_THIS, SDL_VideoDisplay *display, SDL_Rect *rect);

View file

@ -364,7 +364,7 @@ void Cocoa_InitModes(_THIS)
int Cocoa_GetDisplayBounds(_THIS, SDL_VideoDisplay *display, SDL_Rect *rect)
{
SDL_DisplayData *displaydata = (SDL_DisplayData *)display->driverdata;
SDL_DisplayData *displaydata = display->driverdata;
CGRect cgrect;
cgrect = CGDisplayBounds(displaydata->display);
@ -377,7 +377,7 @@ int Cocoa_GetDisplayBounds(_THIS, SDL_VideoDisplay *display, SDL_Rect *rect)
int Cocoa_GetDisplayUsableBounds(_THIS, SDL_VideoDisplay *display, SDL_Rect *rect)
{
SDL_DisplayData *displaydata = (SDL_DisplayData *)display->driverdata;
SDL_DisplayData *displaydata = display->driverdata;
const CGDirectDisplayID cgdisplay = displaydata->display;
NSArray *screens = [NSScreen screens];
NSScreen *screen = nil;
@ -412,7 +412,7 @@ int Cocoa_GetDisplayPhysicalDPI(_THIS, SDL_VideoDisplay *display, float *ddpi, f
@autoreleasepool {
const float MM_IN_INCH = 25.4f;
SDL_DisplayData *data = (SDL_DisplayData *)display->driverdata;
SDL_DisplayData *data = display->driverdata;
/* we need the backingScaleFactor for Retina displays, which is only exposed through NSScreen, not CGDisplay, afaik, so find our screen... */
NSArray *screens = [NSScreen screens];
@ -476,7 +476,7 @@ int Cocoa_GetDisplayPhysicalDPI(_THIS, SDL_VideoDisplay *display, float *ddpi, f
void Cocoa_GetDisplayModes(_THIS, SDL_VideoDisplay *display)
{
SDL_DisplayData *data = (SDL_DisplayData *)display->driverdata;
SDL_DisplayData *data = display->driverdata;
CVDisplayLinkRef link = NULL;
CGDisplayModeRef desktopmoderef;
SDL_DisplayMode desktopmode;
@ -571,7 +571,7 @@ static CGError SetDisplayModeForDisplay(CGDirectDisplayID display, SDL_DisplayMo
int Cocoa_SetDisplayMode(_THIS, SDL_VideoDisplay *display, SDL_DisplayMode *mode)
{
SDL_DisplayData *displaydata = (SDL_DisplayData *)display->driverdata;
SDL_DisplayData *displaydata = display->driverdata;
SDL_DisplayModeData *data = (SDL_DisplayModeData *)mode->driverdata;
CGDisplayFadeReservationToken fade_token = kCGDisplayFadeReservationInvalidToken;
CGError result;

View file

@ -219,7 +219,7 @@ static int Cocoa_ShowCursor(SDL_Cursor *cursor)
SDL_VideoDevice *device = SDL_GetVideoDevice();
SDL_Window *window = (device ? device->windows : NULL);
for (; window != NULL; window = window->next) {
SDL_WindowData *driverdata = (__bridge SDL_WindowData *)window->driverdata;
SDL_WindowData *driverdata = window->driverdata;
if (driverdata) {
[driverdata.nswindow performSelectorOnMainThread:@selector(invalidateCursorRectsForView:)
withObject:[driverdata.nswindow contentView]
@ -249,7 +249,7 @@ static int Cocoa_WarpMouseGlobal(float x, float y)
CGPoint point;
SDL_Mouse *mouse = SDL_GetMouse();
if (mouse->focus) {
SDL_WindowData *data = (__bridge SDL_WindowData *)mouse->focus->driverdata;
SDL_WindowData *data = mouse->focus->driverdata;
if ([data.listener isMovingOrFocusClickPending]) {
DLog("Postponing warp, window being moved or focused.");
[data.listener setPendingMoveX:x Y:y];
@ -317,7 +317,7 @@ static int Cocoa_SetRelativeMouseMode(SDL_bool enabled)
/* We will re-apply the non-relative mode when the window finishes being moved,
* if it is being moved right now.
*/
data = (__bridge SDL_WindowData *)window->driverdata;
data = window->driverdata;
if ([data.listener isMovingOrFocusClickPending]) {
return 0;
}
@ -398,7 +398,7 @@ static void Cocoa_HandleTitleButtonEvent(_THIS, NSEvent *event)
}
for (window = _this->windows; window; window = window->next) {
SDL_WindowData *data = (__bridge SDL_WindowData *)window->driverdata;
SDL_WindowData *data = window->driverdata;
if (data && data.nswindow == nswindow) {
switch ([event type]) {
case NSEventTypeLeftMouseDown:

View file

@ -138,7 +138,7 @@ static CVReturn DisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTimeSt
- (void)setWindow:(SDL_Window *)newWindow
{
if (self->window) {
SDL_WindowData *oldwindowdata = (__bridge SDL_WindowData *)self->window->driverdata;
SDL_WindowData *oldwindowdata = self->window->driverdata;
/* Make sure to remove us from the old window's context list, or we'll get scheduled updates from it too. */
NSMutableArray *contexts = oldwindowdata.nscontexts;
@ -150,7 +150,7 @@ static CVReturn DisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTimeSt
self->window = newWindow;
if (newWindow) {
SDL_WindowData *windowdata = (__bridge SDL_WindowData *)newWindow->driverdata;
SDL_WindowData *windowdata = newWindow->driverdata;
NSView *contentview = windowdata.sdlContentView;
/* Now sign up for scheduled updates for the new window. */
@ -253,8 +253,8 @@ void Cocoa_GL_UnloadLibrary(_THIS)
SDL_GLContext Cocoa_GL_CreateContext(_THIS, SDL_Window *window)
{
@autoreleasepool {
SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
SDL_DisplayData *displaydata = (SDL_DisplayData *)display->driverdata;
SDL_VideoDisplay *display = SDL_GetVideoDisplayForWindow(window);
SDL_DisplayData *displaydata = display->driverdata;
NSOpenGLPixelFormatAttribute attr[32];
NSOpenGLPixelFormat *fmt;
SDLOpenGLContext *context;
@ -482,7 +482,7 @@ int Cocoa_GL_SwapWindow(_THIS, SDL_Window *window)
{
@autoreleasepool {
SDLOpenGLContext *nscontext = (__bridge SDLOpenGLContext *)SDL_GL_GetCurrentContext();
SDL_VideoData *videodata = (__bridge SDL_VideoData *)_this->driverdata;
SDL_VideoData *videodata = _this->driverdata;
const int setting = SDL_AtomicGet(&nscontext->swapIntervalSetting);
if (setting == 0) {

View file

@ -62,7 +62,7 @@ Cocoa_GLES_CreateContext(_THIS, SDL_Window *window)
{
@autoreleasepool {
SDL_GLContext context;
SDL_WindowData *data = (__bridge SDL_WindowData *)window->driverdata;
SDL_WindowData *data = window->driverdata;
#if SDL_VIDEO_OPENGL_CGL
if (_this->gl_config.profile_mask != SDL_GL_CONTEXT_PROFILE_ES) {
@ -103,14 +103,14 @@ void Cocoa_GLES_DeleteContext(_THIS, SDL_GLContext context)
int Cocoa_GLES_SwapWindow(_THIS, SDL_Window *window)
{
@autoreleasepool {
return SDL_EGL_SwapBuffers(_this, ((__bridge SDL_WindowData *)window->driverdata).egl_surface);
return SDL_EGL_SwapBuffers(_this, window->driverdata.egl_surface);
}
}
int Cocoa_GLES_MakeCurrent(_THIS, SDL_Window *window, SDL_GLContext context)
{
@autoreleasepool {
return SDL_EGL_MakeCurrent(_this, window ? ((__bridge SDL_WindowData *)window->driverdata).egl_surface : EGL_NO_SURFACE, context);
return SDL_EGL_MakeCurrent(_this, window ? window->driverdata.egl_surface : EGL_NO_SURFACE, context);
}
}
@ -119,7 +119,7 @@ int Cocoa_GLES_SetupWindow(_THIS, SDL_Window *window)
@autoreleasepool {
NSView *v;
/* The current context is lost in here; save it and reset it. */
SDL_WindowData *windowdata = (__bridge SDL_WindowData *)window->driverdata;
SDL_WindowData *windowdata = window->driverdata;
SDL_Window *current_win = SDL_GL_GetCurrentWindow();
SDL_GLContext current_ctx = SDL_GL_GetCurrentContext();
@ -151,7 +151,7 @@ SDL_EGLSurface
Cocoa_GLES_GetEGLSurface(_THIS, SDL_Window *window)
{
@autoreleasepool {
return ((__bridge SDL_WindowData *)window->driverdata).egl_surface;
return window->driverdata.egl_surface;
}
}

View file

@ -45,7 +45,7 @@ Cocoa_CreateShaper(SDL_Window *window)
SDL_WindowShaper *result;
SDL_ShapeData *data;
int resized_properly;
SDL_WindowData *windata = (__bridge SDL_WindowData *)window->driverdata;
SDL_WindowData *windata = window->driverdata;
result = (SDL_WindowShaper *)SDL_malloc(sizeof(SDL_WindowShaper));
if (!result) {
@ -90,7 +90,7 @@ int Cocoa_SetWindowShape(SDL_WindowShaper *shaper, SDL_Surface *shape, SDL_Windo
{
@autoreleasepool {
SDL_ShapeData *data = (__bridge SDL_ShapeData *)shaper->driverdata;
SDL_WindowData *windata = (__bridge SDL_WindowData *)shaper->window->driverdata;
SDL_WindowData *windata = shaper->window->driverdata;
SDL_CocoaClosure *closure;
if (data.saved == SDL_TRUE) {
[data.context restoreGraphicsState];

View file

@ -48,7 +48,7 @@ static void Cocoa_DeleteDevice(SDL_VideoDevice *device)
if (device->wakeup_lock) {
SDL_DestroyMutex(device->wakeup_lock);
}
CFBridgingRelease(device->driverdata);
device->driverdata = nil;
SDL_free(device);
}
}
@ -73,7 +73,7 @@ static SDL_VideoDevice *Cocoa_CreateDevice(void)
SDL_free(device);
return NULL;
}
device->driverdata = (void *)CFBridgingRetain(data);
device->driverdata = data;
device->wakeup_lock = SDL_CreateMutex();
/* Set the function pointers */
@ -110,7 +110,7 @@ static SDL_VideoDevice *Cocoa_CreateDevice(void)
device->SetWindowAlwaysOnTop = Cocoa_SetWindowAlwaysOnTop;
device->SetWindowFullscreen = Cocoa_SetWindowFullscreen;
device->GetWindowICCProfile = Cocoa_GetWindowICCProfile;
device->GetWindowDisplayIndex = Cocoa_GetWindowDisplayIndex;
device->GetDisplayForWindow = Cocoa_GetDisplayForWindow;
device->SetWindowMouseRect = Cocoa_SetWindowMouseRect;
device->SetWindowMouseGrab = Cocoa_SetWindowMouseGrab;
device->SetWindowKeyboardGrab = Cocoa_SetWindowKeyboardGrab;
@ -190,7 +190,7 @@ VideoBootStrap COCOA_bootstrap = {
int Cocoa_VideoInit(_THIS)
{
@autoreleasepool {
SDL_VideoData *data = (__bridge SDL_VideoData *)_this->driverdata;
SDL_VideoData *data = _this->driverdata;
Cocoa_InitModes(_this);
Cocoa_InitKeyboard(_this);
@ -213,7 +213,7 @@ int Cocoa_VideoInit(_THIS)
void Cocoa_VideoQuit(_THIS)
{
@autoreleasepool {
SDL_VideoData *data = (__bridge SDL_VideoData *)_this->driverdata;
SDL_VideoData *data = _this->driverdata;
Cocoa_QuitModes(_this);
Cocoa_QuitKeyboard(_this);
Cocoa_QuitMouse(_this);

View file

@ -262,7 +262,7 @@ SDL_bool Cocoa_Vulkan_CreateSurface(_THIS,
if (window->flags & SDL_WINDOW_FOREIGN) {
@autoreleasepool {
SDL_WindowData *data = (__bridge SDL_WindowData *)window->driverdata;
SDL_WindowData *data = window->driverdata;
if (![data.sdlContentView.layer isKindOfClass:[CAMetalLayer class]]) {
[data.sdlContentView setLayer:[CAMetalLayer layer]];
}

View file

@ -160,7 +160,7 @@ extern void Cocoa_SetWindowResizable(_THIS, SDL_Window *window, SDL_bool resizab
extern void Cocoa_SetWindowAlwaysOnTop(_THIS, SDL_Window *window, SDL_bool on_top);
extern void Cocoa_SetWindowFullscreen(_THIS, SDL_Window *window, SDL_VideoDisplay *display, SDL_bool fullscreen);
extern void *Cocoa_GetWindowICCProfile(_THIS, SDL_Window *window, size_t *size);
extern int Cocoa_GetWindowDisplayIndex(_THIS, SDL_Window *window);
extern SDL_DisplayID Cocoa_GetDisplayForWindow(_THIS, SDL_Window *window);
extern void Cocoa_SetWindowMouseRect(_THIS, SDL_Window *window);
extern void Cocoa_SetWindowMouseGrab(_THIS, SDL_Window *window, SDL_bool grabbed);
extern void Cocoa_DestroyWindow(_THIS, SDL_Window *window);

View file

@ -239,7 +239,7 @@
/* !!! FIXME: is there a better way to do this? */
if (_this) {
for (sdlwindow = _this->windows; sdlwindow; sdlwindow = sdlwindow->next) {
NSWindow *nswindow = ((__bridge SDL_WindowData *)sdlwindow->driverdata).nswindow;
NSWindow *nswindow = sdlwindow->driverdata.nswindow;
if (nswindow == self) {
break;
}
@ -333,7 +333,7 @@ static NSUInteger GetWindowStyle(SDL_Window *window)
static SDL_bool SetWindowStyle(SDL_Window *window, NSUInteger style)
{
SDL_WindowData *data = (__bridge SDL_WindowData *)window->driverdata;
SDL_WindowData *data = window->driverdata;
NSWindow *nswindow = data.nswindow;
/* The view responder chain gets messed with during setStyleMask */
@ -353,7 +353,7 @@ static SDL_bool SetWindowStyle(SDL_Window *window, NSUInteger style)
static SDL_bool ShouldAdjustCoordinatesForGrab(SDL_Window *window)
{
SDL_WindowData *data = (__bridge SDL_WindowData *)window->driverdata;
SDL_WindowData *data = window->driverdata;
if (!data || [data.listener isMovingOrFocusClickPending]) {
return SDL_FALSE;
@ -410,7 +410,7 @@ static SDL_bool AdjustCoordinatesForGrab(SDL_Window *window, float x, float y, C
static void Cocoa_UpdateClipCursor(SDL_Window *window)
{
SDL_WindowData *data = (__bridge SDL_WindowData *)window->driverdata;
SDL_WindowData *data = window->driverdata;
if (NSAppKitVersionNumber >= NSAppKitVersionNumber10_13_2) {
NSWindow *nswindow = data.nswindow;
@ -564,7 +564,7 @@ static void Cocoa_UpdateClipCursor(SDL_Window *window)
{
SDL_Window *window = _data.window;
NSWindow *nswindow = _data.nswindow;
SDL_VideoData *videodata = ((__bridge SDL_WindowData *)window->driverdata).videodata;
SDL_VideoData *videodata = window->driverdata.videodata;
if (!videodata.allow_spaces) {
return NO; /* Spaces are forcibly disabled. */
@ -1198,7 +1198,7 @@ static int Cocoa_SendMouseButtonClicks(SDL_Mouse *mouse, NSEvent *theEvent, SDL_
// the position in the currently-focused window. We don't (currently) send a mousemove
// event for the background window, this just makes sure the button is reported at the
// correct position in its own event.
if (focus && ([theEvent window] == ((__bridge SDL_WindowData *)focus->driverdata).nswindow)) {
if (focus && ([theEvent window] == focus->driverdata.nswindow)) {
rc = SDL_SendMouseButtonClicks(Cocoa_GetEventTimestamp([theEvent timestamp]), window, mouseID, state, button, clicks);
} else {
const int orig_x = mouse->x;
@ -1384,7 +1384,7 @@ static int Cocoa_SendMouseButtonClicks(SDL_Mouse *mouse, NSEvent *theEvent, SDL_
- (BOOL)isTouchFromTrackpad:(NSEvent *)theEvent
{
SDL_Window *window = _data.window;
SDL_VideoData *videodata = ((__bridge SDL_WindowData *)window->driverdata).videodata;
SDL_VideoData *videodata = window->driverdata.videodata;
/* if this a MacBook trackpad, we'll make input look like a synthesized
event. This is backwards from reality, but better matches user
@ -1573,7 +1573,7 @@ static int Cocoa_SendMouseButtonClicks(SDL_Mouse *mouse, NSEvent *theEvent, SDL_
white until the app is ready to draw. In practice on modern macOS, this
only gets called for window creation and other extraordinary events. */
self.layer.backgroundColor = CGColorGetConstantColor(kCGColorBlack);
ScheduleContextUpdates((__bridge SDL_WindowData *)_sdlWindow->driverdata);
ScheduleContextUpdates(_sdlWindow->driverdata);
SDL_SendWindowEvent(_sdlWindow, SDL_EVENT_WINDOW_EXPOSED, 0, 0);
}
@ -1618,7 +1618,7 @@ static int Cocoa_SendMouseButtonClicks(SDL_Mouse *mouse, NSEvent *theEvent, SDL_
static int SetupWindowData(_THIS, SDL_Window *window, NSWindow *nswindow, NSView *nsview, SDL_bool created)
{
@autoreleasepool {
SDL_VideoData *videodata = (__bridge SDL_VideoData *)_this->driverdata;
SDL_VideoData *videodata = _this->driverdata;
SDL_WindowData *data;
/* Allocate the window data */
@ -1705,7 +1705,7 @@ static int SetupWindowData(_THIS, SDL_Window *window, NSWindow *nswindow, NSView
[nswindow setOneShot:NO];
/* All done! */
window->driverdata = (void *)CFBridgingRetain(data);
window->driverdata = data;
return 0;
}
}
@ -1713,9 +1713,9 @@ static int SetupWindowData(_THIS, SDL_Window *window, NSWindow *nswindow, NSView
int Cocoa_CreateWindow(_THIS, SDL_Window *window)
{
@autoreleasepool {
SDL_VideoData *videodata = (__bridge SDL_VideoData *)_this->driverdata;
SDL_VideoData *videodata = _this->driverdata;
NSWindow *nswindow;
SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
SDL_VideoDisplay *display = SDL_GetVideoDisplayForWindow(window);
NSRect rect;
BOOL fullscreen;
SDL_Rect bounds;
@ -1882,7 +1882,7 @@ void Cocoa_SetWindowTitle(_THIS, SDL_Window *window)
{
@autoreleasepool {
const char *title = window->title ? window->title : "";
NSWindow *nswindow = ((__bridge SDL_WindowData *)window->driverdata).nswindow;
NSWindow *nswindow = window->driverdata.nswindow;
NSString *string = [[NSString alloc] initWithUTF8String:title];
[nswindow setTitle:string];
}
@ -1902,7 +1902,7 @@ void Cocoa_SetWindowIcon(_THIS, SDL_Window *window, SDL_Surface *icon)
void Cocoa_SetWindowPosition(_THIS, SDL_Window *window)
{
@autoreleasepool {
SDL_WindowData *windata = (__bridge SDL_WindowData *)window->driverdata;
SDL_WindowData *windata = window->driverdata;
NSWindow *nswindow = windata.nswindow;
NSRect rect;
BOOL fullscreen;
@ -1927,7 +1927,7 @@ void Cocoa_SetWindowPosition(_THIS, SDL_Window *window)
void Cocoa_SetWindowSize(_THIS, SDL_Window *window)
{
@autoreleasepool {
SDL_WindowData *windata = (__bridge SDL_WindowData *)window->driverdata;
SDL_WindowData *windata = window->driverdata;
NSWindow *nswindow = windata.nswindow;
NSRect rect;
BOOL fullscreen;
@ -1956,7 +1956,7 @@ void Cocoa_SetWindowSize(_THIS, SDL_Window *window)
void Cocoa_SetWindowMinimumSize(_THIS, SDL_Window *window)
{
@autoreleasepool {
SDL_WindowData *windata = (__bridge SDL_WindowData *)window->driverdata;
SDL_WindowData *windata = window->driverdata;
NSSize minSize;
minSize.width = window->min_w;
@ -1969,7 +1969,7 @@ void Cocoa_SetWindowMinimumSize(_THIS, SDL_Window *window)
void Cocoa_SetWindowMaximumSize(_THIS, SDL_Window *window)
{
@autoreleasepool {
SDL_WindowData *windata = (__bridge SDL_WindowData *)window->driverdata;
SDL_WindowData *windata = window->driverdata;
NSSize maxSize;
maxSize.width = window->max_w;
@ -1982,7 +1982,7 @@ void Cocoa_SetWindowMaximumSize(_THIS, SDL_Window *window)
void Cocoa_GetWindowSizeInPixels(_THIS, SDL_Window *window, int *w, int *h)
{
@autoreleasepool {
SDL_WindowData *windata = (__bridge SDL_WindowData *)window->driverdata;
SDL_WindowData *windata = window->driverdata;
NSView *contentView = windata.sdlContentView;
NSRect viewport = [contentView bounds];
@ -1999,7 +1999,7 @@ void Cocoa_GetWindowSizeInPixels(_THIS, SDL_Window *window, int *w, int *h)
void Cocoa_ShowWindow(_THIS, SDL_Window *window)
{
@autoreleasepool {
SDL_WindowData *windowData = ((__bridge SDL_WindowData *)window->driverdata);
SDL_WindowData *windowData = window->driverdata;
NSWindow *nswindow = windowData.nswindow;
if (![nswindow isMiniaturized]) {
@ -2013,7 +2013,7 @@ void Cocoa_ShowWindow(_THIS, SDL_Window *window)
void Cocoa_HideWindow(_THIS, SDL_Window *window)
{
@autoreleasepool {
NSWindow *nswindow = ((__bridge SDL_WindowData *)window->driverdata).nswindow;
NSWindow *nswindow = window->driverdata.nswindow;
[nswindow orderOut:nil];
}
@ -2022,7 +2022,7 @@ void Cocoa_HideWindow(_THIS, SDL_Window *window)
void Cocoa_RaiseWindow(_THIS, SDL_Window *window)
{
@autoreleasepool {
SDL_WindowData *windowData = ((__bridge SDL_WindowData *)window->driverdata);
SDL_WindowData *windowData = window->driverdata;
NSWindow *nswindow = windowData.nswindow;
/* makeKeyAndOrderFront: has the side-effect of deminiaturizing and showing
@ -2040,7 +2040,7 @@ void Cocoa_RaiseWindow(_THIS, SDL_Window *window)
void Cocoa_MaximizeWindow(_THIS, SDL_Window *window)
{
@autoreleasepool {
SDL_WindowData *windata = (__bridge SDL_WindowData *)window->driverdata;
SDL_WindowData *windata = window->driverdata;
NSWindow *nswindow = windata.nswindow;
[nswindow zoom:nil];
@ -2052,7 +2052,7 @@ void Cocoa_MaximizeWindow(_THIS, SDL_Window *window)
void Cocoa_MinimizeWindow(_THIS, SDL_Window *window)
{
@autoreleasepool {
SDL_WindowData *data = (__bridge SDL_WindowData *)window->driverdata;
SDL_WindowData *data = window->driverdata;
NSWindow *nswindow = data.nswindow;
if ([data.listener isInFullscreenSpaceTransition]) {
[data.listener addPendingWindowOperation:PENDING_OPERATION_MINIMIZE];
@ -2065,7 +2065,7 @@ void Cocoa_MinimizeWindow(_THIS, SDL_Window *window)
void Cocoa_RestoreWindow(_THIS, SDL_Window *window)
{
@autoreleasepool {
NSWindow *nswindow = ((__bridge SDL_WindowData *)window->driverdata).nswindow;
NSWindow *nswindow = window->driverdata.nswindow;
if ([nswindow isMiniaturized]) {
[nswindow deminiaturize:nil];
@ -2093,7 +2093,7 @@ void Cocoa_SetWindowResizable(_THIS, SDL_Window *window, SDL_bool resizable)
* The window will get permanently stuck if resizable is false.
* -flibit
*/
SDL_WindowData *data = (__bridge SDL_WindowData *)window->driverdata;
SDL_WindowData *data = window->driverdata;
Cocoa_WindowListener *listener = data.listener;
NSWindow *nswindow = data.nswindow;
SDL_VideoData *videodata = data.videodata;
@ -2114,7 +2114,7 @@ void Cocoa_SetWindowResizable(_THIS, SDL_Window *window, SDL_bool resizable)
void Cocoa_SetWindowAlwaysOnTop(_THIS, SDL_Window *window, SDL_bool on_top)
{
@autoreleasepool {
NSWindow *nswindow = ((__bridge SDL_WindowData *)window->driverdata).nswindow;
NSWindow *nswindow = window->driverdata.nswindow;
if (on_top) {
[nswindow setLevel:NSFloatingWindowLevel];
} else {
@ -2126,7 +2126,7 @@ void Cocoa_SetWindowAlwaysOnTop(_THIS, SDL_Window *window, SDL_bool on_top)
void Cocoa_SetWindowFullscreen(_THIS, SDL_Window *window, SDL_VideoDisplay *display, SDL_bool fullscreen)
{
@autoreleasepool {
SDL_WindowData *data = (__bridge SDL_WindowData *)window->driverdata;
SDL_WindowData *data = window->driverdata;
NSWindow *nswindow = data.nswindow;
NSRect rect;
@ -2216,7 +2216,7 @@ void *
Cocoa_GetWindowICCProfile(_THIS, SDL_Window *window, size_t *size)
{
@autoreleasepool {
SDL_WindowData *data = (__bridge SDL_WindowData *)window->driverdata;
SDL_WindowData *data = window->driverdata;
NSWindow *nswindow = data.nswindow;
NSScreen *screen = [nswindow screen];
NSData *iccProfileData = nil;
@ -2250,17 +2250,17 @@ Cocoa_GetWindowICCProfile(_THIS, SDL_Window *window, size_t *size)
}
}
int Cocoa_GetWindowDisplayIndex(_THIS, SDL_Window *window)
SDL_DisplayID Cocoa_GetDisplayForWindow(_THIS, SDL_Window *window)
{
@autoreleasepool {
NSScreen *screen;
SDL_WindowData *data = (__bridge SDL_WindowData *)window->driverdata;
SDL_WindowData *data = window->driverdata;
/* Not recognized via CHECK_WINDOW_MAGIC */
if (data == nil) {
/* Don't set the error here, it hides other errors and is ignored anyway */
/*return SDL_SetError("Window data not set");*/
return -1;
return 0;
}
/* NSWindow.screen may be nil when the window is off-screen. */
@ -2274,18 +2274,15 @@ int Cocoa_GetWindowDisplayIndex(_THIS, SDL_Window *window)
displayid = [[screen.deviceDescription objectForKey:@"NSScreenNumber"] unsignedIntValue];
for (i = 0; i < _this->num_displays; i++) {
SDL_DisplayData *displaydata = (SDL_DisplayData *)_this->displays[i].driverdata;
SDL_DisplayData *displaydata = _this->displays[i].driverdata;
if (displaydata != NULL && displaydata->display == displayid) {
return i;
return _this->displays[i].id;
}
}
}
/* Other code may expect SDL_GetWindowDisplayIndex to always return a valid
* index for a window. The higher level GetWindowDisplayIndex code will fall
* back to a generic position-based query if the backend implementation
* fails. */
return SDL_SetError("Couldn't find the display where the window is located.");
/* The higher level code will use other logic to find the display */
return 0;
}
}
@ -2297,7 +2294,7 @@ void Cocoa_SetWindowMouseRect(_THIS, SDL_Window *window)
void Cocoa_SetWindowMouseGrab(_THIS, SDL_Window *window, SDL_bool grabbed)
{
@autoreleasepool {
SDL_WindowData *data = (__bridge SDL_WindowData *)window->driverdata;
SDL_WindowData *data = window->driverdata;
Cocoa_UpdateClipCursor(window);
@ -2318,7 +2315,7 @@ void Cocoa_SetWindowMouseGrab(_THIS, SDL_Window *window, SDL_bool grabbed)
void Cocoa_DestroyWindow(_THIS, SDL_Window *window)
{
@autoreleasepool {
SDL_WindowData *data = (SDL_WindowData *)CFBridgingRelease(window->driverdata);
SDL_WindowData *data = window->driverdata;
if (data) {
#if SDL_VIDEO_OPENGL
@ -2354,14 +2351,14 @@ void Cocoa_DestroyWindow(_THIS, SDL_Window *window)
window->shaper = NULL;
}
}
window->driverdata = NULL;
window->driverdata = nil;
}
}
int Cocoa_GetWindowWMInfo(_THIS, SDL_Window *window, SDL_SysWMinfo *info)
{
@autoreleasepool {
NSWindow *nswindow = ((__bridge SDL_WindowData *)window->driverdata).nswindow;
NSWindow *nswindow = window->driverdata.nswindow;
info->subsystem = SDL_SYSWM_COCOA;
info->info.cocoa.window = nswindow;
@ -2373,7 +2370,7 @@ SDL_bool
Cocoa_IsWindowInFullscreenSpace(SDL_Window *window)
{
@autoreleasepool {
SDL_WindowData *data = (__bridge SDL_WindowData *)window->driverdata;
SDL_WindowData *data = window->driverdata;
if ([data.listener isInFullscreenSpace]) {
return SDL_TRUE;
@ -2388,7 +2385,7 @@ Cocoa_SetWindowFullscreenSpace(SDL_Window *window, SDL_bool state)
{
@autoreleasepool {
SDL_bool succeeded = SDL_FALSE;
SDL_WindowData *data = (__bridge SDL_WindowData *)window->driverdata;
SDL_WindowData *data = window->driverdata;
if (data.inWindowFullscreenTransition) {
return SDL_FALSE;
@ -2437,7 +2434,7 @@ int Cocoa_SetWindowHitTest(SDL_Window *window, SDL_bool enabled)
void Cocoa_AcceptDragAndDrop(SDL_Window *window, SDL_bool accept)
{
@autoreleasepool {
SDL_WindowData *data = (__bridge SDL_WindowData *)window->driverdata;
SDL_WindowData *data = window->driverdata;
if (accept) {
[data.nswindow registerForDraggedTypes:[NSArray arrayWithObject:(NSString *)kUTTypeFileURL]];
} else {
@ -2450,7 +2447,7 @@ int Cocoa_FlashWindow(_THIS, SDL_Window *window, SDL_FlashOperation operation)
{
@autoreleasepool {
/* Note that this is app-wide and not window-specific! */
SDL_WindowData *data = (__bridge SDL_WindowData *)window->driverdata;
SDL_WindowData *data = window->driverdata;
if (data.flash_request) {
[NSApp cancelUserAttentionRequest:data.flash_request];
@ -2477,7 +2474,7 @@ int Cocoa_FlashWindow(_THIS, SDL_Window *window, SDL_FlashOperation operation)
int Cocoa_SetWindowOpacity(_THIS, SDL_Window *window, float opacity)
{
@autoreleasepool {
SDL_WindowData *data = (__bridge SDL_WindowData *)window->driverdata;
SDL_WindowData *data = window->driverdata;
[data.nswindow setAlphaValue:opacity];
return 0;
}

View file

@ -843,7 +843,7 @@ static EM_BOOL Emscripten_HandleFullscreenChange(int eventType, const Emscripten
window_data->window->flags &= ~SDL_WINDOW_FULLSCREEN_MASK;
/* reset fullscreen window if the browser left fullscreen */
display = SDL_GetDisplayForWindow(window_data->window);
display = SDL_GetVideoDisplayForWindow(window_data->window);
if (display->fullscreen_window == window_data->window) {
display->fullscreen_window = NULL;

View file

@ -24,13 +24,8 @@
#include "SDL_emscriptenvideo.h"
extern void
Emscripten_RegisterEventHandlers(SDL_WindowData *data);
extern void
Emscripten_UnregisterEventHandlers(SDL_WindowData *data);
extern EM_BOOL
Emscripten_HandleCanvasResize(int eventType, const void *reserved, void *userData);
extern void Emscripten_RegisterEventHandlers(SDL_WindowData *data);
extern void Emscripten_UnregisterEventHandlers(SDL_WindowData *data);
extern EM_BOOL Emscripten_HandleCanvasResize(int eventType, const void *reserved, void *userData);
#endif /* SDL_emscriptenevents_h_ */

View file

@ -34,7 +34,7 @@ int Emscripten_CreateWindowFramebuffer(_THIS, SDL_Window *window, Uint32 *format
int w, h;
/* Free the old framebuffer surface */
SDL_WindowData *data = (SDL_WindowData *)window->driverdata;
SDL_WindowData *data = window->driverdata;
surface = data->surface;
SDL_DestroySurface(surface);
@ -58,7 +58,7 @@ int Emscripten_UpdateWindowFramebuffer(_THIS, SDL_Window *window, const SDL_Rect
{
SDL_Surface *surface;
SDL_WindowData *data = (SDL_WindowData *)window->driverdata;
SDL_WindowData *data = window->driverdata;
surface = data->surface;
if (surface == NULL) {
return SDL_SetError("Couldn't find framebuffer surface for window");
@ -152,7 +152,7 @@ int Emscripten_UpdateWindowFramebuffer(_THIS, SDL_Window *window, const SDL_Rect
void Emscripten_DestroyWindowFramebuffer(_THIS, SDL_Window *window)
{
SDL_WindowData *data = (SDL_WindowData *)window->driverdata;
SDL_WindowData *data = window->driverdata;
SDL_DestroySurface(data->surface);
data->surface = NULL;

View file

@ -216,7 +216,7 @@ static int Emscripten_SetRelativeMouseMode(SDL_bool enabled)
return -1;
}
window_data = (SDL_WindowData *)window->driverdata;
window_data = window->driverdata;
if (emscripten_request_pointerlock(window_data->canvas_id, 1) >= EMSCRIPTEN_RESULT_SUCCESS) {
return 0;

View file

@ -88,7 +88,7 @@ SDL_GLContext Emscripten_GLES_CreateContext(_THIS, SDL_Window *window)
if (_this->gl_config.major_version == 3)
attribs.majorVersion = 2; /* WebGL 2.0 ~= GLES 3.0 */
window_data = (SDL_WindowData *)window->driverdata;
window_data = window->driverdata;
if (window_data->gl_context) {
SDL_SetError("Cannot create multiple webgl contexts per window");
@ -118,8 +118,7 @@ void Emscripten_GLES_DeleteContext(_THIS, SDL_GLContext context)
/* remove the context from its window */
for (window = _this->windows; window != NULL; window = window->next) {
SDL_WindowData *window_data;
window_data = (SDL_WindowData *)window->driverdata;
SDL_WindowData *window_data = window->driverdata;
if (window_data->gl_context == context) {
window_data->gl_context = NULL;
@ -142,8 +141,7 @@ int Emscripten_GLES_MakeCurrent(_THIS, SDL_Window *window, SDL_GLContext context
{
/* it isn't possible to reuse contexts across canvases */
if (window && context) {
SDL_WindowData *window_data;
window_data = (SDL_WindowData *)window->driverdata;
SDL_WindowData *window_data = window->driverdata;
if (context != window_data->gl_context) {
return SDL_SetError("Cannot make context current to another window");

View file

@ -267,7 +267,7 @@ static void Emscripten_SetWindowSize(_THIS, SDL_Window *window)
SDL_WindowData *data;
if (window->driverdata) {
data = (SDL_WindowData *)window->driverdata;
data = window->driverdata;
/* update pixel ratio */
if (window->flags & SDL_WINDOW_ALLOW_HIGHDPI) {
data->pixel_ratio = emscripten_get_device_pixel_ratio();
@ -285,7 +285,7 @@ static void Emscripten_GetWindowSizeInPixels(_THIS, SDL_Window *window, int *w,
{
SDL_WindowData *data;
if (window->driverdata) {
data = (SDL_WindowData *)window->driverdata;
data = window->driverdata;
*w = window->w * data->pixel_ratio;
*h = window->h * data->pixel_ratio;
}
@ -296,7 +296,7 @@ static void Emscripten_DestroyWindow(_THIS, SDL_Window *window)
SDL_WindowData *data;
if (window->driverdata) {
data = (SDL_WindowData *)window->driverdata;
data = window->driverdata;
Emscripten_UnregisterEventHandlers(data);
@ -313,7 +313,7 @@ static void Emscripten_SetWindowFullscreen(_THIS, SDL_Window *window, SDL_VideoD
{
SDL_WindowData *data;
if (window->driverdata) {
data = (SDL_WindowData *)window->driverdata;
data = window->driverdata;
if (fullscreen) {
EmscriptenFullscreenStrategy strategy;

View file

@ -28,7 +28,7 @@
#include <emscripten/emscripten.h>
#include <emscripten/html5.h>
typedef struct SDL_WindowData
struct SDL_WindowData
{
SDL_Window *window;
SDL_Surface *surface;
@ -45,6 +45,6 @@ typedef struct SDL_WindowData
SDL_bool fullscreen_resize;
SDL_bool has_pointer_lock;
} SDL_WindowData;
};
#endif /* SDL_emscriptenvideo_h_ */

View file

@ -57,7 +57,6 @@ static SDL_INLINE SDL_BWin *_ToBeWin(SDL_Window *window) {
static SDL_VideoDevice * HAIKU_CreateDevice(void)
{
SDL_VideoDevice *device;
/*SDL_VideoData *data;*/
/* Initialize all variables that we clean on shutdown */
device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice));

View file

@ -63,7 +63,7 @@ static SDL_Cursor *KMSDRM_CreateDefaultCursor(void)
destroy the driverdata for the window's display. */
void KMSDRM_DestroyCursorBO(_THIS, SDL_VideoDisplay *display)
{
SDL_DisplayData *dispdata = (SDL_DisplayData *)display->driverdata;
SDL_DisplayData *dispdata = display->driverdata;
/* Destroy the curso GBM BO. */
if (dispdata->cursor_bo) {
@ -80,8 +80,8 @@ void KMSDRM_CreateCursorBO(SDL_VideoDisplay *display)
{
SDL_VideoDevice *dev = SDL_GetVideoDevice();
SDL_VideoData *viddata = ((SDL_VideoData *)dev->driverdata);
SDL_DisplayData *dispdata = (SDL_DisplayData *)display->driverdata;
SDL_VideoData *viddata = dev->driverdata;
SDL_DisplayData *dispdata = display->driverdata;
if (!KMSDRM_gbm_device_is_format_supported(viddata->gbm_dev,
GBM_FORMAT_ARGB8888,
@ -119,9 +119,9 @@ void KMSDRM_CreateCursorBO(SDL_VideoDisplay *display)
static int KMSDRM_RemoveCursorFromBO(SDL_VideoDisplay *display)
{
int ret = 0;
SDL_DisplayData *dispdata = (SDL_DisplayData *)display->driverdata;
SDL_DisplayData *dispdata = display->driverdata;
SDL_VideoDevice *video_device = SDL_GetVideoDevice();
SDL_VideoData *viddata = ((SDL_VideoData *)video_device->driverdata);
SDL_VideoData *viddata = video_device->driverdata;
ret = KMSDRM_drmModeSetCursor(viddata->drm_fd,
dispdata->crtc->crtc_id, 0, 0, 0);
@ -136,10 +136,10 @@ static int KMSDRM_RemoveCursorFromBO(SDL_VideoDisplay *display)
/* Dump a cursor buffer to a display's DRM cursor BO. */
static int KMSDRM_DumpCursorToBO(SDL_VideoDisplay *display, SDL_Cursor *cursor)
{
SDL_DisplayData *dispdata = (SDL_DisplayData *)display->driverdata;
SDL_DisplayData *dispdata = display->driverdata;
KMSDRM_CursorData *curdata = (KMSDRM_CursorData *)cursor->driverdata;
SDL_VideoDevice *video_device = SDL_GetVideoDevice();
SDL_VideoData *viddata = ((SDL_VideoData *)video_device->driverdata);
SDL_VideoData *viddata = video_device->driverdata;
uint32_t bo_handle;
size_t bo_stride;
@ -302,7 +302,7 @@ static int KMSDRM_ShowCursor(SDL_Cursor *cursor)
SDL_Window *window;
SDL_Mouse *mouse;
int num_displays, i;
int i;
int ret = 0;
/* Get the mouse focused window, if any. */
@ -315,33 +315,28 @@ static int KMSDRM_ShowCursor(SDL_Cursor *cursor)
window = mouse->focus;
if (window == NULL || cursor == NULL) {
/* If no window is focused by mouse or cursor is NULL,
since we have no window (no mouse->focus) and hence
we have no display, we simply hide mouse on all displays.
This happens on video quit, where we get here after
the mouse focus has been unset, yet SDL wants to
restore the system default cursor (makes no sense here). */
num_displays = SDL_GetNumVideoDisplays();
/* Iterate on the displays hidding the cursor. */
for (i = 0; i < num_displays; i++) {
display = SDL_GetDisplay(i);
SDL_DisplayID *displays = SDL_GetDisplays(NULL);
if (displays) {
/* Iterate on the displays, hiding the cursor. */
for (i = 0; i < displays[i]; i++) {
display = SDL_GetVideoDisplay(displays[i]);
ret = KMSDRM_RemoveCursorFromBO(display);
}
SDL_free(displays);
}
} else {
display = SDL_GetDisplayForWindow(window);
display = SDL_GetVideoDisplayForWindow(window);
if (display) {
if (cursor) {
/* Dump the cursor to the display DRM cursor BO so it becomes visible
on that display. */
ret = KMSDRM_DumpCursorToBO(display, cursor);
} else {
/* Hide the cursor on that display. */
ret = KMSDRM_RemoveCursorFromBO(display);
@ -359,7 +354,7 @@ static int KMSDRM_WarpMouseGlobal(float x, float y)
if (mouse && mouse->cur_cursor && mouse->focus) {
SDL_Window *window = mouse->focus;
SDL_DisplayData *dispdata = (SDL_DisplayData *)SDL_GetDisplayForWindow(window)->driverdata;
SDL_DisplayData *dispdata = SDL_GetDisplayDriverDataForWindow(window);
/* Update internal mouse position. */
SDL_SendMouseMotion(0, mouse->focus, mouse->mouseID, 0, x, y);
@ -394,7 +389,7 @@ static void KMSDRM_WarpMouse(SDL_Window *window, float x, float y)
void KMSDRM_InitMouse(_THIS, SDL_VideoDisplay *display)
{
SDL_Mouse *mouse = SDL_GetMouse();
SDL_DisplayData *dispdata = (SDL_DisplayData *)display->driverdata;
SDL_DisplayData *dispdata = display->driverdata;
mouse->CreateCursor = KMSDRM_CreateCursor;
mouse->ShowCursor = KMSDRM_ShowCursor;
@ -427,7 +422,7 @@ static void KMSDRM_MoveCursor(SDL_Cursor *cursor)
if (mouse && mouse->cur_cursor && mouse->focus) {
SDL_Window *window = mouse->focus;
SDL_DisplayData *dispdata = (SDL_DisplayData *)SDL_GetDisplayForWindow(window)->driverdata;
SDL_DisplayData *dispdata = SDL_GetDisplayDriverDataForWindow(window);
if (!dispdata->cursor_bo) {
SDL_SetError("Cursor not initialized properly.");

View file

@ -54,7 +54,7 @@ int KMSDRM_GLES_LoadLibrary(_THIS, const char *path)
so gbm dev isn't yet created when this is called, AND we can't alter the
call order in SDL_CreateWindow(). */
#if 0
NativeDisplayType display = (NativeDisplayType)((SDL_VideoData *)_this->driverdata)->gbm_dev;
NativeDisplayType display = (NativeDisplayType)_this->driverdata->gbm_dev;
return SDL_EGL_LoadLibrary(_this, path, display, EGL_PLATFORM_GBM_MESA);
#endif
return 0;
@ -86,9 +86,9 @@ SDL_EGL_CreateContext_impl(KMSDRM)
int KMSDRM_GLES_SwapWindow(_THIS, SDL_Window *window)
{
SDL_WindowData *windata = ((SDL_WindowData *)window->driverdata);
SDL_DisplayData *dispdata = (SDL_DisplayData *)SDL_GetDisplayForWindow(window)->driverdata;
SDL_VideoData *viddata = ((SDL_VideoData *)_this->driverdata);
SDL_WindowData *windata = window->driverdata;
SDL_DisplayData *dispdata = SDL_GetDisplayDriverDataForWindow(window);
SDL_VideoData *viddata = _this->driverdata;
KMSDRM_FBInfo *fb_info;
int ret = 0;

View file

@ -353,7 +353,7 @@ static void KMSDRM_FBDestroyCallback(struct gbm_bo *bo, void *data)
KMSDRM_FBInfo *
KMSDRM_FBFromBO(_THIS, struct gbm_bo *bo)
{
SDL_VideoData *viddata = ((SDL_VideoData *)_this->driverdata);
SDL_VideoData *viddata = _this->driverdata;
unsigned w, h;
int ret;
Uint32 stride, handle;
@ -406,7 +406,7 @@ SDL_bool
KMSDRM_WaitPageflip(_THIS, SDL_WindowData *windata)
{
SDL_VideoData *viddata = ((SDL_VideoData *)_this->driverdata);
SDL_VideoData *viddata = _this->driverdata;
drmEventContext ev = { 0 };
struct pollfd pfd = { 0 };
int ret;
@ -494,7 +494,7 @@ static drmModeModeInfo *KMSDRM_GetClosestDisplayMode(SDL_VideoDisplay *display,
uint32_t width, uint32_t height, uint32_t refresh_rate)
{
SDL_DisplayData *dispdata = (SDL_DisplayData *)display->driverdata;
SDL_DisplayData *dispdata = display->driverdata;
drmModeConnector *connector = dispdata->connector;
SDL_DisplayMode target, closest;
@ -522,17 +522,17 @@ static drmModeModeInfo *KMSDRM_GetClosestDisplayMode(SDL_VideoDisplay *display,
/* Deinitializes the driverdata of the SDL Displays in the SDL display list. */
static void KMSDRM_DeinitDisplays(_THIS)
{
SDL_DisplayID *displays;
SDL_DisplayData *dispdata;
int num_displays, i;
num_displays = SDL_GetNumVideoDisplays();
int i;
displays = SDL_GetDisplays(NULL);
if (displays) {
/* Iterate on the SDL Display list. */
for (i = 0; i < num_displays; i++) {
for (i = 0; displays[i]; ++i) {
/* Get the driverdata for this display */
dispdata = (SDL_DisplayData *)SDL_GetDisplayDriverData(i);
dispdata = SDL_GetDisplayDriverData(displays[i]);
/* Free connector */
if (dispdata && dispdata->connector) {
@ -546,6 +546,8 @@ static void KMSDRM_DeinitDisplays(_THIS)
dispdata->crtc = NULL;
}
}
SDL_free(displays);
}
}
static uint32_t KMSDRM_CrtcGetPropId(uint32_t drm_fd,
@ -686,7 +688,7 @@ static SDL_bool KMSDRM_CrtcGetVrr(uint32_t drm_fd, uint32_t crtc_id)
list of SDL Displays in _this->displays[] */
static void KMSDRM_AddDisplay(_THIS, drmModeConnector *connector, drmModeRes *resources)
{
SDL_VideoData *viddata = ((SDL_VideoData *)_this->driverdata);
SDL_VideoData *viddata = _this->driverdata;
SDL_DisplayData *dispdata = NULL;
SDL_VideoDisplay display = { 0 };
SDL_DisplayModeData *modedata = NULL;
@ -908,7 +910,7 @@ cleanup:
static int KMSDRM_InitDisplays(_THIS)
{
SDL_VideoData *viddata = ((SDL_VideoData *)_this->driverdata);
SDL_VideoData *viddata = _this->driverdata;
drmModeRes *resources = NULL;
uint64_t async_pageflip = 0;
@ -959,7 +961,7 @@ static int KMSDRM_InitDisplays(_THIS)
}
/* Have we added any SDL displays? */
if (!SDL_GetNumVideoDisplays()) {
if (SDL_GetPrimaryDisplay() == 0) {
ret = SDL_SetError("No connected displays found.");
goto cleanup;
}
@ -1003,7 +1005,7 @@ cleanup:
*/
static int KMSDRM_GBMInit(_THIS, SDL_DisplayData *dispdata)
{
SDL_VideoData *viddata = (SDL_VideoData *)_this->driverdata;
SDL_VideoData *viddata = _this->driverdata;
int ret = 0;
/* Reopen the FD! */
@ -1026,7 +1028,7 @@ static int KMSDRM_GBMInit(_THIS, SDL_DisplayData *dispdata)
/* Deinit the Vulkan-incompatible KMSDRM stuff. */
static void KMSDRM_GBMDeinit(_THIS, SDL_DisplayData *dispdata)
{
SDL_VideoData *viddata = ((SDL_VideoData *)_this->driverdata);
SDL_VideoData *viddata = _this->driverdata;
/* Destroy GBM device. GBM surface is destroyed by DestroySurfaces(),
already called when we get here. */
@ -1046,9 +1048,9 @@ static void KMSDRM_GBMDeinit(_THIS, SDL_DisplayData *dispdata)
static void KMSDRM_DestroySurfaces(_THIS, SDL_Window *window)
{
SDL_VideoData *viddata = ((SDL_VideoData *)_this->driverdata);
SDL_WindowData *windata = (SDL_WindowData *)window->driverdata;
SDL_DisplayData *dispdata = (SDL_DisplayData *)SDL_GetDisplayForWindow(window)->driverdata;
SDL_VideoData *viddata = _this->driverdata;
SDL_WindowData *windata = window->driverdata;
SDL_DisplayData *dispdata = SDL_GetDisplayDriverDataForWindow(window);
int ret;
/**********************************************/
@ -1113,8 +1115,8 @@ static void KMSDRM_DestroySurfaces(_THIS, SDL_Window *window)
static void KMSDRM_GetModeToSet(SDL_Window *window, drmModeModeInfo *out_mode)
{
SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
SDL_DisplayData *dispdata = (SDL_DisplayData *)display->driverdata;
SDL_VideoDisplay *display = SDL_GetVideoDisplayForWindow(window);
SDL_DisplayData *dispdata = display->driverdata;
if ((window->flags & SDL_WINDOW_FULLSCREEN_EXCLUSIVE) != 0) {
*out_mode = dispdata->fullscreen_mode;
@ -1134,7 +1136,7 @@ static void KMSDRM_GetModeToSet(SDL_Window *window, drmModeModeInfo *out_mode)
static void KMSDRM_DirtySurfaces(SDL_Window *window)
{
SDL_WindowData *windata = (SDL_WindowData *)window->driverdata;
SDL_WindowData *windata = window->driverdata;
drmModeModeInfo mode;
/* Can't recreate EGL surfaces right now, need to wait until SwapWindow
@ -1152,10 +1154,10 @@ static void KMSDRM_DirtySurfaces(SDL_Window *window)
that we create here. */
int KMSDRM_CreateSurfaces(_THIS, SDL_Window *window)
{
SDL_VideoData *viddata = ((SDL_VideoData *)_this->driverdata);
SDL_WindowData *windata = (SDL_WindowData *)window->driverdata;
SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
SDL_DisplayData *dispdata = (SDL_DisplayData *)display->driverdata;
SDL_VideoData *viddata = _this->driverdata;
SDL_WindowData *windata = window->driverdata;
SDL_VideoDisplay *display = SDL_GetVideoDisplayForWindow(window);
SDL_DisplayData *dispdata = display->driverdata;
SDL_DisplayMode current_mode;
uint32_t surface_fmt = GBM_FORMAT_ARGB8888;
@ -1234,7 +1236,7 @@ int KMSDRM_VideoInit(_THIS)
{
int ret = 0;
SDL_VideoData *viddata = ((SDL_VideoData *)_this->driverdata);
SDL_VideoData *viddata = _this->driverdata;
SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, "KMSDRM_VideoInit()");
viddata->video_init = SDL_FALSE;
@ -1263,7 +1265,7 @@ int KMSDRM_VideoInit(_THIS)
are freed by SDL internals, so not our job. */
void KMSDRM_VideoQuit(_THIS)
{
SDL_VideoData *viddata = ((SDL_VideoData *)_this->driverdata);
SDL_VideoData *viddata = _this->driverdata;
KMSDRM_DeinitDisplays(_this);
@ -1314,8 +1316,8 @@ int KMSDRM_SetDisplayMode(_THIS, SDL_VideoDisplay *display, SDL_DisplayMode *mod
/* Set the dispdata->mode to the new mode and leave actual modesetting
pending to be done on SwapWindow() via drmModeSetCrtc() */
SDL_VideoData *viddata = (SDL_VideoData *)_this->driverdata;
SDL_DisplayData *dispdata = (SDL_DisplayData *)display->driverdata;
SDL_VideoData *viddata = _this->driverdata;
SDL_DisplayData *dispdata = display->driverdata;
SDL_DisplayModeData *modedata = (SDL_DisplayModeData *)mode->driverdata;
drmModeConnector *conn = dispdata->connector;
int i;
@ -1342,8 +1344,8 @@ int KMSDRM_SetDisplayMode(_THIS, SDL_VideoDisplay *display, SDL_DisplayMode *mod
void KMSDRM_DestroyWindow(_THIS, SDL_Window *window)
{
SDL_WindowData *windata = (SDL_WindowData *)window->driverdata;
SDL_DisplayData *dispdata = (SDL_DisplayData *)SDL_GetDisplayForWindow(window)->driverdata;
SDL_WindowData *windata = window->driverdata;
SDL_DisplayData *dispdata = SDL_GetDisplayDriverDataForWindow(window);
SDL_VideoData *viddata;
SDL_bool is_vulkan = window->flags & SDL_WINDOW_VULKAN; /* Is this a VK window? */
unsigned int i, j;
@ -1360,7 +1362,7 @@ void KMSDRM_DestroyWindow(_THIS, SDL_Window *window)
if (!is_vulkan && viddata->gbm_init) {
/* Destroy cursor GBM BO of the display of this window. */
KMSDRM_DestroyCursorBO(_this, SDL_GetDisplayForWindow(window));
KMSDRM_DestroyCursorBO(_this, SDL_GetVideoDisplayForWindow(window));
/* Destroy GBM surface and buffers. */
KMSDRM_DestroySurfaces(_this, window);
@ -1421,8 +1423,8 @@ void KMSDRM_DestroyWindow(_THIS, SDL_Window *window)
int KMSDRM_CreateWindow(_THIS, SDL_Window *window)
{
SDL_WindowData *windata = NULL;
SDL_VideoData *viddata = (SDL_VideoData *)_this->driverdata;
SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
SDL_VideoData *viddata = _this->driverdata;
SDL_VideoDisplay *display = SDL_GetVideoDisplayForWindow(window);
SDL_DisplayData *dispdata = display->driverdata;
SDL_bool is_vulkan = window->flags & SDL_WINDOW_VULKAN; /* Is this a VK window? */
SDL_bool vulkan_mode = viddata->vulkan_mode; /* Do we have any Vulkan windows? */
@ -1476,7 +1478,7 @@ int KMSDRM_CreateWindow(_THIS, SDL_Window *window)
If we let SDL_CreateWindow() load the lib, it would be loaded
before we call KMSDRM_GBMInit(), causing all GLES programs to fail. */
if (!_this->egl_data) {
egl_display = (NativeDisplayType)((SDL_VideoData *)_this->driverdata)->gbm_dev;
egl_display = (NativeDisplayType)_this->driverdata->gbm_dev;
if (SDL_EGL_LoadLibrary(_this, NULL, egl_display, EGL_PLATFORM_GBM_MESA) < 0) {
/* Try again with OpenGL ES 2.0 */
_this->gl_config.profile_mask = SDL_GL_CONTEXT_PROFILE_ES;
@ -1569,7 +1571,7 @@ void KMSDRM_SetWindowPosition(_THIS, SDL_Window *window)
}
void KMSDRM_SetWindowSize(_THIS, SDL_Window *window)
{
SDL_VideoData *viddata = ((SDL_VideoData *)_this->driverdata);
SDL_VideoData *viddata = _this->driverdata;
if (!viddata->vulkan_mode) {
KMSDRM_DirtySurfaces(window);
}
@ -1577,7 +1579,7 @@ void KMSDRM_SetWindowSize(_THIS, SDL_Window *window)
void KMSDRM_SetWindowFullscreen(_THIS, SDL_Window *window, SDL_VideoDisplay *display, SDL_bool fullscreen)
{
SDL_VideoData *viddata = ((SDL_VideoData *)_this->driverdata);
SDL_VideoData *viddata = _this->driverdata;
if (!viddata->vulkan_mode) {
KMSDRM_DirtySurfaces(window);
}
@ -1606,7 +1608,7 @@ void KMSDRM_RestoreWindow(_THIS, SDL_Window *window)
/*****************************************************************************/
int KMSDRM_GetWindowWMInfo(_THIS, SDL_Window *window, struct SDL_SysWMinfo *info)
{
SDL_VideoData *viddata = ((SDL_VideoData *)_this->driverdata);
SDL_VideoData *viddata = _this->driverdata;
info->subsystem = SDL_SYSWM_KMSDRM;
info->info.kmsdrm.dev_index = viddata->devindex;

View file

@ -33,7 +33,7 @@
#include <gbm.h>
#include <EGL/egl.h>
typedef struct SDL_VideoData
struct SDL_VideoData
{
int devindex; /* device index that was passed on creation */
int drm_fd; /* DRM file desc */
@ -53,14 +53,14 @@ typedef struct SDL_VideoData
open 1 FD and create 1 gbm device. */
SDL_bool gbm_init;
} SDL_VideoData;
};
typedef struct SDL_DisplayModeData
struct SDL_DisplayModeData
{
int mode_index;
} SDL_DisplayModeData;
};
typedef struct SDL_DisplayData
struct SDL_DisplayData
{
drmModeConnector *connector;
drmModeCrtc *crtc;
@ -80,9 +80,9 @@ typedef struct SDL_DisplayData
uint64_t cursor_w, cursor_h;
SDL_bool default_cursor_init;
} SDL_DisplayData;
};
typedef struct SDL_WindowData
struct SDL_WindowData
{
SDL_VideoData *viddata;
/* SDL internals expect EGL surface to be here, and in KMSDRM the GBM surface is
@ -98,7 +98,7 @@ typedef struct SDL_WindowData
EGLSurface egl_surface;
SDL_bool egl_surface_dirty;
} SDL_WindowData;
};
typedef struct KMSDRM_FBInfo
{

View file

@ -201,7 +201,7 @@ SDL_bool KMSDRM_Vulkan_CreateSurface(_THIS,
SDL_bool plane_supports_display = SDL_FALSE;
/* Get the display index from the display being used by the window. */
int display_index = SDL_atoi(SDL_GetDisplayForWindow(window)->name);
int display_index = SDL_GetDisplayIndex(SDL_GetDisplayForWindow(window));
int i, j;
/* Get the function pointers for the functions we will use. */

View file

@ -75,7 +75,7 @@ CreateNewWindowFramebuffer(SDL_Window *window)
int SDL_N3DS_UpdateWindowFramebuffer(_THIS, SDL_Window *window, const SDL_Rect *rects, int numrects)
{
SDL_WindowData *drv_data = (SDL_WindowData *)window->driverdata;
SDL_WindowData *drv_data = window->driverdata;
SDL_Surface *surface;
u16 width, height;
u32 *framebuffer;

View file

@ -40,10 +40,10 @@ static int N3DS_GetDisplayBounds(_THIS, SDL_VideoDisplay *display, SDL_Rect *rec
static int N3DS_CreateWindow(_THIS, SDL_Window *window);
static void N3DS_DestroyWindow(_THIS, SDL_Window *window);
typedef struct
struct SDL_DisplayData
{
gfxScreen_t screen;
} DisplayDriverData;
};
/* N3DS driver bootstrap functions */
@ -107,7 +107,7 @@ AddN3DSDisplay(gfxScreen_t screen)
{
SDL_DisplayMode mode;
SDL_VideoDisplay display;
DisplayDriverData *display_driver_data = SDL_calloc(1, sizeof(DisplayDriverData));
SDL_DisplayData *display_driver_data = SDL_calloc(1, sizeof(SDL_DisplayData));
if (display_driver_data == NULL) {
SDL_OutOfMemory();
return;
@ -148,7 +148,7 @@ static void N3DS_GetDisplayModes(_THIS, SDL_VideoDisplay *display)
static int N3DS_GetDisplayBounds(_THIS, SDL_VideoDisplay *display, SDL_Rect *rect)
{
DisplayDriverData *driver_data = (DisplayDriverData *)display->driverdata;
SDL_DisplayData *driver_data = display->driverdata;
if (driver_data == NULL) {
return -1;
}
@ -162,12 +162,12 @@ static int N3DS_GetDisplayBounds(_THIS, SDL_VideoDisplay *display, SDL_Rect *rec
static int N3DS_CreateWindow(_THIS, SDL_Window *window)
{
DisplayDriverData *display_data;
SDL_DisplayData *display_data;
SDL_WindowData *window_data = (SDL_WindowData *)SDL_calloc(1, sizeof(SDL_WindowData));
if (window_data == NULL) {
return SDL_OutOfMemory();
}
display_data = (DisplayDriverData *)SDL_GetDisplayDriverData(window->display_index);
display_data = SDL_GetDisplayDriverDataForWindow(window);
window_data->screen = display_data->screen;
window->driverdata = window_data;
SDL_SetKeyboardFocus(window);

View file

@ -26,10 +26,11 @@
#include <3ds.h>
#include "../SDL_sysvideo.h"
typedef struct SDL_WindowData
struct SDL_WindowData
{
gfxScreen_t screen; /**< Keeps track of which N3DS screen is targetted */
} SDL_WindowData;
};
#define FRAMEBUFFER_FORMAT SDL_PIXELFORMAT_RGBA8888

View file

@ -44,7 +44,7 @@ int HandleWsEvent(_THIS, const TWsEvent &aWsEvent);
void NGAGE_PumpEvents(_THIS)
{
SDL_VideoData *phdata = (SDL_VideoData *)_this->driverdata;
SDL_VideoData *phdata = _this->driverdata;
while (phdata->NGAGE_WsEventStatus != KRequestPending) {
phdata->NGAGE_WsSession.GetEvent(phdata->NGAGE_WsEvent);
@ -149,7 +149,7 @@ static SDL_Scancode ConvertScancode(_THIS, int key)
int HandleWsEvent(_THIS, const TWsEvent &aWsEvent)
{
SDL_VideoData *phdata = (SDL_VideoData *)_this->driverdata;
SDL_VideoData *phdata = _this->driverdata;
int posted = 0;
switch (aWsEvent.Type()) {

View file

@ -46,7 +46,7 @@ void RedrawWindowL(_THIS);
int SDL_NGAGE_CreateWindowFramebuffer(_THIS, SDL_Window *window, Uint32 *format, void **pixels, int *pitch)
{
SDL_VideoData *phdata = (SDL_VideoData *)_this->driverdata;
SDL_VideoData *phdata = _this->driverdata;
SDL_Surface *surface;
const Uint32 surface_format = SDL_PIXELFORMAT_RGB444;
int w, h;
@ -199,7 +199,7 @@ int GetBpp(TDisplayMode displaymode)
void DrawBackground(_THIS)
{
SDL_VideoData *phdata = (SDL_VideoData *)_this->driverdata;
SDL_VideoData *phdata = _this->driverdata;
/* Draw background */
TUint16 *screenBuffer = (TUint16 *)phdata->NGAGE_FrameBuffer;
/* Draw black background */
@ -208,7 +208,7 @@ void DrawBackground(_THIS)
void DirectDraw(_THIS, int numrects, SDL_Rect *rects, TUint16 *screenBuffer)
{
SDL_VideoData *phdata = (SDL_VideoData *)_this->driverdata;
SDL_VideoData *phdata = _this->driverdata;
SDL_Surface *screen = (SDL_Surface *)SDL_GetWindowData(_this->windows, NGAGE_SURFACE);
TInt i;
@ -333,7 +333,7 @@ void DirectDraw(_THIS, int numrects, SDL_Rect *rects, TUint16 *screenBuffer)
void DirectUpdate(_THIS, int numrects, SDL_Rect *rects)
{
SDL_VideoData *phdata = (SDL_VideoData *)_this->driverdata;
SDL_VideoData *phdata = _this->driverdata;
if (!phdata->NGAGE_IsWindowFocused) {
SDL_PauseAudio(1);
@ -368,7 +368,7 @@ void DirectUpdate(_THIS, int numrects, SDL_Rect *rects)
void RedrawWindowL(_THIS)
{
SDL_VideoData *phdata = (SDL_VideoData *)_this->driverdata;
SDL_VideoData *phdata = _this->driverdata;
SDL_Surface *screen = (SDL_Surface *)SDL_GetWindowData(_this->windows, NGAGE_SURFACE);
int w = screen->w;

View file

@ -55,7 +55,7 @@ static void NGAGE_VideoQuit(_THIS);
static void NGAGE_DeleteDevice(SDL_VideoDevice *device)
{
SDL_VideoData *phdata = (SDL_VideoData *)device->driverdata;
SDL_VideoData *phdata = device->driverdata;
if (phdata) {
/* Free Epoc resources */

View file

@ -34,7 +34,7 @@
#define _THIS SDL_VideoDevice *_this
typedef struct SDL_VideoData
struct SDL_VideoData
{
/* Epoc window server info */
RWsSession NGAGE_WsSession;
@ -61,6 +61,6 @@ typedef struct SDL_VideoData
CFbsBitGc::TGraphicsOrientation NGAGE_ScreenOrientation;
} SDL_VideoData;
};
#endif /* SDL_ngagevideo_h */

View file

@ -74,7 +74,7 @@ void NGAGE_DestroyWindow(_THIS, SDL_Window *window)
void DisableKeyBlocking(_THIS)
{
SDL_VideoData *phdata = (SDL_VideoData *)_this->driverdata;
SDL_VideoData *phdata = _this->driverdata;
TRawEvent event;
event.Set((TRawEvent::TType) /*EDisableKeyBlock*/ 51);
@ -83,7 +83,7 @@ void DisableKeyBlocking(_THIS)
void ConstructWindowL(_THIS)
{
SDL_VideoData *phdata = (SDL_VideoData *)_this->driverdata;
SDL_VideoData *phdata = _this->driverdata;
TInt error;
error = phdata->NGAGE_WsSession.Connect();

View file

@ -57,7 +57,7 @@ int OFFSCREEN_GLES_LoadLibrary(_THIS, const char *path)
SDL_GLContext
OFFSCREEN_GLES_CreateContext(_THIS, SDL_Window *window)
{
OFFSCREEN_Window *offscreen_window = window->driverdata;
SDL_WindowData *offscreen_window = window->driverdata;
SDL_GLContext context;
context = SDL_EGL_CreateContext(_this, offscreen_window->egl_surface);
@ -68,7 +68,7 @@ OFFSCREEN_GLES_CreateContext(_THIS, SDL_Window *window)
int OFFSCREEN_GLES_MakeCurrent(_THIS, SDL_Window *window, SDL_GLContext context)
{
if (window) {
EGLSurface egl_surface = ((OFFSCREEN_Window *)window->driverdata)->egl_surface;
EGLSurface egl_surface = window->driverdata->egl_surface;
return SDL_EGL_MakeCurrent(_this, egl_surface, context);
} else {
return SDL_EGL_MakeCurrent(_this, NULL, NULL);
@ -77,7 +77,7 @@ int OFFSCREEN_GLES_MakeCurrent(_THIS, SDL_Window *window, SDL_GLContext context)
int OFFSCREEN_GLES_SwapWindow(_THIS, SDL_Window *window)
{
OFFSCREEN_Window *offscreen_wind = window->driverdata;
SDL_WindowData *offscreen_wind = window->driverdata;
return SDL_EGL_SwapBuffers(_this, offscreen_wind->egl_surface);
}

View file

@ -29,7 +29,7 @@
int OFFSCREEN_CreateWindow(_THIS, SDL_Window *window)
{
OFFSCREEN_Window *offscreen_window = SDL_calloc(1, sizeof(OFFSCREEN_Window));
SDL_WindowData *offscreen_window = (SDL_WindowData *)SDL_calloc(1, sizeof(SDL_WindowData));
if (offscreen_window == NULL) {
return SDL_OutOfMemory();
@ -70,7 +70,7 @@ int OFFSCREEN_CreateWindow(_THIS, SDL_Window *window)
void OFFSCREEN_DestroyWindow(_THIS, SDL_Window *window)
{
OFFSCREEN_Window *offscreen_window = window->driverdata;
SDL_WindowData *offscreen_window = window->driverdata;
if (offscreen_window) {
#if SDL_VIDEO_OPENGL_EGL

View file

@ -25,14 +25,17 @@
#include "SDL_offscreenvideo.h"
typedef struct
#if defined(SDL_VIDEO_DRIVER_COCOA) || defined(SDL_VIDEO_DRIVER_UIKIT)
struct _SDL_WindowData
#else
struct SDL_WindowData
#endif
{
SDL_Window *sdl_window;
#if SDL_VIDEO_OPENGL_EGL
EGLSurface egl_surface;
#endif
} OFFSCREEN_Window;
};
extern int OFFSCREEN_CreateWindow(_THIS, SDL_Window *window);
extern void OFFSCREEN_DestroyWindow(_THIS, SDL_Window *window);

View file

@ -70,7 +70,7 @@ static EGLint height = 272;
SDL_GLContext PSP_GL_CreateContext(_THIS, SDL_Window *window)
{
SDL_WindowData *wdata = (SDL_WindowData *)window->driverdata;
SDL_WindowData *wdata = window->driverdata;
EGLint attribs[32];
EGLDisplay display;
@ -167,7 +167,7 @@ int PSP_GL_SwapWindow(_THIS, SDL_Window *window)
void PSP_GL_DeleteContext(_THIS, SDL_GLContext context)
{
SDL_VideoData *phdata = (SDL_VideoData *)_this->driverdata;
SDL_VideoData *phdata = _this->driverdata;
EGLBoolean status;
if (phdata->egl_initialized != SDL_TRUE) {

View file

@ -41,11 +41,8 @@ static SDL_bool PSP_initialized = SDL_FALSE;
static void PSP_Destroy(SDL_VideoDevice *device)
{
/* SDL_VideoData *phdata = (SDL_VideoData *) device->driverdata; */
if (device->driverdata != NULL) {
device->driverdata = NULL;
}
SDL_free(device->driverdata);
SDL_free(device);
}
static SDL_VideoDevice *PSP_Create()

View file

@ -27,23 +27,18 @@
#include "SDL_internal.h"
#include "../SDL_sysvideo.h"
typedef struct SDL_VideoData
struct SDL_VideoData
{
SDL_bool egl_initialized; /* OpenGL ES device initialization status */
uint32_t egl_refcount; /* OpenGL ES reference count */
} SDL_VideoData;
};
typedef struct SDL_DisplayData
{
} SDL_DisplayData;
typedef struct SDL_WindowData
struct SDL_WindowData
{
SDL_bool uses_gles; /* if true window must support OpenGL ES */
} SDL_WindowData;
};
/****************************************************************************/
/* SDL_VideoDevice functions declaration */

View file

@ -107,7 +107,6 @@ static int RPI_ShowCursor(SDL_Cursor *cursor)
RPI_CursorData *curdata;
VC_RECT_T src_rect, dst_rect;
SDL_Mouse *mouse;
SDL_VideoDisplay *display;
SDL_DisplayData *data;
VC_DISPMANX_ALPHA_T alpha = { DISPMANX_FLAGS_ALPHA_FROM_SOURCE /* flags */, 255 /*opacity 0->255*/, 0 /* mask */ };
uint32_t layer = SDL_RPI_MOUSELAYER;
@ -147,12 +146,7 @@ static int RPI_ShowCursor(SDL_Cursor *cursor)
return -1;
}
display = SDL_GetDisplayForWindow(mouse->focus);
if (display == NULL) {
return -1;
}
data = (SDL_DisplayData *)display->driverdata;
data = SDL_GetDisplayDriverDataForWindow(mouse->focus);
if (data == NULL) {
return -1;
}

View file

@ -41,7 +41,7 @@ int RPI_GLES_LoadLibrary(_THIS, const char *path)
int RPI_GLES_SwapWindow(_THIS, SDL_Window *window)
{
SDL_WindowData *wdata = ((SDL_WindowData *)window->driverdata);
SDL_WindowData *wdata = window->driverdata;
if (!(_this->egl_data->eglSwapBuffers(_this->egl_data->egl_display, wdata->egl_surface))) {
SDL_LogError(SDL_LOG_CATEGORY_VIDEO, "eglSwapBuffers failed.");

View file

@ -227,7 +227,7 @@ int RPI_SetDisplayMode(_THIS, SDL_VideoDisplay *display, SDL_DisplayMode *mode)
static void RPI_vsync_callback(DISPMANX_UPDATE_HANDLE_T u, void *data)
{
SDL_WindowData *wdata = ((SDL_WindowData *)data);
SDL_WindowData *wdata = (SDL_WindowData *)data;
SDL_LockMutex(wdata->vsync_cond_mutex);
SDL_CondSignal(wdata->vsync_cond);
@ -256,8 +256,8 @@ int RPI_CreateWindow(_THIS, SDL_Window *window)
if (wdata == NULL) {
return SDL_OutOfMemory();
}
display = SDL_GetDisplayForWindow(window);
displaydata = (SDL_DisplayData *)display->driverdata;
display = SDL_GetVideoDisplayForWindow(window);
displaydata = display->driverdata;
/* Windows have one size for now */
window->w = display->desktop_mode.w;
@ -330,9 +330,8 @@ int RPI_CreateWindow(_THIS, SDL_Window *window)
void RPI_DestroyWindow(_THIS, SDL_Window *window)
{
SDL_WindowData *data = (SDL_WindowData *)window->driverdata;
SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
SDL_DisplayData *displaydata = (SDL_DisplayData *)display->driverdata;
SDL_WindowData *data = window->driverdata;
SDL_DisplayData *displaydata = SDL_GetDisplayDriverDataForWindow(window);
if (data) {
if (data->double_buffer) {

View file

@ -28,17 +28,17 @@
#include <bcm_host.h>
#include <SDL3/SDL_egl.h>
typedef struct SDL_VideoData
struct SDL_VideoData
{
uint32_t egl_refcount; /* OpenGL ES reference count */
} SDL_VideoData;
};
typedef struct SDL_DisplayData
struct SDL_DisplayData
{
DISPMANX_DISPLAY_HANDLE_T dispman_display;
} SDL_DisplayData;
};
typedef struct SDL_WindowData
struct SDL_WindowData
{
EGL_DISPMANX_WINDOW_T dispman_window;
#if SDL_VIDEO_OPENGL_EGL
@ -49,8 +49,7 @@ typedef struct SDL_WindowData
SDL_cond *vsync_cond;
SDL_mutex *vsync_cond_mutex;
SDL_bool double_buffer;
} SDL_WindowData;
};
#define SDL_RPI_VIDEOLAYER 10000 /* High enough so to occlude everything */
#define SDL_RPI_MOUSELAYER SDL_RPI_VIDEOLAYER + 1

View file

@ -50,7 +50,7 @@ static SDL_Scancode SDL_RISCOS_translate_keycode(int keycode)
void RISCOS_PollKeyboard(_THIS)
{
SDL_VideoData *driverdata = (SDL_VideoData *)_this->driverdata;
SDL_VideoData *driverdata = _this->driverdata;
Uint8 key = 2;
int i;
@ -110,13 +110,13 @@ static const Uint8 mouse_button_map[] = {
void RISCOS_PollMouse(_THIS)
{
SDL_VideoData *driverdata = (SDL_VideoData *)_this->driverdata;
SDL_VideoData *driverdata = _this->driverdata;
SDL_Mouse *mouse = SDL_GetMouse();
SDL_Rect rect;
_kernel_swi_regs regs;
int i, x, y, buttons;
if (SDL_GetDisplayBounds(0, &rect) < 0) {
if (SDL_GetDisplayBounds(SDL_GetPrimaryDisplay(), &rect) < 0) {
return;
}
@ -139,7 +139,7 @@ void RISCOS_PollMouse(_THIS)
int RISCOS_InitEvents(_THIS)
{
SDL_VideoData *driverdata = (SDL_VideoData *)_this->driverdata;
SDL_VideoData *driverdata = _this->driverdata;
_kernel_swi_regs regs;
int i, status;

View file

@ -32,7 +32,7 @@
int RISCOS_CreateWindowFramebuffer(_THIS, SDL_Window *window, Uint32 *format, void **pixels, int *pitch)
{
SDL_WindowData *driverdata = (SDL_WindowData *)window->driverdata;
SDL_WindowData *driverdata = window->driverdata;
const char *sprite_name = "display";
unsigned int sprite_mode;
_kernel_oserror *error;
@ -47,7 +47,7 @@ int RISCOS_CreateWindowFramebuffer(_THIS, SDL_Window *window, Uint32 *format, vo
RISCOS_DestroyWindowFramebuffer(_this, window);
/* Create a new one */
SDL_GetCurrentDisplayMode(SDL_GetWindowDisplayIndex(window), &mode);
SDL_GetCurrentDisplayMode(SDL_GetDisplayForWindow(window), &mode);
if ((SDL_ISPIXELFORMAT_PACKED(mode.format) || SDL_ISPIXELFORMAT_ARRAY(mode.format))) {
*format = mode.format;
sprite_mode = (unsigned int)mode.driverdata;
@ -93,7 +93,7 @@ int RISCOS_CreateWindowFramebuffer(_THIS, SDL_Window *window, Uint32 *format, vo
int RISCOS_UpdateWindowFramebuffer(_THIS, SDL_Window *window, const SDL_Rect *rects, int numrects)
{
SDL_WindowData *driverdata = (SDL_WindowData *)window->driverdata;
SDL_WindowData *driverdata = window->driverdata;
_kernel_swi_regs regs;
_kernel_oserror *error;
@ -115,7 +115,7 @@ int RISCOS_UpdateWindowFramebuffer(_THIS, SDL_Window *window, const SDL_Rect *re
void RISCOS_DestroyWindowFramebuffer(_THIS, SDL_Window *window)
{
SDL_WindowData *driverdata = (SDL_WindowData *)window->driverdata;
SDL_WindowData *driverdata = window->driverdata;
if (driverdata->fb_area) {
SDL_free(driverdata->fb_area);

View file

@ -27,10 +27,10 @@
#define RISCOS_MAX_KEYS_PRESSED 6
typedef struct SDL_VideoData
struct SDL_VideoData
{
int last_mouse_buttons;
Uint8 key_pressed[RISCOS_MAX_KEYS_PRESSED];
} SDL_VideoData;
};
#endif /* SDL_riscosvideo_h_ */

View file

@ -51,7 +51,7 @@ int RISCOS_CreateWindow(_THIS, SDL_Window *window)
void RISCOS_DestroyWindow(_THIS, SDL_Window *window)
{
SDL_WindowData *driverdata = (SDL_WindowData *)window->driverdata;
SDL_WindowData *driverdata = window->driverdata;
if (driverdata == NULL) {
return;

View file

@ -25,12 +25,12 @@
#include "SDL_riscosdefs.h"
typedef struct
struct SDL_WindowData
{
SDL_Window *window;
sprite_area *fb_area;
sprite_header *fb_sprite;
} SDL_WindowData;
};
extern int RISCOS_CreateWindow(_THIS, SDL_Window *window);
extern void RISCOS_DestroyWindow(_THIS, SDL_Window *window);

View file

@ -468,7 +468,7 @@ static UIImage *SDL_LoadLaunchImageNamed(NSString *name, int screenh)
if (_this) {
SDL_Window *window = NULL;
for (window = _this->windows; window != NULL; window = window->next) {
SDL_WindowData *data = (__bridge SDL_WindowData *)window->driverdata;
SDL_WindowData *data = window->driverdata;
if (data != nil) {
return data.uiwindow;
}

View file

@ -75,7 +75,7 @@ void UIKit_InitClipboard(_THIS)
{
#if !TARGET_OS_TV
@autoreleasepool {
SDL_VideoData *data = (__bridge SDL_VideoData *)_this->driverdata;
SDL_VideoData *data = _this->driverdata;
NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
id observer = [center addObserverForName:UIPasteboardChangedNotification
@ -93,7 +93,7 @@ void UIKit_InitClipboard(_THIS)
void UIKit_QuitClipboard(_THIS)
{
@autoreleasepool {
SDL_VideoData *data = (__bridge SDL_VideoData *)_this->driverdata;
SDL_VideoData *data = _this->driverdata;
if (data.pasteboardObserver != nil) {
[[NSNotificationCenter defaultCenter] removeObserver:data.pasteboardObserver];

View file

@ -94,7 +94,7 @@ static BOOL UIKit_ShowMessageBoxAlertController(const SDL_MessageBoxData *messag
}
if (messageboxdata->window) {
SDL_WindowData *data = (__bridge SDL_WindowData *)messageboxdata->window->driverdata;
SDL_WindowData *data = messageboxdata->window->driverdata;
window = data.uiwindow;
}

View file

@ -78,7 +78,7 @@ SDL_MetalView
UIKit_Metal_CreateView(_THIS, SDL_Window *window)
{
@autoreleasepool {
SDL_WindowData *data = (__bridge SDL_WindowData *)window->driverdata;
SDL_WindowData *data = window->driverdata;
CGFloat scale = 1.0;
SDL_uikitmetalview *metalview;

View file

@ -358,7 +358,7 @@ int UIKit_AddDisplay(UIScreen *uiscreen, SDL_bool send_event)
return SDL_OutOfMemory();
}
display.driverdata = (void *)CFBridgingRetain(data);
display.driverdata = data;
SDL_AddVideoDisplay(&display, send_event);
return 0;
@ -366,17 +366,23 @@ int UIKit_AddDisplay(UIScreen *uiscreen, SDL_bool send_event)
void UIKit_DelDisplay(UIScreen *uiscreen)
{
SDL_DisplayID *displays;
int i;
for (i = 0; i < SDL_GetNumVideoDisplays(); ++i) {
SDL_DisplayData *data = (__bridge SDL_DisplayData *)SDL_GetDisplayDriverData(i);
displays = SDL_GetDisplays(NULL);
if (displays) {
for (i = 0; displays[i]; ++i) {
SDL_VideoDisplay *display = SDL_GetVideoDisplay(displays[i]);
SDL_DisplayData *data = display->driverdata;
if (data && data.uiscreen == uiscreen) {
CFRelease(SDL_GetDisplayDriverData(i));
SDL_DelVideoDisplay(i);
display->driverdata = nil;
SDL_DelVideoDisplay(displays[i]);
return;
}
}
SDL_free(displays);
}
}
SDL_bool
@ -414,7 +420,7 @@ int UIKit_InitModes(_THIS)
void UIKit_GetDisplayModes(_THIS, SDL_VideoDisplay *display)
{
@autoreleasepool {
SDL_DisplayData *data = (__bridge SDL_DisplayData *)display->driverdata;
SDL_DisplayData *data = display->driverdata;
SDL_bool isLandscape = UIKit_IsDisplayLandscape(data.uiscreen);
SDL_bool addRotation = (data.uiscreen == [UIScreen mainScreen]);
@ -447,7 +453,7 @@ void UIKit_GetDisplayModes(_THIS, SDL_VideoDisplay *display)
int UIKit_GetDisplayPhysicalDPI(_THIS, SDL_VideoDisplay *display, float *ddpi, float *hdpi, float *vdpi)
{
@autoreleasepool {
SDL_DisplayData *data = (__bridge SDL_DisplayData *)display->driverdata;
SDL_DisplayData *data = display->driverdata;
float dpi = data.screenDPI;
if (ddpi) {
@ -467,7 +473,7 @@ int UIKit_GetDisplayPhysicalDPI(_THIS, SDL_VideoDisplay *display, float *ddpi, f
int UIKit_SetDisplayMode(_THIS, SDL_VideoDisplay *display, SDL_DisplayMode *mode)
{
@autoreleasepool {
SDL_DisplayData *data = (__bridge SDL_DisplayData *)display->driverdata;
SDL_DisplayData *data = display->driverdata;
#if !TARGET_OS_TV
SDL_DisplayModeData *modedata = (__bridge SDL_DisplayModeData *)mode->driverdata;
@ -496,13 +502,12 @@ int UIKit_SetDisplayMode(_THIS, SDL_VideoDisplay *display, SDL_DisplayMode *mode
int UIKit_GetDisplayUsableBounds(_THIS, SDL_VideoDisplay *display, SDL_Rect *rect)
{
@autoreleasepool {
int displayIndex = (int)(display - _this->displays);
SDL_DisplayData *data = (__bridge SDL_DisplayData *)display->driverdata;
SDL_DisplayData *data = display->driverdata;
CGRect frame = data.uiscreen.bounds;
/* the default function iterates displays to make a fake offset,
as if all the displays were side-by-side, which is fine for iOS. */
if (SDL_GetDisplayBounds(displayIndex, rect) < 0) {
if (SDL_GetDisplayBounds(display->id, rect) < 0) {
return -1;
}
@ -531,9 +536,8 @@ void UIKit_QuitModes(_THIS)
UIKit_FreeDisplayModeData(mode);
}
if (display->driverdata != NULL) {
CFRelease(display->driverdata);
display->driverdata = NULL;
if (display->driverdata) {
display->driverdata = nil;
}
}
}
@ -543,7 +547,7 @@ void UIKit_QuitModes(_THIS)
void SDL_OnApplicationDidChangeStatusBarOrientation()
{
BOOL isLandscape = UIInterfaceOrientationIsLandscape([UIApplication sharedApplication].statusBarOrientation);
SDL_VideoDisplay *display = SDL_GetDisplay(0);
SDL_VideoDisplay *display = SDL_GetVideoDisplay(SDL_GetPrimaryDisplay());
if (display) {
SDL_DisplayMode *desktopmode = &display->desktop_mode;

View file

@ -113,7 +113,7 @@ SDL_GLContext UIKit_GL_CreateContext(_THIS, SDL_Window *window)
@autoreleasepool {
SDLEAGLContext *context = nil;
SDL_uikitopenglview *view;
SDL_WindowData *data = (__bridge SDL_WindowData *)window->driverdata;
SDL_WindowData *data = window->driverdata;
CGRect frame = UIKit_ComputeViewFrame(window, data.uiwindow.screen);
EAGLSharegroup *sharegroup = nil;
CGFloat scale = 1.0;

View file

@ -52,7 +52,7 @@ static void UIKit_VideoQuit(_THIS);
static void UIKit_DeleteDevice(SDL_VideoDevice *device)
{
@autoreleasepool {
CFRelease(device->driverdata);
device->driverdata = nil;
SDL_free(device);
}
}
@ -73,7 +73,7 @@ static SDL_VideoDevice *UIKit_CreateDevice(void)
return (0);
}
device->driverdata = (void *)CFBridgingRetain(data);
device->driverdata = data;
/* Set the function pointers */
device->VideoInit = UIKit_VideoInit;
@ -184,7 +184,7 @@ UIKit_IsSystemVersionAtLeast(double version)
CGRect
UIKit_ComputeViewFrame(SDL_Window *window, UIScreen *screen)
{
SDL_WindowData *data = (__bridge SDL_WindowData *)window->driverdata;
SDL_WindowData *data = window->driverdata;
CGRect frame = screen.bounds;
/* Use the UIWindow bounds instead of the UIScreen bounds, when possible.
@ -225,7 +225,7 @@ void UIKit_ForceUpdateHomeIndicator()
/* Force the main SDL window to re-evaluate home indicator state */
SDL_Window *focus = SDL_GetFocusWindow();
if (focus) {
SDL_WindowData *data = (__bridge SDL_WindowData *)focus->driverdata;
SDL_WindowData *data = focus->driverdata;
if (data != nil) {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunguarded-availability-new"

View file

@ -103,7 +103,7 @@ extern int SDL_AppleTVRemoteOpenedAsJoystick;
/* Remove ourself from the old window. */
if (sdlwindow) {
SDL_uikitview *view = nil;
data = (__bridge SDL_WindowData *)sdlwindow->driverdata;
data = sdlwindow->driverdata;
[data.views removeObject:self];
@ -122,7 +122,7 @@ extern int SDL_AppleTVRemoteOpenedAsJoystick;
/* Add ourself to the new window. */
if (window) {
data = (__bridge SDL_WindowData *)window->driverdata;
data = window->driverdata;
/* Make sure the SDL window has a strong reference to this view. */
[data.views addObject:self];

View file

@ -156,7 +156,7 @@ static void SDLCALL SDL_HideHomeIndicatorHintChanged(void *userdata, const char
displayLink = [CADisplayLink displayLinkWithTarget:self selector:@selector(doLoop:)];
#ifdef __IPHONE_10_3
SDL_WindowData *data = (__bridge SDL_WindowData *)window->driverdata;
SDL_WindowData *data = window->driverdata;
if ([displayLink respondsToSelector:@selector(preferredFramesPerSecond)] && data != nil && data.uiwindow != nil && [data.uiwindow.screen respondsToSelector:@selector(maximumFramesPerSecond)]) {
displayLink.preferredFramesPerSecond = data.uiwindow.screen.maximumFramesPerSecond / animationInterval;
@ -513,7 +513,7 @@ static SDL_uikitviewcontroller *GetWindowViewController(SDL_Window *window)
return nil;
}
SDL_WindowData *data = (__bridge SDL_WindowData *)window->driverdata;
SDL_WindowData *data = window->driverdata;
return data.viewcontroller;
}

View file

@ -81,8 +81,8 @@
static int SetupWindowData(_THIS, SDL_Window *window, UIWindow *uiwindow, SDL_bool created)
{
SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
SDL_DisplayData *displaydata = (__bridge SDL_DisplayData *)display->driverdata;
SDL_VideoDisplay *display = SDL_GetVideoDisplayForWindow(window);
SDL_DisplayData *displaydata = display->driverdata;
SDL_uikitview *view;
CGRect frame = UIKit_ComputeViewFrame(window, displaydata.uiscreen);
@ -94,7 +94,7 @@ static int SetupWindowData(_THIS, SDL_Window *window, UIWindow *uiwindow, SDL_bo
return SDL_OutOfMemory();
}
window->driverdata = (void *)CFBridgingRetain(data);
window->driverdata = data;
data.uiwindow = uiwindow;
@ -152,13 +152,13 @@ static int SetupWindowData(_THIS, SDL_Window *window, UIWindow *uiwindow, SDL_bo
int UIKit_CreateWindow(_THIS, SDL_Window *window)
{
@autoreleasepool {
SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
SDL_DisplayData *data = (__bridge SDL_DisplayData *)display->driverdata;
SDL_VideoDisplay *display = SDL_GetVideoDisplayForWindow(window);
SDL_DisplayData *data = display->driverdata;
SDL_Window *other;
/* We currently only handle a single window per display on iOS */
for (other = _this->windows; other; other = other->next) {
if (other != window && SDL_GetDisplayForWindow(other) == display) {
if (other != window && SDL_GetVideoDisplayForWindow(other) == display) {
return SDL_SetError("Only one window allowed per display.");
}
}
@ -222,7 +222,7 @@ int UIKit_CreateWindow(_THIS, SDL_Window *window)
void UIKit_SetWindowTitle(_THIS, SDL_Window *window)
{
@autoreleasepool {
SDL_WindowData *data = (__bridge SDL_WindowData *)window->driverdata;
SDL_WindowData *data = window->driverdata;
data.viewcontroller.title = @(window->title);
}
}
@ -230,12 +230,12 @@ void UIKit_SetWindowTitle(_THIS, SDL_Window *window)
void UIKit_ShowWindow(_THIS, SDL_Window *window)
{
@autoreleasepool {
SDL_WindowData *data = (__bridge SDL_WindowData *)window->driverdata;
SDL_WindowData *data = window->driverdata;
[data.uiwindow makeKeyAndVisible];
/* Make this window the current mouse focus for touch input */
SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
SDL_DisplayData *displaydata = (__bridge SDL_DisplayData *)display->driverdata;
SDL_VideoDisplay *display = SDL_GetVideoDisplayForWindow(window);
SDL_DisplayData *displaydata = display->driverdata;
if (displaydata.uiscreen == [UIScreen mainScreen]) {
SDL_SetMouseFocus(window);
SDL_SetKeyboardFocus(window);
@ -246,7 +246,7 @@ void UIKit_ShowWindow(_THIS, SDL_Window *window)
void UIKit_HideWindow(_THIS, SDL_Window *window)
{
@autoreleasepool {
SDL_WindowData *data = (__bridge SDL_WindowData *)window->driverdata;
SDL_WindowData *data = window->driverdata;
data.uiwindow.hidden = YES;
}
}
@ -262,7 +262,7 @@ void UIKit_RaiseWindow(_THIS, SDL_Window *window)
static void UIKit_UpdateWindowBorder(_THIS, SDL_Window *window)
{
SDL_WindowData *data = (__bridge SDL_WindowData *)window->driverdata;
SDL_WindowData *data = window->driverdata;
SDL_uikitviewcontroller *viewcontroller = data.viewcontroller;
#if !TARGET_OS_TV
@ -313,7 +313,7 @@ void UIKit_UpdatePointerLock(_THIS, SDL_Window *window)
#if !TARGET_OS_TV
#if defined(__IPHONE_14_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_14_0
@autoreleasepool {
SDL_WindowData *data = (__bridge SDL_WindowData *)window->driverdata;
SDL_WindowData *data = window->driverdata;
SDL_uikitviewcontroller *viewcontroller = data.viewcontroller;
if (@available(iOS 14.0, *)) {
[viewcontroller setNeedsUpdateOfPrefersPointerLocked];
@ -327,7 +327,7 @@ void UIKit_DestroyWindow(_THIS, SDL_Window *window)
{
@autoreleasepool {
if (window->driverdata != NULL) {
SDL_WindowData *data = (SDL_WindowData *)CFBridgingRelease(window->driverdata);
SDL_WindowData *data = window->driverdata;
NSArray *views = nil;
[data.viewcontroller stopAnimation];
@ -346,15 +346,16 @@ void UIKit_DestroyWindow(_THIS, SDL_Window *window)
* SDL window. */
data.uiwindow.rootViewController = nil;
data.uiwindow.hidden = YES;
window->driverdata = nil;
}
}
window->driverdata = NULL;
}
void UIKit_GetWindowSizeInPixels(_THIS, SDL_Window *window, int *w, int *h)
{
@autoreleasepool {
SDL_WindowData *windata = (__bridge SDL_WindowData *)window->driverdata;
SDL_WindowData *windata = window->driverdata;
UIView *view = windata.viewcontroller.view;
CGSize size = view.bounds.size;
CGFloat scale = 1.0;
@ -373,7 +374,7 @@ void UIKit_GetWindowSizeInPixels(_THIS, SDL_Window *window, int *w, int *h)
int UIKit_GetWindowWMInfo(_THIS, SDL_Window *window, SDL_SysWMinfo *info)
{
@autoreleasepool {
SDL_WindowData *data = (__bridge SDL_WindowData *)window->driverdata;
SDL_WindowData *data = window->driverdata;
info->subsystem = SDL_SYSWM_UIKIT;
info->info.uikit.window = data.uiwindow;
@ -399,7 +400,7 @@ UIKit_GetSupportedOrientations(SDL_Window *window)
NSUInteger orientationMask = 0;
@autoreleasepool {
SDL_WindowData *data = (__bridge SDL_WindowData *)window->driverdata;
SDL_WindowData *data = window->driverdata;
UIApplication *app = [UIApplication sharedApplication];
/* Get all possible valid orientations. If the app delegate doesn't tell
@ -465,7 +466,7 @@ int SDL_iPhoneSetAnimationCallback(SDL_Window *window, int interval, void (*call
}
@autoreleasepool {
SDL_WindowData *data = (__bridge SDL_WindowData *)window->driverdata;
SDL_WindowData *data = window->driverdata;
[data.viewcontroller setAnimationCallback:interval
callback:callback
callbackParam:callbackParam];

View file

@ -65,7 +65,7 @@ void vita_gpu_free(SceUID uid)
int VITA_CreateWindowFramebuffer(_THIS, SDL_Window *window, Uint32 *format, void **pixels, int *pitch)
{
SDL_WindowData *data = (SDL_WindowData *)window->driverdata;
SDL_WindowData *data = window->driverdata;
SceDisplayFrameBuf framebuf;
*format = SDL_PIXELFORMAT_ABGR8888;
@ -101,7 +101,7 @@ int VITA_UpdateWindowFramebuffer(_THIS, SDL_Window *window, const SDL_Rect *rect
void VITA_DestroyWindowFramebuffer(_THIS, SDL_Window *window)
{
SDL_WindowData *data = (SDL_WindowData *)window->driverdata;
SDL_WindowData *data = window->driverdata;
if (data == NULL) {
/* The window wasn't fully initialized */

View file

@ -94,7 +94,7 @@ VITA_GL_CreateContext(_THIS, SDL_Window *window)
_this->gl_config.minor_version = 0;
_this->gl_config.profile_mask = SDL_GL_CONTEXT_PROFILE_ES;
context = SDL_EGL_CreateContext(_this, ((SDL_WindowData *)window->driverdata)->egl_surface);
context = SDL_EGL_CreateContext(_this, window->driverdata->egl_surface);
if (context != NULL) {
FB_WIDTH = window->w;

View file

@ -80,7 +80,7 @@ static EGLint height = 544;
SDL_GLContext VITA_GLES_CreateContext(_THIS, SDL_Window *window)
{
SDL_WindowData *wdata = (SDL_WindowData *)window->driverdata;
SDL_WindowData *wdata = window->driverdata;
EGLint attribs[32];
EGLDisplay display;
@ -193,7 +193,7 @@ int VITA_GLES_SwapWindow(_THIS, SDL_Window *window)
void VITA_GLES_DeleteContext(_THIS, SDL_GLContext context)
{
SDL_VideoData *phdata = (SDL_VideoData *)_this->driverdata;
SDL_VideoData *phdata = _this->driverdata;
EGLBoolean status;
if (phdata->egl_initialized != SDL_TRUE) {

View file

@ -70,13 +70,13 @@ int VITA_GLES_LoadLibrary(_THIS, const char *path)
SDL_GLContext
VITA_GLES_CreateContext(_THIS, SDL_Window *window)
{
return SDL_EGL_CreateContext(_this, ((SDL_WindowData *)window->driverdata)->egl_surface);
return SDL_EGL_CreateContext(_this, window->driverdata->egl_surface);
}
int VITA_GLES_MakeCurrent(_THIS, SDL_Window *window, SDL_GLContext context)
{
if (window && context) {
return SDL_EGL_MakeCurrent(_this, ((SDL_WindowData *)window->driverdata)->egl_surface, context);
return SDL_EGL_MakeCurrent(_this, window->driverdata->egl_surface, context);
} else {
return SDL_EGL_MakeCurrent(_this, NULL, NULL);
}
@ -84,11 +84,11 @@ int VITA_GLES_MakeCurrent(_THIS, SDL_Window *window, SDL_GLContext context)
int VITA_GLES_SwapWindow(_THIS, SDL_Window *window)
{
SDL_VideoData *videodata = (SDL_VideoData *)_this->driverdata;
SDL_VideoData *videodata = _this->driverdata;
if (videodata->ime_active) {
sceImeUpdate();
}
return SDL_EGL_SwapBuffers(_this, ((SDL_WindowData *)window->driverdata)->egl_surface);
return SDL_EGL_SwapBuffers(_this, window->driverdata->egl_surface);
}
#endif /* SDL_VIDEO_DRIVER_VITA && SDL_VIDEO_VITA_PVR */

View file

@ -56,13 +56,8 @@ SDL_Window *Vita_Window;
static void VITA_Destroy(SDL_VideoDevice *device)
{
/* SDL_VideoData *phdata = (SDL_VideoData *) device->driverdata; */
SDL_free(device->driverdata);
SDL_free(device);
// if (device->driverdata != NULL) {
// device->driverdata = NULL;
// }
}
static SDL_VideoDevice *VITA_Create()
@ -352,7 +347,6 @@ void VITA_SetWindowGrab(_THIS, SDL_Window *window, SDL_bool grabbed)
void VITA_DestroyWindow(_THIS, SDL_Window *window)
{
// SDL_VideoData *videodata = (SDL_VideoData *)_this->driverdata;
SDL_WindowData *data;
data = window->driverdata;
@ -441,7 +435,7 @@ void VITA_ImeEventHandler(void *arg, const SceImeEventData *e)
void VITA_ShowScreenKeyboard(_THIS, SDL_Window *window)
{
SDL_VideoData *videodata = (SDL_VideoData *)_this->driverdata;
SDL_VideoData *videodata = _this->driverdata;
SceInt32 res;
#if defined(SDL_VIDEO_VITA_PVR)
@ -503,7 +497,7 @@ void VITA_ShowScreenKeyboard(_THIS, SDL_Window *window)
void VITA_HideScreenKeyboard(_THIS, SDL_Window *window)
{
#if !defined(SDL_VIDEO_VITA_PVR)
SDL_VideoData *videodata = (SDL_VideoData *)_this->driverdata;
SDL_VideoData *videodata = _this->driverdata;
SceCommonDialogStatus dialogStatus = sceImeDialogGetStatus();
@ -524,7 +518,7 @@ void VITA_HideScreenKeyboard(_THIS, SDL_Window *window)
SDL_bool VITA_IsScreenKeyboardShown(_THIS, SDL_Window *window)
{
#if defined(SDL_VIDEO_VITA_PVR)
SDL_VideoData *videodata = (SDL_VideoData *)_this->driverdata;
SDL_VideoData *videodata = _this->driverdata;
return videodata->ime_active;
#else
SceCommonDialogStatus dialogStatus = sceImeDialogGetStatus();
@ -535,7 +529,7 @@ SDL_bool VITA_IsScreenKeyboardShown(_THIS, SDL_Window *window)
void VITA_PumpEvents(_THIS)
{
#if !defined(SDL_VIDEO_VITA_PVR)
SDL_VideoData *videodata = (SDL_VideoData *)_this->driverdata;
SDL_VideoData *videodata = _this->driverdata;
#endif
if (_this->suspend_screensaver) {

View file

@ -31,21 +31,16 @@
#include <psp2/ime_dialog.h>
#include <psp2/sysmodule.h>
typedef struct SDL_VideoData
struct SDL_VideoData
{
SDL_bool egl_initialized; /* OpenGL device initialization status */
uint32_t egl_refcount; /* OpenGL reference count */
SceWChar16 ime_buffer[SCE_IME_DIALOG_MAX_TEXT_LENGTH];
SDL_bool ime_active;
} SDL_VideoData;
};
typedef struct SDL_DisplayData
{
} SDL_DisplayData;
typedef struct SDL_WindowData
struct SDL_WindowData
{
SDL_bool uses_gles;
SceUID buffer_uid;
@ -54,7 +49,7 @@ typedef struct SDL_WindowData
EGLSurface egl_surface;
EGLContext egl_context;
#endif
} SDL_WindowData;
};
extern SDL_Window *Vita_Window;

View file

@ -29,9 +29,7 @@
int VIVANTE_GLES_LoadLibrary(_THIS, const char *path)
{
SDL_DisplayData *displaydata;
displaydata = SDL_GetDisplayDriverData(0);
SDL_DisplayData *displaydata = SDL_GetDisplayDriverData(SDL_GetPrimaryDisplay());
return SDL_EGL_LoadLibrary(_this, path, displaydata->native_display, 0);
}

View file

@ -39,10 +39,8 @@
static void VIVANTE_Destroy(SDL_VideoDevice *device)
{
if (device->driverdata != NULL) {
SDL_free(device->driverdata);
device->driverdata = NULL;
}
SDL_free(device);
}
static SDL_VideoDevice *VIVANTE_Create()
@ -169,7 +167,7 @@ static int VIVANTE_AddVideoDisplays(_THIS)
int VIVANTE_VideoInit(_THIS)
{
SDL_VideoData *videodata = (SDL_VideoData *)_this->driverdata;
SDL_VideoData *videodata = _this->driverdata;
#if SDL_VIDEO_DRIVER_VIVANTE_VDK
videodata->vdk_private = vdkInitialize();
@ -221,7 +219,7 @@ int VIVANTE_VideoInit(_THIS)
void VIVANTE_VideoQuit(_THIS)
{
SDL_VideoData *videodata = (SDL_VideoData *)_this->driverdata;
SDL_VideoData *videodata = _this->driverdata;
#ifdef SDL_INPUT_LINUXEV
SDL_EVDEV_Quit();
@ -255,7 +253,7 @@ int VIVANTE_SetDisplayMode(_THIS, SDL_VideoDisplay *display, SDL_DisplayMode *mo
int VIVANTE_CreateWindow(_THIS, SDL_Window *window)
{
SDL_VideoData *videodata = (SDL_VideoData *)_this->driverdata;
SDL_VideoData *videodata = _this->driverdata;
SDL_DisplayData *displaydata;
SDL_WindowData *data;
@ -296,7 +294,7 @@ int VIVANTE_CreateWindow(_THIS, SDL_Window *window)
void VIVANTE_DestroyWindow(_THIS, SDL_Window *window)
{
SDL_VideoData *videodata = (SDL_VideoData *)_this->driverdata;
SDL_VideoData *videodata = _this->driverdata;
SDL_WindowData *data;
data = window->driverdata;
@ -361,7 +359,7 @@ void VIVANTE_HideWindow(_THIS, SDL_Window *window)
/*****************************************************************************/
int VIVANTE_GetWindowWMInfo(_THIS, SDL_Window *window, struct SDL_SysWMinfo *info)
{
SDL_WindowData *data = (SDL_WindowData *)window->driverdata;
SDL_WindowData *data = window->driverdata;
SDL_DisplayData *displaydata = SDL_GetDisplayDriverData(0);
info->subsystem = SDL_SYSWM_VIVANTE;

Some files were not shown because too many files have changed in this diff Show more