Commit Graph

7240 Commits (7b284dbb34a8c34f5d6f79c58c860c9f7894fd56)

Author SHA1 Message Date
Sylvain 7b284dbb34
EglChooseConfig: choose an accelerated configuration
- especially because we can be promoted to true color 888
  make sure we don't select a potentially software implementation

- hopefully fix bug #1482 (EGL ChooseConfig selects software renderer on Android)
2021-04-30 22:01:48 +02:00
Ethan Lee 9161f95166 egl: Reject attempts to set negative swap intervals 2021-04-30 13:24:01 -04:00
Ryan C. Gordon c54c16d353
wayland: don't hang in SDL_GL_SwapBuffers if the compositor is ghosting us.
If you hide a window on Mutter, for example, the compositor never requests
new frames, which will cause Mesa to block forever in eglSwapBuffers to
satisfy the swap interval.

We now always set the swap interval to 0 and manage this ourselves, handing
the frame to Wayland when it requests a new one, and timing out at 10fps just
to keep apps moving if the compositor wants no frames at all.

My understanding is that other protocols are coming that might improve upon
this solution, but for now it solves the total hang.

Fixes #4335.
2021-04-30 13:20:35 -04:00
Ozkan Sezer 227021b647 SDL_windowsmessagebox.c (MessageBoxDialogProc): fix calling convention. 2021-04-30 11:25:20 +03:00
Sylvain 13472cec67
Fixed bug #4228: move from jcenter() to mavenCentral()
SDL can use relinker. If it's enabled on your project, you need to update to version 1.4.3
2021-04-30 09:48:29 +02:00
Sylvain a74f888ff9
Fixed bug #4337 - compilation of 'SDL_vulkan_utils' fails with 'VK_ERROR_INCOMPATIBLE_VERSION_KHR' undeclared 2021-04-29 22:25:00 +02:00
Sylvain 8ac0fb52cb
OpenSLES: CloseDevice() is called at higher level, if OpenDevice() fails
- explicit initialization of static variables
2021-04-29 09:29:02 +02:00
Sylvain 1f3df900f9
Error missing 'flags' initialization (see bug #2881) 2021-04-28 23:40:26 +02:00
Sylvain fcbf19b764
AAudio: make sure stream is not null to prevent crash in RequestStop (see #3710) 2021-04-28 21:04:47 +02:00
Sylvain c93e3b3607
Fixed bug #2881 - SDL_RLEsurface may encode RGB888 if it has no color key (Thanks Simon Hug)
To encode with BLEND mode, it needs a valid alpha channel
2021-04-28 10:43:28 +02:00
Sylvain b626429745
Merge remote-tracking branch 'refs/remotes/origin/main' 2021-04-27 11:10:41 +02:00
Sylvain f869518533
Audio: normalize conversion Stereo to 5.1, Quad to 7.1, 5.1 to 7.1 (bug #4104) 2021-04-27 11:07:51 +02:00
Sylvain 21349901ea
Audio: convert 5.1 to 7.1, use right-surround for r-front and r-back (see #4104) 2021-04-27 10:57:48 +02:00
Ryan C. Gordon 8527c583f4 cocoa: Fix recreated windows that are both borderless and resizable.
These would accidentally get a titlebar because the "borderless" style mask
is zero but the resizable attribute adds a bit. I assume this happens because
you used to need window decoration to resize a window in macOS, but this
changed in later releases.

This only caused problems when recreating a window (you had an
SDL_WINDOW_OPENGL window and tried to create a Metal SDL_Renderer on it, etc).

Fixes #4324.
2021-04-27 01:36:23 -04:00
Ethan Lee 40210f8945 winrt: Always use a thread for joystick support 2021-04-26 21:29:56 -04:00
Ryan C. Gordon 2fdbae22cb cocoa: Remove mouse event tap.
It doesn't appear to work anymore, and was disabled by default anyhow, since
the needed APIs are forbidden on the Mac App Store.

A better solution to lock the mouse to the window on macOS would still be
welcome. CGAssociateMouseAndMouseCursorPosition() works fine for relative
mouse mode, this was just a question of SDL_SetWindowGrab(). As it stands
now, a grabbed mouse can briefly break out of the window, causing varying
degrees of chaos.
2021-04-26 18:43:28 -04:00
Sylvain 9727655b89
SDL_test_common: add other window flags: --shown, --hidden, --input-focus, --mouse-focus 2021-04-26 14:22:19 +02:00
Sylvain d62ebec260
SDL_test_common: replace 'resize' by 'resizable' 2021-04-26 14:10:39 +02:00
Ryan C. Gordon 1f482174b5
x11: Mark backing_store as NotUseful when creating windows.
This can give some performance boost, and save some resources, as there's no
reason to keep a copy of an SDL window's contents on the server: most SDL
apps are redrawing completely every frame, and the API allows for expose
events to tell an app a redraw is needed anyhow.

(And compositors are free to ignore this setting if it makes sense to do so,
according to the Xlib docs.)

Reference Issue #3776.
2021-04-25 12:44:35 -04:00
Ryan C. Gordon 9c063468d6
x11: call XSync before XSetInputFocus during SDL_ShowWindow.
This only happens when using a non-NET_WM window manager, as we might try to
set the focus before the window is mapped.

Fixes #3949.
2021-04-24 19:55:41 -04:00
Ozkan Sezer 89a2980a6d CMake: fixes to pthreads detection.
changes unnecessary check_c_source_runs to check_c_source_compiles,
removes the reduntant cross-compile check, and defines _GNU_SOURCE
for PTHREAD_MUTEX_RECURSIVE checks just like the autotools version.

Fixes: https://github.com/libsdl-org/SDL/issues/4262
Closes:  https://github.com/libsdl-org/SDL/pull/4282
2021-04-25 01:28:03 +03:00
Ivan Epifanov ca969eb2be Remove gles2 vita render 2021-04-24 14:13:09 -07:00
Ivan Epifanov 058bbe0286 Set volume on device open 2021-04-24 14:13:09 -07:00
Ivan Epifanov e3ea5b6468 Migrate to lightweight mutexes 2021-04-24 14:13:09 -07:00
Steven Noonan f1ad942a11 SDL_windows_main: use HeapAlloc/HeapFree for command line arguments
If a developer uses SDL_SetMemoryFunctions, we can't rely on SDL_free()
working when SDL_main() returns.

Signed-off-by: Steven Noonan <steven@valvesoftware.com>
Signed-off-by: Sam Lantinga <slouken@libsdl.org>
2021-04-22 17:26:13 -07:00
Steven Noonan 17d8479d98 hidapi/libusb: maintain in-memory cache of vendor/product strings
The get_usb_string call is rather expensive on some USB devices, so we
cache the vendor/product strings for future lookups (e.g. when
hid_enumerate is invoked again later).

This way, we only need to ask libusb for strings for devices we haven't
seen since before we started.

Signed-off-by: Steven Noonan <steven@valvesoftware.com>
Signed-off-by: Sam Lantinga <slouken@libsdl.org>
2021-04-22 16:40:23 -07:00
Steven Noonan 4535d65491 HIDAPI_UpdateDiscovery: only treat "add" and "remove" events as relevant
I have a buggy system which reports a udev "change" event for an empty
USB-C port every 0.14 seconds, which causes annoying frame hitches
because SDL decides that means it needs to do a libusb hid_enumerate,
which is slow (~25ms!) because of the get_usb_string() calls in there.

We only need to re-enumerate if we've seen a device added or removed, so
let's filter out the change event first.

Signed-off-by: Steven Noonan <steven@valvesoftware.com>
Signed-off-by: Sam Lantinga <slouken@libsdl.org>
2021-04-22 16:40:16 -07:00
Steven Noonan b15bbd4e3f SDL_udev: check for NULL return value from udev_device_get_action
Signed-off-by: Steven Noonan <steven@valvesoftware.com>
Signed-off-by: Sam Lantinga <slouken@libsdl.org>
2021-04-22 16:39:22 -07:00
Sylvain cf05a5eb0c
eglChooseConfig: only add EGL_DEPTH_SIZE if non 0
and fix static / shadowed variables warnings for dump configs
2021-04-22 21:40:57 +02:00
Sylvain 98a966d1c2
Android: don't need to set the SurfaceHolder format from java code
It's already set with ANativeWindow_setGeometry, and eventually set/changed also by eglCreateWindowSurface.
 - avoid issues with older device where SurfaceView cycle create/changed/destroy appears broken:
   calling create/changed/changed, and leading to "deuqueBuffer failed at server side, error: -19", with black screen.
 - re-read the format after egl window surface is created, to report the correct one (sometimes, changed from RGBA8888 to RGB24)
2021-04-22 18:06:17 +02:00
Ethan Lee 8e3ec34d34 wayland: Refactor toplevel mapping, implement HideWindow 2021-04-21 13:11:47 -04:00
Cacodemon345 0838f53d5a Implement SDL_SetWindowAlwaysOnTop for X11 2021-04-21 13:09:10 -04:00
Mathieu Eyraud a5825576fb Fix error handling of wayland message box
Zenity return a small integer on success which may be the same as EXIT_FAILURE. Use a bigger integer for error reporting from child process.
2021-04-21 09:53:39 -04:00
Mathieu Eyraud 12dd412b0b Fix icon of wayland message box
Also add some comments and silence a warning.

Co-authored-by: Ethan Lee <flibitijibibo@gmail.com>
2021-04-21 09:53:39 -04:00
meyraud705 d0cf3b7555 Return correct button id 2021-04-21 09:53:39 -04:00
meyraud705 1fd95c53b6 Disable pango markup in wayland massage box
Zenity support pango markup, add --no-markup to disable it.
2021-04-21 09:53:39 -04:00
meyraud705 0cd0e9ba98 Reimplement wayland message box function with execvp.
Previous version used 'popen' which required to sanitize user provided text. Not
sanitizing text could cause failure if user provided text included a " or command
injection with `cmd`.
2021-04-21 09:53:39 -04:00
Cacodemon345 99ef03b96e KMSDRM: Only use OpenBSD-specific defines on pre-6.9 releases 2021-04-20 19:44:55 -07:00
Joseph Lyncheski a0a5da5d91 Add SDL_SetWindowAlwaysOnTop() 2021-04-20 08:45:28 -07:00
Sylvain 6be9c00970
Android: prevent error EGL_BAD_DISPLAY while getting egl version without display
There is an error "E libEGL  : validate_display:91 error 3008 (EGL_BAD_DISPLAY)"
that occurs when calling "eglQueryString(display, EGL_VERSION)", with EGL_NO_DISPLAY.

Khronos says "EGL_BAD_DISPLAY is generated if display is not an EGL display connection, unless display is EGL_NO_DISPLAY and name is EGL_EXTENSIONS."
but this was added in SDL with "EGL 1.5 allows querying for client version"
( 56363ebf61 )

In fact:
- it actually doesn't work on Android that has 1.5 egl client
- it works on desktop X11 (using SDL_VIDEO_X11_FORCE_EGL=1)

The commit moves the version call where it's used, eg inside the "if (platform) {"
and checks that "eglGetPlatformDisplay" has been correctly loaded.
2021-04-20 13:46:25 +02:00
Ryan C. Gordon 03503423e9
filesystem: Better OpenBSD support for SDL_GetBasePath().
Fixes #3752.
2021-04-19 23:32:45 -04:00
ReNoM de6d290266 Fix keymap updating for X11 backend 2021-04-19 15:54:09 -04:00
Ethan Lee 509228c423 wayland: Implement GetDisplayDPI 2021-04-19 00:14:15 -04:00
Ethan Lee fcbfe33ce5 wayland: Implement SetWindowModalFor 2021-04-19 00:14:15 -04:00
Ethan Lee 213bfc194e wayland: Implement RestoreWindow for xdg/zxdg 2021-04-19 00:14:15 -04:00
Ethan Lee 0f51800229 wayland: Removed unused GetDisplayModes/SetDisplayMode functions 2021-04-19 00:14:15 -04:00
Ethan Lee 46df195b2a wayland: Implement GetDisplayBounds 2021-04-19 00:14:15 -04:00
Ethan Lee ed24c3452a wayland: Implement basic window move events via wl_surface_listener.
This unearthed an unspeakably large amount of bugs in the wl_output enumerator,
notably the fact that the wl_output user pointer was to temporary memory!
This was "fixed" in e862856, and was then pointed out as a leak in 4183211,
which was undone in d9ba204. The busted fix was correct that the malloc was an
issue, but wrong about _why_; SDL_AddVideoDisplay copies by value and does not
reuse the pointer, so generally you want your VideoDisplay to be on the stack,
but of course the callbacks don't allow that, so a malloc was a workaround. But
we can do better and just host our temporary display inside WaylandOutputData
because that will be persistent while also not leaking.

Wait, wasn't I talking about move events? Right, that: wl_surface_listener does
at least give us the ability to know what monitor we're on, even though we have
no idea where we are on the monitor. All we need to do is check the wl_output
against the display list and then push a move event that both indicates the
correct display while also not being _too_ much of a lie (but enough of a lie
to where our event doesn't get discarded as "undefined" or whatever). The index
check for the video display is what spawned the great nightmare you see before
you; aside from the bugfix this is actually a really basic patch.
2021-04-16 21:12:02 -07:00
Sylvain 859230ec82
Android: add AAudio entry in CMake SDL_config 2021-04-16 13:04:36 +02:00
Sylvain d4e96e1153
Android: enable audio driver OpenSLES when building with CMake 2021-04-16 09:44:07 +02:00