Commit Graph

128 Commits

Author SHA1 Message Date
Ethan Lee
57a927e8d7 wayland: Explicitly set min/max size for xdg-shell 2021-02-28 19:37:31 -08:00
Cameron Gutman
8c5b7af2d2 Wayland: Fix mouse pointer hiding on Plasma Wayland
Unlike Mutter and Sway, KWin actually checks the serial passed in
wl_pointer_set_cursor(). The serial provided is supposed to be the
serial of the pointer enter event, but We were always passing 0.
This caused KWin to drop our requests to hide the cursor.

Thanks to the KDE folks for spotting this in my debug logs.

Fixes #3576
2021-02-25 18:47:12 -08:00
Ethan Lee
a99eec7751 wayland: Minor whitespace fix 2021-02-13 02:41:29 +03:00
Ethan Lee
cad67082f3 wayland: Check for both _WAYLAND_CLIENT_H and WAYLAND_CLIENT_H 2021-02-11 14:27:08 -08:00
Sam Lantinga
629334f283 Fixed bug 5543 - Wayland: Fix waylandvideo.h warnings
wahil1976

This patch fixes the warnings seen when compiling the Wayland backend. This will also be required in the future to avoid issues with compilation.
2021-02-10 10:22:20 -05:00
Sam Lantinga
d9ba20442e Backed out changeset 852a7bdbdf4b
This causes a use-after-free memory error
2021-02-10 10:22:20 -05:00
Christian Rauch
4183211a54 free the 'display' after it was added to global list 2021-02-10 10:22:20 -05:00
Sam Lantinga
ff297753db Fixed compiler warning 2021-02-10 10:22:19 -05:00
Sebastian Krzyszkowiak
e862856e6f wayland: Don't crash when the properties of already existing wl_output change 2021-02-10 10:22:18 -05:00
Christian Rauch
0ed16ceddb free 'outputs' in 'Wayland_DestroyWindow' 2021-02-10 10:22:18 -05:00
Christian Rauch
a44678465f free the 'data_device_manager' 2021-02-10 10:22:18 -05:00
Sebastian Krzyszkowiak
3ae2ec34fa wayland: Fix transform and scale handling when setting display mode 2021-02-10 10:22:18 -05:00
Cameron Gutman
a0d3c6c63c Rename SetWindowGrab() to SetWindowMouseGrab() 2021-02-10 10:22:16 -05:00
Cameron Gutman
d133a5f6f7 wayland: cancel key repeat when keyboard focus is lost
SDL_SetKeyboardFocus(NULL) will lift any keys still pressed when keyboard focus
leaves the window, but then key repeat comes behind our backs and presses the
key down again. This results in an infinite stream of SDL_KEYDOWN events when
focus leaves the window with a key down (particularly noticeable with Alt+Tab).
2021-02-10 10:22:16 -05:00
Cameron Gutman
e1f73e642b Refactor keyboard grab to be managed by the video core
This gives us flexibility to add others hints to control keyboard grab behavior
without having to touch all of the backends. It also allows us to possibly
expose keyboard grab separately from mouse grab for applications that want to
manage those independently.
2021-02-10 10:22:16 -05:00
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
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
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
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
9130f7c377 Updated copyright for 2021 2021-01-02 10:25:38 -08:00
Sam Lantinga
cb36189692 Fixed bug 5235 - All internal sources should include SDL_assert.h
Ryan C. Gordon

We should really stick this in SDL_internal.h or something so it's always available.
2020-12-09 07:16:22 -08:00
Sam Lantinga
f311e0a826 Removed debug log message 2020-10-19 17:29:16 -07:00
Yiding Jia
f31ad57fde Implement keyboard repeat in wayland video driver 2020-10-05 19:17:52 -07:00
Ozkan Sezer
93e1449764 SDL_waylanddatamanager.c (mime_data_list_add): constify the buffer param
Fixes -Wdiscarded-qualifiers warnings from Wayland_data_source_add_data()
2020-10-14 15:50:04 +03:00
Sam Lantinga
76980e30f2 Added events for dynamically connecting and disconnecting displays, with an iOS implementation 2020-10-08 16:42:20 -07:00
Sam Lantinga
8709f67ebc Fixed bug 5215 - Fixing filenames passed to dlopen for OpenBSD
Brad Smith

Attached is a patch to use the proper filenames when trying to dlopen the respective shared libraries on OpenBSD.
2020-09-08 08:42:30 -07:00
Tudor Brindus
c094332825 wayland: defer pointer confine creation until pointer unlock
It is a protocol error to attempt to create a pointer confine (i.e.
`SDL_SetWindowGrab`) while a locked pointer is active, and vice-versa.
Instead of aborting due to a protocol error, this commit makes SDL
gracefully downgrade locked pointers to confines when appropriate.
2020-07-21 13:14:24 -04:00
M Stoeckl
a78b9763f1 Reuse Wayland connection from availability check 2020-07-14 19:18:16 -04:00
M Stoeckl
052a13738d Merge VideoBootStrap::available into VideoBootStrap::create
The two are only ever called together, and combining them makes it possible
to eliminate redundant symbol loading and redundant attempts to connect
to a display server.
2020-07-12 19:11:15 -04:00
Sam Lantinga
958c42827c Fixed build warning 2020-06-04 09:13:49 -07:00
Tudor Brindus
a6ca61d732 wayland: update pointer position on initial enter event 2020-05-21 00:06:09 -04:00
Ryan C. Gordon
aa259ed52d wayland: Changed output removal in handle_surface_leave()
No longer needs an extra malloc, handles unexpected cases like the same
output being listed twice.
2020-05-28 15:18:41 -04:00
Ryan C. Gordon
ce7ae4ec8d wayland: Move buffer copy into mime_data_list_add()
It makes it clearer who owns the memory, and more reasonable to free it on
failure in the creating function.

(and, of course, pacifies static analysis.)
2020-05-28 14:57:10 -04:00
Ryan C. Gordon
22da9d4d77 wayland: assert that mmap() didn't return NULL.
In practice, it never _would_, but in theory it _might_, so this assertion
tells the static analyzer not to worry about it.
2020-05-28 14:47:55 -04:00
Tudor Brindus
1a291ab118 wayland: add support for SDL_SetWindowGrab 2020-04-17 13:55:44 -04:00
Sam Lantinga
0eb6512b53 Fixed bug 5121 - Use SDL_calloc instead of calloc in Wayland_CreateWindow
meyraud705

'SDL_Windows::driverdata' of a Wayland window is allocated by calloc in 'Wayland_CreateWindow' but freed by SDL_free in 'Wayland_DestroyWindow'.
2020-05-04 13:19:26 -07:00
Ryan C. Gordon
024698779b wayland: Support wayland compositors with wl_seat version < 5 (thanks, Nia!).
Fixes Bugzilla #5074.
2020-04-07 13:30:46 -04:00
Sam Lantinga
b6afbe6317 Added SDL_log.h to SDL_internal.h so logging is available everywhere 2020-04-07 09:38:57 -07:00
Ryan C. Gordon
a77a890d4a wayland: Don't delay pending surface resize handling on Vulkan.
OpenGL apparently needs to not do any drawing between wl_egl_window_resize
and eglSwapBuffers, but Vulkan apps don't use SDL to present, so they
never call into an equivalent of SDL_GL_SwapWindow where our Wayland code
was handling pending resize work.

Fixes Bugzilla #4722.
2020-02-14 00:58:36 -05:00
Ryan C. Gordon
7ad77bccb2 wayland: Don't force the window into OpenGL mode if we want Vulkan. 2020-02-14 01:08:21 -05:00
Ryan C. Gordon
4378fcd9a7 wayland: Fix building with -fno-common (which is now the default in GCC 10).
Fixes Bugzilla #4957.
2020-02-10 23:48:06 -05:00
Sam Lantinga
67f4478867 Fixed bug 4917 - Wayland: handle discrete pointer axis events
Luis Caceres

The current handling of Wayland mouse pointer events only handles wl_pointer.axis events, which, according to the Wayland documentation, deal with mouse wheel scroll events on a continuous scale. While this is reasonable for some input sources (e.g. touchpad two-finger scrolling), it is not for mouse wheel clicks which generate wl_pointer.axis events with large deltas.

This patch adds handling for wl_pointer.axis_discrete and wl_pointer.frame events and prefers to report SDL_MouseWheelEvent in discrete units if they are available. This means that for mouse wheel scrolling we count in clicks, but for touchpad two-finger scrolling we still use whatever units Wayland uses. This behaviour is closer to that of the X11 backend.

Since these events are only available since version 5 of the wl_seat interface, this patch also checks for this and falls back to the previous behaviour if its not available. I also had to add definitions for some of the pointer and keyboard events specified in versions 2-5 but these are just stubs and do nothing.
2020-02-03 00:57:12 -08:00
Sam Lantinga
a8780c6a28 Updated copyright date for 2020 2020-01-16 20:49:25 -08:00
Michael Forney
cdbeae521e wayland: support wl_data_device_manager version < 3 2019-12-29 23:10:39 -08:00
Sylvain Becker
88ba6798e9 Wayland: touch events, use of memory after it is freed 2019-10-30 21:12:36 +01:00
Sylvain Becker
86ae245bc0 Use correct enum: typo in org_kde_kwin_server_decoration_mode
instead of org_kde_kwin_server_decoration_manager_mode
2019-10-30 17:59:20 +01:00