Commit Graph

5076 Commits

Author SHA1 Message Date
Ryan C. Gordon
2954b9168d cocoa: Run the CFRunLoop for 20ms during SDL_Quit().
This lets the OS remove windows that were destroyed in cases where we aren't
terminating the process right after calling SDL_Quit(). Otherwise, they'll
stay on the screen, unresponsive.

Apparently there is some animation state that needs to complete, and that is
handled via the runloop.

Fixes #10081.

(cherry picked from commit 4f477c807c)
2026-08-27 00:25:31 -04:00
Ryan C. Gordon
2776931725 emscripten: Don't fall back to simulating vsync if settings are still pending.
Fixes #16146.
Closes #16151.

(cherry picked from commit 618890f8fa)
2026-08-27 00:25:29 -04:00
Frank Praznik
0a80aefd49 wayland: Don't perform hit testing during implicit pointer grabs
Skip hit testing when an implicit grab is active, or button raise events may be lost, and the cursor icon may be improperly set if the client reports hit test results while the pointer is outside the window bounds.

(cherry picked from commit bc0a43ec7f)
2026-08-26 12:07:25 -04:00
Vlad Zahorodnii
4cbc0b06e2 x11: Skip announcing WM_TAKE_FOCUS in WM_PROTOCOLS
By putting the WM_TAKE_FOCUS atom in the WM_PROTOCOLS property, SDL
chooses either the "Locally Active" or "Globally Active" input model
depending on the input flag in WM_HINTS.

In order to assist the window manager with making the right decision,
for example, skip this window when choosing what window to activate
next, it will be better if the WM knows right away that the window
accepts or doesn't accept focus (in other words, have either both
the input flag set in WM_HINTS + WM_TAKE_FOCUS or none).

Since the WM_TAKE_FOCUS atom is placed in the WM_PROTOCOLS property, the
WM wanting to adhere to the spec has no choice but send a client message
asking to activate the window and hope for the better.

At quick glance, it appears that the WM_TAKE_FOCUS atom is leftover from
SDL_WINDOWEVENT_TAKE_FOCUS, which was dropped a while ago, and is not
used anymore. So this change removes the WM_TAKE_FOCUS atom to help
window managers such as kwin work better.

(cherry picked from commit 5e8eb0d4e7)
2026-08-25 12:42:21 -04:00
quasar32
32f1edb4b9 Hit test no longer executes when destroying wayland window
Signed-off-by: quasar32 <fontejam32@gmail.com>
(cherry picked from commit be51a15ba2)
2026-08-24 10:48:41 -04:00
Sam Clegg
5517f5adb1 [emscripten] Use keyEvent->key instead of deprecated charCode
keyEvent->charCode is deprecated in DOM Level 3 and marked deprecated
in Emscripten's html5.h. Use keyEvent->key instead.

(cherry picked from commit f0b84476f9)
2026-08-22 07:54:17 -07:00
Frank Praznik
15bc6cbdd4 wayland: Use the correct parameter type in the capabilities callback
The capabilities parameter is a uint32_t in the function signature in the header, not an enum.

Fixes a clang-tidy warning.

(cherry picked from commit 2afc369e8a)
2026-08-05 11:05:49 -04:00
Frank Praznik
bd9312a108 wayland: Fix a circular include issue
The event header being included before a header guard was hiding a circular include issue.

(cherry picked from commit b23ae0eec7)
2026-08-05 10:57:56 -04:00
Frank Praznik
759df98b36 wayland: Move include after the guard
(cherry picked from commit 2bf7014836)
2026-08-05 10:39:32 -04:00
Ryan C. Gordon
1ef4551c6d cocoa: SDL_GetClipboardData() needs to conform the mimetype.
Fixes #16077.

(cherry picked from commit f17fc121aa)
2026-08-03 11:52:29 -04:00
Ryan C. Gordon
c3e06fe741 cocoa: Use macOS 26.x mouse workaround for all windows, not just fullscreen.
This is a temporary workaround until we understand the issue better.

Reference Issue #15967.

(cherry picked from commit 958c4cbf0d)
2026-08-03 02:21:05 -04:00
Michal Trepka
cecc16ea51 cocoa: Workaround for an issue with incorrect window position after exiting fullscreen on some displays
Fix for https://github.com/libsdl-org/SDL/issues/15920

(cherry picked from commit f514394d1c)
2026-08-02 07:28:03 -07:00
Frank Praznik
105ad5e875 x11: Register the input context destroyed callback
Register the destroyed callback to handle cases where the IC is suddenly no longer valid (e.g. if ibus or fcitx dies).

(cherry picked from commit 63bf4c1c79)
2026-07-28 15:47:34 -04:00
Frank Praznik
01997ebebd wayland: Don't clear the clipboard when a nil selection is ignored
If the previous selection offering was recursive, a nil selection should be ignored, or clearing the clipboard may clear the backing memory of the client's selection offering as well.

(cherry picked from commit cc2713c047)
2026-07-22 12:10:06 -04:00
Hadrian Tang
0a7820fca3 Fix #15985
(cherry picked from commit a8591d943b)
2026-07-19 21:10:27 -07:00
Vlad Zahorodnii
3e536ede68 wayland: Add support for wl_fixes.ack_global_remove
The wl_fixes.ack_global_remove request signals the compositor that the
client will not bind the removed global. It can be used by the
compositor to decide when it is safe to actually destroy the
corresponding global. If a global is destroyed too soon, some clients may
get disconnected.

See also https://gitlab.freedesktop.org/wayland/wayland/-/merge_requests/533

(cherry picked from commit 6eba2f2efe)
2026-07-16 12:32:29 -04:00
Frank Praznik
7626a9c313 x11: Don't block when withdrawing unmapped windows
Some window managers will mark minimized or offscreen windows as unmapped. When hiding a window, unconditionally call XWithdrawWindow, and don't wait for an UnmapNotify event if the window is already in the unmapped state, or it will block indefinitely waiting for an event that never arrives.

(cherry picked from commit e442a9a5e1)
2026-07-15 12:05:33 -04:00
Frank Praznik
d8b18a7e18 cocoa: Clear state on failure to enter fullscreen
A fullscreen exit event doesn't always accompany an entry error, so ensure that all relevant state is cleared if the window fails to enter fullscreen.

(cherry picked from commit 1a9801a16f)
2026-07-15 11:32:24 -04:00
Frank Praznik
432719facc wayland: Refine window raising for new windows
Generate activation tokens for new windows when necessary, and check the hint for activating windows when shown. This will allow new windows to correctly take focus in environments with elevated focus stealing prevention when possible, and it will try to prevent new windows from being activated if the hint is set to false.

(cherry picked from commit 8586f63d2a)
2026-07-14 13:37:09 -04:00
meta-legend
af5b015b21 Avoid unnescessarily updating fullscreen display modes
(cherry picked from commit e90bdfb5ea)
2026-07-07 21:37:53 -07:00
Isabella Basso
27e6b7a119 cocoa: restore discrete mouse wheel ticks
(cherry picked from commit 1f3f714393)
2026-07-07 11:08:20 -04:00
Frank Praznik
6f0544dcca wayland: Fix incorrect dereference when sorting icon surfaces
(cherry picked from commit 2f1cf4629c)
2026-06-30 10:16:28 -04:00
Mason Remaley
25e2ec0407 Fixes invalid dereference in animated cursor sort
`Wayland_CreateAnimatedCursor` calls `SDL_qsort` on an array of
type `**SDL_Surface`, not on an array of `*SDL_Surface`. As such the void
pointers in the callback need to be casted to `SDL_Surface **` not
`SDL_Surface *`.

This was likely not caught since it's very unlikely that reading a few
bytes past the end of this array results in reading unreadable memory,
so the only side effect was invalid sort results, which is a bit subtle.

I caught this because I build SDL with UBSAN enabled in my debug builds,
and it trapped when the multiplication of the garbage `SDL_Surface*`
width and heights overflowed. I validated that the change is correct by
adding logs (that have then since been removed) demonstrating that it
was previously comparing garbage, and is now comparing the actual cursor
surfaces.

(cherry picked from commit a168e96cbc)
2026-06-30 09:54:32 -04:00
Frank Praznik
2ccd76818e win32: Use the current cursor coordinates when processing WM_NCACTIVATE
The event coordinates returned by GetMessagePos() for WM_NCACTIVATE are out of date if the cursor moved while an overlay was active, and may indicate that the cursor is still in the window when it is not. Always use the current cursor coordinates when processing this message to avoid incorrectly setting mouse focus if the cursor is no longer within the window.

(cherry picked from commit 0a8ccb11eb)
2026-06-29 12:39:36 -04:00
Sam Lantinga
1326f406a6 Removed unnecessary assert in WIN_SetWindowOpacity()
Fixes https://github.com/libsdl-org/SDL/issues/15896

(cherry picked from commit f0e99e7c7f)
2026-06-27 21:10:47 -07:00
Frank Praznik
1de0c4e0f0 wayland: Attach EGL objects to custom and external surfaces during reconfiguration
They are required when using EGL with an external surface.

(cherry picked from commit 06795b00ad)
2026-06-18 10:58:24 -04:00
Frank Praznik
2dc9006711 wayland: External windows are never hidden
Needed for the GPU renderer to function properly.

(cherry picked from commit dbfddb6409)
2026-06-18 10:58:24 -04:00
Sam Lantinga
c548acee53 Added SDL_HINT_ENABLE_STEAM_SCREEN_KEYBOARD
(cherry picked from commit c9b6581210)
2026-06-17 16:49:17 -07:00
Frank Praznik
b7b1f7843d EGL: Always pass the platform type when available
Always pass the EGL platform type for Wayland and X11, or the driver could potentially select the wrong backend if certain envvars are misconfigured.

(cherry picked from commit 34af24276f)
2026-06-12 10:26:51 -04:00
expikr
2e604c2bbb don't fetch timestamp again
(cherry picked from commit ed43ec0277)
2026-06-10 06:27:29 -07:00
Rachel Blackman
f6f1376cbd OpenVR: Actually quit correctly if we get a close/quit message.
(cherry picked from commit a7ecd5f777)
2026-05-27 17:40:58 -07:00
Sam Lantinga
9fe4e5cc87 Revert "android: fixed a possible joystick-related deadlock on application termination"
This reverts commit 6b4ae68460.

It turns out this deadlock is possible for any joystick event delivery combined with an event watcher that locks joysticks. I'm reverting this change for now, and will be working on a better global solution for this problem.

(cherry picked from commit 76560f9e47)
2026-05-27 13:08:45 -07:00
Frank Praznik
5dc7a5daed x11: Fix boolean/enum comparison
This could set the pending flag even if there was no state change requested, which would cause errant sync timeouts in certain situations.

(cherry picked from commit 6a3b0413dc)
2026-05-27 12:16:01 -04:00
Ryan C. Gordon
eee7164d9d x11: SetupWindowData shouldn't add to videodata->windowlist until success.
Fixes #15676.

(cherry picked from commit 22fb9edd5c)
2026-05-27 11:45:31 -04:00
Frank Praznik
483d86588c video: Only ignore modes with a lower color depth in SDL_GetClosestFullscreenDisplayMode()
If a mode with a closer refresh was found, but it had the same color depth as the current best match, it was being dropped. Only ignore the new mode if the color depth is below the current best match.

(cherry picked from commit cd0b796a6e)
2026-05-26 18:28:41 -04:00
Jason Millard
efe6062cf4 iOS: Fix SDL_EVENT_DROP_FILE lost on cold start from URL open
(cherry picked from commit 290f0c831f)
2026-05-22 07:17:06 -07:00
Vittorio Romeo
e8eba4a406 emscripten: dedupe keyboard event listeners across multiple windows
(cherry picked from commit 7f03da9588)
2026-05-22 07:11:44 -07:00
Sam Lantinga
9a1ba9f811 android: fixed a possible joystick-related deadlock on application termination
(cherry picked from commit 6b4ae68460)
2026-05-21 12:20:50 -07:00
Sam Lantinga
5bd0eb068c Fixed a rare crash on Raspberry Pi when creating a window
(cherry picked from commit 19d73016e8)
2026-05-20 15:11:26 -07:00
Sam Lantinga
257de23efc Fixed a rare crash on Raspberry Pi when creating a window
(cherry picked from commit 0dbd9d2a65)
2026-05-20 14:58:41 -07:00
Frank Praznik
b94ffff046 x11: Ignore slave button presses when the window lacks keyboard focus
XInput2 can send slave button presses before FocusIn events, which can confuse the click-through suppression logic. A window must have keyboard focus to grab the mouse anyway, so ignore slave presses when lacking keyboard focus.

(cherry picked from commit ef9a5b7040)
2026-05-20 13:08:47 -04:00
Frank Praznik
6f9205a3c3 x11: Reject click-through button events based on serial
XInput2 may send mouse buttons presses on both the master and slave devices, and the click-through button event should be ignored on both if required.

(cherry picked from commit 8371c09aa7)
2026-05-20 13:08:40 -04:00
Sam Lantinga
69300875ec Allow setting NULL palette on any surface
Fixes https://github.com/libsdl-org/SDL/issues/15654

(cherry picked from commit cfed9b3aca)
2026-05-19 14:22:37 -07:00
Frank Praznik
3b73938b5f video: Windows keep any position set when in fullscreen after leaving fullscreen
Adds an automated test for the behavior as well.

(cherry picked from commit f31ca02723)
2026-05-18 09:10:25 -07:00
Susko3
edad1c5563 Properly fix cursor position in Korean IME
(cherry picked from commit b608108593)
2026-05-18 09:02:23 -07:00
7aGiven
89fa8a4c0c fix Korean caret position
(cherry picked from commit 8e6fed2cbf)
2026-05-18 09:02:23 -07:00
7aGiven
7a4cce82eb WM_IME_SETCONTEXT not set 0
(cherry picked from commit 296231e999)
2026-05-18 07:05:26 -07:00
Frank Praznik
bf7c5e2df2 wayland: Implement Wayland_AcceptDragAndDrop()
This simply toggles a flag that rejects DnD offers if false. Events were previously dropped silently, but rejecting the offer makes some desktops display a proper icon when the drop will not work.

(cherry picked from commit 336d07c2b7)
2026-05-17 11:52:58 -04:00
Ozkan Sezer
e03ee2f0d9 SDL_opengl_glext.h, src/video/directx/d3d12.h: revert unintended changes from commit d70578b9aa
(cherry picked from commit 75c94e9b31)
2026-05-17 16:30:30 +03:00
Anonymous Maarten
f00b0291b3 surface: cannot set a palette to a non-indexed surface
This fixes a UBSAN warning later in this function where it calculates
(1 << SDL_BITSPERPIXEL(surface->format)). The bpp might be >= 32 and
out of range for a bit shift.

(cherry picked from commit d5af35e3fb)
2026-05-14 20:55:02 -07:00