Update the Wayland core protocol spec file and add support for the new axis_value120 event to handle high resolution scroll wheels.
The axis_value120 replaces the axis_discrete event, which is no longer sent as of version 8 of the protocol. Note that unlike the axis_discrete event, no mention in the spec is made regarding how many axis_value120 events may occur per-axis per-frame, so the values are accumulated and committed when the pointer frame event occurs.
The libdecor header internally includes wayland-client.h, which pulls in the wayland-client-protocol.h file from the system include path and overrides the local one generated from the included Wayland protocol spec files. Move the Wayland protocol header inclusion above the libdecor header inclusion to ensure that the locally generated protocol header is used instead.
This fixes linking to SDL2::SDL2-static on systems where external libraries such as X11 are not in a standard location.
Pthread also needs special care.
When minimizing a window, we get this sequence of events:
WM_WINDOWPOSCHANGING
WM_GETMINMAXINFO
WM_NCCALCSIZE
WM_WINDOWPOSCHANGED - IsIconic() is true
WM_MOVE
WM_SIZE - SDL sees minimized state here
When restoring a window, we get this sequence of events:
WM_WINDOWPOSCHANGING
WM_GETMINMAXINFO
WM_NCCALCSIZE
WM_NCPAINT
WM_ERASEBKGND
WM_WINDOWPOSCHANGED - IsIconic() is false
WM_MOVE
WM_SIZE - SDL sees restored state here
On Windows 10 a minimized window has a non-empty client rect, so we were delivering a minimized size before SDL knows that the window is minimized, and then ignoring the restored size when handling the restore message.
The fix is to use IsIconic() which returns the correct window state when WM_WINDOWPOSCHANGED is actually delivered.
Uses VK_EXT_metal_surface (vkCreateMetalSurfaceEXT)
when possible, otherwise falls back to the obsoleted
VK_MVK_macos_surface and VK_MVK_ios_surface.
Fixes#3906
If libdecor performs a commit with the frame title being undefined, a crash can occur within the library or its plugins. Always ensure that the title is set to a valid string to avoid this.
This prevents crashes when calling SDL joystick API functions from a different thread while disconnection is happening.
See https://github.com/libsdl-org/SDL/issues/6063 for a more thorough review of joystick locking.
Eliminate excessive calls to SetFullscreen by removing the calls in the libdecor and xdg-toplevel config callbacks.
These calls were being made there in case something explicitly called the window minimization function from within SDL, which unsets fullscreen, and as minimizing a window in Wayland is just a suggestion to the compositor and doesn't actually change the window state or communicate anything back to the application, it was necessary to call SetFullscreen in every call to the config functions just in case something minimized a window via SDL_MinimizeWindow() and later needed to restore it. GNOME in particular had issues when fullscreen set/unset operations were being hammered, leading to overlapping acks and commits when switching to fullscreen.
With the new video system flag to disable unsetting fullscreen when minimizing a window, these calls in the configuration functions are no longer needed and can be removed. This significantly reduces calls to the SetFullscreen() function, reverts #6044 while fixing the issue, and fixes a similar problem when hiding and showing a window initially created with fullscreen flags.
Add quirk flags to the video device struct and add flags to allow video backend drivers to disable mode switching and disable unsetting the fullscreen mode when minimizing a window. As certain platforms can have multiple video backends compiled in at once, #ifdefs, as used by other platforms, aren't suitable as different backends on the same platform may not need the same quirks.
This replaces the formerly dedicated 'disable_display_mode_switching' boolean as additional quirks are needed by the Wayland backend. Helper functions have also been added to simplify reading the flag states.
If the D-Bus subsystem is shutdown and restarted mid-execution, the cached connection will be invalid. Fetch it each time that it is used to ensure that the connection is always from the current context.
Don't call the roundtrip in ShowWindow unless restoring a previously hidden window. This fixes a regression in GNOME when creating a window with the fullscreen flag set, as the fullscreen window will be positioned down the screen by the height of the top bar if the window is made fullscreen on the primary display and the roundtrip is called when initially displaying the window.
SDL_CreateWindow() may call GetWindowDisplayIndex() to compute the position
of a new window that the caller has requested to be placed on a certain
display. Since we haven't fully constructed the window yet, our driverdata
will be nil and we will fail to get the NSScreen (which is fine). However,
we need to return an error (not 0, which is a valid display index) for
SDL_GetWindowDisplayIndex() to know to figure out the display index itself.
Fixes positioning new windows on secondary displays when using
SDL_WINDOWPOS_CENTERED_DISPLAY() and SDL_WINDOWPOS_UNDEFINED_DISPLAY().
OpenGL windows don't actually get the WM_WINDOWPOSCHANGED event in the SetWindowPos() call in WIN_SetWindowFullscreen(), so setting the window size to zero never gets reset and we're stuck with a zero sized window.
Instead, just force the resize event in WM_DPICHANGED handling, where we know we need it. If we end up needing to force it in WIN_SetWindowFullscreen(), just set a flag in the window data and respond to that in WM_WINDOWPOSCHANGED, but that's a fairly risky behavior change as suddenly all applications would start getting SDL_WINDOWEVENT_SIZE_CHANGED when going fullscreen, and they may respond to that in expensive and potentially disruptive ways.
For later we'll probably create a DPI changed event and respond to that in the renderer instead of this window size changed hack.
This fixes https://github.com/libsdl-org/SDL/issues/6033 @ericwa
The video core assumes that window->w/h will be updated before returning
from SetWindowFullscreen(). This is needed to generate a resize event
with the correct window size when exiting fullscreen.
The roundtrip allows us to receive the configure callback that informs
us of the new window size before returning.
Fixes#6043