Compare commits

...

22 Commits

Author SHA1 Message Date
Sam Lantinga
8c9beb0c87 Updated to version Updated to version 2.24.0 for release 2022-08-19 08:44:09 -07:00
Sam Lantinga
6e007c36e7 Add null termination to Wayland_data_source_get_data() if requested
Fixes https://github.com/libsdl-org/SDL/issues/6083
2022-08-18 19:05:55 -07:00
Sam Lantinga
948dbe7d3f Don't include the null terminator in Wayland clipboard text
Fixes https://github.com/libsdl-org/SDL/issues/6083
2022-08-18 16:24:20 -07:00
Sam Lantinga
f6b81125b3 Always define SDL_COMPILE_TIME_ASSERT as static_assert() in C++
Apparently some versions of gcc will define __STDC_VERSION__ even when compiling in C++ mode.

Fixes https://github.com/libsdl-org/SDL/issues/6078
2022-08-18 16:06:42 -07:00
Frank Praznik
3bae2d57da wayland: Set the libdecor app ID after visibility calls
Set the frame app ID after toggling visibility or the name displayed in window manager task switchers may not display correctly.
2022-08-18 10:58:32 -07:00
Ryan C. Gordon
51be30f3cd emscripten-buildbot.sh: force -s USE_SDL=0
This avoids using Emscripten-provided SDL headers from its own
sysroot instead of the headers in our own include directory!

Reference https://github.com/emscripten-core/emscripten/discussions/17647
2022-08-17 21:39:59 -04:00
Sam Lantinga
8acb4e45b3 Fixed interactions between mouse capture and grab on X11
Fixes https://github.com/libsdl-org/SDL/issues/6072
2022-08-17 14:26:34 -07:00
Frank Praznik
7da74eb5be wayland: Never commit with an undefined window title
If libdecor performs a commit with the frame title being undefined, a crash can occur within the library or its plugins. Always ensure that the title is set to a valid string to avoid this.
2022-08-17 12:40:16 -07:00
Cameron Gutman
99e9156ff5 testgles2: Fix typo in help text 2022-08-16 20:38:55 -07:00
Cameron Cawley
09b6956dcc opengl: Support NV12 textures on GPUs with only 2 texture units 2022-08-16 07:30:13 -07:00
Cameron Cawley
2fcd8f889c Handle SDL_PIXELFORMAT_EXTERNAL_OES in SDL_GetPixelFormatName() 2022-08-16 07:29:45 -07:00
Cameron Gutman
222f1a2693 testgles2: Add --threaded option to use a render thread per window
This is helpful for reproducing bugs like #6056
2022-08-16 07:29:07 -07:00
Sam Lantinga
9670d2bb9e Make sure we hold the joystick lock when disconnecting a HIDAPI joystick
This prevents crashes when calling SDL joystick API functions from a different thread while disconnection is happening.

See https://github.com/libsdl-org/SDL/issues/6063 for a more thorough review of joystick locking.
2022-08-15 17:28:50 -07:00
Ryan C. Gordon
26948f01a3 cocoa: Make SDL_MinimizeWindow() work with borderless windows.
Fixes #6046.
2022-08-15 20:09:09 -04:00
Frank Praznik
650612fdcb wayland: Eliminate excessive calls to SetFullscreen
Eliminate excessive calls to SetFullscreen by removing the calls in the libdecor and xdg-toplevel config callbacks.

These calls were being made there in case something explicitly called the window minimization function from within SDL, which unsets fullscreen, and as minimizing a window in Wayland is just a suggestion to the compositor and doesn't actually change the window state or communicate anything back to the application, it was necessary to call SetFullscreen in every call to the config functions just in case something minimized a window via SDL_MinimizeWindow() and later needed to restore it.  GNOME in particular had issues when fullscreen set/unset operations were being hammered, leading to overlapping acks and commits when switching to fullscreen.

With the new video system flag to disable unsetting fullscreen when minimizing a window, these calls in the configuration functions are no longer needed and can be removed. This significantly reduces calls to the SetFullscreen() function, reverts #6044 while fixing the issue, and fixes a similar problem when hiding and showing a window initially created with fullscreen flags.
2022-08-15 11:16:20 -07:00
Frank Praznik
cc9cc2028d video: Add video device quirk flags and apply them to the video subsystem
Add quirk flags to the video device struct and add flags to allow video backend drivers to disable mode switching and disable unsetting the fullscreen mode when minimizing a window. As certain platforms can have multiple video backends compiled in at once, #ifdefs, as used by other platforms, aren't suitable as different backends on the same platform may not need the same quirks.

This replaces the formerly dedicated 'disable_display_mode_switching' boolean as additional quirks are needed by the Wayland backend.  Helper functions have also been added to simplify reading the flag states.
2022-08-15 11:16:20 -07:00
Sam Lantinga
0cc8dfdb58 Added SDL_system.h for the declaration of SDL_iPhoneSetAnimationCallback() and SDL_iPhoneSetEventPump() 2022-08-15 07:44:56 -07:00
Mathieu Eyraud
c6c688ab01 Add SDL_JOYBATTERYUPDATED event to SDL_JoystickEventState() 2022-08-14 07:00:12 -07:00
Frank Praznik
b72cf207fb core: linux: Don't cache the RealtimeKit D-Bus connection
If the D-Bus subsystem is shutdown and restarted mid-execution, the cached connection will be invalid. Fetch it each time that it is used to ensure that the connection is always from the current context.
2022-08-14 06:59:18 -07:00
Francisco Javier Trujillo Mata
7d5ccae22d Fix memory leak when destroying texture 2022-08-14 08:13:37 -04:00
Francisco Javier Trujillo Mata
5b4b4fa1ff Decrease audio thread priority when created 2022-08-14 08:13:17 -04:00
Sam Lantinga
cf134235d7 Removed line wrapping in patch notes 2022-08-13 08:23:40 -07:00
33 changed files with 273 additions and 146 deletions

View File

@@ -80,8 +80,8 @@ endif()
# See docs/release_checklist.md
set(SDL_MAJOR_VERSION 2)
set(SDL_MINOR_VERSION 23)
set(SDL_MICRO_VERSION 2)
set(SDL_MINOR_VERSION 24)
set(SDL_MICRO_VERSION 0)
set(SDL_VERSION "${SDL_MAJOR_VERSION}.${SDL_MINOR_VERSION}.${SDL_MICRO_VERSION}")
# Set defaults preventing destination file conflicts

View File

@@ -12,8 +12,8 @@
LIBNAME = SDL2
MAJOR_VERSION = 2
MINOR_VERSION = 23
MICRO_VERSION = 2
MINOR_VERSION = 24
MICRO_VERSION = 0
VERSION = $(MAJOR_VERSION).$(MINOR_VERSION).$(MICRO_VERSION)
DESCRIPTION = Simple DirectMedia Layer 2

View File

@@ -3,8 +3,8 @@
LIBNAME = SDL2
MAJOR_VERSION = 2
MINOR_VERSION = 23
MICRO_VERSION = 2
MINOR_VERSION = 24
MICRO_VERSION = 0
VERSION = $(MAJOR_VERSION).$(MINOR_VERSION).$(MICRO_VERSION)
DESCRIPTION = Simple DirectMedia Layer 2

View File

@@ -7,17 +7,10 @@ This is a list of major changes in SDL's version history.
General:
* New version numbering scheme, similar to GLib and Flatpak.
* An even number in the minor version (second component) indicates
a production-ready stable release such as 2.24.0, which would have
been 2.0.24 under the old system.
* The patchlevel (micro version, third component) indicates a
bugfix-only update: for example, 2.24.1 would be a bugfix-only
release to fix bugs in 2.24.0, without adding new features.
* An odd number in the minor version indicates a prerelease such
as 2.23.0. Stable distributions should not use these prereleases.
* The patchlevel indicates successive prereleases, for example
2.23.1 and 2.23.2 would be prereleases during development of
the SDL 2.24.0 stable release.
* An even number in the minor version (second component) indicates a production-ready stable release such as 2.24.0, which would have been 2.0.24 under the old system.
* The patchlevel (micro version, third component) indicates a bugfix-only update: for example, 2.24.1 would be a bugfix-only release to fix bugs in 2.24.0, without adding new features.
* An odd number in the minor version indicates a prerelease such as 2.23.0. Stable distributions should not use these prereleases.
* The patchlevel indicates successive prereleases, for example 2.23.1 and 2.23.2 would be prereleases during development of the SDL 2.24.0 stable release.
* Added SDL_GetPointDisplayIndex() and SDL_GetRectDisplayIndex() to get the display associated with a point and rectangle in screen space
* Added SDL_bsearch(), SDL_crc16(), and SDL_utf8strnlen() to the stdlib routines
* Added SDL_CPUPauseInstruction() as a macro in SDL_atomic.h

View File

@@ -19,10 +19,10 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>2.23.2</string>
<string>2.24.0</string>
<key>CFBundleSignature</key>
<string>SDLX</string>
<key>CFBundleVersion</key>
<string>2.23.2</string>
<string>2.24.0</string>
</dict>
</plist>

View File

@@ -9397,7 +9397,7 @@
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEPLOYMENT_POSTPROCESSING = YES;
DYLIB_COMPATIBILITY_VERSION = 1.0.0;
DYLIB_CURRENT_VERSION = 2303.0.0;
DYLIB_CURRENT_VERSION = 2401.0.0;
DYLIB_INSTALL_NAME_BASE = "@rpath";
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_ALTIVEC_EXTENSIONS = YES;
@@ -9482,7 +9482,7 @@
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
DEBUG_INFORMATION_FORMAT = dwarf;
DYLIB_COMPATIBILITY_VERSION = 1.0.0;
DYLIB_CURRENT_VERSION = 2303.0.0;
DYLIB_CURRENT_VERSION = 2401.0.0;
DYLIB_INSTALL_NAME_BASE = "@rpath";
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;

View File

@@ -55,7 +55,7 @@ mkdir buildbot
pushd buildbot
echo "Configuring..."
emconfigure ../configure --host=wasm32-unknown-emscripten --disable-assembly --disable-threads --disable-cpuinfo CFLAGS="-O2 -Wno-warn-absolute-paths -Wdeclaration-after-statement -Werror=declaration-after-statement" --prefix="$PWD/emscripten-sdl2-installed" || exit $?
emconfigure ../configure --host=wasm32-unknown-emscripten --disable-assembly --disable-threads --disable-cpuinfo CFLAGS="-s USE_SDL=0 -O2 -Wno-warn-absolute-paths -Wdeclaration-after-statement -Werror=declaration-after-statement" --prefix="$PWD/emscripten-sdl2-installed" || exit $?
echo "Building..."
emmake $MAKE || exit $?

4
configure vendored
View File

@@ -3433,8 +3433,8 @@ orig_CFLAGS="$CFLAGS"
# See docs/release_checklist.md
SDL_MAJOR_VERSION=2
SDL_MINOR_VERSION=23
SDL_MICRO_VERSION=2
SDL_MINOR_VERSION=24
SDL_MICRO_VERSION=0
SDL_VERSION=$SDL_MAJOR_VERSION.$SDL_MINOR_VERSION.$SDL_MICRO_VERSION
SDL_BINARY_AGE=`expr $SDL_MINOR_VERSION \* 100 + $SDL_MICRO_VERSION`

View File

@@ -12,8 +12,8 @@ orig_CFLAGS="$CFLAGS"
dnl Set various version strings - taken gratefully from the GTk sources
# See docs/release_checklist.md
SDL_MAJOR_VERSION=2
SDL_MINOR_VERSION=23
SDL_MICRO_VERSION=2
SDL_MINOR_VERSION=24
SDL_MICRO_VERSION=0
SDL_VERSION=$SDL_MAJOR_VERSION.$SDL_MINOR_VERSION.$SDL_MICRO_VERSION
SDL_BINARY_AGE=`expr $SDL_MINOR_VERSION \* 100 + $SDL_MICRO_VERSION`

View File

@@ -373,14 +373,22 @@ typedef uint64_t Uint64;
#endif
#endif /* SDL_DISABLE_ANALYZE_MACROS */
#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L)
#define SDL_COMPILE_TIME_ASSERT(name, x) _Static_assert(x, #x)
#elif defined(__cplusplus) && (__cplusplus >= 201103L)
#ifndef SDL_COMPILE_TIME_ASSERT
#if defined(__cplusplus)
#if (__cplusplus >= 201103L)
#define SDL_COMPILE_TIME_ASSERT(name, x) static_assert(x, #x)
#else /* universal, but may trigger -Wunused-local-typedefs */
#endif
#elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L)
#define SDL_COMPILE_TIME_ASSERT(name, x) _Static_assert(x, #x)
#endif
#endif /* !SDL_COMPILE_TIME_ASSERT */
#ifndef SDL_COMPILE_TIME_ASSERT
/* universal, but may trigger -Wunused-local-typedefs */
#define SDL_COMPILE_TIME_ASSERT(name, x) \
typedef int SDL_compile_time_assert_ ## name[(x) * 2 - 1]
#endif
/** \cond */
#ifndef DOXYGEN_SHOULD_IGNORE_THIS
SDL_COMPILE_TIME_ASSERT(uint8, sizeof(Uint8) == 1);

View File

@@ -58,8 +58,8 @@ typedef struct SDL_version
/* Printable format: "%d.%d.%d", MAJOR, MINOR, PATCHLEVEL
*/
#define SDL_MAJOR_VERSION 2
#define SDL_MINOR_VERSION 23
#define SDL_PATCHLEVEL 2
#define SDL_MINOR_VERSION 24
#define SDL_PATCHLEVEL 0
/**
* Macro to determine SDL version program was compiled against.

View File

@@ -130,7 +130,7 @@ static void PS2AUDIO_ThreadInit(_THIS)
ee_thread_status_t status;
thid = GetThreadId();
if (ReferThreadStatus(GetThreadId(), &status) == 0) {
ChangeThreadPriority(thid, status.current_priority);
ChangeThreadPriority(thid, status.current_priority - 1);
}
}

View File

@@ -57,7 +57,7 @@
#define XDG_PORTAL_DBUS_PATH "/org/freedesktop/portal/desktop"
#define XDG_PORTAL_DBUS_INTERFACE "org.freedesktop.portal.Realtime"
static DBusConnection *rtkit_dbus_conn;
static SDL_bool rtkit_use_session_conn;
static const char *rtkit_dbus_node;
static const char *rtkit_dbus_path;
static const char *rtkit_dbus_interface;
@@ -87,37 +87,52 @@ set_rtkit_interface()
/* xdg-desktop-portal works in all instances, so check for it first. */
if (dbus && realtime_portal_supported(dbus->session_conn)) {
rtkit_dbus_conn = dbus->session_conn;
rtkit_use_session_conn = SDL_TRUE;
rtkit_dbus_node = XDG_PORTAL_DBUS_NODE;
rtkit_dbus_path = XDG_PORTAL_DBUS_PATH;
rtkit_dbus_interface = XDG_PORTAL_DBUS_INTERFACE;
} else { /* Fall back to the standard rtkit interface in all other cases. */
rtkit_dbus_conn = dbus ? dbus->system_conn : NULL;
rtkit_use_session_conn = SDL_FALSE;
rtkit_dbus_node = RTKIT_DBUS_NODE;
rtkit_dbus_path = RTKIT_DBUS_PATH;
rtkit_dbus_interface = RTKIT_DBUS_INTERFACE;
}
}
static DBusConnection*
get_rtkit_dbus_connection()
{
SDL_DBusContext *dbus = SDL_DBus_GetContext();
if (dbus) {
return rtkit_use_session_conn ? dbus->session_conn : dbus->system_conn;
}
return NULL;
}
static void
rtkit_initialize()
{
DBusConnection *dbus_conn;
set_rtkit_interface();
dbus_conn = get_rtkit_dbus_connection();
/* Try getting minimum nice level: this is often greater than PRIO_MIN (-20). */
if (!rtkit_dbus_conn || !SDL_DBus_QueryPropertyOnConnection(rtkit_dbus_conn, rtkit_dbus_node, rtkit_dbus_path, rtkit_dbus_interface, "MinNiceLevel",
if (!dbus_conn || !SDL_DBus_QueryPropertyOnConnection(dbus_conn, rtkit_dbus_node, rtkit_dbus_path, rtkit_dbus_interface, "MinNiceLevel",
DBUS_TYPE_INT32, &rtkit_min_nice_level)) {
rtkit_min_nice_level = -20;
}
/* Try getting maximum realtime priority: this can be less than the POSIX default (99). */
if (!rtkit_dbus_conn || !SDL_DBus_QueryPropertyOnConnection(rtkit_dbus_conn, rtkit_dbus_node, rtkit_dbus_path, rtkit_dbus_interface, "MaxRealtimePriority",
if (!dbus_conn || !SDL_DBus_QueryPropertyOnConnection(dbus_conn, rtkit_dbus_node, rtkit_dbus_path, rtkit_dbus_interface, "MaxRealtimePriority",
DBUS_TYPE_INT32, &rtkit_max_realtime_priority)) {
rtkit_max_realtime_priority = 99;
}
/* Try getting maximum rttime allowed by rtkit: exceeding this value will result in SIGKILL */
if (!rtkit_dbus_conn || !SDL_DBus_QueryPropertyOnConnection(rtkit_dbus_conn, rtkit_dbus_node, rtkit_dbus_path, rtkit_dbus_interface, "RTTimeUSecMax",
if (!dbus_conn || !SDL_DBus_QueryPropertyOnConnection(dbus_conn, rtkit_dbus_node, rtkit_dbus_path, rtkit_dbus_interface, "RTTimeUSecMax",
DBUS_TYPE_INT64, &rtkit_max_rttime_usec)) {
rtkit_max_rttime_usec = 200000;
}
@@ -190,16 +205,18 @@ rtkit_initialize_realtime_thread()
static SDL_bool
rtkit_setpriority_nice(pid_t thread, int nice_level)
{
DBusConnection *dbus_conn;
Uint64 pid = (Uint64)getpid();
Uint64 tid = (Uint64)thread;
Sint32 nice = (Sint32)nice_level;
pthread_once(&rtkit_initialize_once, rtkit_initialize);
dbus_conn = get_rtkit_dbus_connection();
if (nice < rtkit_min_nice_level)
nice = rtkit_min_nice_level;
if (!rtkit_dbus_conn || !SDL_DBus_CallMethodOnConnection(rtkit_dbus_conn,
if (!dbus_conn || !SDL_DBus_CallMethodOnConnection(dbus_conn,
rtkit_dbus_node, rtkit_dbus_path, rtkit_dbus_interface, "MakeThreadHighPriorityWithPID",
DBUS_TYPE_UINT64, &pid, DBUS_TYPE_UINT64, &tid, DBUS_TYPE_INT32, &nice, DBUS_TYPE_INVALID,
DBUS_TYPE_INVALID)) {
@@ -211,11 +228,13 @@ rtkit_setpriority_nice(pid_t thread, int nice_level)
static SDL_bool
rtkit_setpriority_realtime(pid_t thread, int rt_priority)
{
DBusConnection *dbus_conn;
Uint64 pid = (Uint64)getpid();
Uint64 tid = (Uint64)thread;
Uint32 priority = (Uint32)rt_priority;
pthread_once(&rtkit_initialize_once, rtkit_initialize);
dbus_conn = get_rtkit_dbus_connection();
if (priority > rtkit_max_realtime_priority)
priority = rtkit_max_realtime_priority;
@@ -228,7 +247,7 @@ rtkit_setpriority_realtime(pid_t thread, int rt_priority)
// go through to determine whether it really needs to fail or not.
rtkit_initialize_realtime_thread();
if (!rtkit_dbus_conn || !SDL_DBus_CallMethodOnConnection(rtkit_dbus_conn,
if (!dbus_conn || !SDL_DBus_CallMethodOnConnection(dbus_conn,
rtkit_dbus_node, rtkit_dbus_path, rtkit_dbus_interface, "MakeThreadRealtimeWithPID",
DBUS_TYPE_UINT64, &pid, DBUS_TYPE_UINT64, &tid, DBUS_TYPE_UINT32, &priority, DBUS_TYPE_INVALID,
DBUS_TYPE_INVALID)) {

View File

@@ -1743,7 +1743,8 @@ SDL_JoystickEventState(int state)
#else
const Uint32 event_list[] = {
SDL_JOYAXISMOTION, SDL_JOYBALLMOTION, SDL_JOYHATMOTION,
SDL_JOYBUTTONDOWN, SDL_JOYBUTTONUP, SDL_JOYDEVICEADDED, SDL_JOYDEVICEREMOVED
SDL_JOYBUTTONDOWN, SDL_JOYBUTTONUP, SDL_JOYDEVICEADDED, SDL_JOYDEVICEREMOVED,
SDL_JOYBATTERYUPDATED
};
unsigned int i;

View File

@@ -522,21 +522,19 @@ void
HIDAPI_JoystickDisconnected(SDL_HIDAPI_Device *device, SDL_JoystickID joystickID)
{
int i, j;
SDL_bool unique = HIDAPI_JoystickInstanceIsUnique(device, joystickID);
SDL_LockJoysticks();
if (!unique) {
if (!HIDAPI_JoystickInstanceIsUnique(device, joystickID)) {
/* Disconnecting a child always disconnects the parent */
device = device->parent;
unique = SDL_TRUE;
}
for (i = 0; i < device->num_joysticks; ++i) {
if (device->joysticks[i] == joystickID) {
if (unique) {
SDL_Joystick *joystick = SDL_JoystickFromInstanceID(joystickID);
if (joystick) {
HIDAPI_JoystickClose(joystick);
}
SDL_Joystick *joystick = SDL_JoystickFromInstanceID(joystickID);
if (joystick) {
HIDAPI_JoystickClose(joystick);
}
HIDAPI_DelJoystickInstanceFromDevice(device, joystickID);
@@ -546,18 +544,18 @@ HIDAPI_JoystickDisconnected(SDL_HIDAPI_Device *device, SDL_JoystickID joystickID
HIDAPI_DelJoystickInstanceFromDevice(child, joystickID);
}
if (unique) {
--SDL_HIDAPI_numjoysticks;
--SDL_HIDAPI_numjoysticks;
if (!shutting_down) {
SDL_PrivateJoystickRemoved(joystickID);
}
if (!shutting_down) {
SDL_PrivateJoystickRemoved(joystickID);
}
}
}
/* Rescan the device list in case device state has changed */
SDL_HIDAPI_change_count = 0;
SDL_UnlockJoysticks();
}
static int

View File

@@ -9,8 +9,8 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 2,23,2,0
PRODUCTVERSION 2,23,2,0
FILEVERSION 2,24,0,0
PRODUCTVERSION 2,24,0,0
FILEFLAGSMASK 0x3fL
FILEFLAGS 0x0L
FILEOS 0x40004L
@@ -23,12 +23,12 @@ BEGIN
BEGIN
VALUE "CompanyName", "\0"
VALUE "FileDescription", "SDL\0"
VALUE "FileVersion", "2, 23, 2, 0\0"
VALUE "FileVersion", "2, 24, 0, 0\0"
VALUE "InternalName", "SDL\0"
VALUE "LegalCopyright", "Copyright (C) 2022 Sam Lantinga\0"
VALUE "OriginalFilename", "SDL2.dll\0"
VALUE "ProductName", "Simple DirectMedia Layer\0"
VALUE "ProductVersion", "2, 23, 2, 0\0"
VALUE "ProductVersion", "2, 24, 0, 0\0"
END
END
BLOCK "VarFileInfo"

View File

@@ -1919,6 +1919,10 @@ GL_CreateRenderer(SDL_Window * window, Uint32 flags)
if (data->shaders && data->num_texture_units >= 3) {
renderer->info.texture_formats[renderer->info.num_texture_formats++] = SDL_PIXELFORMAT_YV12;
renderer->info.texture_formats[renderer->info.num_texture_formats++] = SDL_PIXELFORMAT_IYUV;
}
/* We support NV12 textures using 2 textures and a shader */
if (data->shaders && data->num_texture_units >= 2) {
renderer->info.texture_formats[renderer->info.num_texture_formats++] = SDL_PIXELFORMAT_NV12;
renderer->info.texture_formats[renderer->info.num_texture_formats++] = SDL_PIXELFORMAT_NV21;
}

View File

@@ -678,9 +678,20 @@ static void
PS2_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture)
{
GSTEXTURE *ps2_texture = (GSTEXTURE *) texture->driverdata;
PS2_RenderData *data = (PS2_RenderData *)renderer->driverdata;
if (data == 0)
return;
if(ps2_texture == 0)
return;
// Free from vram
gsKit_TexManager_free(data->gsGlobal, ps2_texture);
SDL_free(ps2_texture->Mem);
SDL_free(ps2_texture);
texture->driverdata = NULL;
}
static void

View File

@@ -126,6 +126,7 @@ SDL_GetPixelFormatName(Uint32 format)
CASE(SDL_PIXELFORMAT_YVYU)
CASE(SDL_PIXELFORMAT_NV12)
CASE(SDL_PIXELFORMAT_NV21)
CASE(SDL_PIXELFORMAT_EXTERNAL_OES)
#undef CASE
default:
return "SDL_PIXELFORMAT_UNKNOWN";

View File

@@ -149,6 +149,12 @@ struct SDL_SysWMinfo;
/* Define the SDL video driver structure */
#define _THIS SDL_VideoDevice *_this
/* Video device flags */
typedef enum {
VIDEO_DEVICE_QUIRK_DISABLE_DISPLAY_MODE_SWITCHING = 0x01,
VIDEO_DEVICE_QUIRK_DISABLE_UNSET_FULLSCREEN_ON_MINIMIZE = 0x02,
} DeviceQuirkFlags;
struct SDL_VideoDevice
{
/* * * */
@@ -347,7 +353,7 @@ struct SDL_VideoDevice
Uint32 next_object_id;
char *clipboard_text;
SDL_bool setting_display_mode;
SDL_bool disable_display_mode_switching;
Uint32 quirk_flags;
/* * * */
/* Data used by the GL drivers */

View File

@@ -166,6 +166,18 @@ extern SDL_bool Cocoa_IsWindowInFullscreenSpace(SDL_Window * window);
extern SDL_bool Cocoa_SetWindowFullscreenSpace(SDL_Window * window, SDL_bool state);
#endif
/* Convenience functions for reading driver flags */
static SDL_bool
DisableDisplayModeSwitching(_THIS)
{
return !!(_this->quirk_flags & VIDEO_DEVICE_QUIRK_DISABLE_DISPLAY_MODE_SWITCHING);
}
static SDL_bool
DisableUnsetFullscreenOnMinimize(_THIS)
{
return !!(_this->quirk_flags & VIDEO_DEVICE_QUIRK_DISABLE_UNSET_FULLSCREEN_ON_MINIMIZE);
}
/* Support for framebuffer emulation using an accelerated renderer */
@@ -1419,7 +1431,7 @@ SDL_UpdateFullscreenMode(SDL_Window * window, SDL_bool fullscreen)
}
/* Don't try to change the display mode if the driver doesn't want it. */
if (_this->disable_display_mode_switching == SDL_FALSE) {
if (DisableDisplayModeSwitching(_this) == SDL_FALSE) {
/* only do the mode change if we want exclusive fullscreen */
if ((window->flags & SDL_WINDOW_FULLSCREEN_DESKTOP) != SDL_WINDOW_FULLSCREEN_DESKTOP) {
if (SDL_SetDisplayModeForDisplay(display, &fullscreen_mode) < 0) {
@@ -2524,7 +2536,9 @@ SDL_MinimizeWindow(SDL_Window * window)
return;
}
SDL_UpdateFullscreenMode(window, SDL_FALSE);
if (!DisableUnsetFullscreenOnMinimize(_this)) {
SDL_UpdateFullscreenMode(window, SDL_FALSE);
}
if (_this->MinimizeWindow) {
_this->MinimizeWindow(_this, window);
@@ -3072,7 +3086,9 @@ SDL_OnWindowMoved(SDL_Window * window)
void
SDL_OnWindowMinimized(SDL_Window * window)
{
SDL_UpdateFullscreenMode(window, SDL_FALSE);
if (!DisableUnsetFullscreenOnMinimize(_this)) {
SDL_UpdateFullscreenMode(window, SDL_FALSE);
}
}
void
@@ -3153,7 +3169,7 @@ ShouldMinimizeOnFocusLoss(SDL_Window * window)
hint = SDL_GetHint(SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS);
if (!hint || !*hint || SDL_strcasecmp(hint, "auto") == 0) {
if ((window->flags & SDL_WINDOW_FULLSCREEN_DESKTOP) == SDL_WINDOW_FULLSCREEN_DESKTOP ||
_this->disable_display_mode_switching == SDL_TRUE) {
DisableDisplayModeSwitching(_this) == SDL_TRUE) {
return SDL_FALSE;
} else {
return SDL_TRUE;

View File

@@ -299,12 +299,14 @@ GetHintCtrlClickEmulateRightClick()
static NSUInteger
GetWindowWindowedStyle(SDL_Window * window)
{
NSUInteger style = 0;
/* always allow miniaturization, otherwise you can't programatically
minimize the window, whether there's a title bar or not */
NSUInteger style = NSWindowStyleMaskMiniaturizable;
if (window->flags & SDL_WINDOW_BORDERLESS) {
style = NSWindowStyleMaskBorderless;
style |= NSWindowStyleMaskBorderless;
} else {
style = (NSWindowStyleMaskTitled|NSWindowStyleMaskClosable|NSWindowStyleMaskMiniaturizable);
style |= (NSWindowStyleMaskTitled|NSWindowStyleMaskClosable);
}
if (window->flags & SDL_WINDOW_RESIZABLE) {
style |= NSWindowStyleMaskResizable;

View File

@@ -24,6 +24,7 @@
#include "../../events/SDL_events_c.h"
#include "SDL_system.h"
#include "SDL_uikitevents.h"
#include "SDL_uikitopengles.h"
#include "SDL_uikitvideo.h"

View File

@@ -22,10 +22,11 @@
#if SDL_VIDEO_DRIVER_UIKIT
#include "SDL_hints.h"
#include "SDL_mouse.h"
#include "SDL_system.h"
#include "SDL_syswm.h"
#include "SDL_video.h"
#include "SDL_mouse.h"
#include "SDL_hints.h"
#include "../SDL_sysvideo.h"
#include "../SDL_pixels_c.h"
#include "../../events/SDL_events_c.h"

View File

@@ -43,7 +43,7 @@ Wayland_SetClipboardText(_THIS, const char *text)
if (text[0] != '\0') {
SDL_WaylandDataSource* source = Wayland_data_source_create(_this);
Wayland_data_source_add_data(source, TEXT_MIME, text,
SDL_strlen(text) + 1);
SDL_strlen(text));
status = Wayland_data_device_set_selection(data_device, source);
if (status != 0) {

View File

@@ -305,14 +305,22 @@ Wayland_data_source_get_data(SDL_WaylandDataSource *source,
} else {
mime_data = mime_data_list_find(&source->mimes, mime_type);
if (mime_data != NULL && mime_data->length > 0) {
buffer = SDL_malloc(mime_data->length);
size_t buffer_length = mime_data->length;
if (null_terminate == SDL_TRUE) {
++buffer_length;
}
buffer = SDL_malloc(buffer_length);
if (buffer == NULL) {
*length = SDL_OutOfMemory();
} else {
*length = mime_data->length;
SDL_memcpy(buffer, mime_data->data, mime_data->length);
if (null_terminate) {
*((Uint8 *)buffer + mime_data->length) = 0;
}
}
}
}
}
return buffer;

View File

@@ -279,7 +279,8 @@ Wayland_CreateDevice(void)
device->free = Wayland_DeleteDevice;
device->disable_display_mode_switching = SDL_TRUE;
device->quirk_flags = VIDEO_DEVICE_QUIRK_DISABLE_DISPLAY_MODE_SWITCHING |
VIDEO_DEVICE_QUIRK_DISABLE_UNSET_FULLSCREEN_ON_MINIMIZE;
return device;
}

View File

@@ -547,9 +547,6 @@ handle_configure_xdg_toplevel(void *data,
if (!fullscreen) {
if (window->flags & SDL_WINDOW_FULLSCREEN) {
/* We might need to re-enter fullscreen after being restored from minimized */
SetFullscreen(window, driverdata->output, SDL_FALSE);
/* Foolishly do what the compositor says here. If it's wrong, don't
* blame us, we were explicitly instructed to do this.
*
@@ -785,13 +782,6 @@ decoration_frame_configure(struct libdecor_frame *frame,
driverdata = (SDL_WaylandOutputData *) SDL_GetDisplayForWindow(window)->driverdata;
if (!fullscreen) {
if (window->flags & SDL_WINDOW_FULLSCREEN) {
/* We might need to re-enter fullscreen after being restored from minimized */
SetFullscreen(window, driverdata->output, SDL_FALSE);
fullscreen = SDL_TRUE;
floating = SDL_FALSE;
}
/* Always send a maximized/restore event; if the event is redundant it will
* automatically be discarded (see src/events/SDL_windowevents.c)
*
@@ -1227,6 +1217,7 @@ void Wayland_ShowWindow(_THIS, SDL_Window *window)
if (data->shell_surface.libdecor.frame) {
/* If the frame already exists, just set the visibility. */
libdecor_frame_set_visibility(data->shell_surface.libdecor.frame, true);
libdecor_frame_set_app_id(data->shell_surface.libdecor.frame, c->classname);
} else {
data->shell_surface.libdecor.frame = libdecor_decorate(c->shell.libdecor,
data->surface,
@@ -1311,8 +1302,7 @@ void Wayland_ShowWindow(_THIS, SDL_Window *window)
* libdecor will call this as part of their configure event!
* -flibit
*/
SDL_WaylandOutputData *odata = SDL_GetDisplayForWindow(window)->driverdata;
SetFullscreen(window, (window->flags & SDL_WINDOW_FULLSCREEN) ? odata->output : NULL, SDL_TRUE);
wl_surface_commit(data->surface);
if (data->shell_surface.xdg.surface) {
while (!data->shell_surface.xdg.initial_configure_seen) {
WAYLAND_wl_display_flush(c->display);
@@ -1370,10 +1360,7 @@ void Wayland_ShowWindow(_THIS, SDL_Window *window)
* Roundtrip required to avoid a possible protocol violation when
* HideWindow was called immediately before ShowWindow.
*/
if (data->needs_roundtrip) {
data->needs_roundtrip = SDL_FALSE;
WAYLAND_wl_display_roundtrip(c->display);
}
WAYLAND_wl_display_roundtrip(c->display);
}
static void
@@ -1430,6 +1417,7 @@ void Wayland_HideWindow(_THIS, SDL_Window *window)
if (WINDOW_IS_LIBDECOR(data, window)) {
if (wind->shell_surface.libdecor.frame) {
libdecor_frame_set_visibility(wind->shell_surface.libdecor.frame, false);
libdecor_frame_set_app_id(wind->shell_surface.libdecor.frame, data->classname);
}
} else
#endif
@@ -1450,7 +1438,6 @@ void Wayland_HideWindow(_THIS, SDL_Window *window)
* Roundtrip required to avoid a possible protocol violation when
* ShowWindow is called immediately after HideWindow.
*/
wind->needs_roundtrip = SDL_TRUE;
WAYLAND_wl_display_roundtrip(data->display);
}
@@ -2084,26 +2071,25 @@ void Wayland_SetWindowTitle(_THIS, SDL_Window * window)
{
SDL_WindowData *wind = window->driverdata;
SDL_VideoData *viddata = _this->driverdata;
const char *title = window->title ? window->title : "";
if (WINDOW_IS_XDG_POPUP(window)) {
return;
}
if (window->title != NULL) {
#ifdef HAVE_LIBDECOR_H
if (WINDOW_IS_LIBDECOR(viddata, window)) {
if (wind->shell_surface.libdecor.frame == NULL) {
return; /* Can't do anything yet, wait for ShowWindow */
}
libdecor_frame_set_title(wind->shell_surface.libdecor.frame, window->title);
} else
if (WINDOW_IS_LIBDECOR(viddata, window)) {
if (wind->shell_surface.libdecor.frame == NULL) {
return; /* Can't do anything yet, wait for ShowWindow */
}
libdecor_frame_set_title(wind->shell_surface.libdecor.frame, title);
} else
#endif
if (viddata->shell.xdg) {
if (wind->shell_surface.xdg.roleobj.toplevel == NULL) {
return; /* Can't do anything yet, wait for ShowWindow */
}
xdg_toplevel_set_title(wind->shell_surface.xdg.roleobj.toplevel, window->title);
if (wind->shell_surface.xdg.roleobj.toplevel == NULL) {
return; /* Can't do anything yet, wait for ShowWindow */
}
xdg_toplevel_set_title(wind->shell_surface.xdg.roleobj.toplevel, title);
}
WAYLAND_wl_display_flush(viddata->display);

View File

@@ -107,7 +107,6 @@ typedef struct {
SDL_Rect viewport_rect;
SDL_bool needs_resize_event;
SDL_bool floating_resize_pending;
SDL_bool needs_roundtrip;
} SDL_WindowData;
extern void Wayland_ShowWindow(_THIS, SDL_Window *window);

View File

@@ -358,16 +358,20 @@ static int
X11_CaptureMouse(SDL_Window *window)
{
Display *display = GetDisplay();
SDL_Window *mouse_focus = SDL_GetMouseFocus();
if (window) {
SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
const unsigned int mask = ButtonPressMask | ButtonReleaseMask | PointerMotionMask | FocusChangeMask;
Window confined = (data->mouse_grabbed ? data->xwindow : None);
const int rc = X11_XGrabPointer(display, data->xwindow, False,
mask, GrabModeAsync, GrabModeAsync,
None, None, CurrentTime);
confined, None, CurrentTime);
if (rc != GrabSuccess) {
return SDL_SetError("X server refused mouse capture");
}
} else if (mouse_focus) {
SDL_UpdateWindowGrab(mouse_focus);
} else {
X11_XUngrabPointer(display, CurrentTime);
}

View File

@@ -1600,6 +1600,7 @@ X11_SetWindowMouseGrab(_THIS, SDL_Window * window, SDL_bool grabbed)
if (data == NULL) {
return;
}
data->mouse_grabbed = SDL_FALSE;
display = data->videodata->display;
@@ -1622,6 +1623,7 @@ X11_SetWindowMouseGrab(_THIS, SDL_Window * window, SDL_bool grabbed)
result = X11_XGrabPointer(display, data->xwindow, True, mask, GrabModeAsync,
GrabModeAsync, data->xwindow, None, CurrentTime);
if (result == GrabSuccess) {
data->mouse_grabbed = SDL_TRUE;
break;
}
SDL_Delay(50);

View File

@@ -59,6 +59,7 @@ typedef struct
int border_right;
int border_top;
int border_bottom;
SDL_bool mouse_grabbed;
Uint32 last_focus_event_time;
PendingFocusEnum pending_focus;
Uint32 pending_focus_time;

View File

@@ -51,6 +51,13 @@ typedef struct shader_data
GLuint color_buffer;
} shader_data;
typedef struct thread_data
{
SDL_Thread *thread;
int done;
int index;
} thread_data;
static SDLTest_CommonState *state;
static SDL_GLContext *context = NULL;
static int depth = 16;
@@ -434,6 +441,7 @@ Render(unsigned int width, unsigned int height, shader_data* data)
if(data->angle_z >= 360) data->angle_z -= 360;
if(data->angle_z < 0) data->angle_z += 360;
GL_CHECK(ctx.glViewport(0, 0, width, height));
GL_CHECK(ctx.glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT));
GL_CHECK(ctx.glDrawArrays(GL_TRIANGLES, 0, 36));
}
@@ -441,56 +449,84 @@ Render(unsigned int width, unsigned int height, shader_data* data)
int done;
Uint32 frames;
shader_data *datas;
thread_data *threads;
void loop()
static void
render_window(int index)
{
int w, h, status;
if (!state->windows[index]) {
return;
}
status = SDL_GL_MakeCurrent(state->windows[index], context[index]);
if (status) {
SDL_Log("SDL_GL_MakeCurrent(): %s\n", SDL_GetError());
return;
}
SDL_GL_GetDrawableSize(state->windows[index], &w, &h);
Render(w, h, &datas[index]);
SDL_GL_SwapWindow(state->windows[index]);
++frames;
}
static int SDLCALL
render_thread_fn(void* render_ctx)
{
thread_data *thread = render_ctx;
while (!done && !thread->done && state->windows[thread->index]) {
render_window(thread->index);
}
SDL_GL_MakeCurrent(state->windows[thread->index], NULL);
return 0;
}
static void
loop_threaded()
{
SDL_Event event;
int i;
int status;
/* Check for events */
++frames;
while (SDL_PollEvent(&event) && !done) {
switch (event.type) {
case SDL_WINDOWEVENT:
switch (event.window.event) {
case SDL_WINDOWEVENT_SIZE_CHANGED:
for (i = 0; i < state->num_windows; ++i) {
if (event.window.windowID == SDL_GetWindowID(state->windows[i])) {
int w, h;
status = SDL_GL_MakeCurrent(state->windows[i], context[i]);
if (status) {
SDL_Log("SDL_GL_MakeCurrent(): %s\n", SDL_GetError());
break;
}
/* Change view port to the new window dimensions */
SDL_GL_GetDrawableSize(state->windows[i], &w, &h);
ctx.glViewport(0, 0, w, h);
state->window_w = event.window.data1;
state->window_h = event.window.data2;
/* Update window content */
Render(event.window.data1, event.window.data2, &datas[i]);
SDL_GL_SwapWindow(state->windows[i]);
break;
/* Wait for events */
while (SDL_WaitEvent(&event) && !done) {
if (event.type == SDL_WINDOWEVENT && event.window.event == SDL_WINDOWEVENT_CLOSE) {
SDL_Window *window = SDL_GetWindowFromID(event.window.windowID);
if (window) {
for (i = 0; i < state->num_windows; ++i) {
if (window == state->windows[i]) {
/* Stop the render thread when the window is closed */
threads[i].done = 1;
if (threads[i].thread) {
SDL_WaitThread(threads[i].thread, NULL);
threads[i].thread = NULL;
}
break;
}
break;
}
}
}
SDLTest_CommonEvent(state, &event, &done);
}
if (!done) {
for (i = 0; i < state->num_windows; ++i) {
status = SDL_GL_MakeCurrent(state->windows[i], context[i]);
if (status) {
SDL_Log("SDL_GL_MakeCurrent(): %s\n", SDL_GetError());
}
/* Continue for next window */
continue;
}
Render(state->window_w, state->window_h, &datas[i]);
SDL_GL_SwapWindow(state->windows[i]);
}
static void
loop()
{
SDL_Event event;
int i;
/* Check for events */
while (SDL_PollEvent(&event) && !done) {
SDLTest_CommonEvent(state, &event, &done);
}
if (!done) {
for (i = 0; i < state->num_windows; ++i) {
render_window(i);
}
}
#ifdef __EMSCRIPTEN__
else {
@@ -502,7 +538,7 @@ void loop()
int
main(int argc, char *argv[])
{
int fsaa, accel;
int fsaa, accel, threaded;
int value;
int i;
SDL_DisplayMode mode;
@@ -513,6 +549,7 @@ main(int argc, char *argv[])
/* Initialize parameters */
fsaa = 0;
accel = 0;
threaded = 0;
/* Initialize test framework */
state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO);
@@ -530,6 +567,9 @@ main(int argc, char *argv[])
} else if (SDL_strcasecmp(argv[i], "--accel") == 0) {
++accel;
consumed = 1;
} else if (SDL_strcasecmp(argv[i], "--threaded") == 0) {
++threaded;
consumed = 1;
} else if (SDL_strcasecmp(argv[i], "--zdepth") == 0) {
i++;
if (!argv[i]) {
@@ -543,7 +583,7 @@ main(int argc, char *argv[])
}
}
if (consumed < 0) {
static const char *options[] = { "[--fsaa]", "[--accel]", "[--zdepth %d]", NULL };
static const char *options[] = { "[--fsaa]", "[--accel]", "[--zdepth %d]", "[--threaded]", NULL };
SDLTest_CommonLogUsage(state, argv[0], options);
quit(1);
}
@@ -551,7 +591,7 @@ main(int argc, char *argv[])
}
/* Set OpenGL parameters */
state->window_flags |= SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE | SDL_WINDOW_BORDERLESS;
state->window_flags |= SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE;
state->gl_red_size = 5;
state->gl_green_size = 5;
state->gl_blue_size = 5;
@@ -603,6 +643,7 @@ main(int argc, char *argv[])
}
SDL_GetCurrentDisplayMode(0, &mode);
SDL_Log("Threaded : %s\n", threaded ? "yes" : "no");
SDL_Log("Screen bpp: %d\n", SDL_BITSPERPIXEL(mode.format));
SDL_Log("\n");
SDL_Log("Vendor : %s\n", ctx.glGetString(GL_VENDOR));
@@ -724,6 +765,8 @@ main(int argc, char *argv[])
GL_CHECK(ctx.glEnable(GL_CULL_FACE));
GL_CHECK(ctx.glEnable(GL_DEPTH_TEST));
SDL_GL_MakeCurrent(state->windows[i], NULL);
}
/* Main render loop */
@@ -734,8 +777,30 @@ main(int argc, char *argv[])
#ifdef __EMSCRIPTEN__
emscripten_set_main_loop(loop, 0, 1);
#else
while (!done) {
loop();
if (threaded) {
threads = (thread_data*)SDL_calloc(state->num_windows, sizeof(thread_data));
/* Start a render thread for each window */
for (i = 0; i < state->num_windows; ++i) {
threads[i].index = i;
threads[i].thread = SDL_CreateThread(render_thread_fn, "RenderThread", &threads[i]);
}
while (!done) {
loop_threaded();
}
/* Join the remaining render threads (if any) */
for (i = 0; i < state->num_windows; ++i) {
threads[i].done = 1;
if (threads[i].thread) {
SDL_WaitThread(threads[i].thread, NULL);
}
}
} else {
while (!done) {
loop();
}
}
#endif