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
+7 -2
View File
@@ -1993,12 +1993,12 @@ typedef SDL_GameControllerButtonBind, SDL_GamepadBinding;
@@ @@
@@ @@
- SDL_GetPointDisplayIndex - SDL_GetPointDisplayIndex
+ SDL_GetDisplayIndexForPoint + SDL_GetDisplayForPoint
(...) (...)
@@ @@
@@ @@
- SDL_GetRectDisplayIndex - SDL_GetRectDisplayIndex
+ SDL_GetDisplayIndexForRect + SDL_GetDisplayForRect
(...) (...)
@ depends on rule_init_noparachute @ @ depends on rule_init_noparachute @
expression e; expression e;
@@ -2354,3 +2354,8 @@ SDL_DisplayMode e;
- e.h - e.h
+ e.screen_h + e.screen_h
) )
@@
@@
- SDL_GetWindowDisplayIndex
+ SDL_GetDisplayForWindow
(...)
+29 -3
View File
@@ -444,7 +444,7 @@ The following functions have been removed:
* SDL_JoystickGetDeviceVendor() - replaced with SDL_GetJoystickInstanceVendor() * SDL_JoystickGetDeviceVendor() - replaced with SDL_GetJoystickInstanceVendor()
* SDL_JoystickNameForIndex() - replaced with SDL_GetJoystickInstanceName() * SDL_JoystickNameForIndex() - replaced with SDL_GetJoystickInstanceName()
* SDL_JoystickPathForIndex() - replaced with SDL_GetJoystickInstancePath() * SDL_JoystickPathForIndex() - replaced with SDL_GetJoystickInstancePath()
* SDL_NumJoysticks - replaced with SDL_GetJoysticks() * SDL_NumJoysticks() - replaced with SDL_GetJoysticks()
## SDL_keyboard.h ## 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. 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_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. 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: The following functions have been renamed:
* SDL_GetDisplayDPI() => SDL_GetDisplayPhysicalDPI() * SDL_GetDisplayDPI() => SDL_GetDisplayPhysicalDPI()
* SDL_GetPointDisplayIndex() => SDL_GetDisplayIndexForPoint() * SDL_GetPointDisplayIndex() => SDL_GetDisplayForPoint()
* SDL_GetRectDisplayIndex() => SDL_GetDisplayIndexForRect() * 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 SDL_Window id type is named SDL_WindowID
+1 -1
View File
@@ -341,7 +341,7 @@ int main(int argc, char **argv)
if (SDL_Init(SDL_INIT_VIDEO) != 0) { if (SDL_Init(SDL_INIT_VIDEO) != 0) {
return 1; return 1;
} else if (SDL_GetCurrentDisplayMode(0, &mode) != 0) { } else if (SDL_GetCurrentDisplayMode(SDL_GetPrimaryDisplay(), &mode) != 0) {
return 1; return 1;
} else if (SDL_CreateWindowAndRenderer(mode.w, mode.h, SDL_WINDOW_FULLSCREEN_EXCLUSIVE, &window, &renderer) != 0) { } else if (SDL_CreateWindowAndRenderer(mode.w, mode.h, SDL_WINDOW_FULLSCREEN_EXCLUSIVE, &window, &renderer) != 0) {
return 1; return 1;
+1 -1
View File
@@ -215,7 +215,7 @@ typedef struct SDL_DisplayEvent
{ {
Uint32 type; /**< ::SDL_DISPLAYEVENT_* */ Uint32 type; /**< ::SDL_DISPLAYEVENT_* */
Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */ 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 */ Sint32 data1; /**< event dependent data */
} SDL_DisplayEvent; } SDL_DisplayEvent;
+6 -4
View File
@@ -413,8 +413,9 @@
/* ##SDL_video.h */ /* ##SDL_video.h */
#define SDL_GetDisplayDPI SDL_GetDisplayPhysicalDPI #define SDL_GetDisplayDPI SDL_GetDisplayPhysicalDPI
#define SDL_GetPointDisplayIndex SDL_GetDisplayIndexForPoint #define SDL_GetPointDisplayIndex SDL_GetDisplayForPoint
#define SDL_GetRectDisplayIndex SDL_GetDisplayIndexForRect #define SDL_GetRectDisplayIndex SDL_GetDisplayForRect
#define SDL_GetWindowDisplayIndex SDL_GetDisplayForWindow
#define SDL_WINDOW_FULLSCREEN SDL_WINDOW_FULLSCREEN_EXCLUSIVE #define SDL_WINDOW_FULLSCREEN SDL_WINDOW_FULLSCREEN_EXCLUSIVE
#define SDL_WINDOW_INPUT_GRABBED SDL_WINDOW_MOUSE_GRABBED #define SDL_WINDOW_INPUT_GRABBED SDL_WINDOW_MOUSE_GRABBED
@@ -795,8 +796,9 @@
/* ##SDL_video.h */ /* ##SDL_video.h */
#define SDL_GetDisplayDPI SDL_GetDisplayDPI_renamed_SDL_GetDisplayPhysicalDPI #define SDL_GetDisplayDPI SDL_GetDisplayDPI_renamed_SDL_GetDisplayPhysicalDPI
#define SDL_GetPointDisplayIndex SDL_GetPointDisplayIndex_renamed_SDL_GetDisplayIndexForPoint #define SDL_GetPointDisplayIndex SDL_GetPointDisplayIndex_renamed_SDL_GetDisplayForPoint
#define SDL_GetRectDisplayIndex SDL_GetRectDisplayIndex_renamed_SDL_GetDisplayIndexForRect #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_FULLSCREEN SDL_WINDOW_FULLSCREEN_renamed_SDL_WINDOW_FULLSCREEN_EXCLUSIVE
#define SDL_WINDOW_INPUT_GRABBED SDL_WINDOW_INPUT_GRABBED_renamed_SDL_WINDOW_MOUSE_GRABBED #define SDL_WINDOW_INPUT_GRABBED SDL_WINDOW_INPUT_GRABBED_renamed_SDL_WINDOW_MOUSE_GRABBED
+6 -10
View File
@@ -60,19 +60,18 @@ extern DECLSPEC void SDLCALL SDL_SetWindowsMessageHook(SDL_WindowsMessageHook ca
#if defined(__WIN32__) || defined(__WINGDK__) #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 * The returned adapter index can be passed to `IDirect3D9::CreateDevice` and
* controls on which monitor a full screen application will appear. * controls on which monitor a full screen application will appear.
* *
* \param displayIndex the display index for which to get the D3D9 adapter * \param displayID the instance of the display to query
* index
* \returns the D3D9 adapter index on success or a negative error code on * \returns the D3D9 adapter index on success or a negative error code on
* failure; call SDL_GetError() for more information. * failure; call SDL_GetError() for more information.
* *
* \since This function is available since SDL 3.0.0. * \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; typedef struct IDirect3DDevice9 IDirect3DDevice9;
@@ -131,16 +130,13 @@ extern DECLSPEC ID3D12Device* SDLCALL SDL_RenderGetD3D12Device(SDL_Renderer* ren
#if defined(__WIN32__) || defined(__WINGDK__) #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 * The DXGI Adapter and Output indices can be passed to `EnumAdapters` and
* `EnumOutputs` respectively to get the objects required to create a DX10 or * `EnumOutputs` respectively to get the objects required to create a DX10 or
* DX11 device and swap chain. * DX11 device and swap chain.
* *
* Before SDL 2.0.4 this function did not return a value. Since SDL 2.0.4 it * \param displayID the instance of the display to query
* returns an SDL_bool.
*
* \param displayIndex the display index for which to get both indices
* \param adapterIndex a pointer to be filled in with the adapter index * \param adapterIndex a pointer to be filled in with the adapter index
* \param outputIndex a pointer to be filled in with the output 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() * \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. * \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__) */ #endif /* defined(__WIN32__) || defined(__WINGDK__) */
+66 -73
View File
@@ -40,6 +40,7 @@ extern "C" {
#endif #endif
typedef Uint32 SDL_DisplayID;
typedef Uint32 SDL_WindowID; 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); 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 * \param count a pointer filled in with the number of displays returned
* SDL_GetError() for more information. * \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. * \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. * Get the name of a display in UTF-8 encoding.
* *
* \param displayIndex the index of display from which the name should be * \param displayID the instance ID of the display to query
* queried * \returns the name of a display or NULL on failure; call SDL_GetError() for more information.
* \returns the name of a display or NULL for an invalid display index or
* failure; call SDL_GetError() for more information.
* *
* \since This function is available since SDL 3.0.0. * \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. * 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 * \param rect the SDL_Rect structure filled in with the display bounds
* \returns 0 on success or a negative error code on failure; call * \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information. * SDL_GetError() for more information.
* *
* \since This function is available since SDL 3.0.0. * \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 * Get the usable desktop area represented by a display, in screen
* coordinates. * coordinates.
* *
* The primary display (`displayIndex` zero) is always located at 0,0.
*
* This is the same area as SDL_GetDisplayBounds() reports, but with portions * This is the same area as SDL_GetDisplayBounds() reports, but with portions
* reserved by the system removed. For example, on Apple's macOS, this * reserved by the system removed. For example, on Apple's macOS, this
* subtracts the area occupied by the menu bar and dock. * 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 * so these are good guidelines for the maximum space available to a
* non-fullscreen window. * non-fullscreen window.
* *
* The parameter `rect` is ignored if it is NULL. * \param displayID the instance ID of the display to query
*
* 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 rect the SDL_Rect structure filled in with the display bounds * \param rect the SDL_Rect structure filled in with the display bounds
* \returns 0 on success or a negative error code on failure; call * \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information. * 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. * \since This function is available since SDL 3.0.0.
* *
* \sa SDL_GetDisplayBounds * \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. * 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 * Diagonal, horizontal and vertical DPI can all be optionally returned if the
* appropriate parameter is non-NULL. * 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 * **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 * 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, * 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 * will be rethinking how high-dpi details should be managed in SDL3 to make
* things more consistent, reliable, and clear. * things more consistent, reliable, and clear.
* *
* \param displayIndex the index of the display from which DPI information * \param displayID the instance ID of the display to query
* should be queried
* \param ddpi a pointer filled in with the diagonal DPI of the display; may * \param ddpi a pointer filled in with the diagonal DPI of the display; may
* be NULL * be NULL
* \param hdpi a pointer filled in with the horizontal DPI of the display; may * \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. * \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. * 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 * \returns The SDL_DisplayOrientation enum value of the display, or
* `SDL_ORIENTATION_UNKNOWN` if it isn't available. * `SDL_ORIENTATION_UNKNOWN` if it isn't available.
* *
* \since This function is available since SDL 3.0.0. * \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. * Get the number of available display modes.
* *
* The `displayIndex` needs to be in the range from 0 to * \param displayID the instance ID of the display to query
* SDL_GetNumVideoDisplays() - 1.
*
* \param displayIndex the index of the display to query
* \returns a number >= 1 on success or a negative error code on failure; call * \returns a number >= 1 on success or a negative error code on failure; call
* SDL_GetError() for more information. * SDL_GetError() for more information.
* *
* \since This function is available since SDL 3.0.0. * \since This function is available since SDL 3.0.0.
* *
* \sa SDL_GetDisplayMode * \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. * Get information about a specific display mode.
* *
* The display modes are sorted in this priority: * The display modes are sorted in this priority:
* *
* - width -> largest to smallest * - screen_w -> largest to smallest
* - height -> largest to smallest * - screen_h -> largest to smallest
* - display_scale -> smallest to largest * - pixel_w -> largest to smallest
* - pixel_h -> largest to smallest
* - bits per pixel -> more colors to fewer colors * - bits per pixel -> more colors to fewer colors
* - packed pixel layout -> largest to smallest * - packed pixel layout -> largest to smallest
* - refresh rate -> highest to lowest * - 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 modeIndex the index of the display mode to query
* \param mode an SDL_DisplayMode structure filled in with the mode at * \param mode an SDL_DisplayMode structure filled in with the mode at
* `modeIndex` * `modeIndex`
@@ -460,7 +457,7 @@ extern DECLSPEC int SDLCALL SDL_GetNumDisplayModes(int displayIndex);
* *
* \sa SDL_GetNumDisplayModes * \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. * 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 * function will return the previous native display mode, and not the current
* display mode. * 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 * \param mode an SDL_DisplayMode structure filled in with the current display
* mode * mode
* \returns 0 on success or a negative error code on failure; call * \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_GetDisplayMode
* \sa SDL_SetWindowDisplayMode * \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. * 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 * function will return the current display mode, and not the previous native
* display mode. * 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 * \param mode an SDL_DisplayMode structure filled in with the current display
* mode * mode
* \returns 0 on success or a negative error code on failure; call * \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_GetDesktopDisplayMode
* \sa SDL_GetDisplayMode * \sa SDL_GetDisplayMode
* \sa SDL_GetNumVideoDisplays * \sa SDL_GetDisplays
* \sa SDL_SetWindowDisplayMode * \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. * 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 * and finally checking the refresh rate. If all the available modes are too
* small, then NULL is returned. * 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 * \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 * \param closest an SDL_DisplayMode structure filled in with the closest
* match of the available display modes * match of the available display modes
* \returns the passed in value `closest` or NULL if no matching video mode * \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_GetDisplayMode
* \sa SDL_GetNumDisplayModes * \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 * \param point the point to query
* \returns the index of the display containing the point or a negative error * \returns the instance ID of the display containing the point or 0 on failure; call SDL_GetError() for more information.
* code on failure; call SDL_GetError() for more information.
* *
* \since This function is available since SDL 3.0.0. * \since This function is available since SDL 3.0.0.
* *
* \sa SDL_GetDisplayBounds * \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 * \param rect the rect to query
* \returns the index of the display entirely containing the rect or closest * \returns the instance ID of the display entirely containing the rect or closest
* to the center of the rect on success or a negative error code on * to the center of the rect on success or 0 on failure; call SDL_GetError() for more information.
* failure; call SDL_GetError() for more information.
* *
* \since This function is available since SDL 3.0.0. * \since This function is available since SDL 3.0.0.
* *
* \sa SDL_GetDisplayBounds * \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 * \param window the window to query
* \returns the index of the display containing the center of the window on * \returns the instance ID of the display containing the center of the window on
* success or a negative error code on failure; call SDL_GetError() * success or 0 on failure; call SDL_GetError() for more information.
* for more information.
* *
* \since This function is available since SDL 3.0.0. * \since This function is available since SDL 3.0.0.
* *
* \sa SDL_GetDisplayBounds * \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. * Set the display mode to use when a window is visible at fullscreen.
+4 -4
View File
@@ -901,7 +901,7 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeOrientationChanged)(
displayOrientation = (SDL_DisplayOrientation)orientation; displayOrientation = (SDL_DisplayOrientation)orientation;
if (Android_Window) { if (Android_Window) {
SDL_VideoDisplay *display = SDL_GetDisplay(0); SDL_VideoDisplay *display = SDL_GetVideoDisplay(SDL_GetPrimaryDisplay());
SDL_SendDisplayEvent(display, SDL_EVENT_DISPLAY_ORIENTATION, orientation); 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); SDL_LockMutex(Android_ActivityMutex);
if (Android_Window) { if (Android_Window) {
SDL_WindowData *data = (SDL_WindowData *)Android_Window->driverdata; SDL_WindowData *data = Android_Window->driverdata;
data->native_window = Android_JNI_GetNativeWindow(); data->native_window = Android_JNI_GetNativeWindow();
if (data->native_window == NULL) { 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 SDL_VIDEO_OPENGL_EGL
if (Android_Window) { if (Android_Window) {
SDL_VideoDevice *_this = SDL_GetVideoDevice(); 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 the surface has been previously destroyed by onNativeSurfaceDestroyed, recreate it here */
if (data->egl_surface == EGL_NO_SURFACE) { if (data->egl_surface == EGL_NO_SURFACE) {
@@ -1078,7 +1078,7 @@ retry:
if (Android_Window) { if (Android_Window) {
SDL_VideoDevice *_this = SDL_GetVideoDevice(); 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' */ /* Wait for Main thread being paused and context un-activated to release 'egl_surface' */
if (!data->backup_done) { if (!data->backup_done) {
+4 -5
View File
@@ -432,16 +432,15 @@ void SDL_SetWindowsMessageHook(SDL_WindowsMessageHook callback, void *userdata)
#endif /* __WIN32__ || __GDK__ */ #endif /* __WIN32__ || __GDK__ */
#if defined(__WIN32__) || defined(__WINGDK__) #if defined(__WIN32__) || defined(__WINGDK__)
int SDL_Direct3D9GetAdapterIndex(int displayIndex) int SDL_Direct3D9GetAdapterIndex(SDL_DisplayID displayID)
{ {
(void)displayIndex; (void)displayID;
return 0; /* D3DADAPTER_DEFAULT */ return 0; /* D3DADAPTER_DEFAULT */
} }
SDL_bool SDL_bool SDL_DXGIGetOutputInfo(SDL_DisplayID displayID, int *adapterIndex, int *outputIndex)
SDL_DXGIGetOutputInfo(int displayIndex, int *adapterIndex, int *outputIndex)
{ {
(void)displayIndex; (void)displayID;
if (adapterIndex) { if (adapterIndex) {
*adapterIndex = -1; *adapterIndex = -1;
} }
+2 -2
View File
@@ -114,7 +114,7 @@ static void WINRT_ProcessWindowSizeChange() // TODO: Pass an SDL_Window-identify
if (coreWindow) { if (coreWindow) {
if (WINRT_GlobalSDLWindow) { if (WINRT_GlobalSDLWindow) {
SDL_Window *window = 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 x = (int)SDL_lroundf(data->coreWindow->Bounds.Left);
int y = (int)SDL_lroundf(data->coreWindow->Bounds.Top); 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 // 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; SDL_Window *window = WINRT_GlobalSDLWindow;
if (window) { if (window) {
SDL_WindowData *data = (SDL_WindowData *)window->driverdata; SDL_WindowData *data = window->driverdata;
int w = (int)SDL_floorf(data->coreWindow->Bounds.Width); int w = (int)SDL_floorf(data->coreWindow->Bounds.Width);
int h = (int)SDL_floorf(data->coreWindow->Bounds.Height); int h = (int)SDL_floorf(data->coreWindow->Bounds.Height);
SDL_SendWindowEvent(WINRT_GlobalSDLWindow, SDL_EVENT_WINDOW_RESIZED, w, h); SDL_SendWindowEvent(WINRT_GlobalSDLWindow, SDL_EVENT_WINDOW_RESIZED, w, h);
+5 -4
View File
@@ -164,8 +164,8 @@ SDL3_0.0.0 {
SDL_GetDesktopDisplayMode; SDL_GetDesktopDisplayMode;
SDL_GetDisplayBounds; SDL_GetDisplayBounds;
SDL_GetDisplayPhysicalDPI; SDL_GetDisplayPhysicalDPI;
SDL_GetDisplayIndexForPoint; SDL_GetDisplayForPoint;
SDL_GetDisplayIndexForRect; SDL_GetDisplayForRect;
SDL_GetDisplayMode; SDL_GetDisplayMode;
SDL_GetDisplayName; SDL_GetDisplayName;
SDL_GetDisplayOrientation; SDL_GetDisplayOrientation;
@@ -268,7 +268,6 @@ SDL3_0.0.0 {
SDL_GetNumRenderDrivers; SDL_GetNumRenderDrivers;
SDL_GetNumTouchDevices; SDL_GetNumTouchDevices;
SDL_GetNumTouchFingers; SDL_GetNumTouchFingers;
SDL_GetNumVideoDisplays;
SDL_GetNumVideoDrivers; SDL_GetNumVideoDrivers;
SDL_GetOriginalMemoryFunctions; SDL_GetOriginalMemoryFunctions;
SDL_GetPerformanceCounter; SDL_GetPerformanceCounter;
@@ -348,7 +347,7 @@ SDL3_0.0.0 {
SDL_GetVideoDriver; SDL_GetVideoDriver;
SDL_GetWindowBordersSize; SDL_GetWindowBordersSize;
SDL_GetWindowData; SDL_GetWindowData;
SDL_GetWindowDisplayIndex; SDL_GetDisplayForWindow;
SDL_GetWindowDisplayMode; SDL_GetWindowDisplayMode;
SDL_GetWindowFlags; SDL_GetWindowFlags;
SDL_GetWindowFromID; SDL_GetWindowFromID;
@@ -839,6 +838,8 @@ SDL3_0.0.0 {
SDL_aligned_alloc; SDL_aligned_alloc;
SDL_aligned_free; SDL_aligned_free;
SDL_ConvertAudioSamples; SDL_ConvertAudioSamples;
SDL_GetDisplays;
SDL_GetPrimaryDisplay;
# extra symbols go here (don't modify this line) # extra symbols go here (don't modify this line)
local: *; local: *;
}; };
+5 -4
View File
@@ -189,8 +189,8 @@
#define SDL_GetDesktopDisplayMode SDL_GetDesktopDisplayMode_REAL #define SDL_GetDesktopDisplayMode SDL_GetDesktopDisplayMode_REAL
#define SDL_GetDisplayBounds SDL_GetDisplayBounds_REAL #define SDL_GetDisplayBounds SDL_GetDisplayBounds_REAL
#define SDL_GetDisplayPhysicalDPI SDL_GetDisplayPhysicalDPI_REAL #define SDL_GetDisplayPhysicalDPI SDL_GetDisplayPhysicalDPI_REAL
#define SDL_GetDisplayIndexForPoint SDL_GetDisplayIndexForPoint_REAL #define SDL_GetDisplayForPoint SDL_GetDisplayForPoint_REAL
#define SDL_GetDisplayIndexForRect SDL_GetDisplayIndexForRect_REAL #define SDL_GetDisplayForRect SDL_GetDisplayForRect_REAL
#define SDL_GetDisplayMode SDL_GetDisplayMode_REAL #define SDL_GetDisplayMode SDL_GetDisplayMode_REAL
#define SDL_GetDisplayName SDL_GetDisplayName_REAL #define SDL_GetDisplayName SDL_GetDisplayName_REAL
#define SDL_GetDisplayOrientation SDL_GetDisplayOrientation_REAL #define SDL_GetDisplayOrientation SDL_GetDisplayOrientation_REAL
@@ -293,7 +293,6 @@
#define SDL_GetNumRenderDrivers SDL_GetNumRenderDrivers_REAL #define SDL_GetNumRenderDrivers SDL_GetNumRenderDrivers_REAL
#define SDL_GetNumTouchDevices SDL_GetNumTouchDevices_REAL #define SDL_GetNumTouchDevices SDL_GetNumTouchDevices_REAL
#define SDL_GetNumTouchFingers SDL_GetNumTouchFingers_REAL #define SDL_GetNumTouchFingers SDL_GetNumTouchFingers_REAL
#define SDL_GetNumVideoDisplays SDL_GetNumVideoDisplays_REAL
#define SDL_GetNumVideoDrivers SDL_GetNumVideoDrivers_REAL #define SDL_GetNumVideoDrivers SDL_GetNumVideoDrivers_REAL
#define SDL_GetOriginalMemoryFunctions SDL_GetOriginalMemoryFunctions_REAL #define SDL_GetOriginalMemoryFunctions SDL_GetOriginalMemoryFunctions_REAL
#define SDL_GetPerformanceCounter SDL_GetPerformanceCounter_REAL #define SDL_GetPerformanceCounter SDL_GetPerformanceCounter_REAL
@@ -373,7 +372,7 @@
#define SDL_GetVideoDriver SDL_GetVideoDriver_REAL #define SDL_GetVideoDriver SDL_GetVideoDriver_REAL
#define SDL_GetWindowBordersSize SDL_GetWindowBordersSize_REAL #define SDL_GetWindowBordersSize SDL_GetWindowBordersSize_REAL
#define SDL_GetWindowData SDL_GetWindowData_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_GetWindowDisplayMode SDL_GetWindowDisplayMode_REAL
#define SDL_GetWindowFlags SDL_GetWindowFlags_REAL #define SDL_GetWindowFlags SDL_GetWindowFlags_REAL
#define SDL_GetWindowFromID SDL_GetWindowFromID_REAL #define SDL_GetWindowFromID SDL_GetWindowFromID_REAL
@@ -866,3 +865,5 @@
#define SDL_aligned_alloc SDL_aligned_alloc_REAL #define SDL_aligned_alloc SDL_aligned_alloc_REAL
#define SDL_aligned_free SDL_aligned_free_REAL #define SDL_aligned_free SDL_aligned_free_REAL
#define SDL_ConvertAudioSamples SDL_ConvertAudioSamples_REAL #define SDL_ConvertAudioSamples SDL_ConvertAudioSamples_REAL
#define SDL_GetDisplays SDL_GetDisplays_REAL
#define SDL_GetPrimaryDisplay SDL_GetPrimaryDisplay_REAL
+17 -16
View File
@@ -72,8 +72,8 @@ SDL_DYNAPI_PROC(void,SDL_UnregisterApp,(void),(),)
#endif #endif
#if defined(__WIN32__) || defined(__WINGDK__) #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(SDL_bool,SDL_DXGIGetOutputInfo,(SDL_DisplayID a, int *b, int *c),(a,b,c),return)
SDL_DYNAPI_PROC(int,SDL_Direct3D9GetAdapterIndex,(int a),(a),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(ID3D11Device*,SDL_GetRenderD3D11Device,(SDL_Renderer *a),(a),return)
SDL_DYNAPI_PROC(IDirect3DDevice9*,SDL_GetRenderD3D9Device,(SDL_Renderer *a),(a),return) SDL_DYNAPI_PROC(IDirect3DDevice9*,SDL_GetRenderD3D9Device,(SDL_Renderer *a),(a),return)
#endif #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_GetCPUCacheLineSize,(void),(),return)
SDL_DYNAPI_PROC(int,SDL_GetCPUCount,(void),(),return) SDL_DYNAPI_PROC(int,SDL_GetCPUCount,(void),(),return)
SDL_DYNAPI_PROC(char*,SDL_GetClipboardText,(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(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(const char*,SDL_GetCurrentVideoDriver,(void),(),return)
SDL_DYNAPI_PROC(SDL_Cursor*,SDL_GetCursor,(void),(),return) SDL_DYNAPI_PROC(SDL_Cursor*,SDL_GetCursor,(void),(),return)
SDL_DYNAPI_PROC(SDL_AssertionHandler,SDL_GetDefaultAssertionHandler,(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(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(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_GetDesktopDisplayMode,(SDL_DisplayID 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_GetDisplayBounds,(SDL_DisplayID 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_GetDisplayPhysicalDPI,(SDL_DisplayID 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(SDL_DisplayID,SDL_GetDisplayForPoint,(const SDL_Point *a),(a),return)
SDL_DYNAPI_PROC(int,SDL_GetDisplayIndexForRect,(const SDL_Rect *a),(a),return) SDL_DYNAPI_PROC(SDL_DisplayID,SDL_GetDisplayForRect,(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(int,SDL_GetDisplayMode,(SDL_DisplayID a, int b, SDL_DisplayMode *c),(a,b,c),return)
SDL_DYNAPI_PROC(const char*,SDL_GetDisplayName,(int a),(a),return) SDL_DYNAPI_PROC(const char*,SDL_GetDisplayName,(SDL_DisplayID a),(a),return)
SDL_DYNAPI_PROC(SDL_DisplayOrientation,SDL_GetDisplayOrientation,(int a),(a),return) SDL_DYNAPI_PROC(SDL_DisplayOrientation,SDL_GetDisplayOrientation,(SDL_DisplayID a),(a),return)
SDL_DYNAPI_PROC(int,SDL_GetDisplayUsableBounds,(int a, SDL_Rect *b),(a,b),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(const char*,SDL_GetError,(void),(),return)
SDL_DYNAPI_PROC(char*,SDL_GetErrorMsg,(char *a, int b),(a,b),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) 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_GetNumAllocations,(void),(),return)
SDL_DYNAPI_PROC(int,SDL_GetNumAudioDevices,(int a),(a),return) SDL_DYNAPI_PROC(int,SDL_GetNumAudioDevices,(int a),(a),return)
SDL_DYNAPI_PROC(int,SDL_GetNumAudioDrivers,(void),(),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_GetNumGamepadMappings,(void),(),return)
SDL_DYNAPI_PROC(int,SDL_GetNumJoystickAxes,(SDL_Joystick *a),(a),return) SDL_DYNAPI_PROC(int,SDL_GetNumJoystickAxes,(SDL_Joystick *a),(a),return)
SDL_DYNAPI_PROC(int,SDL_GetNumJoystickButtons,(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_GetNumRenderDrivers,(void),(),return)
SDL_DYNAPI_PROC(int,SDL_GetNumTouchDevices,(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_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(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(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) 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(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(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(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(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(Uint32,SDL_GetWindowFlags,(SDL_Window *a),(a),return)
SDL_DYNAPI_PROC(SDL_Window*,SDL_GetWindowFromID,(Uint32 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_alloc,(size_t a, size_t b),(a,b),return)
SDL_DYNAPI_PROC(void,SDL_aligned_free,(void *a),(a),) 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(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)
+1 -1
View File
@@ -48,7 +48,7 @@ int SDL_SendDisplayEvent(SDL_VideoDisplay *display, SDL_EventType displayevent,
SDL_Event event; SDL_Event event;
event.type = displayevent; event.type = displayevent;
event.common.timestamp = 0; event.common.timestamp = 0;
event.display.display = SDL_GetIndexOfDisplay(display); event.display.displayID = display->id;
event.display.data1 = data1; event.display.data1 = data1;
posted = (SDL_PushEvent(&event) > 0); posted = (SDL_PushEvent(&event) > 0);
} }
+1 -1
View File
@@ -217,7 +217,7 @@ static void SDL_LogEvent(const SDL_Event *event)
case x: \ case x: \
SDL_strlcpy(name, #x, sizeof(name)); \ SDL_strlcpy(name, #x, sizeof(name)); \
(void)SDL_snprintf(details, sizeof(details), " (timestamp=%u display=%u event=%s data1=%d)", \ (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 break
SDL_DISPLAYEVENT_CASE(SDL_EVENT_DISPLAY_ORIENTATION); SDL_DISPLAYEVENT_CASE(SDL_EVENT_DISPLAY_ORIENTATION);
SDL_DISPLAYEVENT_CASE(SDL_EVENT_DISPLAY_CONNECTED); SDL_DISPLAYEVENT_CASE(SDL_EVENT_DISPLAY_CONNECTED);
+2 -2
View File
@@ -141,10 +141,10 @@ int SDL_SendWindowEvent(SDL_Window *window, SDL_EventType windowevent,
window->flags &= ~SDL_WINDOW_INPUT_FOCUS; window->flags &= ~SDL_WINDOW_INPUT_FOCUS;
break; break;
case SDL_EVENT_WINDOW_DISPLAY_CHANGED: case SDL_EVENT_WINDOW_DISPLAY_CHANGED:
if (data1 < 0 || data1 == window->display_index) { if (data1 == 0 || (SDL_DisplayID)data1 == window->displayID) {
return 0; return 0;
} }
window->display_index = data1; window->displayID = (SDL_DisplayID)data1;
break; break;
default: default:
break; break;
+4 -4
View File
@@ -915,15 +915,15 @@ static SDL_RenderLineMethod SDL_GetRenderLineMethod()
static void SDL_CalculateSimulatedVSyncInterval(SDL_Renderer *renderer, SDL_Window *window) 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; SDL_DisplayMode mode;
float refresh_rate; float refresh_rate;
int num, den; int num, den;
if (display_index < 0) { if (displayID == 0) {
display_index = 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; refresh_rate = mode.refresh_rate;
} else { } else {
/* Pick a good default refresh rate */ /* Pick a good default refresh rate */
+3 -3
View File
@@ -1557,7 +1557,7 @@ D3D_CreateRenderer(SDL_Window *window, Uint32 flags)
Uint32 window_flags; Uint32 window_flags;
int w, h; int w, h;
SDL_DisplayMode fullscreen_mode; SDL_DisplayMode fullscreen_mode;
int displayIndex; SDL_DisplayID displayID;
if (SDL_GetWindowWMInfo(window, &windowinfo, SDL_SYSWM_CURRENT_VERSION) < 0 || if (SDL_GetWindowWMInfo(window, &windowinfo, SDL_SYSWM_CURRENT_VERSION) < 0 ||
windowinfo.subsystem != SDL_SYSWM_WINDOWS) { 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 */ /* Get the adapter for the display that the window is on */
displayIndex = SDL_GetWindowDisplayIndex(window); displayID = SDL_GetDisplayForWindow(window);
data->adapter = SDL_Direct3D9GetAdapterIndex(displayIndex); data->adapter = SDL_Direct3D9GetAdapterIndex(displayID);
IDirect3D9_GetDeviceCaps(data->d3d, data->adapter, D3DDEVTYPE_HAL, &caps); IDirect3D9_GetDeviceCaps(data->d3d, data->adapter, D3DDEVTYPE_HAL, &caps);
+64 -37
View File
@@ -1099,6 +1099,7 @@ SDLTest_CommonInit(SDLTest_CommonState *state)
} }
if (state->verbose & VERBOSE_MODES) { if (state->verbose & VERBOSE_MODES) {
SDL_DisplayID *displays;
SDL_Rect bounds, usablebounds; SDL_Rect bounds, usablebounds;
float hdpi = 0; float hdpi = 0;
float vdpi = 0; float vdpi = 0;
@@ -1109,24 +1110,25 @@ SDLTest_CommonInit(SDLTest_CommonState *state)
int adapterIndex = 0; int adapterIndex = 0;
int outputIndex = 0; int outputIndex = 0;
#endif #endif
n = SDL_GetNumVideoDisplays(); displays = SDL_GetDisplays(&n);
SDL_Log("Number of displays: %d\n", n); SDL_Log("Number of displays: %d\n", n);
for (i = 0; i < n; ++i) { 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_zero(bounds);
SDL_GetDisplayBounds(i, &bounds); SDL_GetDisplayBounds(displayID, &bounds);
SDL_zero(usablebounds); 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("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("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_Log("DPI: %gx%g\n", hdpi, vdpi);
SDL_GetDesktopDisplayMode(i, &mode); SDL_GetDesktopDisplayMode(displayID, &mode);
SDL_GetMasksForPixelFormatEnum(mode.format, &bpp, &Rmask, &Gmask, SDL_GetMasksForPixelFormatEnum(mode.format, &bpp, &Rmask, &Gmask,
&Bmask, &Amask); &Bmask, &Amask);
SDL_Log(" Current mode: %dx%d@%gHz, %d%% scale, %d bits-per-pixel (%s)\n", 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 */ /* Print available fullscreen video modes */
m = SDL_GetNumDisplayModes(i); m = SDL_GetNumDisplayModes(displayID);
if (m == 0) { if (m == 0) {
SDL_Log("No available fullscreen video modes\n"); SDL_Log("No available fullscreen video modes\n");
} else { } else {
SDL_Log(" Fullscreen video modes:\n"); SDL_Log(" Fullscreen video modes:\n");
for (j = 0; j < m; ++j) { for (j = 0; j < m; ++j) {
SDL_GetDisplayMode(i, j, &mode); SDL_GetDisplayMode(displayID, j, &mode);
SDL_GetMasksForPixelFormatEnum(mode.format, &bpp, &Rmask, SDL_GetMasksForPixelFormatEnum(mode.format, &bpp, &Rmask,
&Gmask, &Bmask, &Amask); &Gmask, &Bmask, &Amask);
SDL_Log(" Mode %d: %dx%d@%gHz, %d%% scale, %d bits-per-pixel (%s)\n", 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__) #if SDL_VIDEO_DRIVER_WINDOWS && !defined(__XBOXONE__) && !defined(__XBOXSERIES__)
/* Print the D3D9 adapter index */ /* Print the D3D9 adapter index */
adapterIndex = SDL_Direct3D9GetAdapterIndex(i); adapterIndex = SDL_Direct3D9GetAdapterIndex(displayID);
SDL_Log("D3D9 Adapter Index: %d", adapterIndex); SDL_Log("D3D9 Adapter Index: %d", adapterIndex);
/* Print the DXGI adapter and output indices */ /* 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); SDL_Log("DXGI Adapter Index: %d Output Index: %d", adapterIndex, outputIndex);
#endif #endif
} }
SDL_free(displays);
} }
if (state->verbose & VERBOSE_RENDER) { if (state->verbose & VERBOSE_RENDER) {
@@ -1236,7 +1239,14 @@ SDLTest_CommonInit(SDLTest_CommonState *state)
/* !!! FIXME: hack to make --usable-bounds work for now. */ /* !!! FIXME: hack to make --usable-bounds work for now. */
if ((r.x == -1) && (r.y == -1) && (r.w == -1) && (r.h == -1)) { 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) { if (state->num_windows > 1) {
@@ -1421,19 +1431,19 @@ static void SDLTest_PrintEvent(SDL_Event *event)
switch (event->type) { switch (event->type) {
case SDL_EVENT_DISPLAY_CONNECTED: case SDL_EVENT_DISPLAY_CONNECTED:
SDL_Log("SDL EVENT: Display %" SDL_PRIu32 " connected", SDL_Log("SDL EVENT: Display %" SDL_PRIu32 " connected",
event->display.display); event->display.displayID);
break; break;
case SDL_EVENT_DISPLAY_MOVED: case SDL_EVENT_DISPLAY_MOVED:
SDL_Log("SDL EVENT: Display %" SDL_PRIu32 " changed position", SDL_Log("SDL EVENT: Display %" SDL_PRIu32 " changed position",
event->display.display); event->display.displayID);
break; break;
case SDL_EVENT_DISPLAY_ORIENTATION: case SDL_EVENT_DISPLAY_ORIENTATION:
SDL_Log("SDL EVENT: Display %" SDL_PRIu32 " changed orientation to %s", 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; break;
case SDL_EVENT_DISPLAY_DISCONNECTED: case SDL_EVENT_DISPLAY_DISCONNECTED:
SDL_Log("SDL EVENT: Display %" SDL_PRIu32 " disconnected", SDL_Log("SDL EVENT: Display %" SDL_PRIu32 " disconnected",
event->display.display); event->display.displayID);
break; break;
case SDL_EVENT_WINDOW_SHOWN: case SDL_EVENT_WINDOW_SHOWN:
SDL_Log("SDL EVENT: Window %" SDL_PRIu32 " shown", event->window.windowID); 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) static void FullscreenTo(int index, int windowId)
{ {
int num_displays;
SDL_DisplayID *displays;
SDL_Window *window;
Uint32 flags; Uint32 flags;
struct SDL_Rect rect = { 0, 0, 0, 0 }; 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); flags = SDL_GetWindowFlags(window);
if ((flags & SDL_WINDOW_FULLSCREEN_MASK) != 0) { 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_SetWindowPosition(window, rect.x, rect.y);
SDL_SetWindowFullscreen(window, SDL_WINDOW_FULLSCREEN_EXCLUSIVE); SDL_SetWindowFullscreen(window, SDL_WINDOW_FULLSCREEN_EXCLUSIVE);
} }
}
SDL_free(displays);
}
void SDLTest_CommonEvent(SDLTest_CommonState *state, SDL_Event *event, int *done) 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 */ /* Alt-Up/Down/Left/Right switches between displays */
SDL_Window *window = SDL_GetWindowFromID(event->key.windowID); SDL_Window *window = SDL_GetWindowFromID(event->key.windowID);
if (window) { if (window) {
int currentIndex = SDL_GetWindowDisplayIndex(window); int num_displays;
int numDisplays = SDL_GetNumVideoDisplays(); SDL_DisplayID *displays = SDL_GetDisplays(&num_displays);
if (displays) {
SDL_DisplayID displayID = SDL_GetDisplayForWindow(window);
int current_index = -1;
if (currentIndex >= 0 && numDisplays >= 1) { for (i = 0; i < num_displays; ++i) {
int dest; if (displayID == displays[i]) {
if (event->key.keysym.sym == SDLK_UP || event->key.keysym.sym == SDLK_LEFT) { current_index = i;
dest = (currentIndex + numDisplays - 1) % numDisplays; break;
} else {
dest = (currentIndex + numDisplays + 1) % numDisplays;
} }
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_SetWindowPosition(window,
SDL_WINDOWPOS_CENTERED_DISPLAY(dest), SDL_WINDOWPOS_CENTERED_DISPLAY(dest),
SDL_WINDOWPOS_CENTERED_DISPLAY(dest)); SDL_WINDOWPOS_CENTERED_DISPLAY(dest));
} }
SDL_free(displays);
}
} }
} }
if (withShift) { if (withShift) {
@@ -2169,7 +2196,7 @@ void SDLTest_CommonDrawWindowInfo(SDL_Renderer *renderer, SDL_Window *window, fl
float ddpi, hdpi, vdpi; float ddpi, hdpi, vdpi;
float scaleX, scaleY; float scaleX, scaleY;
Uint32 flags; Uint32 flags;
const int windowDisplayIndex = SDL_GetWindowDisplayIndex(window); SDL_DisplayID windowDisplayID = SDL_GetDisplayForWindow(window);
SDL_RendererInfo info; SDL_RendererInfo info;
/* Video */ /* Video */
@@ -2259,36 +2286,36 @@ void SDLTest_CommonDrawWindowInfo(SDL_Renderer *renderer, SDL_Window *window, fl
SDL_SetRenderDrawColor(renderer, 170, 170, 170, 255); 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); SDLTest_DrawString(renderer, 0.0f, textY, text);
textY += lineHeight; 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); SDLTest_DrawString(renderer, 0.0f, textY, text);
textY += lineHeight; 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", (void)SDL_snprintf(text, sizeof text, "SDL_GetDisplayBounds: %d,%d, %dx%d",
rect.x, rect.y, rect.w, rect.h); rect.x, rect.y, rect.w, rect.h);
SDLTest_DrawString(renderer, 0.0f, textY, text); SDLTest_DrawString(renderer, 0.0f, textY, text);
textY += lineHeight; 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)", (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)); 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); SDLTest_DrawString(renderer, 0.0f, textY, text);
textY += lineHeight; 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)", (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)); 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); SDLTest_DrawString(renderer, 0.0f, textY, text);
textY += lineHeight; 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", (void)SDL_snprintf(text, sizeof text, "SDL_GetDisplayPhysicalDPI: ddpi: %g, hdpi: %g, vdpi: %g",
ddpi, hdpi, vdpi); ddpi, hdpi, vdpi);
SDLTest_DrawString(renderer, 0.0f, textY, text); 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: "); (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); SDLTest_DrawString(renderer, 0.0f, textY, text);
textY += lineHeight; textY += lineHeight;
+6 -9
View File
@@ -148,24 +148,21 @@ extern int SDL_EGL_SetErrorEx(const char *message, const char *eglFunctionName,
/* A few of useful macros */ /* A few of useful macros */
#define SDL_EGL_SwapWindow_impl(BACKEND) \ #define SDL_EGL_SwapWindow_impl(BACKEND) \
int \ int BACKEND##_GLES_SwapWindow(_THIS, SDL_Window *window) \
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) \ #define SDL_EGL_MakeCurrent_impl(BACKEND) \
int \ int BACKEND##_GLES_MakeCurrent(_THIS, SDL_Window *window, SDL_GLContext context) \
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) \ #define SDL_EGL_CreateContext_impl(BACKEND) \
SDL_GLContext \ SDL_GLContext BACKEND##_GLES_CreateContext(_THIS, SDL_Window *window) \
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 */ #endif /* SDL_VIDEO_OPENGL_EGL */
+11 -19
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); result = _this->shape_driver.SetWindowShape(window->shaper, shape, shape_mode);
window->shaper->hasshape = SDL_TRUE; window->shaper->hasshape = SDL_TRUE;
if (window->shaper->userx != 0 && window->shaper->usery != 0) { if (window->shaper->userx != 0 && window->shaper->usery != 0) {
SDL_DisplayID displayID = 0;
int x = window->shaper->userx; int x = window->shaper->userx;
int y = window->shaper->usery; int y = window->shaper->usery;
if (SDL_WINDOWPOS_ISUNDEFINED(x) || SDL_WINDOWPOS_ISUNDEFINED(y) || if (!displayID) {
SDL_WINDOWPOS_ISCENTERED(x) || SDL_WINDOWPOS_ISCENTERED(y)) { displayID = SDL_GetDisplayForWindowCoordinate(x);
int displayIndex; }
if (!displayID) {
displayID = SDL_GetDisplayForWindowCoordinate(y);
}
if (displayID) {
SDL_Rect bounds; SDL_Rect bounds;
SDL_GetDisplayBounds(displayID, &bounds);
if (SDL_WINDOWPOS_ISUNDEFINED(x) || SDL_WINDOWPOS_ISCENTERED(x)) { if (SDL_WINDOWPOS_ISUNDEFINED(x) || SDL_WINDOWPOS_ISCENTERED(x)) {
displayIndex = (x & 0xFFFF); x = bounds.x + (bounds.w - window->w) / 2;
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;
} }
if (SDL_WINDOWPOS_ISUNDEFINED(y) || SDL_WINDOWPOS_ISCENTERED(y)) { 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); SDL_SetWindowPosition(window, x, y);
+45 -16
View File
@@ -31,6 +31,34 @@ typedef struct SDL_WindowShaper SDL_WindowShaper;
typedef struct SDL_ShapeDriver SDL_ShapeDriver; typedef struct SDL_ShapeDriver SDL_ShapeDriver;
typedef struct SDL_VideoDisplay SDL_VideoDisplay; typedef struct SDL_VideoDisplay SDL_VideoDisplay;
typedef struct SDL_VideoDevice SDL_VideoDevice; 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 */ /* Define the SDL window-shaper structure */
struct SDL_WindowShaper struct SDL_WindowShaper
@@ -79,7 +107,7 @@ struct SDL_Window
int last_pixel_w, last_pixel_h; int last_pixel_w, last_pixel_h;
Uint32 flags; Uint32 flags;
Uint32 last_fullscreen_flags; Uint32 last_fullscreen_flags;
Uint32 display_index; SDL_DisplayID displayID;
/* Stored position and size for windowed mode */ /* Stored position and size for windowed mode */
SDL_Rect windowed; SDL_Rect windowed;
@@ -104,7 +132,7 @@ struct SDL_Window
SDL_WindowUserData *data; SDL_WindowUserData *data;
void *driverdata; SDL_WindowData *driverdata;
SDL_Window *prev; SDL_Window *prev;
SDL_Window *next; SDL_Window *next;
@@ -120,6 +148,7 @@ struct SDL_Window
*/ */
struct SDL_VideoDisplay struct SDL_VideoDisplay
{ {
SDL_DisplayID id;
char *name; char *name;
int max_display_modes; int max_display_modes;
int num_display_modes; int num_display_modes;
@@ -132,7 +161,7 @@ struct SDL_VideoDisplay
SDL_VideoDevice *device; SDL_VideoDevice *device;
void *driverdata; SDL_DisplayData *driverdata;
}; };
/* Forward declaration */ /* Forward declaration */
@@ -240,7 +269,7 @@ struct SDL_VideoDevice
void (*SetWindowAlwaysOnTop)(_THIS, SDL_Window *window, SDL_bool on_top); void (*SetWindowAlwaysOnTop)(_THIS, SDL_Window *window, SDL_bool on_top);
void (*SetWindowFullscreen)(_THIS, SDL_Window *window, SDL_VideoDisplay *display, SDL_bool fullscreen); void (*SetWindowFullscreen)(_THIS, SDL_Window *window, SDL_VideoDisplay *display, SDL_bool fullscreen);
void *(*GetWindowICCProfile)(_THIS, SDL_Window *window, size_t *size); 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 (*SetWindowMouseRect)(_THIS, SDL_Window *window);
void (*SetWindowMouseGrab)(_THIS, SDL_Window *window, SDL_bool grabbed); void (*SetWindowMouseGrab)(_THIS, SDL_Window *window, SDL_bool grabbed);
void (*SetWindowKeyboardGrab)(_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 */ /* Data private to this driver */
void *driverdata; SDL_VideoData *driverdata;
struct SDL_GLDriverData *gl_data; struct SDL_GLDriverData *gl_data;
#if SDL_VIDEO_OPENGL_EGL #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 */ /* Use SDL_OnVideoThread() sparingly, to avoid regressions in use cases that currently happen to work */
extern SDL_bool SDL_OnVideoThread(void); extern SDL_bool SDL_OnVideoThread(void);
extern SDL_VideoDevice *SDL_GetVideoDevice(void); extern SDL_VideoDevice *SDL_GetVideoDevice(void);
extern int SDL_AddBasicVideoDisplay(const SDL_DisplayMode *desktop_mode); extern SDL_bool SDL_IsVideoContextExternal(void);
extern int SDL_AddVideoDisplay(const SDL_VideoDisplay *display, SDL_bool send_event); extern SDL_DisplayID SDL_AddBasicVideoDisplay(const SDL_DisplayMode *desktop_mode);
extern void SDL_DelVideoDisplay(int index); 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 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_SetCurrentDisplayMode(SDL_VideoDisplay *display, const SDL_DisplayMode *mode);
extern void SDL_SetDesktopDisplayMode(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 void SDL_ResetDisplayModes(SDL_VideoDisplay *display);
extern int SDL_GetIndexOfDisplay(SDL_VideoDisplay *display); extern SDL_VideoDisplay *SDL_GetVideoDisplay(SDL_DisplayID display);
extern SDL_VideoDisplay *SDL_GetDisplay(int displayIndex); extern SDL_VideoDisplay *SDL_GetVideoDisplayForWindow(SDL_Window *window);
extern SDL_VideoDisplay *SDL_GetDisplayForWindow(SDL_Window *window); extern int SDL_GetDisplayIndex(SDL_DisplayID displayID);
extern void *SDL_GetDisplayDriverData(int displayIndex); extern SDL_DisplayData *SDL_GetDisplayDriverData(SDL_DisplayID display);
extern SDL_bool SDL_IsVideoContextExternal(void); extern SDL_DisplayData *SDL_GetDisplayDriverDataForWindow(SDL_Window *window);
extern SDL_DisplayID SDL_GetDisplayForWindowCoordinate(int coordinate);
extern int SDL_GetMessageBoxCount(void); extern int SDL_GetMessageBoxCount(void);
extern void SDL_GL_DeduceMaxSupportedESProfile(int *major, int *minor); 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 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 */ /* This has been moved out of the public API, but is still available for now */
#define SDL_WINDOW_ALLOW_HIGHDPI 0x00002000 #define SDL_WINDOW_ALLOW_HIGHDPI 0x00002000
+232 -202
View File
File diff suppressed because it is too large Load Diff
+4 -4
View File
@@ -72,7 +72,7 @@ static void android_egl_context_restore(SDL_Window *window)
{ {
if (window) { if (window) {
SDL_Event event; 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) { if (SDL_GL_MakeCurrent(window, (SDL_GLContext)data->egl_context) < 0) {
/* The context is no longer valid, create a new one */ /* The context is no longer valid, create a new one */
data->egl_context = (EGLContext)SDL_GL_CreateContext(window); data->egl_context = (EGLContext)SDL_GL_CreateContext(window);
@@ -89,7 +89,7 @@ static void android_egl_context_backup(SDL_Window *window)
{ {
if (window) { if (window) {
/* Keep a copy of the EGL Context so we can try to restore it when we resume */ /* 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(); data->egl_context = SDL_GL_GetCurrentContext();
/* We need to do this so the EGLSurface can be freed */ /* We need to do this so the EGLSurface can be freed */
SDL_GL_MakeCurrent(window, NULL); SDL_GL_MakeCurrent(window, NULL);
@@ -107,7 +107,7 @@ static void android_egl_context_backup(SDL_Window *window)
void Android_PumpEvents_Blocking(_THIS) void Android_PumpEvents_Blocking(_THIS)
{ {
SDL_VideoData *videodata = (SDL_VideoData *)_this->driverdata; SDL_VideoData *videodata = _this->driverdata;
if (videodata->isPaused) { if (videodata->isPaused) {
SDL_bool isContextExternal = SDL_IsVideoContextExternal(); SDL_bool isContextExternal = SDL_IsVideoContextExternal();
@@ -182,7 +182,7 @@ void Android_PumpEvents_Blocking(_THIS)
void Android_PumpEvents_NonBlocking(_THIS) void Android_PumpEvents_NonBlocking(_THIS)
{ {
SDL_VideoData *videodata = (SDL_VideoData *)_this->driverdata; SDL_VideoData *videodata = _this->driverdata;
static int backup_context = 0; static int backup_context = 0;
if (videodata->isPaused) { if (videodata->isPaused) {
+3 -3
View File
@@ -38,7 +38,7 @@
int Android_GLES_MakeCurrent(_THIS, SDL_Window *window, SDL_GLContext context) int Android_GLES_MakeCurrent(_THIS, SDL_Window *window, SDL_GLContext context)
{ {
if (window && 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 { } else {
return SDL_EGL_MakeCurrent(_this, NULL, NULL); return SDL_EGL_MakeCurrent(_this, NULL, NULL);
} }
@@ -51,7 +51,7 @@ Android_GLES_CreateContext(_THIS, SDL_Window *window)
Android_ActivityMutex_Lock_Running(); 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); 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->eglWaitNative(EGL_CORE_NATIVE_ENGINE);
_this->egl_data->eglWaitGL();*/ _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); SDL_UnlockMutex(Android_ActivityMutex);
+2 -2
View File
@@ -350,7 +350,7 @@ Android_IsScreenKeyboardShown(_THIS, SDL_Window *window)
void Android_StartTextInput(_THIS) void Android_StartTextInput(_THIS)
{ {
SDL_VideoData *videodata = (SDL_VideoData *)_this->driverdata; SDL_VideoData *videodata = _this->driverdata;
Android_JNI_ShowTextInput(&videodata->textRect); Android_JNI_ShowTextInput(&videodata->textRect);
} }
@@ -361,7 +361,7 @@ void Android_StopTextInput(_THIS)
void Android_SetTextInputRect(_THIS, const SDL_Rect *rect) void Android_SetTextInputRect(_THIS, const SDL_Rect *rect)
{ {
SDL_VideoData *videodata = (SDL_VideoData *)_this->driverdata; SDL_VideoData *videodata = _this->driverdata;
if (rect == NULL) { if (rect == NULL) {
SDL_InvalidParamError("rect"); SDL_InvalidParamError("rect");
+6 -6
View File
@@ -169,8 +169,8 @@ VideoBootStrap Android_bootstrap = {
int Android_VideoInit(_THIS) int Android_VideoInit(_THIS)
{ {
SDL_VideoData *videodata = (SDL_VideoData *)_this->driverdata; SDL_VideoData *videodata = _this->driverdata;
int display_index; SDL_DisplayID displayID;
SDL_VideoDisplay *display; SDL_VideoDisplay *display;
SDL_DisplayMode mode; SDL_DisplayMode mode;
@@ -186,11 +186,11 @@ int Android_VideoInit(_THIS)
mode.refresh_rate = Android_ScreenRate; mode.refresh_rate = Android_ScreenRate;
mode.driverdata = NULL; mode.driverdata = NULL;
display_index = SDL_AddBasicVideoDisplay(&mode); displayID = SDL_AddBasicVideoDisplay(&mode);
if (display_index < 0) { if (displayID == 0) {
return -1; return -1;
} }
display = SDL_GetDisplay(display_index); display = SDL_GetVideoDisplay(displayID);
display->orientation = Android_JNI_GetDisplayOrientation(); display->orientation = Android_JNI_GetDisplayOrientation();
SDL_AddDisplayMode(&_this->displays[0], &mode); 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 /* Force the current mode to match the resize otherwise the SDL_EVENT_WINDOW_RESTORED event
* will fall back to the old mode */ * will fall back to the old mode */
int w, h; int w, h;
SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window); SDL_VideoDisplay *display = SDL_GetVideoDisplayForWindow(window);
SDL_DisplayMode current_mode; SDL_DisplayMode current_mode;
current_mode.format = Android_ScreenFormat; current_mode.format = Android_ScreenFormat;
+2 -2
View File
@@ -32,13 +32,13 @@ extern void Android_SendResize(SDL_Window *window);
/* Private display data */ /* Private display data */
typedef struct SDL_VideoData struct SDL_VideoData
{ {
SDL_Rect textRect; SDL_Rect textRect;
int isPaused; int isPaused;
int isPausing; int isPausing;
int pauseAudio; int pauseAudio;
} SDL_VideoData; };
extern int Android_SurfaceWidth; extern int Android_SurfaceWidth;
extern int Android_SurfaceHeight; extern int Android_SurfaceHeight;
+1 -1
View File
@@ -130,7 +130,7 @@ SDL_bool Android_Vulkan_CreateSurface(_THIS,
VkInstance instance, VkInstance instance,
VkSurfaceKHR *surface) VkSurfaceKHR *surface)
{ {
SDL_WindowData *windowData = (SDL_WindowData *)window->driverdata; SDL_WindowData *windowData = window->driverdata;
PFN_vkGetInstanceProcAddr vkGetInstanceProcAddr = PFN_vkGetInstanceProcAddr vkGetInstanceProcAddr =
(PFN_vkGetInstanceProcAddr)_this->vulkan_config.vkGetInstanceProcAddr; (PFN_vkGetInstanceProcAddr)_this->vulkan_config.vkGetInstanceProcAddr;
PFN_vkCreateAndroidSurfaceKHR vkCreateAndroidSurfaceKHR = PFN_vkCreateAndroidSurfaceKHR vkCreateAndroidSurfaceKHR =
+3 -3
View File
@@ -128,7 +128,7 @@ void Android_SetWindowFullscreen(_THIS, SDL_Window *window, SDL_VideoDisplay *di
goto endfunction; goto endfunction;
} }
data = (SDL_WindowData *)window->driverdata; data = window->driverdata;
if (data == NULL || !data->native_window) { if (data == NULL || !data->native_window) {
if (data && !data->native_window) { if (data && !data->native_window) {
SDL_SetError("Missing native window"); SDL_SetError("Missing native window");
@@ -175,7 +175,7 @@ void Android_DestroyWindow(_THIS, SDL_Window *window)
Android_Window = NULL; Android_Window = NULL;
if (window->driverdata) { if (window->driverdata) {
SDL_WindowData *data = (SDL_WindowData *)window->driverdata; SDL_WindowData *data = window->driverdata;
#if SDL_VIDEO_OPENGL_EGL #if SDL_VIDEO_OPENGL_EGL
if (data->egl_surface != EGL_NO_SURFACE) { 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) 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->subsystem = SDL_SYSWM_ANDROID;
info->info.android.window = data->native_window; info->info.android.window = data->native_window;
+2 -2
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 int Android_GetWindowWMInfo(_THIS, SDL_Window *window, struct SDL_SysWMinfo *info);
extern SDL_Window *Android_Window; extern SDL_Window *Android_Window;
typedef struct struct SDL_WindowData
{ {
#if SDL_VIDEO_OPENGL_EGL #if SDL_VIDEO_OPENGL_EGL
EGLSurface egl_surface; EGLSurface egl_surface;
@@ -45,6 +45,6 @@ typedef struct
SDL_bool backup_done; SDL_bool backup_done;
ANativeWindow *native_window; ANativeWindow *native_window;
} SDL_WindowData; };
#endif /* SDL_androidwindow_h_ */ #endif /* SDL_androidwindow_h_ */
+1 -1
View File
@@ -28,7 +28,7 @@
int Cocoa_SetClipboardText(_THIS, const char *text) int Cocoa_SetClipboardText(_THIS, const char *text)
{ {
@autoreleasepool { @autoreleasepool {
SDL_VideoData *data = (__bridge SDL_VideoData *)_this->driverdata; SDL_VideoData *data = _this->driverdata;
NSPasteboard *pasteboard; NSPasteboard *pasteboard;
NSString *format = NSPasteboardTypeString; NSString *format = NSPasteboardTypeString;
NSString *nsstr = [NSString stringWithUTF8String:text]; NSString *nsstr = [NSString stringWithUTF8String:text];
+3 -3
View File
@@ -35,7 +35,7 @@ static SDL_Window *FindSDLWindowForNSWindow(NSWindow *win)
SDL_VideoDevice *device = SDL_GetVideoDevice(); SDL_VideoDevice *device = SDL_GetVideoDevice();
if (device && device->windows) { if (device && device->windows) {
for (sdlwindow = device->windows; sdlwindow; sdlwindow = sdlwindow->next) { for (sdlwindow = device->windows; sdlwindow; sdlwindow = sdlwindow->next) {
NSWindow *nswindow = ((__bridge SDL_WindowData *)sdlwindow->driverdata).nswindow; NSWindow *nswindow = sdlwindow->driverdata.nswindow;
if (win == nswindow) { if (win == nswindow) {
return sdlwindow; return sdlwindow;
} }
@@ -557,7 +557,7 @@ void Cocoa_SendWakeupEvent(_THIS, SDL_Window *window)
location:NSMakePoint(0, 0) location:NSMakePoint(0, 0)
modifierFlags:0 modifierFlags:0
timestamp:0.0 timestamp:0.0
windowNumber:((__bridge SDL_WindowData *)window->driverdata).window_number windowNumber:window->driverdata.window_number
context:nil context:nil
subtype:0 subtype:0
data1:0 data1:0
@@ -570,7 +570,7 @@ void Cocoa_SendWakeupEvent(_THIS, SDL_Window *window)
void Cocoa_SuspendScreenSaver(_THIS) void Cocoa_SuspendScreenSaver(_THIS)
{ {
@autoreleasepool { @autoreleasepool {
SDL_VideoData *data = (__bridge SDL_VideoData *)_this->driverdata; SDL_VideoData *data = _this->driverdata;
if (data.screensaver_assertion) { if (data.screensaver_assertion) {
IOPMAssertionRelease(data.screensaver_assertion); IOPMAssertionRelease(data.screensaver_assertion);
+6 -6
View File
@@ -294,7 +294,7 @@ cleanup:
void Cocoa_InitKeyboard(_THIS) void Cocoa_InitKeyboard(_THIS)
{ {
SDL_VideoData *data = (__bridge SDL_VideoData *)_this->driverdata; SDL_VideoData *data = _this->driverdata;
UpdateKeymap(data, SDL_FALSE); UpdateKeymap(data, SDL_FALSE);
@@ -314,11 +314,11 @@ void Cocoa_StartTextInput(_THIS)
{ {
@autoreleasepool { @autoreleasepool {
NSView *parentView; NSView *parentView;
SDL_VideoData *data = (__bridge SDL_VideoData *)_this->driverdata; SDL_VideoData *data = _this->driverdata;
SDL_Window *window = SDL_GetKeyboardFocus(); SDL_Window *window = SDL_GetKeyboardFocus();
NSWindow *nswindow = nil; NSWindow *nswindow = nil;
if (window) { if (window) {
nswindow = ((__bridge SDL_WindowData *)window->driverdata).nswindow; nswindow = window->driverdata.nswindow;
} }
parentView = [nswindow contentView]; parentView = [nswindow contentView];
@@ -345,7 +345,7 @@ void Cocoa_StartTextInput(_THIS)
void Cocoa_StopTextInput(_THIS) void Cocoa_StopTextInput(_THIS)
{ {
@autoreleasepool { @autoreleasepool {
SDL_VideoData *data = (__bridge SDL_VideoData *)_this->driverdata; SDL_VideoData *data = _this->driverdata;
if (data && data.fieldEdit) { if (data && data.fieldEdit) {
[data.fieldEdit removeFromSuperview]; [data.fieldEdit removeFromSuperview];
@@ -356,7 +356,7 @@ void Cocoa_StopTextInput(_THIS)
void Cocoa_SetTextInputRect(_THIS, const SDL_Rect *rect) void Cocoa_SetTextInputRect(_THIS, const SDL_Rect *rect)
{ {
SDL_VideoData *data = (__bridge SDL_VideoData *)_this->driverdata; SDL_VideoData *data = _this->driverdata;
if (!rect) { if (!rect) {
SDL_InvalidParamError("rect"); SDL_InvalidParamError("rect");
@@ -370,7 +370,7 @@ void Cocoa_HandleKeyEvent(_THIS, NSEvent *event)
{ {
unsigned short scancode; unsigned short scancode;
SDL_Scancode code; SDL_Scancode code;
SDL_VideoData *data = _this ? ((__bridge SDL_VideoData *)_this->driverdata) : nil; SDL_VideoData *data = _this ? _this->driverdata : nil;
if (!data) { if (!data) {
return; /* can happen when returning from fullscreen Space on shutdown */ return; /* can happen when returning from fullscreen Space on shutdown */
} }
+1 -1
View File
@@ -42,7 +42,7 @@
/* Retain the NSWindow because we'll show the alert later on the main thread */ /* Retain the NSWindow because we'll show the alert later on the main thread */
if (window) { if (window) {
nswindow = ((__bridge SDL_WindowData *)window->driverdata).nswindow; nswindow = window->driverdata.nswindow;
} else { } else {
nswindow = nil; nswindow = nil;
} }
+1 -1
View File
@@ -133,7 +133,7 @@ SDL_MetalView
Cocoa_Metal_CreateView(_THIS, SDL_Window *window) Cocoa_Metal_CreateView(_THIS, SDL_Window *window)
{ {
@autoreleasepool { @autoreleasepool {
SDL_WindowData *data = (__bridge SDL_WindowData *)window->driverdata; SDL_WindowData *data = window->driverdata;
NSView *view = data.nswindow.contentView; NSView *view = data.nswindow.contentView;
BOOL highDPI = (window->flags & SDL_WINDOW_ALLOW_HIGHDPI) != 0; BOOL highDPI = (window->flags & SDL_WINDOW_ALLOW_HIGHDPI) != 0;
Uint32 windowID = SDL_GetWindowID(window); Uint32 windowID = SDL_GetWindowID(window);
+4 -4
View File
@@ -23,15 +23,15 @@
#ifndef SDL_cocoamodes_h_ #ifndef SDL_cocoamodes_h_
#define SDL_cocoamodes_h_ #define SDL_cocoamodes_h_
typedef struct struct SDL_DisplayData
{ {
CGDirectDisplayID display; CGDirectDisplayID display;
} SDL_DisplayData; };
typedef struct struct SDL_DisplayModeData
{ {
CFMutableArrayRef modes; CFMutableArrayRef modes;
} SDL_DisplayModeData; };
extern void Cocoa_InitModes(_THIS); extern void Cocoa_InitModes(_THIS);
extern int Cocoa_GetDisplayBounds(_THIS, SDL_VideoDisplay *display, SDL_Rect *rect); extern int Cocoa_GetDisplayBounds(_THIS, SDL_VideoDisplay *display, SDL_Rect *rect);
+5 -5
View File
@@ -364,7 +364,7 @@ void Cocoa_InitModes(_THIS)
int Cocoa_GetDisplayBounds(_THIS, SDL_VideoDisplay *display, SDL_Rect *rect) 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 cgrect;
cgrect = CGDisplayBounds(displaydata->display); 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) 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; const CGDirectDisplayID cgdisplay = displaydata->display;
NSArray *screens = [NSScreen screens]; NSArray *screens = [NSScreen screens];
NSScreen *screen = nil; NSScreen *screen = nil;
@@ -412,7 +412,7 @@ int Cocoa_GetDisplayPhysicalDPI(_THIS, SDL_VideoDisplay *display, float *ddpi, f
@autoreleasepool { @autoreleasepool {
const float MM_IN_INCH = 25.4f; 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... */ /* we need the backingScaleFactor for Retina displays, which is only exposed through NSScreen, not CGDisplay, afaik, so find our screen... */
NSArray *screens = [NSScreen screens]; 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) void Cocoa_GetDisplayModes(_THIS, SDL_VideoDisplay *display)
{ {
SDL_DisplayData *data = (SDL_DisplayData *)display->driverdata; SDL_DisplayData *data = display->driverdata;
CVDisplayLinkRef link = NULL; CVDisplayLinkRef link = NULL;
CGDisplayModeRef desktopmoderef; CGDisplayModeRef desktopmoderef;
SDL_DisplayMode desktopmode; SDL_DisplayMode desktopmode;
@@ -571,7 +571,7 @@ static CGError SetDisplayModeForDisplay(CGDirectDisplayID display, SDL_DisplayMo
int Cocoa_SetDisplayMode(_THIS, SDL_VideoDisplay *display, SDL_DisplayMode *mode) 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; SDL_DisplayModeData *data = (SDL_DisplayModeData *)mode->driverdata;
CGDisplayFadeReservationToken fade_token = kCGDisplayFadeReservationInvalidToken; CGDisplayFadeReservationToken fade_token = kCGDisplayFadeReservationInvalidToken;
CGError result; CGError result;
+4 -4
View File
@@ -219,7 +219,7 @@ static int Cocoa_ShowCursor(SDL_Cursor *cursor)
SDL_VideoDevice *device = SDL_GetVideoDevice(); SDL_VideoDevice *device = SDL_GetVideoDevice();
SDL_Window *window = (device ? device->windows : NULL); SDL_Window *window = (device ? device->windows : NULL);
for (; window != NULL; window = window->next) { for (; window != NULL; window = window->next) {
SDL_WindowData *driverdata = (__bridge SDL_WindowData *)window->driverdata; SDL_WindowData *driverdata = window->driverdata;
if (driverdata) { if (driverdata) {
[driverdata.nswindow performSelectorOnMainThread:@selector(invalidateCursorRectsForView:) [driverdata.nswindow performSelectorOnMainThread:@selector(invalidateCursorRectsForView:)
withObject:[driverdata.nswindow contentView] withObject:[driverdata.nswindow contentView]
@@ -249,7 +249,7 @@ static int Cocoa_WarpMouseGlobal(float x, float y)
CGPoint point; CGPoint point;
SDL_Mouse *mouse = SDL_GetMouse(); SDL_Mouse *mouse = SDL_GetMouse();
if (mouse->focus) { if (mouse->focus) {
SDL_WindowData *data = (__bridge SDL_WindowData *)mouse->focus->driverdata; SDL_WindowData *data = mouse->focus->driverdata;
if ([data.listener isMovingOrFocusClickPending]) { if ([data.listener isMovingOrFocusClickPending]) {
DLog("Postponing warp, window being moved or focused."); DLog("Postponing warp, window being moved or focused.");
[data.listener setPendingMoveX:x Y:y]; [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, /* We will re-apply the non-relative mode when the window finishes being moved,
* if it is being moved right now. * if it is being moved right now.
*/ */
data = (__bridge SDL_WindowData *)window->driverdata; data = window->driverdata;
if ([data.listener isMovingOrFocusClickPending]) { if ([data.listener isMovingOrFocusClickPending]) {
return 0; return 0;
} }
@@ -398,7 +398,7 @@ static void Cocoa_HandleTitleButtonEvent(_THIS, NSEvent *event)
} }
for (window = _this->windows; window; window = window->next) { 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) { if (data && data.nswindow == nswindow) {
switch ([event type]) { switch ([event type]) {
case NSEventTypeLeftMouseDown: case NSEventTypeLeftMouseDown:
+5 -5
View File
@@ -138,7 +138,7 @@ static CVReturn DisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTimeSt
- (void)setWindow:(SDL_Window *)newWindow - (void)setWindow:(SDL_Window *)newWindow
{ {
if (self->window) { 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. */ /* 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; NSMutableArray *contexts = oldwindowdata.nscontexts;
@@ -150,7 +150,7 @@ static CVReturn DisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTimeSt
self->window = newWindow; self->window = newWindow;
if (newWindow) { if (newWindow) {
SDL_WindowData *windowdata = (__bridge SDL_WindowData *)newWindow->driverdata; SDL_WindowData *windowdata = newWindow->driverdata;
NSView *contentview = windowdata.sdlContentView; NSView *contentview = windowdata.sdlContentView;
/* Now sign up for scheduled updates for the new window. */ /* 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) SDL_GLContext Cocoa_GL_CreateContext(_THIS, SDL_Window *window)
{ {
@autoreleasepool { @autoreleasepool {
SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window); SDL_VideoDisplay *display = SDL_GetVideoDisplayForWindow(window);
SDL_DisplayData *displaydata = (SDL_DisplayData *)display->driverdata; SDL_DisplayData *displaydata = display->driverdata;
NSOpenGLPixelFormatAttribute attr[32]; NSOpenGLPixelFormatAttribute attr[32];
NSOpenGLPixelFormat *fmt; NSOpenGLPixelFormat *fmt;
SDLOpenGLContext *context; SDLOpenGLContext *context;
@@ -482,7 +482,7 @@ int Cocoa_GL_SwapWindow(_THIS, SDL_Window *window)
{ {
@autoreleasepool { @autoreleasepool {
SDLOpenGLContext *nscontext = (__bridge SDLOpenGLContext *)SDL_GL_GetCurrentContext(); 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); const int setting = SDL_AtomicGet(&nscontext->swapIntervalSetting);
if (setting == 0) { if (setting == 0) {
+5 -5
View File
@@ -62,7 +62,7 @@ Cocoa_GLES_CreateContext(_THIS, SDL_Window *window)
{ {
@autoreleasepool { @autoreleasepool {
SDL_GLContext context; SDL_GLContext context;
SDL_WindowData *data = (__bridge SDL_WindowData *)window->driverdata; SDL_WindowData *data = window->driverdata;
#if SDL_VIDEO_OPENGL_CGL #if SDL_VIDEO_OPENGL_CGL
if (_this->gl_config.profile_mask != SDL_GL_CONTEXT_PROFILE_ES) { 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) int Cocoa_GLES_SwapWindow(_THIS, SDL_Window *window)
{ {
@autoreleasepool { @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) int Cocoa_GLES_MakeCurrent(_THIS, SDL_Window *window, SDL_GLContext context)
{ {
@autoreleasepool { @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 { @autoreleasepool {
NSView *v; NSView *v;
/* The current context is lost in here; save it and reset it. */ /* 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_Window *current_win = SDL_GL_GetCurrentWindow();
SDL_GLContext current_ctx = SDL_GL_GetCurrentContext(); SDL_GLContext current_ctx = SDL_GL_GetCurrentContext();
@@ -151,7 +151,7 @@ SDL_EGLSurface
Cocoa_GLES_GetEGLSurface(_THIS, SDL_Window *window) Cocoa_GLES_GetEGLSurface(_THIS, SDL_Window *window)
{ {
@autoreleasepool { @autoreleasepool {
return ((__bridge SDL_WindowData *)window->driverdata).egl_surface; return window->driverdata.egl_surface;
} }
} }
+2 -2
View File
@@ -45,7 +45,7 @@ Cocoa_CreateShaper(SDL_Window *window)
SDL_WindowShaper *result; SDL_WindowShaper *result;
SDL_ShapeData *data; SDL_ShapeData *data;
int resized_properly; int resized_properly;
SDL_WindowData *windata = (__bridge SDL_WindowData *)window->driverdata; SDL_WindowData *windata = window->driverdata;
result = (SDL_WindowShaper *)SDL_malloc(sizeof(SDL_WindowShaper)); result = (SDL_WindowShaper *)SDL_malloc(sizeof(SDL_WindowShaper));
if (!result) { if (!result) {
@@ -90,7 +90,7 @@ int Cocoa_SetWindowShape(SDL_WindowShaper *shaper, SDL_Surface *shape, SDL_Windo
{ {
@autoreleasepool { @autoreleasepool {
SDL_ShapeData *data = (__bridge SDL_ShapeData *)shaper->driverdata; 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; SDL_CocoaClosure *closure;
if (data.saved == SDL_TRUE) { if (data.saved == SDL_TRUE) {
[data.context restoreGraphicsState]; [data.context restoreGraphicsState];
+5 -5
View File
@@ -48,7 +48,7 @@ static void Cocoa_DeleteDevice(SDL_VideoDevice *device)
if (device->wakeup_lock) { if (device->wakeup_lock) {
SDL_DestroyMutex(device->wakeup_lock); SDL_DestroyMutex(device->wakeup_lock);
} }
CFBridgingRelease(device->driverdata); device->driverdata = nil;
SDL_free(device); SDL_free(device);
} }
} }
@@ -73,7 +73,7 @@ static SDL_VideoDevice *Cocoa_CreateDevice(void)
SDL_free(device); SDL_free(device);
return NULL; return NULL;
} }
device->driverdata = (void *)CFBridgingRetain(data); device->driverdata = data;
device->wakeup_lock = SDL_CreateMutex(); device->wakeup_lock = SDL_CreateMutex();
/* Set the function pointers */ /* Set the function pointers */
@@ -110,7 +110,7 @@ static SDL_VideoDevice *Cocoa_CreateDevice(void)
device->SetWindowAlwaysOnTop = Cocoa_SetWindowAlwaysOnTop; device->SetWindowAlwaysOnTop = Cocoa_SetWindowAlwaysOnTop;
device->SetWindowFullscreen = Cocoa_SetWindowFullscreen; device->SetWindowFullscreen = Cocoa_SetWindowFullscreen;
device->GetWindowICCProfile = Cocoa_GetWindowICCProfile; device->GetWindowICCProfile = Cocoa_GetWindowICCProfile;
device->GetWindowDisplayIndex = Cocoa_GetWindowDisplayIndex; device->GetDisplayForWindow = Cocoa_GetDisplayForWindow;
device->SetWindowMouseRect = Cocoa_SetWindowMouseRect; device->SetWindowMouseRect = Cocoa_SetWindowMouseRect;
device->SetWindowMouseGrab = Cocoa_SetWindowMouseGrab; device->SetWindowMouseGrab = Cocoa_SetWindowMouseGrab;
device->SetWindowKeyboardGrab = Cocoa_SetWindowKeyboardGrab; device->SetWindowKeyboardGrab = Cocoa_SetWindowKeyboardGrab;
@@ -190,7 +190,7 @@ VideoBootStrap COCOA_bootstrap = {
int Cocoa_VideoInit(_THIS) int Cocoa_VideoInit(_THIS)
{ {
@autoreleasepool { @autoreleasepool {
SDL_VideoData *data = (__bridge SDL_VideoData *)_this->driverdata; SDL_VideoData *data = _this->driverdata;
Cocoa_InitModes(_this); Cocoa_InitModes(_this);
Cocoa_InitKeyboard(_this); Cocoa_InitKeyboard(_this);
@@ -213,7 +213,7 @@ int Cocoa_VideoInit(_THIS)
void Cocoa_VideoQuit(_THIS) void Cocoa_VideoQuit(_THIS)
{ {
@autoreleasepool { @autoreleasepool {
SDL_VideoData *data = (__bridge SDL_VideoData *)_this->driverdata; SDL_VideoData *data = _this->driverdata;
Cocoa_QuitModes(_this); Cocoa_QuitModes(_this);
Cocoa_QuitKeyboard(_this); Cocoa_QuitKeyboard(_this);
Cocoa_QuitMouse(_this); Cocoa_QuitMouse(_this);
+1 -1
View File
@@ -262,7 +262,7 @@ SDL_bool Cocoa_Vulkan_CreateSurface(_THIS,
if (window->flags & SDL_WINDOW_FOREIGN) { if (window->flags & SDL_WINDOW_FOREIGN) {
@autoreleasepool { @autoreleasepool {
SDL_WindowData *data = (__bridge SDL_WindowData *)window->driverdata; SDL_WindowData *data = window->driverdata;
if (![data.sdlContentView.layer isKindOfClass:[CAMetalLayer class]]) { if (![data.sdlContentView.layer isKindOfClass:[CAMetalLayer class]]) {
[data.sdlContentView setLayer:[CAMetalLayer layer]]; [data.sdlContentView setLayer:[CAMetalLayer layer]];
} }
+1 -1
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_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_SetWindowFullscreen(_THIS, SDL_Window *window, SDL_VideoDisplay *display, SDL_bool fullscreen);
extern void *Cocoa_GetWindowICCProfile(_THIS, SDL_Window *window, size_t *size); 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_SetWindowMouseRect(_THIS, SDL_Window *window);
extern void Cocoa_SetWindowMouseGrab(_THIS, SDL_Window *window, SDL_bool grabbed); extern void Cocoa_SetWindowMouseGrab(_THIS, SDL_Window *window, SDL_bool grabbed);
extern void Cocoa_DestroyWindow(_THIS, SDL_Window *window); extern void Cocoa_DestroyWindow(_THIS, SDL_Window *window);
+44 -47
View File
@@ -239,7 +239,7 @@
/* !!! FIXME: is there a better way to do this? */ /* !!! FIXME: is there a better way to do this? */
if (_this) { if (_this) {
for (sdlwindow = _this->windows; sdlwindow; sdlwindow = sdlwindow->next) { for (sdlwindow = _this->windows; sdlwindow; sdlwindow = sdlwindow->next) {
NSWindow *nswindow = ((__bridge SDL_WindowData *)sdlwindow->driverdata).nswindow; NSWindow *nswindow = sdlwindow->driverdata.nswindow;
if (nswindow == self) { if (nswindow == self) {
break; break;
} }
@@ -333,7 +333,7 @@ static NSUInteger GetWindowStyle(SDL_Window *window)
static SDL_bool SetWindowStyle(SDL_Window *window, NSUInteger style) 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; NSWindow *nswindow = data.nswindow;
/* The view responder chain gets messed with during setStyleMask */ /* 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) 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]) { if (!data || [data.listener isMovingOrFocusClickPending]) {
return SDL_FALSE; 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) 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) { if (NSAppKitVersionNumber >= NSAppKitVersionNumber10_13_2) {
NSWindow *nswindow = data.nswindow; NSWindow *nswindow = data.nswindow;
@@ -564,7 +564,7 @@ static void Cocoa_UpdateClipCursor(SDL_Window *window)
{ {
SDL_Window *window = _data.window; SDL_Window *window = _data.window;
NSWindow *nswindow = _data.nswindow; NSWindow *nswindow = _data.nswindow;
SDL_VideoData *videodata = ((__bridge SDL_WindowData *)window->driverdata).videodata; SDL_VideoData *videodata = window->driverdata.videodata;
if (!videodata.allow_spaces) { if (!videodata.allow_spaces) {
return NO; /* Spaces are forcibly disabled. */ 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 // 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 // event for the background window, this just makes sure the button is reported at the
// correct position in its own event. // 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); rc = SDL_SendMouseButtonClicks(Cocoa_GetEventTimestamp([theEvent timestamp]), window, mouseID, state, button, clicks);
} else { } else {
const int orig_x = mouse->x; const int orig_x = mouse->x;
@@ -1384,7 +1384,7 @@ static int Cocoa_SendMouseButtonClicks(SDL_Mouse *mouse, NSEvent *theEvent, SDL_
- (BOOL)isTouchFromTrackpad:(NSEvent *)theEvent - (BOOL)isTouchFromTrackpad:(NSEvent *)theEvent
{ {
SDL_Window *window = _data.window; 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 /* if this a MacBook trackpad, we'll make input look like a synthesized
event. This is backwards from reality, but better matches user 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 white until the app is ready to draw. In practice on modern macOS, this
only gets called for window creation and other extraordinary events. */ only gets called for window creation and other extraordinary events. */
self.layer.backgroundColor = CGColorGetConstantColor(kCGColorBlack); self.layer.backgroundColor = CGColorGetConstantColor(kCGColorBlack);
ScheduleContextUpdates((__bridge SDL_WindowData *)_sdlWindow->driverdata); ScheduleContextUpdates(_sdlWindow->driverdata);
SDL_SendWindowEvent(_sdlWindow, SDL_EVENT_WINDOW_EXPOSED, 0, 0); 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) static int SetupWindowData(_THIS, SDL_Window *window, NSWindow *nswindow, NSView *nsview, SDL_bool created)
{ {
@autoreleasepool { @autoreleasepool {
SDL_VideoData *videodata = (__bridge SDL_VideoData *)_this->driverdata; SDL_VideoData *videodata = _this->driverdata;
SDL_WindowData *data; SDL_WindowData *data;
/* Allocate the window data */ /* Allocate the window data */
@@ -1705,7 +1705,7 @@ static int SetupWindowData(_THIS, SDL_Window *window, NSWindow *nswindow, NSView
[nswindow setOneShot:NO]; [nswindow setOneShot:NO];
/* All done! */ /* All done! */
window->driverdata = (void *)CFBridgingRetain(data); window->driverdata = data;
return 0; return 0;
} }
} }
@@ -1713,9 +1713,9 @@ static int SetupWindowData(_THIS, SDL_Window *window, NSWindow *nswindow, NSView
int Cocoa_CreateWindow(_THIS, SDL_Window *window) int Cocoa_CreateWindow(_THIS, SDL_Window *window)
{ {
@autoreleasepool { @autoreleasepool {
SDL_VideoData *videodata = (__bridge SDL_VideoData *)_this->driverdata; SDL_VideoData *videodata = _this->driverdata;
NSWindow *nswindow; NSWindow *nswindow;
SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window); SDL_VideoDisplay *display = SDL_GetVideoDisplayForWindow(window);
NSRect rect; NSRect rect;
BOOL fullscreen; BOOL fullscreen;
SDL_Rect bounds; SDL_Rect bounds;
@@ -1882,7 +1882,7 @@ void Cocoa_SetWindowTitle(_THIS, SDL_Window *window)
{ {
@autoreleasepool { @autoreleasepool {
const char *title = window->title ? window->title : ""; 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]; NSString *string = [[NSString alloc] initWithUTF8String:title];
[nswindow setTitle:string]; [nswindow setTitle:string];
} }
@@ -1902,7 +1902,7 @@ void Cocoa_SetWindowIcon(_THIS, SDL_Window *window, SDL_Surface *icon)
void Cocoa_SetWindowPosition(_THIS, SDL_Window *window) void Cocoa_SetWindowPosition(_THIS, SDL_Window *window)
{ {
@autoreleasepool { @autoreleasepool {
SDL_WindowData *windata = (__bridge SDL_WindowData *)window->driverdata; SDL_WindowData *windata = window->driverdata;
NSWindow *nswindow = windata.nswindow; NSWindow *nswindow = windata.nswindow;
NSRect rect; NSRect rect;
BOOL fullscreen; BOOL fullscreen;
@@ -1927,7 +1927,7 @@ void Cocoa_SetWindowPosition(_THIS, SDL_Window *window)
void Cocoa_SetWindowSize(_THIS, SDL_Window *window) void Cocoa_SetWindowSize(_THIS, SDL_Window *window)
{ {
@autoreleasepool { @autoreleasepool {
SDL_WindowData *windata = (__bridge SDL_WindowData *)window->driverdata; SDL_WindowData *windata = window->driverdata;
NSWindow *nswindow = windata.nswindow; NSWindow *nswindow = windata.nswindow;
NSRect rect; NSRect rect;
BOOL fullscreen; BOOL fullscreen;
@@ -1956,7 +1956,7 @@ void Cocoa_SetWindowSize(_THIS, SDL_Window *window)
void Cocoa_SetWindowMinimumSize(_THIS, SDL_Window *window) void Cocoa_SetWindowMinimumSize(_THIS, SDL_Window *window)
{ {
@autoreleasepool { @autoreleasepool {
SDL_WindowData *windata = (__bridge SDL_WindowData *)window->driverdata; SDL_WindowData *windata = window->driverdata;
NSSize minSize; NSSize minSize;
minSize.width = window->min_w; minSize.width = window->min_w;
@@ -1969,7 +1969,7 @@ void Cocoa_SetWindowMinimumSize(_THIS, SDL_Window *window)
void Cocoa_SetWindowMaximumSize(_THIS, SDL_Window *window) void Cocoa_SetWindowMaximumSize(_THIS, SDL_Window *window)
{ {
@autoreleasepool { @autoreleasepool {
SDL_WindowData *windata = (__bridge SDL_WindowData *)window->driverdata; SDL_WindowData *windata = window->driverdata;
NSSize maxSize; NSSize maxSize;
maxSize.width = window->max_w; 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) void Cocoa_GetWindowSizeInPixels(_THIS, SDL_Window *window, int *w, int *h)
{ {
@autoreleasepool { @autoreleasepool {
SDL_WindowData *windata = (__bridge SDL_WindowData *)window->driverdata; SDL_WindowData *windata = window->driverdata;
NSView *contentView = windata.sdlContentView; NSView *contentView = windata.sdlContentView;
NSRect viewport = [contentView bounds]; 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) void Cocoa_ShowWindow(_THIS, SDL_Window *window)
{ {
@autoreleasepool { @autoreleasepool {
SDL_WindowData *windowData = ((__bridge SDL_WindowData *)window->driverdata); SDL_WindowData *windowData = window->driverdata;
NSWindow *nswindow = windowData.nswindow; NSWindow *nswindow = windowData.nswindow;
if (![nswindow isMiniaturized]) { if (![nswindow isMiniaturized]) {
@@ -2013,7 +2013,7 @@ void Cocoa_ShowWindow(_THIS, SDL_Window *window)
void Cocoa_HideWindow(_THIS, SDL_Window *window) void Cocoa_HideWindow(_THIS, SDL_Window *window)
{ {
@autoreleasepool { @autoreleasepool {
NSWindow *nswindow = ((__bridge SDL_WindowData *)window->driverdata).nswindow; NSWindow *nswindow = window->driverdata.nswindow;
[nswindow orderOut:nil]; [nswindow orderOut:nil];
} }
@@ -2022,7 +2022,7 @@ void Cocoa_HideWindow(_THIS, SDL_Window *window)
void Cocoa_RaiseWindow(_THIS, SDL_Window *window) void Cocoa_RaiseWindow(_THIS, SDL_Window *window)
{ {
@autoreleasepool { @autoreleasepool {
SDL_WindowData *windowData = ((__bridge SDL_WindowData *)window->driverdata); SDL_WindowData *windowData = window->driverdata;
NSWindow *nswindow = windowData.nswindow; NSWindow *nswindow = windowData.nswindow;
/* makeKeyAndOrderFront: has the side-effect of deminiaturizing and showing /* 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) void Cocoa_MaximizeWindow(_THIS, SDL_Window *window)
{ {
@autoreleasepool { @autoreleasepool {
SDL_WindowData *windata = (__bridge SDL_WindowData *)window->driverdata; SDL_WindowData *windata = window->driverdata;
NSWindow *nswindow = windata.nswindow; NSWindow *nswindow = windata.nswindow;
[nswindow zoom:nil]; [nswindow zoom:nil];
@@ -2052,7 +2052,7 @@ void Cocoa_MaximizeWindow(_THIS, SDL_Window *window)
void Cocoa_MinimizeWindow(_THIS, SDL_Window *window) void Cocoa_MinimizeWindow(_THIS, SDL_Window *window)
{ {
@autoreleasepool { @autoreleasepool {
SDL_WindowData *data = (__bridge SDL_WindowData *)window->driverdata; SDL_WindowData *data = window->driverdata;
NSWindow *nswindow = data.nswindow; NSWindow *nswindow = data.nswindow;
if ([data.listener isInFullscreenSpaceTransition]) { if ([data.listener isInFullscreenSpaceTransition]) {
[data.listener addPendingWindowOperation:PENDING_OPERATION_MINIMIZE]; [data.listener addPendingWindowOperation:PENDING_OPERATION_MINIMIZE];
@@ -2065,7 +2065,7 @@ void Cocoa_MinimizeWindow(_THIS, SDL_Window *window)
void Cocoa_RestoreWindow(_THIS, SDL_Window *window) void Cocoa_RestoreWindow(_THIS, SDL_Window *window)
{ {
@autoreleasepool { @autoreleasepool {
NSWindow *nswindow = ((__bridge SDL_WindowData *)window->driverdata).nswindow; NSWindow *nswindow = window->driverdata.nswindow;
if ([nswindow isMiniaturized]) { if ([nswindow isMiniaturized]) {
[nswindow deminiaturize:nil]; [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. * The window will get permanently stuck if resizable is false.
* -flibit * -flibit
*/ */
SDL_WindowData *data = (__bridge SDL_WindowData *)window->driverdata; SDL_WindowData *data = window->driverdata;
Cocoa_WindowListener *listener = data.listener; Cocoa_WindowListener *listener = data.listener;
NSWindow *nswindow = data.nswindow; NSWindow *nswindow = data.nswindow;
SDL_VideoData *videodata = data.videodata; 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) void Cocoa_SetWindowAlwaysOnTop(_THIS, SDL_Window *window, SDL_bool on_top)
{ {
@autoreleasepool { @autoreleasepool {
NSWindow *nswindow = ((__bridge SDL_WindowData *)window->driverdata).nswindow; NSWindow *nswindow = window->driverdata.nswindow;
if (on_top) { if (on_top) {
[nswindow setLevel:NSFloatingWindowLevel]; [nswindow setLevel:NSFloatingWindowLevel];
} else { } 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) void Cocoa_SetWindowFullscreen(_THIS, SDL_Window *window, SDL_VideoDisplay *display, SDL_bool fullscreen)
{ {
@autoreleasepool { @autoreleasepool {
SDL_WindowData *data = (__bridge SDL_WindowData *)window->driverdata; SDL_WindowData *data = window->driverdata;
NSWindow *nswindow = data.nswindow; NSWindow *nswindow = data.nswindow;
NSRect rect; NSRect rect;
@@ -2216,7 +2216,7 @@ void *
Cocoa_GetWindowICCProfile(_THIS, SDL_Window *window, size_t *size) Cocoa_GetWindowICCProfile(_THIS, SDL_Window *window, size_t *size)
{ {
@autoreleasepool { @autoreleasepool {
SDL_WindowData *data = (__bridge SDL_WindowData *)window->driverdata; SDL_WindowData *data = window->driverdata;
NSWindow *nswindow = data.nswindow; NSWindow *nswindow = data.nswindow;
NSScreen *screen = [nswindow screen]; NSScreen *screen = [nswindow screen];
NSData *iccProfileData = nil; 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 { @autoreleasepool {
NSScreen *screen; NSScreen *screen;
SDL_WindowData *data = (__bridge SDL_WindowData *)window->driverdata; SDL_WindowData *data = window->driverdata;
/* Not recognized via CHECK_WINDOW_MAGIC */ /* Not recognized via CHECK_WINDOW_MAGIC */
if (data == nil) { if (data == nil) {
/* Don't set the error here, it hides other errors and is ignored anyway */ /* Don't set the error here, it hides other errors and is ignored anyway */
/*return SDL_SetError("Window data not set");*/ /*return SDL_SetError("Window data not set");*/
return -1; return 0;
} }
/* NSWindow.screen may be nil when the window is off-screen. */ /* 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]; displayid = [[screen.deviceDescription objectForKey:@"NSScreenNumber"] unsignedIntValue];
for (i = 0; i < _this->num_displays; i++) { 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) { if (displaydata != NULL && displaydata->display == displayid) {
return i; return _this->displays[i].id;
} }
} }
} }
/* Other code may expect SDL_GetWindowDisplayIndex to always return a valid /* The higher level code will use other logic to find the display */
* index for a window. The higher level GetWindowDisplayIndex code will fall return 0;
* 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.");
} }
} }
@@ -2297,7 +2294,7 @@ void Cocoa_SetWindowMouseRect(_THIS, SDL_Window *window)
void Cocoa_SetWindowMouseGrab(_THIS, SDL_Window *window, SDL_bool grabbed) void Cocoa_SetWindowMouseGrab(_THIS, SDL_Window *window, SDL_bool grabbed)
{ {
@autoreleasepool { @autoreleasepool {
SDL_WindowData *data = (__bridge SDL_WindowData *)window->driverdata; SDL_WindowData *data = window->driverdata;
Cocoa_UpdateClipCursor(window); Cocoa_UpdateClipCursor(window);
@@ -2318,7 +2315,7 @@ void Cocoa_SetWindowMouseGrab(_THIS, SDL_Window *window, SDL_bool grabbed)
void Cocoa_DestroyWindow(_THIS, SDL_Window *window) void Cocoa_DestroyWindow(_THIS, SDL_Window *window)
{ {
@autoreleasepool { @autoreleasepool {
SDL_WindowData *data = (SDL_WindowData *)CFBridgingRelease(window->driverdata); SDL_WindowData *data = window->driverdata;
if (data) { if (data) {
#if SDL_VIDEO_OPENGL #if SDL_VIDEO_OPENGL
@@ -2354,14 +2351,14 @@ void Cocoa_DestroyWindow(_THIS, SDL_Window *window)
window->shaper = NULL; window->shaper = NULL;
} }
} }
window->driverdata = NULL; window->driverdata = nil;
} }
} }
int Cocoa_GetWindowWMInfo(_THIS, SDL_Window *window, SDL_SysWMinfo *info) int Cocoa_GetWindowWMInfo(_THIS, SDL_Window *window, SDL_SysWMinfo *info)
{ {
@autoreleasepool { @autoreleasepool {
NSWindow *nswindow = ((__bridge SDL_WindowData *)window->driverdata).nswindow; NSWindow *nswindow = window->driverdata.nswindow;
info->subsystem = SDL_SYSWM_COCOA; info->subsystem = SDL_SYSWM_COCOA;
info->info.cocoa.window = nswindow; info->info.cocoa.window = nswindow;
@@ -2373,7 +2370,7 @@ SDL_bool
Cocoa_IsWindowInFullscreenSpace(SDL_Window *window) Cocoa_IsWindowInFullscreenSpace(SDL_Window *window)
{ {
@autoreleasepool { @autoreleasepool {
SDL_WindowData *data = (__bridge SDL_WindowData *)window->driverdata; SDL_WindowData *data = window->driverdata;
if ([data.listener isInFullscreenSpace]) { if ([data.listener isInFullscreenSpace]) {
return SDL_TRUE; return SDL_TRUE;
@@ -2388,7 +2385,7 @@ Cocoa_SetWindowFullscreenSpace(SDL_Window *window, SDL_bool state)
{ {
@autoreleasepool { @autoreleasepool {
SDL_bool succeeded = SDL_FALSE; SDL_bool succeeded = SDL_FALSE;
SDL_WindowData *data = (__bridge SDL_WindowData *)window->driverdata; SDL_WindowData *data = window->driverdata;
if (data.inWindowFullscreenTransition) { if (data.inWindowFullscreenTransition) {
return SDL_FALSE; 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) void Cocoa_AcceptDragAndDrop(SDL_Window *window, SDL_bool accept)
{ {
@autoreleasepool { @autoreleasepool {
SDL_WindowData *data = (__bridge SDL_WindowData *)window->driverdata; SDL_WindowData *data = window->driverdata;
if (accept) { if (accept) {
[data.nswindow registerForDraggedTypes:[NSArray arrayWithObject:(NSString *)kUTTypeFileURL]]; [data.nswindow registerForDraggedTypes:[NSArray arrayWithObject:(NSString *)kUTTypeFileURL]];
} else { } else {
@@ -2450,7 +2447,7 @@ int Cocoa_FlashWindow(_THIS, SDL_Window *window, SDL_FlashOperation operation)
{ {
@autoreleasepool { @autoreleasepool {
/* Note that this is app-wide and not window-specific! */ /* 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) { if (data.flash_request) {
[NSApp cancelUserAttentionRequest: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) int Cocoa_SetWindowOpacity(_THIS, SDL_Window *window, float opacity)
{ {
@autoreleasepool { @autoreleasepool {
SDL_WindowData *data = (__bridge SDL_WindowData *)window->driverdata; SDL_WindowData *data = window->driverdata;
[data.nswindow setAlphaValue:opacity]; [data.nswindow setAlphaValue:opacity];
return 0; return 0;
} }
+1 -1
View File
@@ -843,7 +843,7 @@ static EM_BOOL Emscripten_HandleFullscreenChange(int eventType, const Emscripten
window_data->window->flags &= ~SDL_WINDOW_FULLSCREEN_MASK; window_data->window->flags &= ~SDL_WINDOW_FULLSCREEN_MASK;
/* reset fullscreen window if the browser left fullscreen */ /* 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) { if (display->fullscreen_window == window_data->window) {
display->fullscreen_window = NULL; display->fullscreen_window = NULL;
+3 -8
View File
@@ -24,13 +24,8 @@
#include "SDL_emscriptenvideo.h" #include "SDL_emscriptenvideo.h"
extern void extern void Emscripten_RegisterEventHandlers(SDL_WindowData *data);
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_UnregisterEventHandlers(SDL_WindowData *data);
extern EM_BOOL
Emscripten_HandleCanvasResize(int eventType, const void *reserved, void *userData);
#endif /* SDL_emscriptenevents_h_ */ #endif /* SDL_emscriptenevents_h_ */
@@ -34,7 +34,7 @@ int Emscripten_CreateWindowFramebuffer(_THIS, SDL_Window *window, Uint32 *format
int w, h; int w, h;
/* Free the old framebuffer surface */ /* Free the old framebuffer surface */
SDL_WindowData *data = (SDL_WindowData *)window->driverdata; SDL_WindowData *data = window->driverdata;
surface = data->surface; surface = data->surface;
SDL_DestroySurface(surface); SDL_DestroySurface(surface);
@@ -58,7 +58,7 @@ int Emscripten_UpdateWindowFramebuffer(_THIS, SDL_Window *window, const SDL_Rect
{ {
SDL_Surface *surface; SDL_Surface *surface;
SDL_WindowData *data = (SDL_WindowData *)window->driverdata; SDL_WindowData *data = window->driverdata;
surface = data->surface; surface = data->surface;
if (surface == NULL) { if (surface == NULL) {
return SDL_SetError("Couldn't find framebuffer surface for window"); 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) void Emscripten_DestroyWindowFramebuffer(_THIS, SDL_Window *window)
{ {
SDL_WindowData *data = (SDL_WindowData *)window->driverdata; SDL_WindowData *data = window->driverdata;
SDL_DestroySurface(data->surface); SDL_DestroySurface(data->surface);
data->surface = NULL; data->surface = NULL;
+1 -1
View File
@@ -216,7 +216,7 @@ static int Emscripten_SetRelativeMouseMode(SDL_bool enabled)
return -1; return -1;
} }
window_data = (SDL_WindowData *)window->driverdata; window_data = window->driverdata;
if (emscripten_request_pointerlock(window_data->canvas_id, 1) >= EMSCRIPTEN_RESULT_SUCCESS) { if (emscripten_request_pointerlock(window_data->canvas_id, 1) >= EMSCRIPTEN_RESULT_SUCCESS) {
return 0; return 0;

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