Commit Graph

1456 Commits

Author SHA1 Message Date
Ethan Lee
e787282ba8 Implement Wayland_SetWindowResizable 2021-01-24 00:51:26 -05:00
Simon McVittie
c16cfc0e92 waylandtouch: Don't export interface structs
These are explicitly written in C code rather than generated at build
time, so they weren't affected by changing how we invoke
wayland-scanner.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2021-01-24 00:51:26 -05:00
Cameron Gutman
bd553ea868 Implement support for inhibiting the screensaver on Wayland
We support both the org.freedesktop.ScreenSaver D-Bus API (same as the X11
backend) and the Wayland idle_inhibit_unstable_v1 protocol.

Some Wayland compositors only support one or the other, so we need both to
for broad compatibility.
2021-01-24 00:51:25 -05:00
Cameron Gutman
7ff3832e4d Fix continuous scrolling speed on Wayland
Wayland compositors seem to have standardized on 10 units per "wheel tick" for
continuous scroll events, so we need to convert these axis values to ticks by
dividing by 10 before reporting them in SDL_MOUSEWHEEL events.
2021-01-24 00:51:25 -05:00
Cameron Gutman
8c921d8201 Implement keyboard grab support for Windows
This is implemented via a low-level keyboard hook. Unfortunately, this is
rather invasive, but it's how Microsoft recommends that it be done [0].
We want to do as little as possible in the hook, so we only intercept a few
crucial modifier keys there, while leaving other keys to the normal event
processing flow.

We will only install this hook if SDL_HINT_GRAB_KEYBOARD=1, which is not
the default. This will reduce any compatibility concerns to just the SDL
applications that explicitly ask for this behavior.

We also remove the hook when the grab is terminated to ensure that we're
not unnecessarily staying involved in key event processing when it's not
required anymore.

[0]: https://docs.microsoft.com/en-us/windows/win32/dxtecharts/disabling-shortcut-keys-in-games
2021-01-24 00:51:25 -05:00
Cameron Gutman
19236b462a Implement support for minimizing windows on Wayland
This required a bit of extra code to deal with the transition from minimized
back to fullscreen
2021-01-24 00:51:25 -05:00
Cameron Gutman
cf84ec441f Improve reliability of cursor hiding on GNOME Wayland
Hiding the cursor doesn't appear to work reliably on GNOME when another window
steals mouse focus right as we call SDL_ShowCursor(SDL_DISABLE). This can happen
when the keyboard shortcut inhibition permission prompt appears in response to a
call to SDL_SetRelativeMouseMode() with SDL_HINT_GRAB_KEYBOARD=1. The result is
that the default cursor is stuck locked in position and visible on screen
indefinitely.

By redrawing the cursor on pointer focus enter, the cursor now disappears upon
the first mouse motion event. It's not perfect but it's way better than the
current behavior.
2021-01-24 00:51:25 -05:00
Ozkan Sezer
b6ae9a7cba renamed my_gradd.h to SDL_gradd.h 2021-01-24 00:51:24 -05:00
Cameron Gutman
d789ba8332 Implement keyboard grab support for Wayland
Use zwp_keyboard_shortcuts_inhibit_manager_v1 to allow SDL applications
to capture system keyboard shortcuts like Alt+Tab when keyboard grab is
enabled via SDL_HINT_GRAB_KEYBOARD.
2021-01-24 00:51:24 -05:00
Manuel Alfayate Corchete
ee93f0edee [KMS/DRM] Revert unaproved fix for bug #5465. 2021-01-24 00:51:24 -05:00
Manuel Alfayate Corchete
e1d932f8b6 [KMS/DRM] Fix for bug #5468: corruption on dynamic cursor changing caused by wrong buffer size. 2021-01-24 00:51:24 -05:00
Manuel Alfayate Corchete
99facb1df3 [KMS/DRM] Fix for bug #5470: ratio correction for fullscreen windows with no matching resolution. Correct bracket position in else statements so they follow the coding style. 2021-01-24 00:51:24 -05:00
Manuel Alfayate Corchete
03665004d0 [KMS/DRM] Small fix to KMSDRM_Waitpageflip(). More comments on how it works. 2021-01-24 00:51:23 -05:00
Sam Lantinga
6a342954e8 Fixed bug 5451 - Can't create EGLSurface in Wayland from SDLWindow (no EGLNativeWindow pointer)
sashikknox

In some cases, need create EGLWindow with SDLWindow. In X11 i can get pointer to NativeWindow from **struct SDL_SysWMinfo wmInfo**
```C++
struct SDL_SysWMinfo wmInfo;
SDL_GetWindowWMInfo(ptSDLWindow, &wmInfo)
#if defined(__unix__) && defined(SDL_VIDEO_DRIVER_X11)
nativeWindow=(EGLNativeWindowType)wmInfo.info.x11.window;
nativeDisplay=(EGLNativeDisplayType)wmInfo.info.x11.display;
#endif
```
than i can create EGLSurface
```
eglCreateWindowSurface(nativeDisplay, EGL_CONFIG, nativeWindow, SURFACE_ATTRIBUTES);
```
in Wayland i can do it with same way, just need pointer to **EGLWindow**, we already have pointer to **wl_display** from **SDL_sysWMInfo**, need add to **wl** struct in SDL_SysWMInfo another pointer to **struct wl_egl_window *egl_window;**. And in wayland backend, in function **Wayland_GetWindowWMInfo** return pointer to **egl_window** from **SDL_WindowData**
Now i use patched statically built SDL2 in port of Quake 2 GLES2 for SailfishOS (it use QtWayland):
link to SDL2 commit and changed string for patch:
- 6858a618cd
- b1e29e87b9/SDL2/src/video/wayland/SDL_waylandwindow.c (L463)

link to use in Quake2 port:
1. here i get pointer to EGLNativeWindowType:  6d94fedb1b/Engine/Sources/Compatibility/OpenGLES/EGLWrapper.c (L319)
2. then use it for create EGLSurface: 6d94fedb1b/Engine/Sources/Compatibility/OpenGLES/EGLWrapper.c (L391)
2021-01-14 14:42:53 -08:00
Sam Lantinga
82aafa9aa8 Fixed bug 5461 - Add rewritten WSCONS driver for OpenBSD
wahil1976

This patch adds a written-from-scratch WSCONS driver for OpenBSD. It does not have hardcoded keymaps, and it features mouse support when wsmux is available.

For this to work, it needs access to the /dev/wskbd* devices which are not available to non-root users by default. Access to those can be granted by changing /etc/fbtab to give the logging user the ownership of those devices.
2021-01-14 14:32:11 -08:00
Manuel Alfayate Corchete
1adadc7702 [KMS/DRM] Adjust come return values. Improve comments. 2021-01-14 10:18:40 +01:00
Manuel Alfayate Corchete
57661e42c3 [KMS/DRM] Remove unused header. 2021-01-13 20:17:50 +01:00
Manuel Alfayate Corchete
ead3c406a2 [KMS/DRM] Refactor, improve and re-comment async pageflips code. 2021-01-13 20:11:01 +01:00
Manuel Alfayate Corchete
aac74db685 [KMS/DRM] Enable async pageflips. 2021-01-13 15:54:26 +01:00
Manuel Alfayate Corchete
9384e59561 [KMS/DRM] Add warning comentary to avoid future experiments with scaling. 2021-01-12 20:15:37 +01:00
Manuel Alfayate Corchete
8442754912 [KMS/DRM] Refactor KMSDR_CreateSurface to group all non-Vulkan stuff in a block. 2021-01-12 00:22:58 +01:00
Manuel Alfayate Corchete
87eb734c4e [KMS/DRM] Don't ask SDL to scale image when in Vulkan mode. 2021-01-11 23:59:40 +01:00
Manuel Alfayate Corchete
85e8adf78d [KMS/DRM] Unused code cleaning. 2021-01-11 22:28:27 +01:00
Manuel Alfayate Corchete
5105ecf8b1 [KMS/DRM] Move surface size info to window driverdata, for coherency. 2021-01-11 21:02:07 +01:00
Manuel Alfayate Corchete
2067a7db8e [KMS/DRM] Fix fullscreen to windowed transition. Fix aspect ratio correction without using planes. 2021-01-11 20:29:09 +01:00
Manuel Alfayate Corchete
850d9c8c0d [KMS/DRM] Cleanup remainings from plane/scaling usage. 2021-01-09 02:25:13 +01:00
Manuel Alfayate Corchete
2aeb317743 [KMS/DRM] Fix vkQuake3 in OpenGL mode. 2021-01-08 22:00:28 +01:00
Sam Lantinga
8746788fea KMSDRM_LEGACY is no longer legacy 2021-01-08 11:08:23 -08:00
Manuel Alfayate Corchete
b24494734b [KMS/DRM] Go back to the LEGACY interface only because using planes breaks compatibility with HW, so no advantage on using ATOMIC. 2021-01-08 18:57:12 +01:00
Manuel Alfayate Corchete
940e1b8dd9 [KMS/DRM] Small readability changes. 2021-01-08 16:33:50 +01:00
Manuel Alfayate Corchete
e5bf1850f5 [KMS/DRM] Fix cpmpilation warnings. Thanks to Ozkan Sezer for pointing this out! 2021-01-08 15:39:05 +01:00
Manuel Alfayate Corchete
cef1bd0639 [KMS/DRM] Prevent creating another default cursor everytime a window is created. Other fixes and cleanups. 2021-01-08 13:14:42 +01:00
Sam Lantinga
e778881ada Fixed bug 5449 - SDL_DROPFILE update mouse location of drop in Cocoa
Dominik Reichardt

Exult (http://exult.info) has an editor app that uses GTK+2. Up to now we were using X's drag'n'drop to allow dropping of assets from the editor onto Exult.
There is now an experimental branch that makes use of SDL_DROPFILE. That works under X, dropping in Exult's SDL2 window puts the asset right at the spot you dropped at.
On macOS with native Exult and Quartz GTK+2 this doesn't work, the location of the drop is where the mouse was last tracked before you left the window (usually one of the edges, unless you tabbed out).
All we tried out pointed to the fact that the location update needs to be done by the dropfile event in SDL2, not by our own (which always only worked after the Exult window getting focus).

This patch adds this to SDL_cocoawindow.m and it works perfectly, passing the correct coordinates to our code (SDL_GetMouseState()).
2021-01-07 11:49:28 -08:00
Manuel Alfayate Corchete
d079130c24 [KMS/DRM] Don't use primary plane for scaling because that's unsupported on most LEGACY-only HW. 2021-01-07 18:44:34 +01:00
Manuel Alfayate Corchete
e168d1138c [KMS/DRM] Correct drmModeSetCursor() dimensions. 2021-01-07 14:40:24 +01:00
Manuel Alfayate Corchete
335d78ff86 [KMS/DRM] Add the missing files for Vulkan support to the KMSDRM_LEGACY backend, had forgotted to do -hg add-. 2021-01-07 11:30:33 +01:00
Manuel Alfayate Corchete
661bacfe27 [KMS/DRM] Add Vulkan suport to the KMSDRM_LEGACY backend.Minor text spacing tweaks for better readability. Comment out unused function. 2021-01-07 00:47:21 +01:00
Ozkan Sezer
dfb0afe36a fix build after commit 5730b2005da1 2021-01-07 00:41:32 +03:00
Manuel Alfayate Corchete
67e0b1dd4e [KMS/DRM] Rewrite KMSDRM_LEGACY backend to accomodate Vulkan compatibility. Fix several bugs on that backend. 2021-01-06 22:15:26 +01:00
Ozkan Sezer
76295cecf3 video/windows: ANSI/UNICODE updates (cf. bug 5435):
- explicitly use UNICODE versions of DrawText, EnumDisplaySettings,
  EnumDisplayDevices, and CreateDC: the underlying structures have
  WCHAR strings.
- change WIN_UpdateDisplayMode and WIN_GetDisplayMode() to accept
  LPCWSTR instead of LPCTSTR for the same reason.
- change WIN_StringToUTF8 and WIN_UTF8ToString to the explicit 'W'
  versions where appropriate.
2021-01-05 15:50:10 +03:00
Ozkan Sezer
31751bdcce wmmsg.h: constified wmtab 2021-01-05 15:15:37 +03:00
Ozkan Sezer
390fd14f54 SDL_windowswindow.c (SDL_HelperWindowCreate): adjust for ANSI/UNICODE:
change SDL_HelperWindowClassName and SDL_HelperWindowName from WCHAR *
to be const TCHAR*

cf. bug #5435.
2021-01-04 01:23:50 +03:00
Ozkan Sezer
01a2f27679 consistently use TEXT() macro with LoadLibrary() and GetModuleHandle()
cf. bug #5435.
2021-01-04 01:23:50 +03:00
Sam Lantinga
393c8c1f16 Fixed bug 5440 - MacCatalyst build failures
C.W. Betts

I tested building commit http://hg.libsdl.org/SDL/rev/7adf3fdc19f3 on Mac Catalyst and found some issues:

* MTLFeatureSet_iOS_* enums aren't available under Mac Catalyst.
* OpenGL ES is unavailable under Mac Catalyst.
* Some Metal features are available under Catalyst but not iOS, such as displaySyncEnabled.
* Set Metal as the default renderer on Mac Catalyst

Attaching a patch that will make SDL2 build for Mac Catalyst.
2021-01-03 10:32:55 -08:00
Cameron Gutman
6cbd4417f0 Add a hint for D3D9Ex to avoid having to choose at compile-time 2021-01-02 14:45:15 -06:00
Sylvain Becker
fea49a3e2f SDL_stretch.c: compilation NEON on Windows 10 2021-01-03 15:24:47 +01:00
Sylvain Becker
acccc71f27 Fixed bug 5436 - MSVC 2019 ARM64 build fails to compile SDL_stretch.c 2021-01-02 22:31:44 +01:00
Sam Lantinga
9130f7c377 Updated copyright for 2021 2021-01-02 10:25:38 -08:00
Sam Lantinga
963c9495d3 Fixed bug 5431 - SDL_Metal_GetDrawableSize is inaccurate for high dpi displays if a Metal view has not already been created
Caleb Cornett

For a window created with SDL_WINDOW_ALLOW_HIGHDPI, SDL_GL_GetDrawableSize will return the high-dpi drawable size even before any GL context creation happens. But SDL_Metal_GetDrawableSize will return the size of the window if the Metal view has not been created. This is confusing and inconsistent behavior.

An easy way to test this is to build testgl2 and testvulkan on macOS with the SDL_WINDOW_ALLOW_HIGHDPI flag enabled during window creation. The GL2 program will report a drawable size of 2x window width and 2x window height, while the Vulkan program will report the window size.

This patch addresses the issue by falling back to using the content view dimensions if no Metal view exists in the window. (The code for this was taken directly from Cocoa_GL_GetDrawableSize.) With this change, the testvulkan behavior matches that of testgl2.

Note that I haven't tested for this issue on UIKit. It's possible a similar change will need to be made there too.
2021-01-02 10:11:08 -08:00
Sylvain Becker
c005267fb1 SDL_BlitScaled: better and safer fix clipping bug #2687
And re-use SDL_round(), since it's been re-added
(remove in https://hg.libsdl.org/SDL/rev/34043108b7e4 )
2021-01-02 09:38:19 +01:00