Commit Graph

8468 Commits (2e9821423a237a1206e3c09020778faacfe430be)

Author SHA1 Message Date
Ethan Lee 1fb1aa1983 wayland: Keep the fullscreen check for maximize/restore events 2021-08-02 12:57:28 -04:00
Ethan Lee 584673a5a1 wayland: Don't ignore configs for non-fullscreen, non-resizable windows.
This was causing configure events to not inform SDL of window size
changes, even when they were based on resizes that we fully expected. The
result was fullscreen->windowed not working at all, because it would
retain the desktop resolution instead of reverting to the floating size
that it had before moving to fullscreen mode.

Fixes Super Hexagon fullscreen toggling.
2021-08-02 12:54:39 -04:00
Sebastian Krzyszkowiak 2506729893 wayland: Flush in SetWindowFullscreen
The flush has been removed in e5f9fae034.
Unfortunately, even though ideally the flush shouldn't be necessary,
our resize sequence isn't... well, perfect, and removing that flush causes
tons of troubles.

We're also still flushing in other paths where the window size can be
changed by the compositor and where we may potentially have to obey that
change, like in Wayland_MaximizeWindow.

This also removes the hack introduced in 7f261d3b76,
which introduces problems with protocol violations and seems to not be
necessary when flushing.
2021-08-02 12:18:23 -04:00
Sebastian Krzyszkowiak ea28187cd5 wayland: Hack surface resize into compliance with set_window_geometry
We have issues with correct resize sequence and happen to commit old-sized
buffers even after configure event for the new size has been already
acknowledged. While the reason for that stays unknown, let's at least
workaround the problem by faking window geometry into expected size.
This does not fix visual glitch on e.g. fullscreen toggling, but having
a split-second glitch is still a much better outcome than being
terminated by the compositor for protocol violation.
2021-08-02 12:18:23 -04:00
Sebastian Krzyszkowiak b5210cac44 wayland: Initialize floating size at window creation
This allows the windowed size to be restored for windows initially
created already in non-floating state.
2021-08-02 12:11:06 -04:00
Ethan Lee dab33844e3 wayland: Fix a warning in handle_configure_xdg_toplevel 2021-08-02 12:05:13 -04:00
Ethan Lee 754aa2d321 Mostly revert cfcdfb7be9.
This was causing window changes to completely break, resulting in broken
decorations and bizarre frame timing, I don't know what exactly it's doing
but it's not good. Kept the libdecor_frame_is_floating logic, at least.
2021-08-02 12:05:10 -04:00
Ethan Lee 8803589fc3 wayland: Avoid redundant SetWindowBordered for libdecor 2021-08-02 12:05:06 -04:00
Sebastian Krzyszkowiak b4c4060ad2 wayland: Clean up Wayland_HandlePendingResize
Commit 871c11191b removed delayed
resize handling, but it left the whole structure untouched that
now became unnecessary. To help with code clarity, get rid
of the structure where pending resize state used to be stored
and pass all the data directly to Wayland_HandlePendingResize
(now renamed to Wayland_HandleResize, since it's not "pending"
anymore but applied immediately)
2021-08-01 21:07:51 -07:00
Sebastian Krzyszkowiak 9bb24ad0cf wayland: Always call Wayland_SetWindowBordered when showing the window
Otherwise our windows have no window decoration on compositors that
support xdg-decoration-unstable-v1, but default to client-side mode.

Contrary to what the comment was stating, there is nothing in the protocol
that would make redundant calls to zxdg_toplevel_decoration_v1::set_mode
problematic.
2021-08-01 21:07:14 -07:00
Christian Rauch cfcdfb7be9 libdecor: use same fullscreen/maximised restore logic as for xdg-toplevel 2021-08-01 15:14:44 -07:00
Christian Rauch 42452f8ca5 wayland: store and restore floating states
Some Wayland compositors send (0,0) as "suggested" configure event sizes to
indicate that the client has to decide on its own which sizes to used. This
is commonly done when restoring from maximised, fullscreen or tiles states
to fullscreen.
We now store the last known floating states in a new set of variables and
restore them when we receive such a (0,0) configure event.
2021-08-01 15:14:44 -07:00
Sebastian Krzyszkowiak d4e1b4974a unix: OpenURL: Move unsetenv above vfork
From the vfork manpage:

> The  vfork()  function has the same effect as fork(2), except that
> the behavior is undefined if the process created by vfork() either
> modifies any data other than a variable of type pid_t used to store
> the return value from vfork(), or returns from the function in which
> vfork() was called, or calls any other function before successfully
> calling _exit(2) or one of the exec(3) family of functions.

unsetenv is still called inside a child process, so it does not
influence the rest of the application.
2021-08-01 03:58:49 -07:00
Sam Lantinga 9b7b928765 Clear LD_PRELOAD so Chrome opens correctly when this application is launched by Steam
This fixes https://github.com/libsdl-org/SDL/issues/4565
2021-07-31 23:28:59 -07:00
Sebastian Krzyszkowiak 54aea2446e wayland: Disable key repeat when repeat rate equals 0
This fixes a crash on pressing keyboard button when compositor sends
zero as repeat rate, indicating that key repeat should be disabled.

From Wayland protocol spec:

> Negative values for either rate or delay are illegal. A rate of zero
> will disable any repeating (regardless of the value of delay).
2021-07-31 21:40:27 -07:00
Sam Lantinga d784dd20b6 Updated WhatsNew with major changes for 2.0.16 2021-07-31 17:53:07 -07:00
Sam Lantinga b033cd0d2e Fixed XSync sequence to match other cases where we set the X11 error handler 2021-07-31 16:01:48 -07:00
Ozkan Sezer d373af044b CMakeLists.txt: update DYLIB_CURRENT_VERSION too 2.0.16 for release 2021-08-01 01:39:20 +03:00
Ryan C. Gordon 4c7825f6bd
x11: XSync while trying to catch XRRSetScreenSize error.
Reference issue #4561
2021-07-31 18:27:14 -04:00
Sam Lantinga cb1fd30e9a Updated to version 2.0.16 for release 2021-07-31 13:28:54 -07:00
Sam Lantinga 3e76646cc6 Added libSDLmain.a for iOS and tvOS 2021-07-31 13:10:05 -07:00
Ryan C. Gordon d0effadf68
x11: Don't let XRRSetScreenSize fire a BadMatch error.
This is a workaround and not a proper fix, but this is possibly complicated,
and possibly a corner case, so this will do for 2.0.16, if not the
foreseeable future.

Reference issue #4561
2021-07-31 15:58:31 -04:00
Sam Lantinga 3a4b217d6c Allow defining SDL_MAIN_HANDLED on iOS if you're using another runtime that provides an application delegate 2021-07-31 12:44:29 -07:00
Sam Lantinga deed21a83d Removed useless forward declaration 2021-07-31 12:44:11 -07:00
Sam Lantinga 1a9253f752 Removed unused IOS_DYLIB definition 2021-07-31 12:37:28 -07:00
Ethan Lee e5594e6677 wayland: Prefer our SSD implementation if available 2021-07-30 22:19:48 -07:00
Sam Lantinga 2d0075eff8 Updated comments for third party Nintendo Switch controllers 2021-07-30 18:23:43 -07:00
Sam Lantinga 16010f7561 Added support for the PowerA Nintendo Switch Fusion Arcade Stick 2021-07-30 18:23:43 -07:00
Sam Lantinga b33f470901 Fixed detection of the PDP Afterglow Wireless Switch Controller over Bluetooth 2021-07-30 18:23:42 -07:00
Sam Lantinga 6af6950dbc Added support for the Victrix Gambit Tournament Controller 2021-07-30 18:23:42 -07:00
Sam Lantinga 243a8836af The PowerA Nintendo Switch Fusion Pro Controller has a working USB mode, enabled via the switch on the underside of the controller. 2021-07-30 18:23:41 -07:00
Ethan Lee 71897cc1c9 wayland: Always trigger a resize when handling a configure event.
When we removed the OpenGL resize workaround it introduced a problem for
fullscreen windows in particular: When leaving fullscreen we tried to send a
resize event, but UpdateFullscreenMode would send a SIZE_CHANGED immediately
after, deleting our resize event and causing the following configure event's
resize to be ignored. This timing issue resulted in fullscreen windows not
being resized at all when becoming a floating window.

By always forcing resize events from configure events, we ensure that RESIZED
always makes it through. SetWindowSize-type changes should be unaffected as
they do not fire configure events.
2021-07-30 16:05:06 -04:00
David Gow 8f06a629aa render: Fix -Wmaybe-uninitialized warning in RenderDrawLinesWithRects{,F}
The RenderDrawLinesWithRects and RenderDrawLinesWithRectsF functions can
sometimes call QueueCmdFillRects() with the data pointed to by frects
uninitialised. This can occur if none of the lines can be replaced with
rects, in which case the frects array is empty, and nrects is 0.

gcc 10.3.0 will detect this possibility, and print a warning like:
/home/david/Development/SDL/src/render/SDL_render.c: In function 'RenderDrawLinesWithRectsF':
/home/david/Development/SDL/src/render/SDL_render.c:2725:15: warning: '<unknown>' may be used uninitialized [-Wmaybe-uninitialized]
 2725 |     retval += QueueCmdFillRects(renderer, frects, nrects);
      |               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/david/Development/SDL/src/render/SDL_render.c:499:1: note: by argument 2 of type 'const SDL_FRect *' to 'QueueCmdFillRects' declared here
  499 | QueueCmdFillRects(SDL_Renderer *renderer, const SDL_FRect * rects, const int count)
      | ^~~~~~~~~~~~~~~~~

This is harmless, because when this is uninitialised, nrects is always
0, so QueueCmdFillRects() does nothing anyway. We therefore can work
around this by only calling QueueCmdFillRects() when nrects is nonzero.
Somewhat impressively, gcc recognises that this is now safe.
2021-07-30 10:53:49 -04:00
Ethan Lee c20ab7dae9 wayland: Fix GetWindowWMInfo for <2.0.15 2021-07-30 00:16:52 -07:00
Ryan C. Gordon 585c11c5ae
direct3d: Fix possibly-incorrect scissor test when clearing.
Thanks to @JayFoxRox who did the detective work on this!

Fixes #3357.
2021-07-30 00:33:15 -04:00
Cameron Gutman 6f684f674e cocoa: Add keyboard grab support
CGSSetGlobalHotKeyOperatingMode() is not a public API, so we will only
compile this in if SDL_MAC_NO_SANDBOX=1 is defined during compilation.
2021-07-29 19:06:43 -07:00
Sam Lantinga 69518b9ecc Make sure we don't send a resize event while a window is being destroyed
This fixes https://github.com/libsdl-org/SDL/issues/3669
2021-07-29 17:09:24 -07:00
Sam Lantinga 3ababa09c5 Don't explicitly use any C runtime library with Visual Studio
Visual Studio will still use Multi-threaded DLL by default, but since we don't link with a C runtime we won't end up with any Visual Studio runtime dependency.

This fixes https://github.com/libsdl-org/SDL/issues/4328
2021-07-29 15:17:42 -07:00
Ryan C. Gordon 659e1f0a3f
audiocvt: The to-5.1 converters now soften FL and FR channels more.
This is experimental and might be tweaked further.

Reference #4104.

Also reference:

https://github.com/Keriew/augustus/issues/194#issuecomment-847655049
2021-07-29 17:55:59 -04:00
Christian Rauch f20a85818c commit after setting/unsetting limits 2021-07-29 14:55:03 -07:00
Sam Lantinga 9984891ba8 Use the wl_touch object as a touch ID on Wayland (thanks @russelltg!)
This fixes https://github.com/libsdl-org/SDL/issues/4517
2021-07-29 14:46:24 -07:00
Ethan Lee 74162b7401 wayland: Add support for text-input-unstable-v3 2021-07-29 14:43:46 -07:00
Jessica Clarke e4411505ab Don't pack SDL_AudioCVT on CHERI architectures
This is needed to support CHERI, and thus Arm's experimental Morello
prototype, where pointers are implemented using unforgeable capabilities
that include bounds and permissions metadata to provide fine-grained
spatial and referential memory safety, as well as revocation by sweeping
memory to provide heap temporal memory safety.

The referential safety is enforced through the use of tagged memory, and
there is only a single tag bit per capability-sized word, meaning it is
impossible to store capabilities at unaligned locations, either getting
a trap on load/store or the validity tag being stripped when
round-tripepd through memory.

Since this is a new ABI for which SDL has never been compiled before, we
do not need to be concerned with this compatibility measure, so just
don't pack the struct for CHERI architectures.

This code is inherently rather dubious anyway; if MSVC and GCC disagree
on struct layout when targeting Windows then that is a bug in GCC, but
likely extends from the bogus #pragma pack directives for MSVC in
begin_code.h, which will force types to be *underaligned* (and is
attempting to work around something that is fundamentally a broken idea
to be doing). In particular 8-byte-aligned types will be underaligned to
4 bytes, but only on MSVC.  Since that code is not used for GCC that is
probably the cause of the struct layout discrepancy, and there are
likely other instances of that throughout SDL. Moreover, the supposed
fix here is not in fact a fix, as now GCC will think SDL_AudioCVT is
only 1-byte-aligned but MSVC will think it's 4-byte or 8-byte-aligned,
meaning ABI incomatibility is introduced by this change. However,
removing it would break ABI compatibility for purely-GCC-compiled code
(as old binaries would see the struct as 1-byte-aligned and new binaries
would see the struct as 8-byte-aligned) so SDL is stuck with this until
it bumps its ABI.
2021-07-29 14:42:15 -07:00
Jessica Clarke 02daab8736 Fix pointer provenance in SDL_SIMDRealloc
This is needed to support CHERI, and thus Arm's experimental Morello
prototype, where pointers are implemented using unforgeable capabilities
that include bounds and permissions metadata to provide fine-grained
spatial and referential memory safety, as well as revocation by sweeping
memory to provide heap temporal memory safety.

The C standard does not guarantee that if two pointers compare equal
they are the same pointer, as C pointers have a notion of provenance,
and compilers have been known to exploit this during optimisation. For
CHERI, this becomes even more important, as in-place expansion can
result in realloc returning a capability to the same address but with
increased capability bounds, and so reusing the old capability will trap
trying to access outside the bounds of the original allocation.

In the case that ptr == mem, memdiff and ptrdiff should still be equal,
so the only overhead is a small amount of pointer arithmetic and a store
of the new pointer (which is required per the C standard in order to not
be undefined behaviour when next loaded).

This also fixes the calculation of oldmem to use uintptr_t rather than
size_t as casting the pointer to size_t on CHERI will strip the
capability metadata, including the validity tag, with the subsequent
cast back to void * resulting in a null-derived capability whose
validity tag is clear and thus cannot be dereferenced without trapping.
2021-07-29 14:42:15 -07:00
Jessica Clarke 8f38ba4d68 Fix casts that should be using uintptr_t
This is needed to support CHERI, and thus Arm's experimental Morello
prototype, where pointers are implemented using unforgeable capabilities
that include bounds and permissions metadata to provide fine-grained
spatial and referential memory safety, as well as revocation by sweeping
memory to provide heap temporal memory safety.

On most systems (anything with a flat memory hierarchy rather than using
segment-based addressing), size_t and uintptr_t are the same type.
However, on CHERI, size_t is just an integer offset, whereas uintptr_t
is still a capability as described above. Casting a pointer to size_t
will strip the metadata and validity tag, and casting from size_t to a
pointer will result in a null-derived capability whose validity tag is
not set, and thus cannot be dereferenced without faulting.

The audio and cursor casts were harmless as they intend to stuff an
integer into a pointer, but using uintptr_t is the idiomatic way to do
that and silences our compiler warnings (which our build tool makes
fatal by default as they often indicate real problems). The iconv and
egl casts were true positives as SDL_iconv_t and iconv_t are pointer
types, as is NativeDisplayType on most OSes, so this would have trapped
at run time when using the round-tripped pointers. The gles2 casts were
also harmless; the OpenGL API defines this argument to be a pointer type
(and uses the argument name "pointer"), but it in fact represents an
integer offset, so like audio and cursor the additional idiomatic cast
is needed to silence the warning.
2021-07-29 14:42:15 -07:00
Jessica Clarke c8b4edf3d0 Fix SDL_Event definition to support systems with pointers larger than 8 bytes
This is needed to support CHERI, and thus Arm's experimental Morello
prototype, where pointers are implemented using unforgeable capabilities
that include bounds and permissions metadata to provide fine-grained
spatial and referential memory safety, as well as revocation by sweeping
memory to provide heap temporal memory safety.
2021-07-29 14:42:15 -07:00
Sam Lantinga 9d457aa446 Don't uninitialize COM because of what appears to be a bug in Microsoft WGI reference counting.
This fixes https://github.com/libsdl-org/SDL/issues/4488
2021-07-29 14:25:13 -07:00
Sam Lantinga b3a0174b26 Scale the values correctly based on the sensor type (thanks @meyraud705) 2021-07-29 14:25:13 -07:00
Sam Lantinga 65ff00ec1b Query the rate for the correct sensor (thanks @meyraud705) 2021-07-29 14:25:13 -07:00
SDL Wiki Bot 72ee0ccdd5 Sync wiki -> header 2021-07-29 13:46:05 +00:00