From b0840eb32e67861cfc803dc7eecae39008b4f783 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Wed, 23 Nov 2022 13:33:48 -0800 Subject: [PATCH] Updated SDL_syswm.h for SDL 3.0 * The header is no longer dependent on SDL build configuration * The structures are versioned separately from the rest of SDL * SDL_GetWindowWMInfo() now returns a standard result code and is passed the version expected by the application * Updated WhatsNew.txt and docs/README-migration.md with the first API changes in SDL 3.0 --- WhatsNew.txt | 848 +-------------------- docs/README-migration.md | 24 + include/SDL_syswm.h | 192 ++--- src/core/linux/SDL_fcitx.c | 36 +- src/core/linux/SDL_ibus.c | 36 +- src/dynapi/SDL_dynapi_overrides.h | 1 - src/dynapi/SDL_dynapi_procs.h | 1 - src/render/direct3d/SDL_render_d3d.c | 13 +- src/render/direct3d11/SDL_render_d3d11.c | 13 +- src/render/direct3d11/SDL_render_winrt.cpp | 9 +- src/render/direct3d12/SDL_render_d3d12.c | 14 +- src/render/metal/SDL_render_metal.m | 20 +- src/video/SDL_sysvideo.h | 3 +- src/video/SDL_video.c | 37 +- src/video/android/SDL_androidvulkan.c | 2 + src/video/android/SDL_androidwindow.c | 20 +- src/video/android/SDL_androidwindow.h | 2 +- src/video/cocoa/SDL_cocoametalview.m | 2 + src/video/cocoa/SDL_cocoavulkan.m | 2 + src/video/cocoa/SDL_cocoawindow.h | 2 +- src/video/cocoa/SDL_cocoawindow.m | 21 +- src/video/haiku/SDL_BWin.h | 3 +- src/video/haiku/SDL_bwindow.cc | 18 +- src/video/haiku/SDL_bwindow.h | 3 +- src/video/kmsdrm/SDL_kmsdrmvideo.c | 18 +- src/video/kmsdrm/SDL_kmsdrmvideo.h | 3 +- src/video/kmsdrm/SDL_kmsdrmvulkan.c | 11 +- src/video/ngage/SDL_ngagewindow.h | 1 + src/video/psp/SDL_pspvideo.c | 26 +- src/video/psp/SDL_pspvideo.h | 4 - src/video/raspberry/SDL_rpivideo.c | 26 +- src/video/raspberry/SDL_rpivideo.h | 4 - src/video/riscos/SDL_riscoswindow.c | 16 +- src/video/riscos/SDL_riscoswindow.h | 3 +- src/video/uikit/SDL_uikitmetalview.m | 4 +- src/video/uikit/SDL_uikitvulkan.m | 2 + src/video/uikit/SDL_uikitwindow.h | 3 +- src/video/uikit/SDL_uikitwindow.m | 56 +- src/video/vita/SDL_vitavideo.c | 22 +- src/video/vita/SDL_vitavideo.h | 4 - src/video/vivante/SDL_vivantevideo.c | 3 +- src/video/vivante/SDL_vivantevideo.h | 3 +- src/video/wayland/SDL_waylandvulkan.c | 2 + src/video/wayland/SDL_waylandwindow.c | 94 +-- src/video/wayland/SDL_waylandwindow.h | 7 +- src/video/windows/SDL_windowsevents.c | 6 +- src/video/windows/SDL_windowsvulkan.c | 2 + src/video/windows/SDL_windowswindow.c | 29 +- src/video/windows/SDL_windowswindow.h | 3 +- src/video/winrt/SDL_winrtvideo.cpp | 29 +- src/video/x11/SDL_x11events.c | 6 +- src/video/x11/SDL_x11window.c | 28 +- src/video/x11/SDL_x11window.h | 3 +- test/testautomation_syswm.c | 9 +- test/testnative.h | 7 - test/testnativew32.c | 2 + test/testnativex11.c | 2 + 57 files changed, 349 insertions(+), 1411 deletions(-) create mode 100644 docs/README-migration.md diff --git a/WhatsNew.txt b/WhatsNew.txt index 1f95f0592..4231b8834 100644 --- a/WhatsNew.txt +++ b/WhatsNew.txt @@ -2,852 +2,8 @@ This is a list of major changes in SDL's version history. --------------------------------------------------------------------------- -2.26.0: +3.2.0: --------------------------------------------------------------------------- General: -* Updated OpenGL headers to the latest API from The Khronos Group Inc. -* Added SDL_GetWindowSizeInPixels() to get the window size in pixels, which may differ from the window coordinate size for windows with high-DPI support -* Added simulated vsync synchronization for the software renderer -* Added the mouse position to SDL_MouseWheelEvent -* Added SDL_ResetHints() to reset all hints to their default values -* Added SDL_GetJoystickGUIDInfo() to get device information encoded in a joystick GUID -* Added the hint SDL_HINT_JOYSTICK_HIDAPI_XBOX_360 to control whether the HIDAPI driver for XBox 360 controllers should be used -* Added the hint SDL_HINT_JOYSTICK_HIDAPI_XBOX_360_PLAYER_LED to control whether the player LEDs should be lit to indicate which player is associated with an Xbox 360 controller -* Added the hint SDL_HINT_JOYSTICK_HIDAPI_XBOX_360_WIRELESS to control whether the HIDAPI driver for XBox 360 wireless controllers should be used -* Added the hint SDL_HINT_JOYSTICK_HIDAPI_XBOX_ONE to control whether the HIDAPI driver for XBox One controllers should be used -* Added the hint SDL_HINT_JOYSTICK_HIDAPI_XBOX_ONE_HOME_LED to control the brightness of the XBox One guide button LED -* Added support for PS3 controllers to the HIDAPI driver, enabled by default on macOS, controlled by the SDL_HINT_JOYSTICK_HIDAPI_PS3 hint -* Added support for Nintendo Wii controllers to the HIDAPI driver, not enabled by default, controlled by the SDL_HINT_JOYSTICK_HIDAPI_WII hint -* Added the hint SDL_HINT_JOYSTICK_HIDAPI_WII_PLAYER_LED to control whether the player LED should be lit on the Nintendo Wii controllers -* Added the hint SDL_HINT_JOYSTICK_HIDAPI_VERTICAL_JOY_CONS to control whether Nintendo Switch Joy-Con controllers will be in vertical mode when using the HIDAPI driver -* Added access to the individual left and right gyro sensors of the combined Joy-Cons controller -* Added a microsecond timestamp to SDL_SensorEvent and SDL_ControllerSensorEvent, when the hardware provides that information -* Added SDL_SensorGetDataWithTimestamp() and SDL_GameControllerGetSensorDataWithTimestamp() to retrieve the last sensor data with the associated microsecond timestamp -* Added the hint SDL_HINT_HIDAPI_IGNORE_DEVICES to have the SDL HID API ignore specific devices -* SDL_GetRevision() now includes more information about the SDL build, including the git commit hash if available - -Windows: -* Added the hint SDL_HINT_MOUSE_RELATIVE_SYSTEM_SCALE to control whether the system mouse acceleration curve is used for relative mouse motion - -macOS: -* Implemented vsync synchronization on macOS 12 - -Linux: -* Added SDL_SetPrimarySelectionText(), SDL_GetPrimarySelectionText(), and SDL_HasPrimarySelectionText() to interact with the X11 primary selection clipboard -* Added the hint SDL_HINT_VIDEO_WAYLAND_EMULATE_MOUSE_WARP to control whether mouse pointer warp emulation is enabled under Wayland - -Android: -* Enabled IME soft keyboard input -* Added version checking to make sure the SDL Java and C code are compatible - - ---------------------------------------------------------------------------- -2.24.0: ---------------------------------------------------------------------------- - -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. -* 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 -* Added SDL_size_mul_overflow() and SDL_size_add_overflow() for better size overflow protection -* Added SDL_ResetHint() to reset a hint to the default value -* Added SDL_ResetKeyboard() to reset SDL's internal keyboard state, generating key up events for all currently pressed keys -* Added the hint SDL_HINT_MOUSE_RELATIVE_WARP_MOTION to control whether mouse warping generates motion events in relative mode. This hint defaults off. -* Added the hint SDL_HINT_TRACKPAD_IS_TOUCH_ONLY to control whether trackpads are treated as touch devices or mice. By default touchpads are treated as mouse input. -* The hint SDL_HINT_JOYSTICK_HIDAPI_JOY_CONS now defaults on -* Added support for mini-gamepad mode for Nintendo Joy-Con controllers using the HIDAPI driver -* Added the hint SDL_HINT_JOYSTICK_HIDAPI_COMBINE_JOY_CONS to control whether Joy-Con controllers are automatically merged into a unified gamepad when using the HIDAPI driver. This hint defaults on. -* The hint SDL_HINT_JOYSTICK_HIDAPI_SWITCH_HOME_LED can be set to a floating point value to set the brightness of the Home LED on Nintendo Switch controllers -* Added the hint SDL_HINT_JOYSTICK_HIDAPI_JOYCON_HOME_LED to set the Home LED brightness for the Nintendo Joy-Con controllers. By default the Home LED is not modified. -* Added the hint SDL_HINT_JOYSTICK_HIDAPI_SWITCH_PLAYER_LED to control whether the player LED should be lit on the Nintendo Joy-Con controllers -* Added support for Nintendo Online classic controllers using the HIDAPI driver -* Added the hint SDL_HINT_JOYSTICK_HIDAPI_NINTENDO_CLASSIC to control whether the HIDAPI driver for Nintendo Online classic controllers should be used -* Added support for the NVIDIA Shield Controller to the HIDAPI driver, supporting rumble and battery status -* Added support for NVIDIA SHIELD controller to the HIDAPI driver, and a hint SDL_HINT_JOYSTICK_HIDAPI_SHIELD to control whether this is used -* Added functions to get the platform dependent name for a joystick or game controller: - * SDL_JoystickPathForIndex() - * SDL_JoystickPath() - * SDL_GameControllerPathForIndex() - * SDL_GameControllerPath() -* Added SDL_GameControllerGetFirmwareVersion() and SDL_JoystickGetFirmwareVersion(), currently implemented for DualSense(tm) Wireless Controllers using HIDAPI -* Added SDL_JoystickAttachVirtualEx() for extended virtual controller support -* Added joystick event SDL_JOYBATTERYUPDATED for when battery status changes -* Added SDL_GUIDToString() and SDL_GUIDFromString() to convert between SDL GUID and string -* Added SDL_HasLSX() and SDL_HasLASX() to detect LoongArch SIMD support -* Added SDL_GetOriginalMemoryFunctions() -* Added SDL_GetDefaultAudioInfo() to get the name and format of the default audio device, currently implemented for PipeWire, PulseAudio, WASAPI, and DirectSound -* Added HIDAPI driver for the NVIDIA SHIELD controller (2017 model) to enable support for battery status and rumble -* Added support for opening audio devices with 3 or 5 channels (2.1, 4.1). All channel counts from Mono to 7.1 are now supported. -* Rewrote audio channel converters used by SDL_AudioCVT, based on the channel matrix coefficients used as the default for FAudio voices -* SDL log messages are no longer limited to 4K and can be any length -* Fixed a long-standing calling convention issue with dynapi affecting OpenWatcom or OS/2 builds - -Windows: -* Added initial support for building for Windows and Xbox with Microsoft's Game Development Kit (GDK), see docs/README-gdk.md for details -* Added a D3D12 renderer implementation and SDL_RenderGetD3D12Device() to retrieve the D3D12 device associated with it -* Added the hint SDL_HINT_WINDOWS_DPI_AWARENESS to set whether the application is DPI-aware. This hint must be set before initializing the video subsystem -* Added the hint SDL_HINT_WINDOWS_DPI_SCALING to control whether the SDL coordinates are in DPI-scaled points or pixels -* Added the hint SDL_HINT_DIRECTINPUT_ENABLED to control whether the DirectInput driver should be used -* Added support for SDL_GetAudioDeviceSpec to the DirectSound backend - -Linux: -* Support for XVidMode has been removed, mode changes are only supported using the XRandR extension -* Added the hint SDL_HINT_VIDEO_WAYLAND_MODE_EMULATION to control whether to expose a set of emulated modes in addition to the native resolution modes available on Wayland -* Added the hint SDL_HINT_KMSDRM_DEVICE_INDEX to specify which KMSDRM device to use if the default is not desired -* Added the hint SDL_HINT_LINUX_DIGITAL_HATS to control whether to treat hats as digital rather than checking to see if they may be analog -* Added the hint SDL_HINT_LINUX_HAT_DEADZONES to control whether to use deadzones on analog hats - -macOS: -* Bumped minimum OS deployment version to macOS 10.9 -* Added SDL_GL_FLOATBUFFERS to allow Cocoa GL contexts to use EDR -* Added the hint SDL_HINT_MAC_OPENGL_ASYNC_DISPATCH to control whether dispatching OpenGL context updates should block the dispatching thread until the main thread finishes processing. This hint defaults to blocking, which is the safer option on modern macOS. - - ---------------------------------------------------------------------------- -2.0.22: ---------------------------------------------------------------------------- - -General: -* Added SDL_RenderGetWindow() to get the window associated with a renderer -* Added floating point rectangle functions: - * SDL_PointInFRect() - * SDL_FRectEmpty() - * SDL_FRectEquals() - * SDL_FRectEqualsEpsilon() - * SDL_HasIntersectionF() - * SDL_IntersectFRect() - * SDL_UnionFRect() - * SDL_EncloseFPoints() - * SDL_IntersectFRectAndLine() -* Added SDL_IsTextInputShown() which returns whether the IME window is currently shown -* Added SDL_ClearComposition() to dismiss the composition window without disabling IME input -* Added SDL_TEXTEDITING_EXT event for handling long composition text, and a hint SDL_HINT_IME_SUPPORT_EXTENDED_TEXT to enable it -* Added the hint SDL_HINT_MOUSE_RELATIVE_MODE_CENTER to control whether the mouse should be constrained to the whole window or the center of the window when relative mode is enabled -* The mouse is now automatically captured when mouse buttons are pressed, and the hint SDL_HINT_MOUSE_AUTO_CAPTURE allows you to control this behavior -* Added the hint SDL_HINT_VIDEO_FOREIGN_WINDOW_OPENGL to let SDL know that a foreign window will be used with OpenGL -* Added the hint SDL_HINT_VIDEO_FOREIGN_WINDOW_VULKAN to let SDL know that a foreign window will be used with Vulkan -* Added the hint SDL_HINT_QUIT_ON_LAST_WINDOW_CLOSE to specify whether an SDL_QUIT event will be delivered when the last application window is closed -* Added the hint SDL_HINT_JOYSTICK_ROG_CHAKRAM to control whether ROG Chakram mice show up as joysticks - -Windows: -* Added support for SDL_BLENDOPERATION_MINIMUM and SDL_BLENDOPERATION_MAXIMUM to the D3D9 renderer - -Linux: -* Compiling with Wayland support requires libwayland-client version 1.18.0 or later -* Added the hint SDL_HINT_X11_WINDOW_TYPE to specify the _NET_WM_WINDOW_TYPE of SDL windows -* Added the hint SDL_HINT_VIDEO_WAYLAND_PREFER_LIBDECOR to allow using libdecor with compositors that support xdg-decoration - -Android: -* Added SDL_AndroidSendMessage() to send a custom command to the SDL java activity - - ---------------------------------------------------------------------------- -2.0.20: ---------------------------------------------------------------------------- - -General: -* SDL_RenderGeometryRaw() takes a pointer to SDL_Color, not int. You can cast color data in SDL_PIXELFORMAT_RGBA32 format (SDL_PIXELFORMAT_ABGR8888 on little endian systems) for this parameter. -* Improved accuracy of horizontal and vertical line drawing when using OpenGL or OpenGLES -* Added the hint SDL_HINT_RENDER_LINE_METHOD to control the method of line drawing used, to select speed, correctness, and compatibility. - -Windows: -* Fixed size of custom cursors - -Linux: -* Fixed hotplug controller detection, broken in 2.0.18 - - ---------------------------------------------------------------------------- -2.0.18: ---------------------------------------------------------------------------- - -General: -* The SDL wiki documentation and development headers are automatically kept in sync -* Each function has information about in which version of SDL it was introduced -* SDL-specific CMake options are now prefixed with 'SDL_'. Be sure to update your CMake build scripts accordingly! -* Added the hint SDL_HINT_APP_NAME to let SDL know the name of your application for various places it might show up in system information -* Added SDL_RenderGeometry() and SDL_RenderGeometryRaw() to allow rendering of arbitrary shapes using the SDL 2D render API -* Added SDL_SetTextureUserData() and SDL_GetTextureUserData() to associate application data with an SDL texture -* Added SDL_RenderWindowToLogical() and SDL_RenderLogicalToWindow() to convert between window coordinates and logical render coordinates -* Added SDL_RenderSetVSync() to change whether a renderer present is synchronized with vblank at runtime -* Added SDL_PremultiplyAlpha() to premultiply alpha on a block of SDL_PIXELFORMAT_ARGB8888 pixels -* Added a window event SDL_WINDOWEVENT_DISPLAY_CHANGED which is sent when a window changes what display it's centered on -* Added SDL_GetWindowICCProfile() to query a window's ICC profile, and a window event SDL_WINDOWEVENT_ICCPROF_CHANGED that is sent when it changes -* Added the hint SDL_HINT_VIDEO_EGL_ALLOW_TRANSPARENCY to allow EGL windows to be transparent instead of opaque -* SDL_WaitEvent() has been redesigned to use less CPU in most cases -* Added SDL_SetWindowMouseRect() and SDL_GetWindowMouseRect() to confine the mouse cursor to an area of a window -* You can now read precise mouse wheel motion using 'preciseX' and 'preciseY' event fields -* Added SDL_GameControllerHasRumble() and SDL_GameControllerHasRumbleTriggers() to query whether a game controller supports rumble -* Added SDL_JoystickHasRumble() and SDL_JoystickHasRumbleTriggers() to query whether a joystick supports rumble -* SDL's hidapi implementation is now available as a public API in SDL_hidapi.h - -Windows: -* Improved relative mouse motion over Windows Remote Desktop -* Added the hint SDL_HINT_IME_SHOW_UI to show native UI components instead of hiding them (defaults off) - -Windows/UWP: -* WGI is used instead of XInput for better controller support in UWP apps - -Linux: -* Added the hint SDL_HINT_SCREENSAVER_INHIBIT_ACTIVITY_NAME to set the activity that's displayed by the system when the screensaver is disabled -* Added the hint SDL_HINT_LINUX_JOYSTICK_CLASSIC to control whether /dev/input/js* or /dev/input/event* are used as joystick devices -* Added the hint SDL_HINT_JOYSTICK_DEVICE to allow the user to specify devices that will be opened in addition to the normal joystick detection -* Added SDL_LinuxSetThreadPriorityAndPolicy() for more control over a thread priority on Linux - -Android: -* Added support for audio output and capture using AAudio on Android 8.1 and newer -* Steam Controller support is disabled by default, and can be enabled by setting the hint SDL_HINT_JOYSTICK_HIDAPI_STEAM to "1" before calling SDL_Init() - -Apple Arcade: -* Added SDL_GameControllerGetAppleSFSymbolsNameForButton() and SDL_GameControllerGetAppleSFSymbolsNameForAxis() to support Apple Arcade titles - -iOS: -* Added documentation that the UIApplicationSupportsIndirectInputEvents key must be set to true in your application's Info.plist in order to get real Bluetooth mouse events. -* Steam Controller support is disabled by default, and can be enabled by setting the hint SDL_HINT_JOYSTICK_HIDAPI_STEAM to "1" before calling SDL_Init() - - ---------------------------------------------------------------------------- -2.0.16: ---------------------------------------------------------------------------- -General: -* Added SDL_FlashWindow() to get a user's attention -* Added SDL_GetAudioDeviceSpec() to get the preferred audio format of a device -* Added SDL_SetWindowAlwaysOnTop() to dynamically change the SDL_WINDOW_ALWAYS_ON_TOP flag for a window -* Added SDL_SetWindowKeyboardGrab() to support grabbing the keyboard independently of the mouse -* Added SDL_SoftStretchLinear() to do bilinear scaling between 32-bit software surfaces -* Added SDL_UpdateNVTexture() to update streaming NV12/21 textures -* Added SDL_GameControllerSendEffect() and SDL_JoystickSendEffect() to allow sending custom trigger effects to the DualSense controller -* Added SDL_GameControllerGetSensorDataRate() to get the sensor data rate for PlayStation and Nintendo Switch controllers -* Added support for the Amazon Luna game controller -* Added rumble support for the Google Stadia controller using the HIDAPI driver -* Added SDL_GameControllerType constants for the Amazon Luna and Google Stadia controllers -* Added analog rumble for Nintendo Switch Pro controllers using the HIDAPI driver -* Reduced CPU usage when using SDL_WaitEvent() and SDL_WaitEventTimeout() - -Windows: -* Added SDL_SetWindowsMessageHook() to set a function that is called for all Windows messages -* Added SDL_RenderGetD3D11Device() to get the D3D11 device used by the SDL renderer - -Linux: -* Greatly improved Wayland support -* Added support for audio output and capture using Pipewire -* Added the hint SDL_HINT_AUDIO_INCLUDE_MONITORS to control whether PulseAudio recording should include monitor devices -* Added the hint SDL_HINT_AUDIO_DEVICE_STREAM_ROLE to describe the role of your application for audio control panels - -Android: -* Added SDL_AndroidShowToast() to show a lightweight notification - -iOS: -* Added support for mouse relative mode on iOS 14.1 and newer -* Added support for the Xbox Series X controller - -tvOS: -* Added support for the Xbox Series X controller - - ---------------------------------------------------------------------------- -2.0.14: ---------------------------------------------------------------------------- -General: -* Added support for PS5 DualSense and Xbox Series X controllers to the HIDAPI controller driver -* Added game controller button constants for paddles and new buttons -* Added game controller functions to get additional information: - * SDL_GameControllerGetSerial() - * SDL_GameControllerHasAxis() - * SDL_GameControllerHasButton() - * SDL_GameControllerGetNumTouchpads() - * SDL_GameControllerGetNumTouchpadFingers() - * SDL_GameControllerGetTouchpadFinger() - * SDL_GameControllerHasSensor() - * SDL_GameControllerSetSensorEnabled() - * SDL_GameControllerIsSensorEnabled() - * SDL_GameControllerGetSensorData() - * SDL_GameControllerRumbleTriggers() - * SDL_GameControllerHasLED() - * SDL_GameControllerSetLED() -* Added the hint SDL_HINT_JOYSTICK_HIDAPI_PS5 to control whether the HIDAPI driver for PS5 controllers should be used. -* Added joystick functions to get additional information: - * SDL_JoystickGetSerial() - * SDL_JoystickRumbleTriggers() - * SDL_JoystickHasLED() - * SDL_JoystickSetLED() -* Added an API to allow the application to create virtual joysticks: - * SDL_JoystickAttachVirtual() - * SDL_JoystickDetachVirtual() - * SDL_JoystickIsVirtual() - * SDL_JoystickSetVirtualAxis() - * SDL_JoystickSetVirtualButton() - * SDL_JoystickSetVirtualHat() -* Added SDL_LockSensors() and SDL_UnlockSensors() to guarantee exclusive access to the sensor list -* Added SDL_HAPTIC_STEERING_AXIS to play an effect on the steering wheel -* Added the hint SDL_HINT_MOUSE_RELATIVE_SCALING to control whether relative motion is scaled by the screen DPI or renderer logical size -* The default value for SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS is now false for better compatibility with modern window managers -* Added SDL_GetPreferredLocales() to get the application's current locale setting -* Added the hint SDL_HINT_PREFERRED_LOCALES to override your application's default locale setting -* Added SDL_OpenURL() to open a URL in the system's default browser -* Added SDL_HasSurfaceRLE() to tell whether a surface is currently using RLE encoding -* Added SDL_SIMDRealloc() to reallocate memory obtained from SDL_SIMDAlloc() -* Added SDL_GetErrorMsg() to get the last error in a thread-safe way -* Added SDL_crc32(), SDL_wcscasecmp(), SDL_wcsncasecmp(), SDL_trunc(), SDL_truncf() -* Added clearer names for RGB pixel formats, e.g. SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_XBGR8888, etc. - -Windows: -* Added the RAWINPUT controller driver to support more than 4 Xbox controllers simultaneously -* Added the hint SDL_HINT_JOYSTICK_RAWINPUT to control whether the RAWINPUT driver should be used -* Added the hint SDL_HINT_JOYSTICK_HIDAPI_CORRELATE_XINPUT to control whether XInput and WGI should be used to for complete controller functionality with the RAWINPUT driver. - -macOS: -* Added the SDL_WINDOW_METAL flag to specify that a window should be created with a Metal view -* Added SDL_Metal_GetLayer() to get the CAMetalLayer backing a Metal view -* Added SDL_Metal_GetDrawableSize() to get the size of a window's drawable, in pixels - -Linux: -* Added the hint SDL_HINT_AUDIO_DEVICE_APP_NAME to specify the name that shows up in PulseAudio for your application -* Added the hint SDL_HINT_AUDIO_DEVICE_STREAM_NAME to specify the name that shows up in PulseAudio associated with your audio stream -* Added the hint SDL_HINT_LINUX_JOYSTICK_DEADZONES to control whether HID defined dead zones should be respected on Linux -* Added the hint SDL_HINT_THREAD_PRIORITY_POLICY to specify the thread scheduler policy -* Added the hint SDL_HINT_THREAD_FORCE_REALTIME_TIME_CRITICAL to allow time critical threads to use a realtime scheduling policy - -Android: -* Added SDL_AndroidRequestPermission() to request a specific system permission -* Added the hint SDL_HINT_ANDROID_BLOCK_ON_PAUSE_PAUSEAUDIO to control whether audio will pause when the application goes intot he background - -OS/2: -* Added support for OS/2, see docs/README-os2.md for details - -Emscripten (running in a web browser): -* Added the hint SDL_HINT_EMSCRIPTEN_ASYNCIFY to control whether SDL should call emscripten_sleep internally - - ---------------------------------------------------------------------------- -2.0.12: ---------------------------------------------------------------------------- - -General: -* Added SDL_GetTextureScaleMode() and SDL_SetTextureScaleMode() to get and set the scaling mode used for a texture -* Added SDL_LockTextureToSurface(), similar to SDL_LockTexture() but the locked area is exposed as a SDL surface. -* Added new blend mode, SDL_BLENDMODE_MUL, which does a modulate and blend operation -* Added the hint SDL_HINT_DISPLAY_USABLE_BOUNDS to override the results of SDL_GetDisplayUsableBounds() for display index 0. -* Added the window underneath the finger to the SDL_TouchFingerEvent -* Added SDL_GameControllerTypeForIndex(), SDL_GameControllerGetType() to return the type of a game controller (Xbox 360, Xbox One, PS3, PS4, or Nintendo Switch Pro) -* Added the hint SDL_HINT_GAMECONTROLLERTYPE to override the automatic game controller type detection -* Added SDL_JoystickFromPlayerIndex() and SDL_GameControllerFromPlayerIndex() to get the device associated with a player index -* Added SDL_JoystickSetPlayerIndex() and SDL_GameControllerSetPlayerIndex() to set the player index associated with a device -* Added the hint SDL_HINT_GAMECONTROLLER_USE_BUTTON_LABELS to specify whether Nintendo Switch Pro controllers should use the buttons as labeled or swapped to match positional layout. The default is to use the buttons as labeled. -* Added support for Nintendo GameCube controllers to the HIDAPI driver, and a hint SDL_HINT_JOYSTICK_HIDAPI_GAMECUBE to control whether this is used. -* Improved support for Xbox 360 and Xbox One controllers when using the HIDAPI driver -* Added support for many game controllers, including: - * 8BitDo FC30 Pro - * 8BitDo M30 GamePad - * BDA PS4 Fightpad - * HORI Fighting Commander - * Hyperkin Duke - * Hyperkin X91 - * MOGA XP5-A Plus - * NACON GC-400ES - * NVIDIA Controller v01.04 - * PDP Versus Fighting Pad - * Razer Raion Fightpad for PS4 - * Razer Serval - * Stadia Controller - * SteelSeries Stratus Duo - * Victrix Pro Fight Stick for PS4 - * Xbox One Elite Series 2 -* Fixed blocking game controller rumble calls when using the HIDAPI driver -* Added SDL_zeroa() macro to zero an array of elements -* Added SDL_HasARMSIMD() which returns true if the CPU has ARM SIMD (ARMv6+) features - -Windows: -* Fixed crash when using the release SDL DLL with applications built with gcc -* Fixed performance regression in event handling introduced in 2.0.10 -* Added support for SDL_SetThreadPriority() for UWP applications - -Linux: -* Added the hint SDL_HINT_VIDEO_X11_WINDOW_VISUALID to specify the visual chosen for new X11 windows -* Added the hint SDL_HINT_VIDEO_X11_FORCE_EGL to specify whether X11 should use GLX or EGL by default - -iOS / tvOS / macOS: -* Added SDL_Metal_CreateView() and SDL_Metal_DestroyView() to create CAMetalLayer-backed NSView/UIView and attach it to the specified window. - -iOS/ tvOS: -* Added support for Bluetooth Steam Controllers as game controllers - -tvOS: -* Fixed support for surround sound on Apple TV - -Android: -* Added SDL_GetAndroidSDKVersion() to return the API level of the current device -* Added support for audio capture using OpenSL-ES -* Added support for Bluetooth Steam Controllers as game controllers -* Fixed rare crashes when the app goes into the background or terminates - - ---------------------------------------------------------------------------- -2.0.10: ---------------------------------------------------------------------------- - -General: -* The SDL_RW* macros have been turned into functions that are available only in 2.0.10 and onward -* Added SDL_SIMDGetAlignment(), SDL_SIMDAlloc(), and SDL_SIMDFree(), to allocate memory aligned for SIMD operations for the current CPU -* Added SDL_RenderDrawPointF(), SDL_RenderDrawPointsF(), SDL_RenderDrawLineF(), SDL_RenderDrawLinesF(), SDL_RenderDrawRectF(), SDL_RenderDrawRectsF(), SDL_RenderFillRectF(), SDL_RenderFillRectsF(), SDL_RenderCopyF(), SDL_RenderCopyExF(), to allow floating point precision in the SDL rendering API. -* Added SDL_GetTouchDeviceType() to get the type of a touch device, which can be a touch screen or a trackpad in relative or absolute coordinate mode. -* The SDL rendering API now uses batched rendering by default, for improved performance -* Added SDL_RenderFlush() to force batched render commands to execute, if you're going to mix SDL rendering with native rendering -* Added the hint SDL_HINT_RENDER_BATCHING to control whether batching should be used for the rendering API. This defaults to "1" if you don't specify what rendering driver to use when creating the renderer. -* Added the hint SDL_HINT_EVENT_LOGGING to enable logging of SDL events for debugging purposes -* Added the hint SDL_HINT_GAMECONTROLLERCONFIG_FILE to specify a file that will be loaded at joystick initialization with game controller bindings -* Added the hint SDL_HINT_MOUSE_TOUCH_EVENTS to control whether SDL will synthesize touch events from mouse events -* Improved handling of malformed WAVE and BMP files, fixing potential security exploits - -Linux: -* Removed the Mir video driver in favor of Wayland - -iOS / tvOS: -* Added support for Xbox and PS4 wireless controllers in iOS 13 and tvOS 13 -* Added support for text input using Bluetooth keyboards - -Android: -* Added low latency audio using OpenSL ES -* Removed SDL_HINT_ANDROID_SEPARATE_MOUSE_AND_TOUCH (replaced by SDL_HINT_MOUSE_TOUCH_EVENTS and SDL_HINT_TOUCH_MOUSE_EVENTS) - SDL_HINT_ANDROID_SEPARATE_MOUSE_AND_TOUCH=1, should be replaced by setting both previous hints to 0. - SDL_HINT_ANDROID_SEPARATE_MOUSE_AND_TOUCH=0, should be replaced by setting both previous hints to 1. -* Added the hint SDL_HINT_ANDROID_BLOCK_ON_PAUSE to set whether the event loop will block itself when the app is paused. - - ---------------------------------------------------------------------------- -2.0.9: ---------------------------------------------------------------------------- - -General: -* Added a new sensor API, initialized by passing SDL_INIT_SENSOR to SDL_Init(), and defined in SDL_sensor.h -* Added an event SDL_SENSORUPDATE which is sent when a sensor is updated -* Added SDL_GetDisplayOrientation() to return the current display orientation -* Added an event SDL_DISPLAYEVENT which is sent when the display orientation changes -* Added HIDAPI joystick drivers for more consistent support for Xbox, PS4 and Nintendo Switch Pro controller support across platforms. (Thanks to Valve for contributing the PS4 and Nintendo Switch Pro controller support) -* Added support for many other popular game controllers -* Added SDL_JoystickGetDevicePlayerIndex(), SDL_JoystickGetPlayerIndex(), and SDL_GameControllerGetPlayerIndex() to get the player index for a controller. For XInput controllers this returns the XInput index for the controller. -* Added SDL_GameControllerRumble() and SDL_JoystickRumble() which allow simple rumble without using the haptics API -* Added SDL_GameControllerMappingForDeviceIndex() to get the mapping for a controller before it's opened -* Added the hint SDL_HINT_MOUSE_DOUBLE_CLICK_TIME to control the mouse double-click time -* Added the hint SDL_HINT_MOUSE_DOUBLE_CLICK_RADIUS to control the mouse double-click radius, in pixels -* Added SDL_HasColorKey() to return whether a surface has a colorkey active -* Added SDL_HasAVX512F() to return whether the CPU has AVX-512F features -* Added SDL_IsTablet() to return whether the application is running on a tablet -* Added SDL_THREAD_PRIORITY_TIME_CRITICAL for threads that must run at the highest priority - -Mac OS X: -* Fixed black screen at start on Mac OS X Mojave - -Linux: -* Added SDL_LinuxSetThreadPriority() to allow adjusting the thread priority of native threads using RealtimeKit if available. - -iOS: -* Fixed Asian IME input - -Android: -* Updated required Android SDK to API 26, to match Google's new App Store requirements -* Added support for wired USB Xbox, PS4, and Nintendo Switch Pro controllers -* Added support for relative mouse mode on Android 7.0 and newer (except where it's broken, on Chromebooks and when in DeX mode with Samsung Experience 9.0) -* Added support for custom mouse cursors on Android 7.0 and newer -* Added the hint SDL_HINT_ANDROID_TRAP_BACK_BUTTON to control whether the back button will back out of the app (the default) or be passed to the application as SDL_SCANCODE_AC_BACK -* Added SDL_AndroidBackButton() to trigger the Android system back button behavior when handling the back button in the application -* Added SDL_IsChromebook() to return whether the app is running in the Chromebook Android runtime -* Added SDL_IsDeXMode() to return whether the app is running while docked in the Samsung DeX - - ---------------------------------------------------------------------------- -2.0.8: ---------------------------------------------------------------------------- - -General: -* Added SDL_fmod() and SDL_log10() -* Each of the SDL math functions now has the corresponding float version -* Added SDL_SetYUVConversionMode() and SDL_GetYUVConversionMode() to control the formula used when converting to and from YUV colorspace. The options are JPEG, BT.601, and BT.709 - -Windows: -* Implemented WASAPI support on Windows UWP and removed the deprecated XAudio2 implementation -* Added resampling support on WASAPI on Windows 7 and above - -Windows UWP: -* Added SDL_WinRTGetDeviceFamily() to find out what type of device your application is running on - -Mac OS X: -* Added support for the Vulkan SDK for Mac: - https://www.lunarg.com/lunarg-releases-vulkan-sdk-1-0-69-0-for-mac/ -* Added support for OpenGL ES using ANGLE when it's available - -Mac OS X / iOS / tvOS: -* Added a Metal 2D render implementation -* Added SDL_RenderGetMetalLayer() and SDL_RenderGetMetalCommandEncoder() to insert your own drawing into SDL rendering when using the Metal implementation - -iOS: -* Added the hint SDL_HINT_IOS_HIDE_HOME_INDICATOR to control whether the home indicator bar on iPhone X should be hidden. This defaults to dimming the indicator for fullscreen applications and showing the indicator for windowed applications. - -iOS / Android: -* Added the hint SDL_HINT_RETURN_KEY_HIDES_IME to control whether the return key on the software keyboard should hide the keyboard or send a key event (the default) - -Android: -* SDL now supports building with Android Studio and Gradle by default, and the old Ant project is available in android-project-ant -* SDL now requires the API 19 SDK to build, but can still target devices down to API 14 (Android 4.0.1) -* Added SDL_IsAndroidTV() to tell whether the application is running on Android TV - -Android / tvOS: -* Added the hint SDL_HINT_TV_REMOTE_AS_JOYSTICK to control whether TV remotes should be listed as joystick devices (the default) or send keyboard events. - -Linux: -* Added the hint SDL_HINT_VIDEO_X11_NET_WM_BYPASS_COMPOSITOR to control whether the X server should skip the compositor for the SDL application. This defaults to "1" -* Added the hint SDL_HINT_VIDEO_DOUBLE_BUFFER to control whether the Raspberry Pi and KMSDRM video drivers should use double or triple buffering (the default) - - ---------------------------------------------------------------------------- -2.0.7: ---------------------------------------------------------------------------- - -General: -* Added audio stream conversion functions: - SDL_NewAudioStream - SDL_AudioStreamPut - SDL_AudioStreamGet - SDL_AudioStreamAvailable - SDL_AudioStreamFlush - SDL_AudioStreamClear - SDL_FreeAudioStream -* Added functions to query and set the SDL memory allocation functions: - SDL_GetMemoryFunctions() - SDL_SetMemoryFunctions() - SDL_GetNumAllocations() -* Added locking functions for multi-threaded access to the joystick and game controller APIs: - SDL_LockJoysticks() - SDL_UnlockJoysticks() -* The following functions are now thread-safe: - SDL_SetEventFilter() - SDL_GetEventFilter() - SDL_AddEventWatch() - SDL_DelEventWatch() - - -General: ---------------------------------------------------------------------------- -2.0.6: ---------------------------------------------------------------------------- - -General: -* Added cross-platform Vulkan graphics support in SDL_vulkan.h - SDL_Vulkan_LoadLibrary() - SDL_Vulkan_GetVkGetInstanceProcAddr() - SDL_Vulkan_GetInstanceExtensions() - SDL_Vulkan_CreateSurface() - SDL_Vulkan_GetDrawableSize() - SDL_Vulkan_UnloadLibrary() - This is all the platform-specific code you need to bring up Vulkan on all SDL platforms. You can look at an example in test/testvulkan.c -* Added SDL_ComposeCustomBlendMode() to create custom blend modes for 2D rendering -* Added SDL_HasNEON() which returns whether the CPU has NEON instruction support -* Added support for many game controllers, including the Nintendo Switch Pro Controller -* Added support for inverted axes and separate axis directions in game controller mappings -* Added functions to return information about a joystick before it's opened: - SDL_JoystickGetDeviceVendor() - SDL_JoystickGetDeviceProduct() - SDL_JoystickGetDeviceProductVersion() - SDL_JoystickGetDeviceType() - SDL_JoystickGetDeviceInstanceID() -* Added functions to return information about an open joystick: - SDL_JoystickGetVendor() - SDL_JoystickGetProduct() - SDL_JoystickGetProductVersion() - SDL_JoystickGetType() - SDL_JoystickGetAxisInitialState() -* Added functions to return information about an open game controller: - SDL_GameControllerGetVendor() - SDL_GameControllerGetProduct() - SDL_GameControllerGetProductVersion() -* Added SDL_GameControllerNumMappings() and SDL_GameControllerMappingForIndex() to be able to enumerate the built-in game controller mappings -* Added SDL_LoadFile() and SDL_LoadFile_RW() to load a file into memory -* Added SDL_DuplicateSurface() to make a copy of a surface -* Added an experimental JACK audio driver -* Implemented non-power-of-two audio resampling, optionally using libsamplerate to perform the resampling -* Added the hint SDL_HINT_AUDIO_RESAMPLING_MODE to control the quality of resampling -* Added the hint SDL_HINT_RENDER_LOGICAL_SIZE_MODE to control the scaling policy for SDL_RenderSetLogicalSize(): - "0" or "letterbox" - Uses letterbox/sidebars to fit the entire rendering on screen (the default) - "1" or "overscan" - Will zoom the rendering so it fills the entire screen, allowing edges to be drawn offscreen -* Added the hints SDL_HINT_MOUSE_NORMAL_SPEED_SCALE and SDL_HINT_MOUSE_RELATIVE_SPEED_SCALE to scale the mouse speed when being read from raw mouse input -* Added the hint SDL_HINT_TOUCH_MOUSE_EVENTS to control whether SDL will synthesize mouse events from touch events - -Windows: -* The new default audio driver on Windows is WASAPI and supports hot-plugging devices and changing the default audio device -* The old XAudio2 audio driver is deprecated and will be removed in the next release -* Added hints SDL_HINT_WINDOWS_INTRESOURCE_ICON and SDL_HINT_WINDOWS_INTRESOURCE_ICON_SMALL to specify a custom icon resource ID for SDL windows -* The hint SDL_HINT_WINDOWS_DISABLE_THREAD_NAMING is now on by default for compatibility with .NET languages and various Windows debuggers -* Updated the GUID format for game controller mappings, older mappings will be automatically converted on load -* Implemented the SDL_WINDOW_ALWAYS_ON_TOP flag on Windows - -Linux: -* Added an experimental KMS/DRM video driver for embedded development - -iOS: -* Added a hint SDL_HINT_AUDIO_CATEGORY to control the audio category, determining whether the phone mute switch affects the audio - ---------------------------------------------------------------------------- -2.0.5: ---------------------------------------------------------------------------- - -General: -* Implemented audio capture support for some platforms -* Added SDL_DequeueAudio() to retrieve audio when buffer queuing is turned on for audio capture -* Added events for dragging and dropping text -* Added events for dragging and dropping multiple items -* By default the click raising a window will not be delivered to the SDL application. You can set the hint SDL_HINT_MOUSE_FOCUS_CLICKTHROUGH to "1" to allow that click through to the window. -* Saving a surface with an alpha channel as a BMP will use a newer BMP format that supports alpha information. You can set the hint SDL_HINT_BMP_SAVE_LEGACY_FORMAT to "1" to use the old format. -* Added SDL_GetHintBoolean() to get the boolean value of a hint -* Added SDL_RenderSetIntegerScale() to set whether to smoothly scale or use integral multiples of the viewport size when scaling the rendering output -* Added SDL_CreateRGBSurfaceWithFormat() and SDL_CreateRGBSurfaceWithFormatFrom() to create an SDL surface with a specific pixel format -* Added SDL_GetDisplayUsableBounds() which returns the area usable for windows. For example, on Mac OS X, this subtracts the area occupied by the menu bar and dock. -* Added SDL_GetWindowBordersSize() which returns the size of the window's borders around the client area -* Added a window event SDL_WINDOWEVENT_HIT_TEST when a window had a hit test that wasn't SDL_HITTEST_NORMAL (e.g. in the title bar or window frame) -* Added SDL_SetWindowResizable() to change whether a window is resizable -* Added SDL_SetWindowOpacity() and SDL_GetWindowOpacity() to affect the window transparency -* Added SDL_SetWindowModalFor() to set a window as modal for another window -* Added support for AUDIO_U16LSB and AUDIO_U16MSB to SDL_MixAudioFormat() -* Fixed flipped images when reading back from target textures when using the OpenGL renderer -* Fixed texture color modulation with SDL_BLENDMODE_NONE when using the OpenGL renderer -* Fixed bug where the alpha value of colorkeys was ignored when blitting in some cases - -Windows: -* Added a hint SDL_HINT_WINDOWS_DISABLE_THREAD_NAMING to prevent SDL from raising a debugger exception to name threads. This exception can cause problems with .NET applications when running under a debugger. -* The hint SDL_HINT_THREAD_STACK_SIZE is now supported on Windows -* Fixed XBox controller triggers automatically being pulled at startup -* The first icon from the executable is used as the default window icon at runtime -* Fixed SDL log messages being printed twice if SDL was built with C library support -* Reset dead keys when the SDL window loses focus, so dead keys pressed in SDL applications don't affect text input into other applications. - -Mac OS X: -* Fixed selecting the dummy video driver -* The caps lock key now generates a pressed event when pressed and a released event when released, instead of a press/release event pair when pressed. -* Fixed mouse wheel events on Mac OS X 10.12 -* The audio driver has been updated to use AVFoundation for better compatibility with newer versions of Mac OS X - -Linux: -* Added support for the Fcitx IME -* Added a window event SDL_WINDOWEVENT_TAKE_FOCUS when a window manager asks the SDL window whether it wants to take focus. -* Refresh rates are now rounded instead of truncated, e.g. 59.94 Hz is rounded up to 60 Hz instead of 59. -* Added initial support for touchscreens on Raspberry Pi - -OpenBSD: -* SDL_GetBasePath() is now implemented on OpenBSD - -iOS: -* Added support for dynamically loaded objects on iOS 8 and newer - -tvOS: -* Added support for Apple TV -* Added a hint SDL_HINT_APPLE_TV_REMOTE_ALLOW_ROTATION to control whether he Apple TV remote's joystick axes will automatically match the rotation of the remote. - -Android: -* Fixed SDL not resizing window when Android screen resolution changes -* Corrected the joystick Z axis reporting for the accelerometer - -Emscripten (running in a web browser): -* Many bug fixes and improvements - - ---------------------------------------------------------------------------- -2.0.4: ---------------------------------------------------------------------------- - -General: -* Added support for web applications using Emscripten, see docs/README-emscripten.md for more information -* Added support for web applications using Native Client (NaCl), see docs/README-nacl.md for more information -* Added an API to queue audio instead of using the audio callback: - SDL_QueueAudio(), SDL_GetQueuedAudioSize(), SDL_ClearQueuedAudio() -* Added events for audio device hot plug support: - SDL_AUDIODEVICEADDED, SDL_AUDIODEVICEREMOVED -* Added SDL_PointInRect() -* Added SDL_HasAVX2() to detect CPUs with AVX2 support -* Added SDL_SetWindowHitTest() to let apps treat parts of their SDL window like traditional window decorations (drag areas, resize areas) -* Added SDL_GetGrabbedWindow() to get the window that currently has input grab, if any -* Added SDL_RenderIsClipEnabled() to tell whether clipping is currently enabled in a renderer -* Added SDL_CaptureMouse() to capture the mouse to get events while the mouse is not in your window -* Added SDL_WarpMouseGlobal() to warp the mouse cursor in global screen space -* Added SDL_GetGlobalMouseState() to get the current mouse state outside of an SDL window -* Added a direction field to mouse wheel events to tell whether they are flipped (natural) or not -* Added GL_CONTEXT_RELEASE_BEHAVIOR GL attribute (maps to [WGL|GLX]_ARB_context_flush_control extension) -* Added EGL_KHR_create_context support to allow OpenGL ES version selection on some platforms -* Added NV12 and NV21 YUV texture support for OpenGL and OpenGL ES 2.0 renderers -* Added a Vivante video driver that is used on various SoC platforms -* Added an event SDL_RENDER_DEVICE_RESET that is sent from the D3D renderers when the D3D device is lost, and from Android's event loop when the GLES context had to be recreated -* Added a hint SDL_HINT_NO_SIGNAL_HANDLERS to disable SDL's built in signal handling -* Added a hint SDL_HINT_THREAD_STACK_SIZE to set the stack size of SDL's threads -* Added SDL_sqrtf(), SDL_tan(), and SDL_tanf() to the stdlib routines -* Improved support for WAV and BMP files with unusual chunks in them -* Renamed SDL_assert_data to SDL_AssertData and SDL_assert_state to SDL_AssertState -* Added a hint SDL_HINT_WINDOW_FRAME_USABLE_WHILE_CURSOR_HIDDEN to prevent window interaction while cursor is hidden -* Added SDL_GetDisplayDPI() to get the DPI information for a display -* Added SDL_JoystickCurrentPowerLevel() to get the battery level of a joystick -* Added SDL_JoystickFromInstanceID(), as a helper function, to get the SDL_Joystick* that an event is referring to. -* Added SDL_GameControllerFromInstanceID(), as a helper function, to get the SDL_GameController* that an event is referring to. - -Windows: -* Added support for Windows Phone 8.1 and Windows 10/UWP (Universal Windows Platform) -* Timer resolution is now 1 ms by default, adjustable with the SDL_HINT_TIMER_RESOLUTION hint -* SDLmain no longer depends on the C runtime, so you can use the same .lib in both Debug and Release builds -* Added SDL_SetWindowsMessageHook() to set a function to be called for every windows message before TranslateMessage() -* Added a hint SDL_HINT_WINDOWS_ENABLE_MESSAGELOOP to control whether SDL_PumpEvents() processes the Windows message loop -* You can distinguish between real mouse and touch events by looking for SDL_TOUCH_MOUSEID in the mouse event "which" field -* SDL_SysWMinfo now contains the window HDC -* Added support for Unicode command line options -* Prevent beeping when Alt-key combos are pressed -* SDL_SetTextInputRect() re-positions the OS-rendered IME -* Added a hint SDL_HINT_WINDOWS_NO_CLOSE_ON_ALT_F4 to prevent generating SDL_WINDOWEVENT_CLOSE events when Alt-F4 is pressed -* Added a hint SDL_HINT_XINPUT_USE_OLD_JOYSTICK_MAPPING to use the old axis and button mapping for XInput devices (deprecated) - -Mac OS X: -* Implemented drag-and-drop support -* Improved joystick hot-plug detection -* The SDL_WINDOWEVENT_EXPOSED window event is triggered in the appropriate situations -* Fixed relative mouse mode when the application loses/regains focus -* Fixed bugs related to transitioning to and from Spaces-aware fullscreen-desktop mode -* Fixed the refresh rate of display modes -* SDL_SysWMInfo is now ARC-compatible -* Added a hint SDL_HINT_MAC_BACKGROUND_APP to prevent forcing the application to become a foreground process - -Linux: -* Enabled building with Mir and Wayland support by default. -* Added IBus IME support -* Added a hint SDL_HINT_IME_INTERNAL_EDITING to control whether IBus should handle text editing internally instead of sending SDL_TEXTEDITING events -* Added a hint SDL_HINT_VIDEO_X11_NET_WM_PING to allow disabling _NET_WM_PING protocol handling in SDL_CreateWindow() -* Added support for multiple audio devices when using Pulseaudio -* Fixed duplicate mouse events when using relative mouse motion - -iOS: -* Added support for iOS 8 -* The SDL_WINDOW_ALLOW_HIGHDPI window flag now enables high-dpi support, and SDL_GL_GetDrawableSize() or SDL_GetRendererOutputSize() gets the window resolution in pixels -* SDL_GetWindowSize() and display mode sizes are in the "DPI-independent points" / "screen coordinates" coordinate space rather than pixels (matches OS X behavior) -* Added native resolution support for the iPhone 6 Plus -* Added support for MFi game controllers -* Added support for the hint SDL_HINT_ACCELEROMETER_AS_JOYSTICK -* Added sRGB OpenGL ES context support on iOS 7+ -* Added support for SDL_DisableScreenSaver(), SDL_EnableScreenSaver() and the hint SDL_HINT_VIDEO_ALLOW_SCREENSAVER -* SDL_SysWMinfo now contains the OpenGL ES framebuffer and color renderbuffer objects used by the window's active GLES view -* Fixed various rotation and orientation issues -* Fixed memory leaks - -Android: -* Added a hint SDL_HINT_ANDROID_SEPARATE_MOUSE_AND_TOUCH to prevent mouse events from being registered as touch events -* Added hints SDL_HINT_ANDROID_APK_EXPANSION_MAIN_FILE_VERSION and SDL_HINT_ANDROID_APK_EXPANSION_PATCH_FILE_VERSION -* Added support for SDL_DisableScreenSaver(), SDL_EnableScreenSaver() and the hint SDL_HINT_VIDEO_ALLOW_SCREENSAVER -* Added support for SDL_ShowMessageBox() and SDL_ShowSimpleMessageBox() - -Raspberry Pi: -* Added support for the Raspberry Pi 2 - - ---------------------------------------------------------------------------- -2.0.3: ---------------------------------------------------------------------------- - -Mac OS X: -* Fixed creating an OpenGL context by default on Mac OS X 10.6 - - ---------------------------------------------------------------------------- -2.0.2: ---------------------------------------------------------------------------- -General: -* Added SDL_GL_ResetAttributes() to reset OpenGL attributes to default values -* Added an API to load a database of game controller mappings from a file: - SDL_GameControllerAddMappingsFromFile(), SDL_GameControllerAddMappingsFromRW() -* Added game controller mappings for the PS4 and OUYA controllers -* Added SDL_GetDefaultAssertionHandler() and SDL_GetAssertionHandler() -* Added SDL_DetachThread() -* Added SDL_HasAVX() to determine if the CPU has AVX features -* Added SDL_vsscanf(), SDL_acos(), and SDL_asin() to the stdlib routines -* EGL can now create/manage OpenGL and OpenGL ES 1.x/2.x contexts, and share - them using SDL_GL_SHARE_WITH_CURRENT_CONTEXT -* Added a field "clicks" to the mouse button event which records whether the event is a single click, double click, etc. -* The screensaver is now disabled by default, and there is a hint SDL_HINT_VIDEO_ALLOW_SCREENSAVER that can change that behavior. -* Added a hint SDL_HINT_MOUSE_RELATIVE_MODE_WARP to specify whether mouse relative mode should be emulated using mouse warping. -* testgl2 does not need to link with libGL anymore -* Added testgles2 test program to demonstrate working with OpenGL ES 2.0 -* Added controllermap test program to visually map a game controller - -Windows: -* Support for OpenGL ES 2.x contexts using either WGL or EGL (natively via - the driver or emulated through ANGLE) -* Added a hint SDL_HINT_VIDEO_WIN_D3DCOMPILER to specify which D3D shader compiler to use for OpenGL ES 2 support through ANGLE -* Added a hint SDL_HINT_VIDEO_WINDOW_SHARE_PIXEL_FORMAT that is useful when creating multiple windows that should share the same OpenGL context. -* Added an event SDL_RENDER_TARGETS_RESET that is sent when D3D9 render targets are reset after the device has been restored. - -Mac OS X: -* Added a hint SDL_HINT_MAC_CTRL_CLICK_EMULATE_RIGHT_CLICK to control whether Ctrl+click should be treated as a right click on Mac OS X. This is off by default. - -Linux: -* Fixed fullscreen and focused behavior when receiving NotifyGrab events -* Added experimental Wayland and Mir support, disabled by default - -Android: -* Joystick support (minimum SDK version required to build SDL is now 12, - the required runtime version remains at 10, but on such devices joystick - support won't be available). -* Hotplugging support for joysticks -* Added a hint SDL_HINT_ACCELEROMETER_AS_JOYSTICK to control whether the accelerometer should be listed as a 3 axis joystick, which it will by default. - - ---------------------------------------------------------------------------- -2.0.1: ---------------------------------------------------------------------------- - -General: -* Added an API to get common filesystem paths in SDL_filesystem.h: - SDL_GetBasePath(), SDL_GetPrefPath() -* Added an API to do optimized YV12 and IYUV texture updates: - SDL_UpdateYUVTexture() -* Added an API to get the amount of RAM on the system: - SDL_GetSystemRAM() -* Added a macro to perform timestamp comparisons with SDL_GetTicks(): - SDL_TICKS_PASSED() -* Dramatically improved OpenGL ES 2.0 rendering performance -* Added OpenGL attribute SDL_GL_FRAMEBUFFER_SRGB_CAPABLE - -Windows: -* Created a static library configuration for the Visual Studio 2010 project -* Added a hint to create the Direct3D device with support for multi-threading: - SDL_HINT_RENDER_DIRECT3D_THREADSAFE -* Added a function to get the D3D9 adapter index for a display: - SDL_Direct3D9GetAdapterIndex() -* Added a function to get the D3D9 device for a D3D9 renderer: - SDL_RenderGetD3D9Device() -* Fixed building SDL with the mingw32 toolchain (mingw-w64 is preferred) -* Fixed crash when using two XInput controllers at the same time -* Fixed detecting a mixture of XInput and DirectInput controllers -* Fixed clearing a D3D render target larger than the window -* Improved support for format specifiers in SDL_snprintf() - -Mac OS X: -* Added support for retina displays: - Create your window with the SDL_WINDOW_ALLOW_HIGHDPI flag, and then use SDL_GL_GetDrawableSize() to find the actual drawable size. You are responsible for scaling mouse and drawing coordinates appropriately. -* Fixed mouse warping in fullscreen mode -* Right mouse click is emulated by holding the Ctrl key while left clicking - -Linux: -* Fixed float audio support with the PulseAudio driver -* Fixed missing line endpoints in the OpenGL renderer on some drivers -* X11 symbols are no longer defined to avoid collisions when linking statically - -iOS: -* Fixed status bar visibility on iOS 7 -* Flipped the accelerometer Y axis to match expected values - -Android: -IMPORTANT: You MUST get the updated SDLActivity.java to match C code -* Moved EGL initialization to native code -* Fixed the accelerometer axis rotation relative to the device rotation -* Fixed race conditions when handling the EGL context on pause/resume -* Touch devices are available for enumeration immediately after init - -Raspberry Pi: -* Added support for the Raspberry Pi, see README-raspberrypi.txt for details +* SDL_GetWindowWMInfo() returns a standard int result code instead of SDL_bool, and takes SDL_SYSWM_CURRENT_VERSION as a new third parameter diff --git a/docs/README-migration.md b/docs/README-migration.md new file mode 100644 index 000000000..80fa0f605 --- /dev/null +++ b/docs/README-migration.md @@ -0,0 +1,24 @@ +# Migrating to SDL 3.0 + +This guide provides useful information for migrating applications from SDL 2.0 to SDL 3.0. + +We have provided a handy Python script to automate some of this work for you [link to script], and details on the changes are organized by SDL 2.0 header below. + +## SDL_syswm.h + +This header no longer includes platform specific headers and type definitions, instead allowing you to include the ones appropriate for your use case. You should define one or more of the following to enable the relevant platform-specific support: +* SDL_ENABLE_SYSWM_ANDROID +* SDL_ENABLE_SYSWM_COCOA +* SDL_ENABLE_SYSWM_KMSDRM +* SDL_ENABLE_SYSWM_UIKIT +* SDL_ENABLE_SYSWM_VIVANTE +* SDL_ENABLE_SYSWM_WAYLAND +* SDL_ENABLE_SYSWM_WINDOWS +* SDL_ENABLE_SYSWM_X11 + +The structures in this file are versioned separately from the rest of SDL, allowing better backwards compatibility and limited forwards compatibility with your application. Instead of calling `SDL_VERSION(&info.version)` before calling SDL_GetWindowWMInfo(), you pass the version in explicitly as `SDL_SYSWM_CURRENT_VERSION` so SDL knows what fields you expect to be filled out. + +### SDL_GetWindowWMInfo + +This function now returns a standard int result instead of SDL_bool, returning 0 if the function succeeds or a negative error code if there was an error. You should also pass `SDL_SYSWM_CURRENT_VERSION` as the new third version parameter. The version member of the info structure will be filled in with the version of data that is returned, the minimum of the version you requested and the version supported by the runtime SDL library. + diff --git a/include/SDL_syswm.h b/include/SDL_syswm.h index 16ff40892..6822ef983 100644 --- a/include/SDL_syswm.h +++ b/include/SDL_syswm.h @@ -40,86 +40,38 @@ * which contains window-manager specific information and arrives whenever * an unhandled window event occurs. This event is ignored by default, but * you can enable it with SDL_EventState(). + * + * As of SDL 3.0, this file no longer includes the platform specific headers + * and types. You should include the headers you need and define one or more + * of the following for the subsystems you're working with: + * + * SDL_ENABLE_SYSWM_ANDROID + * SDL_ENABLE_SYSWM_COCOA + * SDL_ENABLE_SYSWM_KMSDRM + * SDL_ENABLE_SYSWM_UIKIT + * SDL_ENABLE_SYSWM_VIVANTE + * SDL_ENABLE_SYSWM_WAYLAND + * SDL_ENABLE_SYSWM_WINDOWS + * SDL_ENABLE_SYSWM_WINRT + * SDL_ENABLE_SYSWM_X11 */ struct SDL_SysWMinfo; -#if !defined(SDL_PROTOTYPES_ONLY) - -#if defined(SDL_VIDEO_DRIVER_WINDOWS) -#ifndef WIN32_LEAN_AND_MEAN -#define WIN32_LEAN_AND_MEAN -#endif -#ifndef NOMINMAX /* don't define min() and max(). */ -#define NOMINMAX -#endif -#include -#endif - -#if defined(SDL_VIDEO_DRIVER_WINRT) -#include -#endif - -/* This is the structure for custom window manager events */ -#if defined(SDL_VIDEO_DRIVER_X11) -#if defined(__APPLE__) && defined(__MACH__) -/* conflicts with Quickdraw.h */ -#define Cursor X11Cursor -#endif - -#include -#include - -#if defined(__APPLE__) && defined(__MACH__) -/* matches the re-define above */ -#undef Cursor -#endif - -#endif /* defined(SDL_VIDEO_DRIVER_X11) */ - -#if defined(SDL_VIDEO_DRIVER_COCOA) -#ifdef __OBJC__ -@class NSWindow; -#else -typedef struct _NSWindow NSWindow; -#endif -#endif - -#if defined(SDL_VIDEO_DRIVER_UIKIT) -#ifdef __OBJC__ -#include -#else -typedef struct _UIWindow UIWindow; -typedef struct _UIViewController UIViewController; -#endif -typedef Uint32 GLuint; -#endif - -#if defined(SDL_VIDEO_VULKAN) || defined(SDL_VIDEO_METAL) -#define SDL_METALVIEW_TAG 255 -#endif - -#if defined(SDL_VIDEO_DRIVER_ANDROID) -typedef struct ANativeWindow ANativeWindow; -typedef void *EGLSurface; -#endif - -#if defined(SDL_VIDEO_DRIVER_VIVANTE) -#include "SDL_egl.h" -#endif - -#endif /* SDL_PROTOTYPES_ONLY */ - -#if defined(SDL_VIDEO_DRIVER_KMSDRM) -struct gbm_device; -#endif - - #include "begin_code.h" /* Set up for C function definitions, even when using C++ */ #ifdef __cplusplus extern "C" { #endif +/* This is the current version of structures in this file */ +#define SDL_SYSWM_CURRENT_VERSION 1 +#define SDL_SYSWM_INFO_SIZE_V1 (16 * (sizeof (void *) >= 8 ? sizeof (void *) : sizeof(Uint64))) +#define SDL_SYSWM_CURRENT_INFO_SIZE SDL_SYSWM_INFO_SIZE_V1 + +/* This is the tag associated with a Metal view so you can find it */ +#define SDL_METALVIEW_TAG 255 + + #if !defined(SDL_PROTOTYPES_ONLY) /** * These are the various supported windowing subsystems @@ -127,17 +79,17 @@ extern "C" { typedef enum { SDL_SYSWM_UNKNOWN, - SDL_SYSWM_WINDOWS, - SDL_SYSWM_X11, - SDL_SYSWM_COCOA, - SDL_SYSWM_UIKIT, - SDL_SYSWM_WAYLAND, - SDL_SYSWM_WINRT, SDL_SYSWM_ANDROID, - SDL_SYSWM_VIVANTE, + SDL_SYSWM_COCOA, SDL_SYSWM_HAIKU, SDL_SYSWM_KMSDRM, - SDL_SYSWM_RISCOS + SDL_SYSWM_RISCOS, + SDL_SYSWM_UIKIT, + SDL_SYSWM_VIVANTE, + SDL_SYSWM_WAYLAND, + SDL_SYSWM_WINDOWS, + SDL_SYSWM_WINRT, + SDL_SYSWM_X11 } SDL_SYSWM_TYPE; /** @@ -145,11 +97,14 @@ typedef enum */ struct SDL_SysWMmsg { - SDL_version version; - SDL_SYSWM_TYPE subsystem; + Uint32 version; + Uint32 subsystem; /**< SDL_SYSWM_TYPE */ + + Uint32 padding[(2 * (sizeof (void *) >= 8 ? sizeof (void *) : sizeof(Uint64)) - 2 * sizeof(Uint32)) / sizeof(Uint32)]; + union { -#if defined(SDL_VIDEO_DRIVER_WINDOWS) +#if defined(SDL_ENABLE_SYSWM_WINDOWS) struct { HWND hwnd; /**< The window for the message */ UINT msg; /**< The type of message */ @@ -157,34 +112,10 @@ struct SDL_SysWMmsg LPARAM lParam; /**< LONG message parameter */ } win; #endif -#if defined(SDL_VIDEO_DRIVER_X11) +#if defined(SDL_ENABLE_SYSWM_X11) struct { XEvent event; } x11; -#endif -#if defined(SDL_VIDEO_DRIVER_COCOA) - struct - { - /* Latest version of Xcode clang complains about empty structs in C v. C++: - error: empty struct has size 0 in C, size 1 in C++ - */ - int dummy; - /* No Cocoa window events yet */ - } cocoa; -#endif -#if defined(SDL_VIDEO_DRIVER_UIKIT) - struct - { - int dummy; - /* No UIKit window events yet */ - } uikit; -#endif -#if defined(SDL_VIDEO_DRIVER_VIVANTE) - struct - { - int dummy; - /* No Vivante window events yet */ - } vivante; #endif /* Can't have an empty union */ int dummy; @@ -199,11 +130,14 @@ struct SDL_SysWMmsg */ struct SDL_SysWMinfo { - SDL_version version; - SDL_SYSWM_TYPE subsystem; + Uint32 version; + Uint32 subsystem; /**< SDL_SYSWM_TYPE */ + + Uint32 padding[(2 * (sizeof (void *) >= 8 ? sizeof (void *) : sizeof(Uint64)) - 2 * sizeof(Uint32)) / sizeof(Uint32)]; + union { -#if defined(SDL_VIDEO_DRIVER_WINDOWS) +#if defined(SDL_ENABLE_SYSWM_WINDOWS) struct { HWND window; /**< The window handle */ @@ -211,20 +145,21 @@ struct SDL_SysWMinfo HINSTANCE hinstance; /**< The instance handle */ } win; #endif -#if defined(SDL_VIDEO_DRIVER_WINRT) +#if defined(SDL_ENABLE_SYSWM_WINRT) struct { IInspectable * window; /**< The WinRT CoreWindow */ } winrt; #endif -#if defined(SDL_VIDEO_DRIVER_X11) +#if defined(SDL_ENABLE_SYSWM_X11) struct { Display *display; /**< The X11 display */ + int screen; /**< The X11 screen */ Window window; /**< The X11 window */ } x11; #endif -#if defined(SDL_VIDEO_DRIVER_COCOA) +#if defined(SDL_ENABLE_SYSWM_COCOA) struct { #if defined(__OBJC__) && defined(__has_feature) @@ -238,7 +173,7 @@ struct SDL_SysWMinfo #endif } cocoa; #endif -#if defined(SDL_VIDEO_DRIVER_UIKIT) +#if defined(SDL_ENABLE_SYSWM_UIKIT) struct { #if defined(__OBJC__) && defined(__has_feature) @@ -255,12 +190,11 @@ struct SDL_SysWMinfo GLuint resolveFramebuffer; /**< The Framebuffer Object which holds the resolve color Renderbuffer, when MSAA is used. */ } uikit; #endif -#if defined(SDL_VIDEO_DRIVER_WAYLAND) +#if defined(SDL_ENABLE_SYSWM_WAYLAND) struct { struct wl_display *display; /**< Wayland display */ struct wl_surface *surface; /**< Wayland surface */ - void *shell_surface; /**< DEPRECATED Wayland shell_surface (window manager handle) */ struct wl_egl_window *egl_window; /**< Wayland EGL window (native window) */ struct xdg_surface *xdg_surface; /**< Wayland xdg surface (window manager handle) */ struct xdg_toplevel *xdg_toplevel; /**< Wayland xdg toplevel role */ @@ -269,7 +203,7 @@ struct SDL_SysWMinfo } wl; #endif -#if defined(SDL_VIDEO_DRIVER_ANDROID) +#if defined(SDL_ENABLE_SYSWM_ANDROID) struct { ANativeWindow *window; @@ -277,7 +211,7 @@ struct SDL_SysWMinfo } android; #endif -#if defined(SDL_VIDEO_DRIVER_VIVANTE) +#if defined(SDL_ENABLE_SYSWM_VIVANTE) struct { EGLNativeDisplayType display; @@ -285,7 +219,7 @@ struct SDL_SysWMinfo } vivante; #endif -#if defined(SDL_VIDEO_DRIVER_KMSDRM) +#if defined(SDL_ENABLE_SYSWM_KMSDRM) struct { int dev_index; /**< Device index (ex: the X in /dev/dri/cardX) */ @@ -294,11 +228,12 @@ struct SDL_SysWMinfo } kmsdrm; #endif - /* Make sure this union is always 64 bytes (8 64-bit pointers). */ - /* Be careful not to overflow this if you add a new target! */ - Uint8 dummy[64]; + /* Make sure this union has enough room for 14 pointers */ + void *dummy_ptrs[14]; + Uint64 dummy_ints[14]; } info; }; +SDL_COMPILE_TIME_ASSERT(SDL_SysWMinfo_size, sizeof(struct SDL_SysWMinfo) == SDL_SYSWM_CURRENT_INFO_SIZE); #endif /* SDL_PROTOTYPES_ONLY */ @@ -310,20 +245,15 @@ typedef struct SDL_SysWMinfo SDL_SysWMinfo; * * You must include SDL_syswm.h for the declaration of SDL_SysWMinfo. * - * The caller must initialize the `info` structure's version by using - * `SDL_VERSION(&info.version)`, and then this function will fill in the rest - * of the structure with information about the given window. - * * \param window the window about which information is being requested * \param info an SDL_SysWMinfo structure filled in with window information - * \returns SDL_TRUE if the function is implemented and the `version` member - * of the `info` struct is valid, or SDL_FALSE if the information - * could not be retrieved; call SDL_GetError() for more information. + * \param version the version of info being requested, should be SDL_SYSWM_CURRENT_VERSION + * \returns 0 on success or a negative error code on failure; call + * SDL_GetError() for more information. * * \since This function is available since SDL 3.0.0. */ -extern DECLSPEC SDL_bool SDLCALL SDL_GetWindowWMInfo(SDL_Window * window, - SDL_SysWMinfo * info); +extern DECLSPEC int SDLCALL SDL_GetWindowWMInfo(SDL_Window *window, SDL_SysWMinfo *info, Uint32 version); /* Ends C function definitions when using C++ */ diff --git a/src/core/linux/SDL_fcitx.c b/src/core/linux/SDL_fcitx.c index f653279d7..b19bcff8b 100644 --- a/src/core/linux/SDL_fcitx.c +++ b/src/core/linux/SDL_fcitx.c @@ -23,15 +23,18 @@ #include #include "SDL_fcitx.h" +#include "SDL_hints.h" #include "SDL_keycode.h" #include "SDL_keyboard.h" #include "../../events/SDL_keyboard_c.h" #include "SDL_dbus.h" -#include "SDL_syswm.h" -#if SDL_VIDEO_DRIVER_X11 -# include "../../video/x11/SDL_x11video.h" + +#ifdef SDL_VIDEO_DRIVER_X11 +#include "../../video/x11/SDL_x11video.h" +#define SDL_ENABLE_SYSWM_X11 #endif -#include "SDL_hints.h" +#include "SDL_syswm.h" + #define FCITX_DBUS_SERVICE "org.freedesktop.portal.Fcitx" @@ -440,24 +443,19 @@ SDL_Fcitx_UpdateTextRect(const SDL_Rect *rect) return ; } - SDL_VERSION(&info.version); - if (!SDL_GetWindowWMInfo(focused_win, &info)) { - return; - } - SDL_GetWindowPosition(focused_win, &x, &y); -#if SDL_VIDEO_DRIVER_X11 - if (info.subsystem == SDL_SYSWM_X11) { - SDL_DisplayData *displaydata = (SDL_DisplayData *) SDL_GetDisplayForWindow(focused_win)->driverdata; - - Display *x_disp = info.info.x11.display; - Window x_win = info.info.x11.window; - int x_screen = displaydata->screen; - Window unused; - X11_XTranslateCoordinates(x_disp, x_win, RootWindow(x_disp, x_screen), 0, 0, &x, &y, &unused); - } + if (SDL_GetWindowWMInfo(focused_win, &info, SDL_SYSWM_CURRENT_VERSION) == 0) { +#ifdef SDL_ENABLE_SYSWM_X11 + if (info.subsystem == SDL_SYSWM_X11) { + Display *x_disp = info.info.x11.display; + int x_screen = info.info.x11.screen; + Window x_win = info.info.x11.window; + Window unused; + X11_XTranslateCoordinates(x_disp, x_win, RootWindow(x_disp, x_screen), 0, 0, &x, &y, &unused); + } #endif + } if (cursor->x == -1 && cursor->y == -1 && cursor->w == 0 && cursor->h == 0) { /* move to bottom left */ diff --git a/src/core/linux/SDL_ibus.c b/src/core/linux/SDL_ibus.c index 1478de880..50472c5c5 100644 --- a/src/core/linux/SDL_ibus.c +++ b/src/core/linux/SDL_ibus.c @@ -23,15 +23,16 @@ #ifdef HAVE_IBUS_IBUS_H #include "SDL.h" #include "SDL_hints.h" -#include "SDL_syswm.h" #include "SDL_ibus.h" #include "SDL_dbus.h" #include "../../video/SDL_sysvideo.h" #include "../../events/SDL_keyboard_c.h" -#if SDL_VIDEO_DRIVER_X11 - #include "../../video/x11/SDL_x11video.h" +#ifdef SDL_VIDEO_DRIVER_X11 +#include "../../video/x11/SDL_x11video.h" +#define SDL_ENABLE_SYSWM_X11 #endif +#include "SDL_syswm.h" #include #include @@ -704,25 +705,20 @@ SDL_IBus_UpdateTextRect(const SDL_Rect *rect) return; } - SDL_VERSION(&info.version); - if (!SDL_GetWindowWMInfo(focused_win, &info)) { - return; - } - SDL_GetWindowPosition(focused_win, &x, &y); - -#if SDL_VIDEO_DRIVER_X11 - if (info.subsystem == SDL_SYSWM_X11) { - SDL_DisplayData *displaydata = (SDL_DisplayData *) SDL_GetDisplayForWindow(focused_win)->driverdata; - - Display *x_disp = info.info.x11.display; - Window x_win = info.info.x11.window; - int x_screen = displaydata->screen; - Window unused; - - X11_XTranslateCoordinates(x_disp, x_win, RootWindow(x_disp, x_screen), 0, 0, &x, &y, &unused); - } + + if (SDL_GetWindowWMInfo(focused_win, &info, SDL_SYSWM_CURRENT_VERSION) == 0) { +#ifdef SDL_ENABLE_SYSWM_X11 + if (info.subsystem == SDL_SYSWM_X11) { + Display *x_disp = info.info.x11.display; + int x_screen = info.info.x11.screen; + Window x_win = info.info.x11.window; + Window unused; + + X11_XTranslateCoordinates(x_disp, x_win, RootWindow(x_disp, x_screen), 0, 0, &x, &y, &unused); + } #endif + } x += ibus_cursor_rect.x; y += ibus_cursor_rect.y; diff --git a/src/dynapi/SDL_dynapi_overrides.h b/src/dynapi/SDL_dynapi_overrides.h index 5045690c0..a242e3709 100644 --- a/src/dynapi/SDL_dynapi_overrides.h +++ b/src/dynapi/SDL_dynapi_overrides.h @@ -468,7 +468,6 @@ #define SDL_SoftStretch SDL_SoftStretch_REAL #define SDL_UpperBlitScaled SDL_UpperBlitScaled_REAL #define SDL_LowerBlitScaled SDL_LowerBlitScaled_REAL -#define SDL_GetWindowWMInfo SDL_GetWindowWMInfo_REAL #define SDL_GetThreadName SDL_GetThreadName_REAL #define SDL_ThreadID SDL_ThreadID_REAL #define SDL_GetThreadID SDL_GetThreadID_REAL diff --git a/src/dynapi/SDL_dynapi_procs.h b/src/dynapi/SDL_dynapi_procs.h index 5145de971..22fc64e97 100644 --- a/src/dynapi/SDL_dynapi_procs.h +++ b/src/dynapi/SDL_dynapi_procs.h @@ -500,7 +500,6 @@ SDL_DYNAPI_PROC(int,SDL_LowerBlit,(SDL_Surface *a, SDL_Rect *b, SDL_Surface *c, SDL_DYNAPI_PROC(int,SDL_SoftStretch,(SDL_Surface *a, const SDL_Rect *b, SDL_Surface *c, const SDL_Rect *d),(a,b,c,d),return) SDL_DYNAPI_PROC(int,SDL_UpperBlitScaled,(SDL_Surface *a, const SDL_Rect *b, SDL_Surface *c, SDL_Rect *d),(a,b,c,d),return) SDL_DYNAPI_PROC(int,SDL_LowerBlitScaled,(SDL_Surface *a, SDL_Rect *b, SDL_Surface *c, SDL_Rect *d),(a,b,c,d),return) -SDL_DYNAPI_PROC(SDL_bool,SDL_GetWindowWMInfo,(SDL_Window *a, SDL_SysWMinfo *b),(a,b),return) SDL_DYNAPI_PROC(const char*,SDL_GetThreadName,(SDL_Thread *a),(a),return) SDL_DYNAPI_PROC(SDL_threadID,SDL_ThreadID,(void),(),return) SDL_DYNAPI_PROC(SDL_threadID,SDL_GetThreadID,(SDL_Thread *a),(a),return) diff --git a/src/render/direct3d/SDL_render_d3d.c b/src/render/direct3d/SDL_render_d3d.c index e68e4d86e..95fb971b7 100644 --- a/src/render/direct3d/SDL_render_d3d.c +++ b/src/render/direct3d/SDL_render_d3d.c @@ -29,11 +29,13 @@ #include "SDL_hints.h" #include "SDL_loadso.h" -#include "SDL_syswm.h" #include "../SDL_sysrender.h" #include "../SDL_d3dmath.h" #include "../../video/windows/SDL_windowsvideo.h" +#define SDL_ENABLE_SYSWM_WINDOWS +#include "SDL_syswm.h" + #if SDL_VIDEO_RENDER_D3D #define D3D_DEBUG_INFO #include @@ -1596,6 +1598,12 @@ D3D_CreateRenderer(SDL_Window * window, Uint32 flags) SDL_DisplayMode fullscreen_mode; int displayIndex; + if (SDL_GetWindowWMInfo(window, &windowinfo, SDL_SYSWM_CURRENT_VERSION) < 0 || + windowinfo.subsystem != SDL_SYSWM_WINDOWS) { + SDL_SetError("Couldn't get window handle"); + return NULL; + } + renderer = (SDL_Renderer *) SDL_calloc(1, sizeof(*renderer)); if (!renderer) { SDL_OutOfMemory(); @@ -1643,9 +1651,6 @@ D3D_CreateRenderer(SDL_Window * window, Uint32 flags) renderer->info.flags = (SDL_RENDERER_ACCELERATED | SDL_RENDERER_TARGETTEXTURE); renderer->driverdata = data; - SDL_VERSION(&windowinfo.version); - SDL_GetWindowWMInfo(window, &windowinfo); - window_flags = SDL_GetWindowFlags(window); SDL_GetWindowSizeInPixels(window, &w, &h); SDL_GetWindowDisplayMode(window, &fullscreen_mode); diff --git a/src/render/direct3d11/SDL_render_d3d11.c b/src/render/direct3d11/SDL_render_d3d11.c index 8369e54f6..ffba1f561 100644 --- a/src/render/direct3d11/SDL_render_d3d11.c +++ b/src/render/direct3d11/SDL_render_d3d11.c @@ -32,10 +32,12 @@ #endif #include "SDL_hints.h" #include "SDL_loadso.h" -#include "SDL_syswm.h" #include "../SDL_sysrender.h" #include "../SDL_d3dmath.h" +#define SDL_ENABLE_SYSWM_WINDOWS +#include "SDL_syswm.h" + #include #include "SDL_shaders_d3d11.h" @@ -829,8 +831,13 @@ D3D11_CreateSwapChain(SDL_Renderer * renderer, int w, int h) } else { #if defined(__WIN32__) || defined(__WINGDK__) SDL_SysWMinfo windowinfo; - SDL_VERSION(&windowinfo.version); - SDL_GetWindowWMInfo(renderer->window, &windowinfo); + + if (SDL_GetWindowWMInfo(renderer->window, &windowinfo, SDL_SYSWM_CURRENT_VERSION) < 0 || + windowinfo.subsystem != SDL_SYSWM_WINDOWS) { + SDL_SetError("Couldn't get window handle"); + result = E_FAIL; + goto done; + } result = IDXGIFactory2_CreateSwapChainForHwnd(data->dxgiFactory, (IUnknown *)data->d3dDevice, diff --git a/src/render/direct3d11/SDL_render_winrt.cpp b/src/render/direct3d11/SDL_render_winrt.cpp index 9784c32c4..f2fb1db14 100644 --- a/src/render/direct3d11/SDL_render_winrt.cpp +++ b/src/render/direct3d11/SDL_render_winrt.cpp @@ -22,7 +22,6 @@ #if SDL_VIDEO_RENDER_D3D11 && !SDL_RENDER_DISABLED -#include "SDL_syswm.h" #include "../../video/winrt/SDL_winrtvideo_cpp.h" extern "C" { #include "../SDL_sysrender.h" @@ -40,6 +39,9 @@ using namespace Windows::Graphics::Display; #include +#define SDL_ENABLE_SYSWM_WINRT +#include "SDL_syswm.h" + #include "SDL_render_winrt.h" @@ -52,8 +54,9 @@ D3D11_GetCoreWindowFromSDLRenderer(SDL_Renderer * renderer) } SDL_SysWMinfo sdlWindowInfo; - SDL_VERSION(&sdlWindowInfo.version); - if ( ! SDL_GetWindowWMInfo(sdlWindow, &sdlWindowInfo) ) { + if (SDL_GetWindowWMInfo(sdlWindow, &sdlWindowInfo, SDL_SYSWM_CURRENT_VERSION) < 0 || + sdlWindowInfo.subsystem != SDL_SYSWM_WINRT) { + SDL_SetError("Couldn't get window handle"); return NULL; } diff --git a/src/render/direct3d12/SDL_render_d3d12.c b/src/render/direct3d12/SDL_render_d3d12.c index 79cf30ef0..ba8c3e9e5 100644 --- a/src/render/direct3d12/SDL_render_d3d12.c +++ b/src/render/direct3d12/SDL_render_d3d12.c @@ -34,10 +34,12 @@ #include "../../video/windows/SDL_windowswindow.h" #include "SDL_hints.h" #include "SDL_loadso.h" -#include "SDL_syswm.h" #include "../SDL_sysrender.h" #include "../SDL_d3dmath.h" +#define SDL_ENABLE_SYSWM_WINDOWS +#include "SDL_syswm.h" + #if defined(__XBOXONE__) || defined(__XBOXSERIES__) #include "SDL_render_d3d12_xbox.h" #ifndef D3D12_TEXTURE_DATA_PITCH_ALIGNMENT @@ -1175,7 +1177,7 @@ static HRESULT D3D12_CreateSwapChain(SDL_Renderer * renderer, int w, int h) { D3D12_RenderData *data = (D3D12_RenderData *)renderer->driverdata; - IDXGISwapChain1* swapChain; + IDXGISwapChain1* swapChain = NULL; HRESULT result = S_OK; SDL_SysWMinfo windowinfo; @@ -1199,8 +1201,12 @@ D3D12_CreateSwapChain(SDL_Renderer * renderer, int w, int h) swapChainDesc.Flags = DXGI_SWAP_CHAIN_FLAG_FRAME_LATENCY_WAITABLE_OBJECT | /* To support SetMaximumFrameLatency */ DXGI_SWAP_CHAIN_FLAG_ALLOW_TEARING; /* To support presenting with allow tearing on */ - SDL_VERSION(&windowinfo.version); - SDL_GetWindowWMInfo(renderer->window, &windowinfo); + if (SDL_GetWindowWMInfo(renderer->window, &windowinfo, SDL_SYSWM_CURRENT_VERSION) < 0 || + windowinfo.subsystem != SDL_SYSWM_WINDOWS) { + SDL_SetError("Couldn't get window handle"); + result = E_FAIL; + goto done; + } result = D3D_CALL(data->dxgiFactory, CreateSwapChainForHwnd, (IUnknown *)data->commandQueue, diff --git a/src/render/metal/SDL_render_metal.m b/src/render/metal/SDL_render_metal.m index 80fd96f07..50cb8bad9 100644 --- a/src/render/metal/SDL_render_metal.m +++ b/src/render/metal/SDL_render_metal.m @@ -23,7 +23,6 @@ #if SDL_VIDEO_RENDER_METAL && !SDL_RENDER_DISABLED #include "SDL_hints.h" -#include "SDL_syswm.h" #include "SDL_metal.h" #include "../SDL_sysrender.h" @@ -31,10 +30,16 @@ #import #import -#ifdef __MACOSX__ +#ifdef SDL_VIDEO_DRIVER_COCOA #import #import +#define SDL_ENABLE_SYSWM_COCOA #endif +#ifdef SDL_VIDEO_DRIVER_UIKIT +#import +#define SDL_ENABLE_SYSWM_UIKIT +#endif +#include "SDL_syswm.h" /* Regenerate these with build-metal-shaders.sh */ #ifdef __MACOSX__ @@ -1599,9 +1604,8 @@ static SDL_MetalView GetWindowView(SDL_Window *window) { SDL_SysWMinfo info; - SDL_VERSION(&info.version); - if (SDL_GetWindowWMInfo(window, &info)) { -#ifdef __MACOSX__ + if (SDL_GetWindowWMInfo(window, &info, SDL_SYSWM_CURRENT_VERSION) == 0) { +#ifdef SDL_ENABLE_SYSWM_COCOA if (info.subsystem == SDL_SYSWM_COCOA) { NSView *view = info.info.cocoa.window.contentView; if (view.subviews.count > 0) { @@ -1611,7 +1615,8 @@ static SDL_MetalView GetWindowView(SDL_Window *window) } } } -#else +#endif +#ifdef SDL_ENABLE_SYSWM_UIKIT if (info.subsystem == SDL_SYSWM_UIKIT) { UIView *view = info.info.uikit.window.rootViewController.view; if (view.tag == SDL_METALVIEW_TAG) { @@ -1683,8 +1688,7 @@ METAL_CreateRenderer(SDL_Window * window, Uint32 flags) 1.0000, 1.7720, 0.0000, 0.0, /* Bcoeff */ }; - SDL_VERSION(&syswm.version); - if (!SDL_GetWindowWMInfo(window, &syswm)) { + if (SDL_GetWindowWMInfo(window, &syswm, SDL_SYSWM_CURRENT_VERSION) < 0) { return NULL; } diff --git a/src/video/SDL_sysvideo.h b/src/video/SDL_sysvideo.h index b0ac1efb5..54a4d6c9c 100644 --- a/src/video/SDL_sysvideo.h +++ b/src/video/SDL_sysvideo.h @@ -262,8 +262,7 @@ struct SDL_VideoDevice SDL_ShapeDriver shape_driver; /* Get some platform dependent window information */ - SDL_bool(*GetWindowWMInfo) (_THIS, SDL_Window * window, - struct SDL_SysWMinfo * info); + int (*GetWindowWMInfo) (_THIS, SDL_Window *window, struct SDL_SysWMinfo *info); /* * * */ /* diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c index 36f0cc13f..6b8fe67e2 100644 --- a/src/video/SDL_video.c +++ b/src/video/SDL_video.c @@ -4416,22 +4416,32 @@ SDL_WM_SetIcon(SDL_Surface * icon, Uint8 * mask) } #endif -SDL_bool -SDL_GetWindowWMInfo(SDL_Window * window, struct SDL_SysWMinfo *info) +int +SDL_GetWindowWMInfo(SDL_Window *window, struct SDL_SysWMinfo *info, Uint32 version) { - CHECK_WINDOW_MAGIC(window, SDL_FALSE); + CHECK_WINDOW_MAGIC(window, -1); if (!info) { - SDL_InvalidParamError("info"); - return SDL_FALSE; + return SDL_InvalidParamError("info"); } - info->subsystem = SDL_SYSWM_UNKNOWN; - if (!_this->GetWindowWMInfo) { - SDL_Unsupported(); - return SDL_FALSE; + /* Set the version in the structure to the minimum of our version and the application expected version */ + version = SDL_min(version, SDL_SYSWM_CURRENT_VERSION); + + if (version == 1) { + SDL_memset(info, 0, SDL_SYSWM_INFO_SIZE_V1); + } else { + return SDL_SetError("Unknown info version"); + } + + info->subsystem = SDL_SYSWM_UNKNOWN; + info->version = version; + + if (_this->GetWindowWMInfo) { + return (_this->GetWindowWMInfo(_this, window, info)); + } else { + return 0; } - return (_this->GetWindowWMInfo(_this, window, info)); } void @@ -4569,12 +4579,7 @@ static SDL_bool SDL_MessageboxValidForDriver(const SDL_MessageBoxData *messagebo SDL_SysWMinfo info; SDL_Window *window = messageboxdata->window; - if (!window) { - return SDL_TRUE; - } - - SDL_VERSION(&info.version); - if (!SDL_GetWindowWMInfo(window, &info)) { + if (!window || SDL_GetWindowWMInfo(window, &info, SDL_SYSWM_CURRENT_VERSION) < 0) { return SDL_TRUE; } else { return (info.subsystem == drivertype); diff --git a/src/video/android/SDL_androidvulkan.c b/src/video/android/SDL_androidvulkan.c index 058165f57..fdedd430e 100644 --- a/src/video/android/SDL_androidvulkan.c +++ b/src/video/android/SDL_androidvulkan.c @@ -33,6 +33,8 @@ #include "SDL_loadso.h" #include "SDL_androidvulkan.h" + +#define SDL_ENABLE_SYSWM_ANDROID #include "SDL_syswm.h" int Android_Vulkan_LoadLibrary(_THIS, const char *path) diff --git a/src/video/android/SDL_androidwindow.c b/src/video/android/SDL_androidwindow.c index 21bedca7d..a36a62514 100644 --- a/src/video/android/SDL_androidwindow.c +++ b/src/video/android/SDL_androidwindow.c @@ -22,7 +22,6 @@ #if SDL_VIDEO_DRIVER_ANDROID -#include "SDL_syswm.h" #include "../SDL_sysvideo.h" #include "../../events/SDL_keyboard_c.h" #include "../../events/SDL_mouse_c.h" @@ -33,6 +32,9 @@ #include "SDL_androidwindow.h" #include "SDL_hints.h" +#define SDL_ENABLE_SYSWM_ANDROID +#include "SDL_syswm.h" + /* Currently only one window */ SDL_Window *Android_Window = NULL; @@ -202,25 +204,19 @@ Android_DestroyWindow(_THIS, SDL_Window *window) SDL_UnlockMutex(Android_ActivityMutex); } -SDL_bool +int Android_GetWindowWMInfo(_THIS, SDL_Window *window, SDL_SysWMinfo *info) { SDL_WindowData *data = (SDL_WindowData *) window->driverdata; - if (info->version.major == SDL_MAJOR_VERSION) { - info->subsystem = SDL_SYSWM_ANDROID; - info->info.android.window = data->native_window; + info->subsystem = SDL_SYSWM_ANDROID; + info->info.android.window = data->native_window; #if SDL_VIDEO_OPENGL_EGL - info->info.android.surface = data->egl_surface; + info->info.android.surface = data->egl_surface; #endif - return SDL_TRUE; - } else { - SDL_SetError("Application not compiled with SDL %d", - SDL_MAJOR_VERSION); - return SDL_FALSE; - } + return 0; } #endif /* SDL_VIDEO_DRIVER_ANDROID */ diff --git a/src/video/android/SDL_androidwindow.h b/src/video/android/SDL_androidwindow.h index 58e459006..bf76b1e35 100644 --- a/src/video/android/SDL_androidwindow.h +++ b/src/video/android/SDL_androidwindow.h @@ -33,7 +33,7 @@ extern void Android_MinimizeWindow(_THIS, SDL_Window *window); extern void Android_SetWindowResizable(_THIS, SDL_Window *window, SDL_bool resizable); extern void Android_DestroyWindow(_THIS, SDL_Window *window); -extern SDL_bool 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; typedef struct diff --git a/src/video/cocoa/SDL_cocoametalview.m b/src/video/cocoa/SDL_cocoametalview.m index 289848561..67b73708f 100644 --- a/src/video/cocoa/SDL_cocoametalview.m +++ b/src/video/cocoa/SDL_cocoametalview.m @@ -31,6 +31,8 @@ #if SDL_VIDEO_DRIVER_COCOA && (SDL_VIDEO_VULKAN || SDL_VIDEO_METAL) #include "SDL_events.h" + +#define SDL_ENABLE_SYSWM_COCOA #include "SDL_syswm.h" diff --git a/src/video/cocoa/SDL_cocoavulkan.m b/src/video/cocoa/SDL_cocoavulkan.m index 73fef7284..05a2eb1e1 100644 --- a/src/video/cocoa/SDL_cocoavulkan.m +++ b/src/video/cocoa/SDL_cocoavulkan.m @@ -33,6 +33,8 @@ #include "SDL_loadso.h" #include "SDL_cocoametalview.h" #include "SDL_cocoavulkan.h" + +#define SDL_ENABLE_SYSWM_COCOA #include "SDL_syswm.h" #include diff --git a/src/video/cocoa/SDL_cocoawindow.h b/src/video/cocoa/SDL_cocoawindow.h index 18f7d8587..8a80e765c 100644 --- a/src/video/cocoa/SDL_cocoawindow.h +++ b/src/video/cocoa/SDL_cocoawindow.h @@ -165,7 +165,7 @@ extern int Cocoa_GetWindowGammaRamp(_THIS, SDL_Window * window, Uint16 * ramp); extern void Cocoa_SetWindowMouseRect(_THIS, SDL_Window * window); extern void Cocoa_SetWindowMouseGrab(_THIS, SDL_Window * window, SDL_bool grabbed); extern void Cocoa_DestroyWindow(_THIS, SDL_Window * window); -extern SDL_bool Cocoa_GetWindowWMInfo(_THIS, SDL_Window * window, struct SDL_SysWMinfo *info); +extern int Cocoa_GetWindowWMInfo(_THIS, SDL_Window *window, struct SDL_SysWMinfo *info); extern int Cocoa_SetWindowHitTest(SDL_Window *window, SDL_bool enabled); extern void Cocoa_AcceptDragAndDrop(SDL_Window * window, SDL_bool accept); extern int Cocoa_FlashWindow(_THIS, SDL_Window * window, SDL_FlashOperation operation); diff --git a/src/video/cocoa/SDL_cocoawindow.m b/src/video/cocoa/SDL_cocoawindow.m index 6bd3ad1ce..e8e27b54a 100644 --- a/src/video/cocoa/SDL_cocoawindow.m +++ b/src/video/cocoa/SDL_cocoawindow.m @@ -26,7 +26,6 @@ # error SDL for Mac OS X must be built with a 10.7 SDK or above. #endif /* MAC_OS_X_VERSION_MAX_ALLOWED < 1070 */ -#include "SDL_syswm.h" #include "SDL_timer.h" /* For SDL_GetTicks() */ #include "SDL_hints.h" #include "../SDL_sysvideo.h" @@ -35,12 +34,16 @@ #include "../../events/SDL_touch_c.h" #include "../../events/SDL_windowevents_c.h" #include "../../events/SDL_dropevents_c.h" + #include "SDL_cocoavideo.h" #include "SDL_cocoashape.h" #include "SDL_cocoamouse.h" #include "SDL_cocoaopengl.h" #include "SDL_cocoaopengles.h" +#define SDL_ENABLE_SYSWM_COCOA +#include "SDL_syswm.h" + /* #define DEBUG_COCOAWINDOW */ #ifdef DEBUG_COCOAWINDOW @@ -2401,21 +2404,15 @@ Cocoa_DestroyWindow(_THIS, SDL_Window * window) window->driverdata = NULL; }} -SDL_bool -Cocoa_GetWindowWMInfo(_THIS, SDL_Window * window, SDL_SysWMinfo * info) +int +Cocoa_GetWindowWMInfo(_THIS, SDL_Window *window, SDL_SysWMinfo *info) { @autoreleasepool { NSWindow *nswindow = ((__bridge SDL_WindowData *) window->driverdata).nswindow; - if (info->version.major <= SDL_MAJOR_VERSION) { - info->subsystem = SDL_SYSWM_COCOA; - info->info.cocoa.window = nswindow; - return SDL_TRUE; - } else { - SDL_SetError("Application not compiled with SDL %d", - SDL_MAJOR_VERSION); - return SDL_FALSE; - } + info->subsystem = SDL_SYSWM_COCOA; + info->info.cocoa.window = nswindow; + return 0; }} SDL_bool diff --git a/src/video/haiku/SDL_BWin.h b/src/video/haiku/SDL_BWin.h index 1ac517164..3c4b12f4b 100644 --- a/src/video/haiku/SDL_BWin.h +++ b/src/video/haiku/SDL_BWin.h @@ -28,9 +28,10 @@ extern "C" { #include "../../SDL_internal.h" #include "SDL.h" -#include "SDL_syswm.h" #include "SDL_bframebuffer.h" +#include "SDL_syswm.h" + #ifdef __cplusplus } #endif diff --git a/src/video/haiku/SDL_bwindow.cc b/src/video/haiku/SDL_bwindow.cc index 24625337d..090259d85 100644 --- a/src/video/haiku/SDL_bwindow.cc +++ b/src/video/haiku/SDL_bwindow.cc @@ -223,22 +223,12 @@ void HAIKU_DestroyWindow(_THIS, SDL_Window * window) { window->driverdata = NULL; } -SDL_bool HAIKU_GetWindowWMInfo(_THIS, SDL_Window * window, - struct SDL_SysWMinfo *info) { - /* FIXME: What is the point of this? What information should be included? */ - if (info->version.major == SDL_MAJOR_VERSION) { - info->subsystem = SDL_SYSWM_HAIKU; - return SDL_TRUE; - } else { - SDL_SetError("Application not compiled with SDL %d", - SDL_MAJOR_VERSION); - return SDL_FALSE; - } +int HAIKU_GetWindowWMInfo(_THIS, SDL_Window *window, struct SDL_SysWMinfo *info) +{ + info->subsystem = SDL_SYSWM_HAIKU; + return 0; } - - - #ifdef __cplusplus } diff --git a/src/video/haiku/SDL_bwindow.h b/src/video/haiku/SDL_bwindow.h index 58a85d872..6cbf1dafd 100644 --- a/src/video/haiku/SDL_bwindow.h +++ b/src/video/haiku/SDL_bwindow.h @@ -46,8 +46,7 @@ extern int HAIKU_SetWindowGammaRamp(_THIS, SDL_Window * window, const Uint16 * r extern int HAIKU_GetWindowGammaRamp(_THIS, SDL_Window * window, Uint16 * ramp); extern void HAIKU_SetWindowMouseGrab(_THIS, SDL_Window * window, SDL_bool grabbed); extern void HAIKU_DestroyWindow(_THIS, SDL_Window * window); -extern SDL_bool HAIKU_GetWindowWMInfo(_THIS, SDL_Window * window, - struct SDL_SysWMinfo *info); +extern int HAIKU_GetWindowWMInfo(_THIS, SDL_Window *window, struct SDL_SysWMinfo *info); diff --git a/src/video/kmsdrm/SDL_kmsdrmvideo.c b/src/video/kmsdrm/SDL_kmsdrmvideo.c index e76c67efc..11aced92c 100644 --- a/src/video/kmsdrm/SDL_kmsdrmvideo.c +++ b/src/video/kmsdrm/SDL_kmsdrmvideo.c @@ -25,7 +25,6 @@ /* SDL internals */ #include "../SDL_sysvideo.h" -#include "SDL_syswm.h" #include "SDL_log.h" #include "SDL_hints.h" #include "../../events/SDL_events_c.h" @@ -38,6 +37,9 @@ #include "../../core/openbsd/SDL_wscons.h" #endif +#define SDL_ENABLE_SYSWM_KMSDRM +#include "SDL_syswm.h" + /* KMS/DRM declarations */ #include "SDL_kmsdrmvideo.h" #include "SDL_kmsdrmevents.h" @@ -1638,25 +1640,17 @@ KMSDRM_RestoreWindow(_THIS, SDL_Window * window) /*****************************************************************************/ /* SDL Window Manager function */ /*****************************************************************************/ -SDL_bool -KMSDRM_GetWindowWMInfo(_THIS, SDL_Window * window, struct SDL_SysWMinfo *info) +int +KMSDRM_GetWindowWMInfo(_THIS, SDL_Window *window, struct SDL_SysWMinfo *info) { SDL_VideoData *viddata = ((SDL_VideoData *)_this->driverdata); - const Uint32 version = SDL_VERSIONNUM((Uint32)info->version.major, - (Uint32)info->version.minor, - (Uint32)info->version.patch); - - if (version < SDL_VERSIONNUM(2, 0, 15)) { - SDL_SetError("Version must be 2.0.15 or newer"); - return SDL_FALSE; - } info->subsystem = SDL_SYSWM_KMSDRM; info->info.kmsdrm.dev_index = viddata->devindex; info->info.kmsdrm.drm_fd = viddata->drm_fd; info->info.kmsdrm.gbm_dev = viddata->gbm_dev; - return SDL_TRUE; + return 0; } #endif /* SDL_VIDEO_DRIVER_KMSDRM */ diff --git a/src/video/kmsdrm/SDL_kmsdrmvideo.h b/src/video/kmsdrm/SDL_kmsdrmvideo.h index b3e719cc5..48b260584 100644 --- a/src/video/kmsdrm/SDL_kmsdrmvideo.h +++ b/src/video/kmsdrm/SDL_kmsdrmvideo.h @@ -141,8 +141,7 @@ void KMSDRM_RestoreWindow(_THIS, SDL_Window * window); void KMSDRM_DestroyWindow(_THIS, SDL_Window * window); /* Window manager function */ -SDL_bool KMSDRM_GetWindowWMInfo(_THIS, SDL_Window * window, - struct SDL_SysWMinfo *info); +int KMSDRM_GetWindowWMInfo(_THIS, SDL_Window *window, struct SDL_SysWMinfo *info); /* OpenGL/OpenGL ES functions */ int KMSDRM_GLES_LoadLibrary(_THIS, const char *path); diff --git a/src/video/kmsdrm/SDL_kmsdrmvulkan.c b/src/video/kmsdrm/SDL_kmsdrmvulkan.c index d404fd802..345cd151d 100644 --- a/src/video/kmsdrm/SDL_kmsdrmvulkan.c +++ b/src/video/kmsdrm/SDL_kmsdrmvulkan.c @@ -28,14 +28,17 @@ #if SDL_VIDEO_VULKAN && SDL_VIDEO_DRIVER_KMSDRM +#include "SDL_assert.h" +#include "SDL_loadso.h" + #include "SDL_kmsdrmvideo.h" #include "SDL_kmsdrmdyn.h" -#include "SDL_assert.h" - -#include "SDL_loadso.h" #include "SDL_kmsdrmvulkan.h" + +#define SDL_ENABLE_SYSWM_KMSDRM #include "SDL_syswm.h" -#include "sys/ioctl.h" + +#include #if defined(__OpenBSD__) #define DEFAULT_VULKAN "libvulkan.so" diff --git a/src/video/ngage/SDL_ngagewindow.h b/src/video/ngage/SDL_ngagewindow.h index 148c79986..ed1f983b9 100644 --- a/src/video/ngage/SDL_ngagewindow.h +++ b/src/video/ngage/SDL_ngagewindow.h @@ -23,6 +23,7 @@ #define _SDL_ngagewindow_h #include "../SDL_sysvideo.h" + #include "SDL_syswm.h" #include "SDL_ngagevideo.h" diff --git a/src/video/psp/SDL_pspvideo.c b/src/video/psp/SDL_pspvideo.c index de31a2012..9c1524bf4 100644 --- a/src/video/psp/SDL_pspvideo.c +++ b/src/video/psp/SDL_pspvideo.c @@ -26,12 +26,12 @@ /* SDL internals */ #include "../SDL_sysvideo.h" #include "SDL_version.h" -#include "SDL_syswm.h" #include "SDL_loadso.h" #include "SDL_events.h" #include "../../events/SDL_mouse_c.h" #include "../../events/SDL_keyboard_c.h" +#include "SDL_syswm.h" /* PSP declarations */ @@ -113,9 +113,6 @@ PSP_Create() device->MinimizeWindow = PSP_MinimizeWindow; device->RestoreWindow = PSP_RestoreWindow; device->DestroyWindow = PSP_DestroyWindow; -#if 0 - device->GetWindowWMInfo = PSP_GetWindowWMInfo; -#endif device->GL_LoadLibrary = PSP_GL_LoadLibrary; device->GL_GetProcAddress = PSP_GL_GetProcAddress; device->GL_UnloadLibrary = PSP_GL_UnloadLibrary; @@ -277,27 +274,6 @@ PSP_DestroyWindow(_THIS, SDL_Window * window) { } -/*****************************************************************************/ -/* SDL Window Manager function */ -/*****************************************************************************/ -#if 0 -SDL_bool -PSP_GetWindowWMInfo(_THIS, SDL_Window * window, struct SDL_SysWMinfo *info) -{ - if (info->version.major <= SDL_MAJOR_VERSION) { - return SDL_TRUE; - } else { - SDL_SetError("Application not compiled with SDL %d", - SDL_MAJOR_VERSION); - return SDL_FALSE; - } - - /* Failed to get window manager information */ - return SDL_FALSE; -} -#endif - - /* TO Write Me */ SDL_bool PSP_HasScreenKeyboardSupport(_THIS) { diff --git a/src/video/psp/SDL_pspvideo.h b/src/video/psp/SDL_pspvideo.h index e046c891e..31b834ac2 100644 --- a/src/video/psp/SDL_pspvideo.h +++ b/src/video/psp/SDL_pspvideo.h @@ -75,10 +75,6 @@ void PSP_MinimizeWindow(_THIS, SDL_Window * window); void PSP_RestoreWindow(_THIS, SDL_Window * window); void PSP_DestroyWindow(_THIS, SDL_Window * window); -/* Window manager function */ -SDL_bool PSP_GetWindowWMInfo(_THIS, SDL_Window * window, - struct SDL_SysWMinfo *info); - /* OpenGL/OpenGL ES functions */ int PSP_GL_LoadLibrary(_THIS, const char *path); void *PSP_GL_GetProcAddress(_THIS, const char *proc); diff --git a/src/video/raspberry/SDL_rpivideo.c b/src/video/raspberry/SDL_rpivideo.c index 4503f56df..6673baf41 100644 --- a/src/video/raspberry/SDL_rpivideo.c +++ b/src/video/raspberry/SDL_rpivideo.c @@ -33,13 +33,14 @@ /* SDL internals */ #include "../SDL_sysvideo.h" #include "SDL_version.h" -#include "SDL_syswm.h" #include "SDL_loadso.h" #include "SDL_events.h" #include "../../events/SDL_mouse_c.h" #include "../../events/SDL_keyboard_c.h" #include "SDL_hints.h" +#include "SDL_syswm.h" + #ifdef SDL_INPUT_LINUXEV #include "../../core/linux/SDL_evdev.h" #endif @@ -121,9 +122,6 @@ RPI_Create() device->MinimizeWindow = RPI_MinimizeWindow; device->RestoreWindow = RPI_RestoreWindow; device->DestroyWindow = RPI_DestroyWindow; -#if 0 - device->GetWindowWMInfo = RPI_GetWindowWMInfo; -#endif device->GL_LoadLibrary = RPI_GLES_LoadLibrary; device->GL_GetProcAddress = RPI_GLES_GetProcAddress; device->GL_UnloadLibrary = RPI_GLES_UnloadLibrary; @@ -421,26 +419,6 @@ RPI_RestoreWindow(_THIS, SDL_Window * window) { } -/*****************************************************************************/ -/* SDL Window Manager function */ -/*****************************************************************************/ -#if 0 -SDL_bool -RPI_GetWindowWMInfo(_THIS, SDL_Window * window, struct SDL_SysWMinfo *info) -{ - if (info->version.major <= SDL_MAJOR_VERSION) { - return SDL_TRUE; - } else { - SDL_SetError("application not compiled with SDL %d", - SDL_MAJOR_VERSION); - return SDL_FALSE; - } - - /* Failed to get window manager information */ - return SDL_FALSE; -} -#endif - #endif /* SDL_VIDEO_DRIVER_RPI */ /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/video/raspberry/SDL_rpivideo.h b/src/video/raspberry/SDL_rpivideo.h index 2b5f40f4d..1fc7e6d5e 100644 --- a/src/video/raspberry/SDL_rpivideo.h +++ b/src/video/raspberry/SDL_rpivideo.h @@ -83,10 +83,6 @@ void RPI_MinimizeWindow(_THIS, SDL_Window * window); void RPI_RestoreWindow(_THIS, SDL_Window * window); void RPI_DestroyWindow(_THIS, SDL_Window * window); -/* Window manager function */ -SDL_bool RPI_GetWindowWMInfo(_THIS, SDL_Window * window, - struct SDL_SysWMinfo *info); - /* OpenGL/OpenGL ES functions */ int RPI_GLES_LoadLibrary(_THIS, const char *path); void *RPI_GLES_GetProcAddress(_THIS, const char *proc); diff --git a/src/video/riscos/SDL_riscoswindow.c b/src/video/riscos/SDL_riscoswindow.c index f47d33ad7..8b92942de 100644 --- a/src/video/riscos/SDL_riscoswindow.c +++ b/src/video/riscos/SDL_riscoswindow.c @@ -23,10 +23,10 @@ #if SDL_VIDEO_DRIVER_RISCOS #include "SDL_version.h" -#include "SDL_syswm.h" #include "../SDL_sysvideo.h" #include "../../events/SDL_mouse_c.h" +#include "SDL_syswm.h" #include "SDL_riscosvideo.h" #include "SDL_riscoswindow.h" @@ -63,17 +63,11 @@ RISCOS_DestroyWindow(_THIS, SDL_Window * window) window->driverdata = NULL; } -SDL_bool -RISCOS_GetWindowWMInfo(_THIS, SDL_Window * window, struct SDL_SysWMinfo *info) +int +RISCOS_GetWindowWMInfo(_THIS, SDL_Window *window, struct SDL_SysWMinfo *info) { - if (info->version.major == SDL_MAJOR_VERSION) { - info->subsystem = SDL_SYSWM_RISCOS; - return SDL_TRUE; - } else { - SDL_SetError("Application not compiled with SDL %d", - SDL_MAJOR_VERSION); - return SDL_FALSE; - } + info->subsystem = SDL_SYSWM_RISCOS; + return 0; } #endif /* SDL_VIDEO_DRIVER_RISCOS */ diff --git a/src/video/riscos/SDL_riscoswindow.h b/src/video/riscos/SDL_riscoswindow.h index d713b7aeb..e57889778 100644 --- a/src/video/riscos/SDL_riscoswindow.h +++ b/src/video/riscos/SDL_riscoswindow.h @@ -34,8 +34,7 @@ typedef struct extern int RISCOS_CreateWindow(_THIS, SDL_Window * window); extern void RISCOS_DestroyWindow(_THIS, SDL_Window * window); -extern SDL_bool RISCOS_GetWindowWMInfo(_THIS, SDL_Window * window, - struct SDL_SysWMinfo *info); +extern int RISCOS_GetWindowWMInfo(_THIS, SDL_Window *window, struct SDL_SysWMinfo *info); #endif /* SDL_riscoswindow_h_ */ diff --git a/src/video/uikit/SDL_uikitmetalview.m b/src/video/uikit/SDL_uikitmetalview.m index 8bc338095..15810e17a 100644 --- a/src/video/uikit/SDL_uikitmetalview.m +++ b/src/video/uikit/SDL_uikitmetalview.m @@ -30,12 +30,14 @@ #if SDL_VIDEO_DRIVER_UIKIT && (SDL_VIDEO_VULKAN || SDL_VIDEO_METAL) -#include "SDL_syswm.h" #include "../SDL_sysvideo.h" #import "SDL_uikitwindow.h" #import "SDL_uikitmetalview.h" +#define SDL_ENABLE_SYSWM_UIKIT +#include "SDL_syswm.h" + @implementation SDL_uikitmetalview diff --git a/src/video/uikit/SDL_uikitvulkan.m b/src/video/uikit/SDL_uikitvulkan.m index 52a1ceddb..9721053fa 100644 --- a/src/video/uikit/SDL_uikitvulkan.m +++ b/src/video/uikit/SDL_uikitvulkan.m @@ -34,6 +34,8 @@ #include "SDL_loadso.h" #include "SDL_uikitvulkan.h" #include "SDL_uikitmetalview.h" + +#define SDL_ENABLE_SYSWM_UIKIT #include "SDL_syswm.h" #include diff --git a/src/video/uikit/SDL_uikitwindow.h b/src/video/uikit/SDL_uikitwindow.h index 7ca9b475e..ac93feb80 100644 --- a/src/video/uikit/SDL_uikitwindow.h +++ b/src/video/uikit/SDL_uikitwindow.h @@ -37,8 +37,7 @@ extern void UIKit_SetWindowMouseGrab(_THIS, SDL_Window * window, SDL_bool grabbe extern void UIKit_UpdatePointerLock(_THIS, SDL_Window * window); extern void UIKit_DestroyWindow(_THIS, SDL_Window * window); extern void UIKit_GetWindowSizeInPixels(_THIS, SDL_Window * window, int *w, int *h); -extern SDL_bool UIKit_GetWindowWMInfo(_THIS, SDL_Window * window, - struct SDL_SysWMinfo * info); +extern int UIKit_GetWindowWMInfo(_THIS, SDL_Window *window, struct SDL_SysWMinfo *info); extern NSUInteger UIKit_GetSupportedOrientations(SDL_Window * window); diff --git a/src/video/uikit/SDL_uikitwindow.m b/src/video/uikit/SDL_uikitwindow.m index 7b8dfff56..45bbc27fe 100644 --- a/src/video/uikit/SDL_uikitwindow.m +++ b/src/video/uikit/SDL_uikitwindow.m @@ -25,7 +25,6 @@ #include "SDL_hints.h" #include "SDL_mouse.h" #include "SDL_system.h" -#include "SDL_syswm.h" #include "SDL_video.h" #include "../SDL_sysvideo.h" #include "../SDL_pixels_c.h" @@ -35,10 +34,12 @@ #include "SDL_uikitevents.h" #include "SDL_uikitmodes.h" #include "SDL_uikitwindow.h" -#import "SDL_uikitappdelegate.h" +#include "SDL_uikitappdelegate.h" +#include "SDL_uikitview.h" +#include "SDL_uikitopenglview.h" -#import "SDL_uikitview.h" -#import "SDL_uikitopenglview.h" +#define SDL_ENABLE_SYSWM_UIKIT +#include "SDL_syswm.h" #include @@ -390,44 +391,25 @@ UIKit_GetWindowSizeInPixels(_THIS, SDL_Window * window, int *w, int *h) *h = size.height * scale; }} -SDL_bool -UIKit_GetWindowWMInfo(_THIS, SDL_Window * window, SDL_SysWMinfo * info) +int +UIKit_GetWindowWMInfo(_THIS, SDL_Window *window, SDL_SysWMinfo *info) +{ @autoreleasepool { - @autoreleasepool { - SDL_WindowData *data = (__bridge SDL_WindowData *) window->driverdata; + SDL_WindowData *data = (__bridge SDL_WindowData *) window->driverdata; - if (info->version.major <= SDL_MAJOR_VERSION) { - int versionnum = SDL_VERSIONNUM(info->version.major, info->version.minor, info->version.patch); + info->subsystem = SDL_SYSWM_UIKIT; + info->info.uikit.window = data.uiwindow; - info->subsystem = SDL_SYSWM_UIKIT; - info->info.uikit.window = data.uiwindow; - - /* These struct members were added in SDL 2.0.4. */ - if (versionnum >= SDL_VERSIONNUM(2,0,4)) { #if SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2 - if ([data.viewcontroller.view isKindOfClass:[SDL_uikitopenglview class]]) { - SDL_uikitopenglview *glview = (SDL_uikitopenglview *)data.viewcontroller.view; - info->info.uikit.framebuffer = glview.drawableFramebuffer; - info->info.uikit.colorbuffer = glview.drawableRenderbuffer; - info->info.uikit.resolveFramebuffer = glview.msaaResolveFramebuffer; - } else { -#else - { -#endif - info->info.uikit.framebuffer = 0; - info->info.uikit.colorbuffer = 0; - info->info.uikit.resolveFramebuffer = 0; - } - } - - return SDL_TRUE; - } else { - SDL_SetError("Application not compiled with SDL %d", - SDL_MAJOR_VERSION); - return SDL_FALSE; - } + if ([data.viewcontroller.view isKindOfClass:[SDL_uikitopenglview class]]) { + SDL_uikitopenglview *glview = (SDL_uikitopenglview *)data.viewcontroller.view; + info->info.uikit.framebuffer = glview.drawableFramebuffer; + info->info.uikit.colorbuffer = glview.drawableRenderbuffer; + info->info.uikit.resolveFramebuffer = glview.msaaResolveFramebuffer; } -} +#endif + return 0; +}} #if !TARGET_OS_TV NSUInteger diff --git a/src/video/vita/SDL_vitavideo.c b/src/video/vita/SDL_vitavideo.c index b7f452303..d8c16115d 100644 --- a/src/video/vita/SDL_vitavideo.c +++ b/src/video/vita/SDL_vitavideo.c @@ -26,12 +26,13 @@ /* SDL internals */ #include "../SDL_sysvideo.h" #include "SDL_version.h" -#include "SDL_syswm.h" #include "SDL_loadso.h" #include "SDL_events.h" #include "../../events/SDL_mouse_c.h" #include "../../events/SDL_keyboard_c.h" +#include "SDL_syswm.h" + /* VITA declarations */ #include #include "SDL_vitavideo.h" @@ -132,7 +133,6 @@ VITA_Create() device->SetWindowMouseGrab = VITA_SetWindowGrab; device->SetWindowKeyboardGrab = VITA_SetWindowGrab; device->DestroyWindow = VITA_DestroyWindow; - device->GetWindowWMInfo = VITA_GetWindowWMInfo; /* // Disabled, causes issues on high-framerate updates. SDL still emulates this. @@ -395,24 +395,6 @@ VITA_DestroyWindow(_THIS, SDL_Window * window) Vita_Window = NULL; } -/*****************************************************************************/ -/* SDL Window Manager function */ -/*****************************************************************************/ -SDL_bool -VITA_GetWindowWMInfo(_THIS, SDL_Window * window, struct SDL_SysWMinfo *info) -{ - if (info->version.major <= SDL_MAJOR_VERSION) { - return SDL_TRUE; - } else { - SDL_SetError("application not compiled with SDL %d\n", - SDL_MAJOR_VERSION); - return SDL_FALSE; - } - - /* Failed to get window manager information */ - return SDL_FALSE; -} - SDL_bool VITA_HasScreenKeyboardSupport(_THIS) { return SDL_TRUE; diff --git a/src/video/vita/SDL_vitavideo.h b/src/video/vita/SDL_vitavideo.h index 9fdf7e69c..90a1306d6 100644 --- a/src/video/vita/SDL_vitavideo.h +++ b/src/video/vita/SDL_vitavideo.h @@ -85,10 +85,6 @@ void VITA_RestoreWindow(_THIS, SDL_Window * window); void VITA_SetWindowGrab(_THIS, SDL_Window * window, SDL_bool grabbed); void VITA_DestroyWindow(_THIS, SDL_Window * window); -/* Window manager function */ -SDL_bool VITA_GetWindowWMInfo(_THIS, SDL_Window * window, - struct SDL_SysWMinfo *info); - #if SDL_VIDEO_DRIVER_VITA #if defined(SDL_VIDEO_VITA_PVR_OGL) /* OpenGL functions */ diff --git a/src/video/vivante/SDL_vivantevideo.c b/src/video/vivante/SDL_vivantevideo.c index 3b18b7db8..ae7826c60 100644 --- a/src/video/vivante/SDL_vivantevideo.c +++ b/src/video/vivante/SDL_vivantevideo.c @@ -25,11 +25,12 @@ /* SDL internals */ #include "../SDL_sysvideo.h" #include "SDL_version.h" -#include "SDL_syswm.h" #include "SDL_loadso.h" #include "SDL_events.h" #include "../../events/SDL_events_c.h" +#include "SDL_syswm.h" + #ifdef SDL_INPUT_LINUXEV #include "../../core/linux/SDL_evdev.h" #endif diff --git a/src/video/vivante/SDL_vivantevideo.h b/src/video/vivante/SDL_vivantevideo.h index ae4a8e142..9acef5ffe 100644 --- a/src/video/vivante/SDL_vivantevideo.h +++ b/src/video/vivante/SDL_vivantevideo.h @@ -80,8 +80,7 @@ void VIVANTE_HideWindow(_THIS, SDL_Window * window); void VIVANTE_DestroyWindow(_THIS, SDL_Window * window); /* Window manager function */ -SDL_bool VIVANTE_GetWindowWMInfo(_THIS, SDL_Window * window, - struct SDL_SysWMinfo *info); +int VIVANTE_GetWindowWMInfo(_THIS, SDL_Window *window, struct SDL_SysWMinfo *info); /* Event functions */ void VIVANTE_PumpEvents(_THIS); diff --git a/src/video/wayland/SDL_waylandvulkan.c b/src/video/wayland/SDL_waylandvulkan.c index f76efd094..ff934eb0f 100644 --- a/src/video/wayland/SDL_waylandvulkan.c +++ b/src/video/wayland/SDL_waylandvulkan.c @@ -33,6 +33,8 @@ #include "SDL_loadso.h" #include "SDL_waylandvulkan.h" + +#define SDL_ENABLE_SYSWM_WAYLAND #include "SDL_syswm.h" #if defined(__OpenBSD__) diff --git a/src/video/wayland/SDL_waylandwindow.c b/src/video/wayland/SDL_waylandwindow.c index a31f6baf6..96b559ae2 100644 --- a/src/video/wayland/SDL_waylandwindow.c +++ b/src/video/wayland/SDL_waylandwindow.c @@ -1152,94 +1152,36 @@ static const struct wl_surface_listener surface_listener = { handle_surface_leave }; -static void -Wayland_FillEmptyShellInfo(SDL_SysWMinfo * info, const Uint32 version) -{ - info->info.wl.xdg_surface = NULL; - if (version >= SDL_VERSIONNUM(2, 0, 17)) { - info->info.wl.xdg_toplevel = NULL; - if (version >= SDL_VERSIONNUM(2, 0, 22)) { - info->info.wl.xdg_popup = NULL; - info->info.wl.xdg_positioner = NULL; - } - } -} - -SDL_bool -Wayland_GetWindowWMInfo(_THIS, SDL_Window * window, SDL_SysWMinfo * info) +int +Wayland_GetWindowWMInfo(_THIS, SDL_Window *window, SDL_SysWMinfo *info) { SDL_VideoData *viddata = (SDL_VideoData *) _this->driverdata; SDL_WindowData *data = (SDL_WindowData *) window->driverdata; - const Uint32 version = SDL_VERSIONNUM((Uint32)info->version.major, - (Uint32)info->version.minor, - (Uint32)info->version.patch); - - /* Before 2.0.6, it was possible to build an SDL with Wayland support - (SDL_SysWMinfo will be large enough to hold Wayland info), but build - your app against SDL headers that didn't have Wayland support - (SDL_SysWMinfo could be smaller than Wayland needs. This would lead - to an app properly using SDL_GetWindowWMInfo() but we'd accidentally - overflow memory on the stack or heap. To protect against this, we've - padded out the struct unconditionally in the headers and Wayland will - just return an error for older apps using this function. Those apps - will need to be recompiled against newer headers or not use Wayland, - maybe by forcing SDL_VIDEODRIVER=x11. */ - if (version < SDL_VERSIONNUM(2, 0, 6)) { - info->subsystem = SDL_SYSWM_UNKNOWN; - SDL_SetError("Version must be 2.0.6 or newer"); - return SDL_FALSE; - } + info->subsystem = SDL_SYSWM_WAYLAND; info->info.wl.display = data->waylandData->display; info->info.wl.surface = data->surface; - - if (version >= SDL_VERSIONNUM(2, 0, 15)) { - info->info.wl.egl_window = data->egl_window; + info->info.wl.egl_window = data->egl_window; #ifdef HAVE_LIBDECOR_H - if (data->shell_surface_type == WAYLAND_SURFACE_LIBDECOR) { - if (data->shell_surface.libdecor.frame != NULL) { - info->info.wl.xdg_surface = libdecor_frame_get_xdg_surface(data->shell_surface.libdecor.frame); - if (version >= SDL_VERSIONNUM(2, 0, 17)) { - info->info.wl.xdg_toplevel = libdecor_frame_get_xdg_toplevel(data->shell_surface.libdecor.frame); - if (version >= SDL_VERSIONNUM(2, 0, 22)) { - info->info.wl.xdg_popup = NULL; - info->info.wl.xdg_positioner = NULL; - } - } - } else { - /* Not mapped yet */ - Wayland_FillEmptyShellInfo(info, version); - } - } else + if (data->shell_surface_type == WAYLAND_SURFACE_LIBDECOR) { + if (data->shell_surface.libdecor.frame != NULL) { + info->info.wl.xdg_surface = libdecor_frame_get_xdg_surface(data->shell_surface.libdecor.frame); + info->info.wl.xdg_toplevel = libdecor_frame_get_xdg_toplevel(data->shell_surface.libdecor.frame); + } + } else #endif - if (viddata->shell.xdg && data->shell_surface.xdg.surface != NULL) { - info->info.wl.xdg_surface = data->shell_surface.xdg.surface; - if (version >= SDL_VERSIONNUM(2, 0, 17)) { - SDL_bool popup = data->shell_surface_type == WAYLAND_SURFACE_XDG_POPUP; - info->info.wl.xdg_toplevel = popup ? NULL : data->shell_surface.xdg.roleobj.toplevel; - if (version >= SDL_VERSIONNUM(2, 0, 22)) { - if (popup) { - info->info.wl.xdg_popup = data->shell_surface.xdg.roleobj.popup.popup; - info->info.wl.xdg_positioner = data->shell_surface.xdg.roleobj.popup.positioner; - } else { - info->info.wl.xdg_popup = NULL; - info->info.wl.xdg_positioner = NULL; - } - } - } - } else { - /* Either it's not mapped yet or we don't have a shell protocol */ - Wayland_FillEmptyShellInfo(info, version); + if (viddata->shell.xdg && data->shell_surface.xdg.surface != NULL) { + SDL_bool popup = (data->shell_surface_type == WAYLAND_SURFACE_XDG_POPUP) ? SDL_TRUE : SDL_FALSE; + info->info.wl.xdg_surface = data->shell_surface.xdg.surface; + info->info.wl.xdg_toplevel = popup ? NULL : data->shell_surface.xdg.roleobj.toplevel; + if (popup) { + info->info.wl.xdg_popup = data->shell_surface.xdg.roleobj.popup.popup; + info->info.wl.xdg_positioner = data->shell_surface.xdg.roleobj.popup.positioner; } } - /* Deprecated in 2.0.16 */ - info->info.wl.shell_surface = NULL; - - info->subsystem = SDL_SYSWM_WAYLAND; - - return SDL_TRUE; + return 0; } int diff --git a/src/video/wayland/SDL_waylandwindow.h b/src/video/wayland/SDL_waylandwindow.h index 6e2701048..a5a5cd43d 100644 --- a/src/video/wayland/SDL_waylandwindow.h +++ b/src/video/wayland/SDL_waylandwindow.h @@ -25,9 +25,11 @@ #define SDL_waylandwindow_h_ #include "../SDL_sysvideo.h" -#include "SDL_syswm.h" #include "../../events/SDL_touch_c.h" +#define SDL_ENABLE_SYSWM_WAYLAND +#include "SDL_syswm.h" + #include "SDL_waylandvideo.h" struct SDL_WaylandInput; @@ -132,8 +134,7 @@ extern void Wayland_SetWindowTitle(_THIS, SDL_Window * window); extern void Wayland_DestroyWindow(_THIS, SDL_Window *window); extern void Wayland_SuspendScreenSaver(_THIS); -extern SDL_bool -Wayland_GetWindowWMInfo(_THIS, SDL_Window * window, SDL_SysWMinfo * info); +extern int Wayland_GetWindowWMInfo(_THIS, SDL_Window *window, SDL_SysWMinfo *info); extern int Wayland_SetWindowHitTest(SDL_Window *window, SDL_bool enabled); extern int Wayland_FlashWindow(_THIS, SDL_Window * window, SDL_FlashOperation operation); diff --git a/src/video/windows/SDL_windowsevents.c b/src/video/windows/SDL_windowsevents.c index 8112610ee..c60690585 100644 --- a/src/video/windows/SDL_windowsevents.c +++ b/src/video/windows/SDL_windowsevents.c @@ -25,7 +25,6 @@ #include "SDL_windowsvideo.h" #include "SDL_windowsshape.h" #include "SDL_system.h" -#include "SDL_syswm.h" #include "SDL_timer.h" #include "SDL_vkeys.h" #include "SDL_hints.h" @@ -36,6 +35,9 @@ #include "SDL_hints.h" #include "SDL_log.h" +#define SDL_ENABLE_SYSWM_WINDOWS +#include "SDL_syswm.h" + /* Dropfile support */ #include @@ -641,7 +643,7 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) if (SDL_GetEventState(SDL_SYSWMEVENT) == SDL_ENABLE) { SDL_SysWMmsg wmmsg; - SDL_VERSION(&wmmsg.version); + wmmsg.version = SDL_SYSWM_CURRENT_VERSION; wmmsg.subsystem = SDL_SYSWM_WINDOWS; wmmsg.msg.win.hwnd = hwnd; wmmsg.msg.win.msg = msg; diff --git a/src/video/windows/SDL_windowsvulkan.c b/src/video/windows/SDL_windowsvulkan.c index 2a66f4398..41417f3c0 100644 --- a/src/video/windows/SDL_windowsvulkan.c +++ b/src/video/windows/SDL_windowsvulkan.c @@ -33,6 +33,8 @@ #include "SDL_loadso.h" #include "SDL_windowsvulkan.h" + +#define SDL_ENABLE_SYSWM_WINDOWS #include "SDL_syswm.h" int WIN_Vulkan_LoadLibrary(_THIS, const char *path) diff --git a/src/video/windows/SDL_windowswindow.c b/src/video/windows/SDL_windowswindow.c index 9d8afee63..93a03c927 100644 --- a/src/video/windows/SDL_windowswindow.c +++ b/src/video/windows/SDL_windowswindow.c @@ -42,7 +42,7 @@ /* Dropfile support */ #include -/* This is included after SDL_windowsvideo.h, which includes windows.h */ +#define SDL_ENABLE_SYSWM_WINDOWS #include "SDL_syswm.h" /* Windows CE compatibility */ @@ -1195,30 +1195,17 @@ WIN_DestroyWindow(_THIS, SDL_Window * window) CleanupWindowData(_this, window); } -SDL_bool -WIN_GetWindowWMInfo(_THIS, SDL_Window * window, SDL_SysWMinfo * info) +int +WIN_GetWindowWMInfo(_THIS, SDL_Window *window, SDL_SysWMinfo *info) { const SDL_WindowData *data = (const SDL_WindowData *) window->driverdata; - if (info->version.major <= SDL_MAJOR_VERSION) { - int versionnum = SDL_VERSIONNUM(info->version.major, info->version.minor, info->version.patch); - info->subsystem = SDL_SYSWM_WINDOWS; - info->info.win.window = data->hwnd; + info->subsystem = SDL_SYSWM_WINDOWS; + info->info.win.window = data->hwnd; + info->info.win.hdc = data->hdc; + info->info.win.hinstance = data->hinstance; - if (versionnum >= SDL_VERSIONNUM(2, 0, 4)) { - info->info.win.hdc = data->hdc; - } - - if (versionnum >= SDL_VERSIONNUM(2, 0, 5)) { - info->info.win.hinstance = data->hinstance; - } - - return SDL_TRUE; - } else { - SDL_SetError("Application not compiled with SDL %d", - SDL_MAJOR_VERSION); - return SDL_FALSE; - } + return 0; } /* diff --git a/src/video/windows/SDL_windowswindow.h b/src/video/windows/SDL_windowswindow.h index 6477530b9..c03b7660f 100644 --- a/src/video/windows/SDL_windowswindow.h +++ b/src/video/windows/SDL_windowswindow.h @@ -101,8 +101,7 @@ extern void WIN_SetWindowMouseRect(_THIS, SDL_Window * window); extern void WIN_SetWindowMouseGrab(_THIS, SDL_Window * window, SDL_bool grabbed); extern void WIN_SetWindowKeyboardGrab(_THIS, SDL_Window * window, SDL_bool grabbed); extern void WIN_DestroyWindow(_THIS, SDL_Window * window); -extern SDL_bool WIN_GetWindowWMInfo(_THIS, SDL_Window * window, - struct SDL_SysWMinfo *info); +extern int WIN_GetWindowWMInfo(_THIS, SDL_Window *window, struct SDL_SysWMinfo *info); extern void WIN_OnWindowEnter(_THIS, SDL_Window * window); extern void WIN_UpdateClipCursor(SDL_Window *window); extern int WIN_SetWindowHitTest(SDL_Window *window, SDL_bool enabled); diff --git a/src/video/winrt/SDL_winrtvideo.cpp b/src/video/winrt/SDL_winrtvideo.cpp index 7511aa531..fbe16b2dc 100644 --- a/src/video/winrt/SDL_winrtvideo.cpp +++ b/src/video/winrt/SDL_winrtvideo.cpp @@ -54,13 +54,10 @@ static const GUID SDL_IID_IDXGIFactory2 = { 0x50c83a1c, 0xe072, 0x4c48, { 0x /* SDL includes */ extern "C" { -#include "SDL_video.h" -#include "SDL_mouse.h" #include "../SDL_sysvideo.h" #include "../SDL_pixels_c.h" #include "../../events/SDL_events_c.h" #include "../../render/SDL_sysrender.h" -#include "SDL_syswm.h" #include "SDL_winrtopengles.h" #include "../../core/windows/SDL_windows.h" } @@ -72,9 +69,14 @@ extern "C" { #include "SDL_winrtgamebar_cpp.h" #include "SDL_winrtmouse_c.h" #include "SDL_main.h" +#include "SDL_mouse.h" +#include "SDL_video.h" #include "SDL_system.h" #include "SDL_hints.h" +#define SDL_ENABLE_SYSWM_WINRT +#include "SDL_syswm.h" + /* Initialization/Query functions */ static int WINRT_VideoInit(_THIS); @@ -88,7 +90,7 @@ static int WINRT_CreateWindow(_THIS, SDL_Window * window); static void WINRT_SetWindowSize(_THIS, SDL_Window * window); static void WINRT_SetWindowFullscreen(_THIS, SDL_Window * window, SDL_VideoDisplay * display, SDL_bool fullscreen); static void WINRT_DestroyWindow(_THIS, SDL_Window * window); -static SDL_bool WINRT_GetWindowWMInfo(_THIS, SDL_Window * window, SDL_SysWMinfo * info); +static int WINRT_GetWindowWMInfo(_THIS, SDL_Window * window, SDL_SysWMinfo * info); /* Misc functions */ @@ -826,21 +828,14 @@ WINRT_DestroyWindow(_THIS, SDL_Window * window) } } -SDL_bool -WINRT_GetWindowWMInfo(_THIS, SDL_Window * window, SDL_SysWMinfo * info) +int +WINRT_GetWindowWMInfo(_THIS, SDL_Window *window, SDL_SysWMinfo *info) { - SDL_WindowData * data = (SDL_WindowData *) window->driverdata; + SDL_WindowData *data = (SDL_WindowData *)window->driverdata; - if (info->version.major <= SDL_MAJOR_VERSION) { - info->subsystem = SDL_SYSWM_WINRT; - info->info.winrt.window = reinterpret_cast(data->coreWindow.Get()); - return SDL_TRUE; - } else { - SDL_SetError("Application not compiled with SDL %d", - SDL_MAJOR_VERSION); - return SDL_FALSE; - } - return SDL_FALSE; + info->subsystem = SDL_SYSWM_WINRT; + info->info.winrt.window = reinterpret_cast(data->coreWindow.Get()); + return 0; } static ABI::Windows::System::Display::IDisplayRequest * diff --git a/src/video/x11/SDL_x11events.c b/src/video/x11/SDL_x11events.c index 6b6b834b4..4fcad5386 100644 --- a/src/video/x11/SDL_x11events.c +++ b/src/video/x11/SDL_x11events.c @@ -39,6 +39,8 @@ #include "SDL_hints.h" #include "SDL_timer.h" + +#define SDL_ENABLE_SYSWM_X11 #include "SDL_syswm.h" #include @@ -317,7 +319,7 @@ static void X11_HandleGenericEvent(SDL_VideoData *videodata, XEvent *xev) if (SDL_GetEventState(SDL_SYSWMEVENT) == SDL_ENABLE) { SDL_SysWMmsg wmmsg; - SDL_VERSION(&wmmsg.version); + wmmsg.version = SDL_SYSWM_CURRENT_VERSION; wmmsg.subsystem = SDL_SYSWM_X11; wmmsg.msg.x11.event = *xev; SDL_SendSysWMEvent(&wmmsg); @@ -812,7 +814,7 @@ X11_DispatchEvent(_THIS, XEvent *xevent) if (SDL_GetEventState(SDL_SYSWMEVENT) == SDL_ENABLE) { SDL_SysWMmsg wmmsg; - SDL_VERSION(&wmmsg.version); + wmmsg.version = SDL_SYSWM_CURRENT_VERSION; wmmsg.subsystem = SDL_SYSWM_X11; wmmsg.msg.x11.event = *xevent; SDL_SendSysWMEvent(&wmmsg); diff --git a/src/video/x11/SDL_x11window.c b/src/video/x11/SDL_x11window.c index c0114b56e..50e7865fa 100644 --- a/src/video/x11/SDL_x11window.c +++ b/src/video/x11/SDL_x11window.c @@ -40,6 +40,8 @@ #endif #include "SDL_timer.h" + +#define SDL_ENABLE_SYSWM_X11 #include "SDL_syswm.h" #define _NET_WM_STATE_REMOVE 0l @@ -1761,30 +1763,22 @@ X11_DestroyWindow(_THIS, SDL_Window * window) window->driverdata = NULL; } -SDL_bool -X11_GetWindowWMInfo(_THIS, SDL_Window * window, SDL_SysWMinfo * info) +int +X11_GetWindowWMInfo(_THIS, SDL_Window *window, SDL_SysWMinfo *info) { SDL_WindowData *data = (SDL_WindowData *) window->driverdata; - Display *display; + SDL_DisplayData *displaydata = (SDL_DisplayData *) SDL_GetDisplayForWindow(window)->driverdata; if (!data) { /* This sometimes happens in SDL_IBus_UpdateTextRect() while creating the window */ - SDL_SetError("Window not initialized"); - return SDL_FALSE; + return SDL_SetError("Window not initialized"); } - display = data->videodata->display; - - if (info->version.major == SDL_MAJOR_VERSION) { - info->subsystem = SDL_SYSWM_X11; - info->info.x11.display = display; - info->info.x11.window = data->xwindow; - return SDL_TRUE; - } else { - SDL_SetError("Application not compiled with SDL %d", - SDL_MAJOR_VERSION); - return SDL_FALSE; - } + info->subsystem = SDL_SYSWM_X11; + info->info.x11.display = data->videodata->display; + info->info.x11.screen = displaydata->screen; + info->info.x11.window = data->xwindow; + return 0; } int diff --git a/src/video/x11/SDL_x11window.h b/src/video/x11/SDL_x11window.h index 5298decc4..93fd2c50e 100644 --- a/src/video/x11/SDL_x11window.h +++ b/src/video/x11/SDL_x11window.h @@ -111,8 +111,7 @@ extern void* X11_GetWindowICCProfile(_THIS, SDL_Window * window, size_t * size); extern void X11_SetWindowMouseGrab(_THIS, SDL_Window * window, SDL_bool grabbed); extern void X11_SetWindowKeyboardGrab(_THIS, SDL_Window * window, SDL_bool grabbed); extern void X11_DestroyWindow(_THIS, SDL_Window * window); -extern SDL_bool X11_GetWindowWMInfo(_THIS, SDL_Window * window, - struct SDL_SysWMinfo *info); +extern int X11_GetWindowWMInfo(_THIS, SDL_Window *window, struct SDL_SysWMinfo *info); extern int X11_SetWindowHitTest(SDL_Window *window, SDL_bool enabled); extern void X11_AcceptDragAndDrop(SDL_Window * window, SDL_bool accept); extern int X11_FlashWindow(_THIS, SDL_Window * window, SDL_FlashOperation operation); diff --git a/test/testautomation_syswm.c b/test/testautomation_syswm.c index d9fd982b3..52088e239 100644 --- a/test/testautomation_syswm.c +++ b/test/testautomation_syswm.c @@ -16,7 +16,7 @@ int syswm_getWindowWMInfo(void *arg) { - SDL_bool result; + int result; SDL_Window *window; SDL_SysWMinfo info; @@ -27,13 +27,10 @@ syswm_getWindowWMInfo(void *arg) return TEST_ABORTED; } - /* Initialize info structure with SDL version info */ - SDL_VERSION(&info.version); - /* Make call */ - result = SDL_GetWindowWMInfo(window, &info); + result = SDL_GetWindowWMInfo(window, &info, SDL_SYSWM_CURRENT_VERSION); SDLTest_AssertPass("Call to SDL_GetWindowWMInfo()"); - SDLTest_Log((result == SDL_TRUE) ? "Got window information" : "Couldn't get window information"); + SDLTest_Log((result == 0) ? "Got window information" : "Couldn't get window information"); SDL_DestroyWindow(window); SDLTest_AssertPass("Call to SDL_DestroyWindow()"); diff --git a/test/testnative.h b/test/testnative.h index 528194927..2a6e087a3 100644 --- a/test/testnative.h +++ b/test/testnative.h @@ -15,9 +15,6 @@ */ #include "SDL.h" -/* This header includes all the necessary system headers for native windows */ -#include "SDL_syswm.h" - typedef struct { const char *tag; @@ -36,10 +33,6 @@ extern NativeWindowFactory X11WindowFactory; #endif #ifdef SDL_VIDEO_DRIVER_COCOA -/* Actually, we don't really do this, since it involves adding Objective C - support to the build system, which is a little tricky. You can uncomment - it manually though and link testnativecocoa.m into the test application. -*/ #define TEST_NATIVE_COCOA extern NativeWindowFactory CocoaWindowFactory; #endif diff --git a/test/testnativew32.c b/test/testnativew32.c index a9bf2c779..34e3641ba 100644 --- a/test/testnativew32.c +++ b/test/testnativew32.c @@ -14,6 +14,8 @@ #ifdef TEST_NATIVE_WINDOWS +#include + static void *CreateWindowNative(int w, int h); static void DestroyWindowNative(void *window); diff --git a/test/testnativex11.c b/test/testnativex11.c index f6bd0c0e4..987d1abf3 100644 --- a/test/testnativex11.c +++ b/test/testnativex11.c @@ -14,6 +14,8 @@ #ifdef TEST_NATIVE_X11 +#include + static void *CreateWindowX11(int w, int h); static void DestroyWindowX11(void *window);