src/video/wayland/SDL_waylandwindow.c


Log

Author Commit Date CI Message
meyraud705 4ada14a2 2021-07-21T13:39:10 Replace libc functions to SDL equivalent in wayland video subsystem Wayland video subsystem uses a mix of libc and SDL function. This patch switches libc functions to SDL ones and fixes a mismatch in memory allocation/dealoccation of SDL_Cursor in SDL_waylandmouse.c (calloc on line 201 and SDL_free on line 313) which caused memory corruption if custom memory allocator where provided to SDL.
Ethan Lee 7f261d3b 2021-06-15T00:35:13 wayland: Fix returning to a window from fullscreen without calling SetWindowSize
Ethan Lee d956636c 2021-06-04T18:39:47 wayland: Implement FlashWindow
Ethan Lee 2af3f64e 2021-06-02T14:37:09 wayland: Activate the window on first ShowWindow, if possible
Ethan Lee 151f9538 2021-06-02T11:41:44 wayland: Implement RaiseWindow with xdg-activation
Ethan Lee d3244035 2021-05-17T01:24:35 wayland: Add support for maximized/restored events
Ethan Lee f2f451a5 2021-05-10T13:29:54 wayland: Call SetWindowBordered at the end of ShowWindow
Ethan Lee efbb6ff9 2021-05-10T12:42:28 wayland: Create the server decorations after the toplevel has been configured
Ethan Lee c69fde34 2021-05-02T16:43:01 wayland: Maximize/Restore should set the relevant window flags. Also, Maximize should be ignored for fixed-size windows.
Christian Rauch 006378b9 2021-05-02T18:30:32 fix NULL frame_callback access
Christian Rauch 424bbaec 2021-05-01T18:53:12 wayland: destroy frame callback when window is destroyed
Ethan Lee 20928550 2021-05-01T09:00:24 wayland: Guard surface_frame_listener for OpenGL, document why it exists
Ryan C. Gordon c54c16d3 2021-04-30T13:19:36 wayland: don't hang in SDL_GL_SwapBuffers if the compositor is ghosting us. If you hide a window on Mutter, for example, the compositor never requests new frames, which will cause Mesa to block forever in eglSwapBuffers to satisfy the swap interval. We now always set the swap interval to 0 and manage this ourselves, handing the frame to Wayland when it requests a new one, and timing out at 10fps just to keep apps moving if the compositor wants no frames at all. My understanding is that other protocols are coming that might improve upon this solution, but for now it solves the total hang. Fixes #4335.
Ethan Lee 8e3ec34d 2021-04-20T12:40:40 wayland: Refactor toplevel mapping, implement HideWindow
Ethan Lee fcbfe33c 2021-04-18T09:45:22 wayland: Implement SetWindowModalFor
Ethan Lee 213bfc19 2021-04-18T09:36:54 wayland: Implement RestoreWindow for xdg/zxdg
Ethan Lee ed24c345 2021-04-16T21:35:50 wayland: Implement basic window move events via wl_surface_listener. This unearthed an unspeakably large amount of bugs in the wl_output enumerator, notably the fact that the wl_output user pointer was to temporary memory! This was "fixed" in e862856, and was then pointed out as a leak in 4183211, which was undone in d9ba204. The busted fix was correct that the malloc was an issue, but wrong about _why_; SDL_AddVideoDisplay copies by value and does not reuse the pointer, so generally you want your VideoDisplay to be on the stack, but of course the callbacks don't allow that, so a malloc was a workaround. But we can do better and just host our temporary display inside WaylandOutputData because that will be persistent while also not leaking. Wait, wasn't I talking about move events? Right, that: wl_surface_listener does at least give us the ability to know what monitor we're on, even though we have no idea where we are on the monitor. All we need to do is check the wl_output against the display list and then push a move event that both indicates the correct display while also not being _too_ much of a lie (but enough of a lie to where our event doesn't get discarded as "undefined" or whatever). The index check for the video display is what spawned the great nightmare you see before you; aside from the bugfix this is actually a really basic patch.
David Edmundson f6a09ef1 2021-04-07T16:16:23 wayland: Drop support for kwin specific decoration management KWin has supported the shared and formalised zxdg_decoration since Plasma 5.16 which came out mid 2019. Whilst it made sense to support them both for a while, it should not be needed for future SDL releases.
Ethan Lee a92cca1a 2021-04-07T16:44:10 wayland: Use the window's display to get wl_output rather than fullscreen_mode. Because Wayland only supports FULLSCREEN_DESKTOP, fullscreen_mode never gets assigned at all, meaning driverdata is always NULL! Depending on what the compositor does this can lead to dramatically different results. GNOME was fine without this, but Plasma would trip an event that unintentionally unset the fullscreen mode and caused the game to fire a configure event _every frame_, and of course the configure would send the fullscreen_mode output which was still empty. The fix is to just use the SDL_VideoDisplay directly, which will always have a valid wl_output.
Ethan Lee c7e29a9e 2021-04-06T18:10:40 wayland: Fix toggling fullscreen with fixed-size windows
Ethan Lee 57a927e8 2021-02-12T14:27:58 wayland: Explicitly set min/max size for xdg-shell
Ethan Lee a99eec77 2021-02-12T14:31:43 wayland: Minor whitespace fix
Sebastian Krzyszkowiak e862856e 2021-02-01T08:57:39 wayland: Don't crash when the properties of already existing wl_output change
Christian Rauch 0ed16ced 2021-01-31T19:10:02 free 'outputs' in 'Wayland_DestroyWindow'
Cameron Gutman a0d3c6c6 2021-01-25T21:42:14 Rename SetWindowGrab() to SetWindowMouseGrab()
Cameron Gutman e1f73e64 2021-01-23T16:22:44 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.
Ethan Lee e787282b 2021-01-23T15:40:22 Implement Wayland_SetWindowResizable
Cameron Gutman bd553ea8 2021-01-20T21:17:20 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.
Cameron Gutman 19236b46 2021-01-21T21:49:13 Implement support for minimizing windows on Wayland This required a bit of extra code to deal with the transition from minimized back to fullscreen
Cameron Gutman d789ba83 2021-01-19T18:20:07 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.
Sam Lantinga 6a342954 2021-01-14T14:42:53 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: - https://github.com/savegame/lp-public/commit/6858a618cd179b766fe3cab36055f07cb03ad0ea - https://github.com/savegame/lp-public/blob/b1e29e87b9d15780e47f04918b329ac15554fc69/SDL2/src/video/wayland/SDL_waylandwindow.c#L463 link to use in Quake2 port: 1. here i get pointer to EGLNativeWindowType: https://github.com/savegame/lp-public/blob/6d94fedb1b720da24999ae6286a1809cd3d55ff5/Engine/Sources/Compatibility/OpenGLES/EGLWrapper.c#L319 2. then use it for create EGLSurface: https://github.com/savegame/lp-public/blob/6d94fedb1b720da24999ae6286a1809cd3d55ff5/Engine/Sources/Compatibility/OpenGLES/EGLWrapper.c#L391
Sam Lantinga 9130f7c3 2021-01-02T10:25:38 Updated copyright for 2021
Sam Lantinga 958c4282 2020-06-04T09:13:49 Fixed build warning
Ryan C. Gordon aa259ed5 2020-05-28T15:18:41 wayland: Changed output removal in handle_surface_leave() No longer needs an extra malloc, handles unexpected cases like the same output being listed twice.
Sam Lantinga 0eb6512b 2020-05-04T13:19:26 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'.
Tudor Brindus 1a291ab1 2020-04-17T13:55:44 wayland: add support for SDL_SetWindowGrab
Ryan C. Gordon 7ad77bcc 2020-02-14T01:08:21 wayland: Don't force the window into OpenGL mode if we want Vulkan.
Ryan C. Gordon a77a890d 2020-02-14T00:58:36 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.
Sam Lantinga a8780c6a 2020-01-16T20:49:25 Updated copyright date for 2020
Sylvain Becker 86ae245b 2019-10-30T17:59:20 Use correct enum: typo in org_kde_kwin_server_decoration_mode instead of org_kde_kwin_server_decoration_manager_mode
Ryan C. Gordon d0fa93d6 2019-06-19T00:52:34 wayland: Fixed C99-style variable declaration inside for-loop.
Sebastian Krzyszkowiak 797b2813 2019-06-12T00:55:05 wayland: HiDPI support
Sam Lantinga 5e13087b 2019-01-04T22:01:14 Updated copyright for 2019
Sebastian Krzyszkowiak 48917e0e 2018-11-07T01:08:35 wayland: fix resizing and fullscreen toggling For starters, we need to correctly respond to 0,0 configure after unsetting fullscreen. Also, turns out that there should be no drawing calls at all in between eglSwapBuffers and wl_egl_window_resize, as otherwise EGL can already allocate a wrongly sized buffer for a next frame, so handle those together.
Sebastian Krzyszkowiak 5f980514 2018-11-04T21:08:40 wayland: ask xdg-decoration protocol extension to use server-side decorations if possible.
Ryan C. Gordon 62494a2e 2018-10-31T15:03:41 Merge SDL-ryan-batching-renderer branch to default.
Ryan C. Gordon a5ebd4d7 2018-10-29T10:14:59 wayland: ask KDE protocol extension to use server-side decorations if possible.
Ryan C. Gordon 367f9b91 2018-10-05T17:24:03 wayland: Fixed missing window sizing events. Fixes Bugzilla #4242.
Sam Lantinga 5febdfce 2018-09-24T11:49:25 Fixed whitespace
Ryan C. Gordon c8ac9096 2018-06-24T22:42:36 wayland: Implemented xdg-wm-base support. This is just in parity with the existing zxdg-shell-unstable-v6 code. Making the Wayland target robust (and uh, with title bars) is going to take a lot of work on top of this.
Ryan C. Gordon 2df59062 2018-04-15T17:42:09 wayland: zxdg_shell_v6 needs a configure event before using a surface at all. Fixes Bugzilla #4109. Fixes Bugzilla #4119.
Ryan C. Gordon cd532207 2018-02-07T13:13:55 wayland: Add support for xdg-shell protocol (unstable v6). This is meant to be the desktop-enhanced version of wl_shell. Right now we just match what the existing wl_shell code does, but there are other areas of functionality available to us now, that we can fill in later. This uses the "unstable" API, since this is what ships in Ubuntu 17.10 (as part of Wayland 1.10), but Wayland 1.12 promotes this to stable with extremely minor changes. We will add support for the stable version when it makes sense to do so.
Sam Lantinga e3cc5b2c 2018-01-03T10:03:25 Updated copyright for 2018
Sam Lantinga de91b124 2017-08-14T06:28:21 Fixed bug 3745 - specify SDLCALL as the calling convention for API callbacks Patches contributed by Ozkan Sezer
Philipp Wiesemann fbd30c36 2017-06-11T22:30:39 Fixed missing error messages for SDL_GetWindowWMInfo().
Ryan C. Gordon 3c955d05 2017-06-11T00:50:26 syswm: prevent buffer overflow if SDL and app have different config headers. This only affects Wayland and DirectFB, as a Unix system generally has X11 support. Other platforms also have different sizes for the C union in question, but are likely the only target for that platform, etc. Apps that might run on Wayland or DirectFB will need to be compiled against new headers from an official 2.0.6 release, or be prepared to force the x11 target, or not use SDL_GetWindowWMInfo(). Fixes Bugzilla #3428.
Sam Lantinga 45b774e3 2017-01-01T18:33:28 Updated copyright for 2017
Thomas Perl acce8659 2016-11-13T10:39:04 [qtwayland] Set orientation and window flags via SDL hints
Sam Lantinga eea76fc1 2016-10-07T18:11:03 Fixed bug 3063 - Wayland: SDL resizes EGL surface to 0x0. x414e54 Wayland will sometimes send empty resize events (0 width and 0 height) to the client. I have not worked out the exact conditions a client would receive these but I can assume it might be if the window is offscreen or not mapped yet. This causes issues with some SDL clients as they receive the 0x0 event and unexpected resize event or might not request to resize back to the correct size. As per the wl_shell Wayland spec configure events are only a suggestion and the client is free to ignore or pick a different size (this is how min/max and fixed aspect ratio is supped to be implemented). A patch is attached but is just the first iteration and I will fix any issues such as checking for FULLSCREEN/MAXIMIZED or RESIZABLE flags unless someone else fixes this first. I have update to take into account non resizable and fullscreen windows. Also adding in maximize/restore and title functions for Wayland.
Sam Lantinga f11a4409 2016-09-01T01:26:56 wayland: Add support for relative mouse mode, by Jonas ?dahl <jadahl@gmail.com> Generate the C protocol files from the protocol XML files installed by wayland-protocols, and use them to implement support for relative pointer motions and pointer locking. Note that at the time, the protocol is unstable and may change in the future. Any future breaking changes will, however, fail gracefully and result in no regressions compared to before this patch.
Bastien Nocera 736a624d 2016-09-01T01:22:58 Wayland: Set "class" for each window we create This will be used by Wayland compositors to match the application ID and .desktop file to the SDL window(s). Applications can set the SDL_VIDEO_WAYLAND_WMCLASS environemnt variable early in the process to override using the binary name as a fallback. Note that we also support the SDL_VIDEO_X11_WMCLASS in the Wayland backend so that if a program correctly associated the desktop file with the window under X11, only a newer SDL would be needed for it to work under Wayland. https://bugzilla.libsdl.org/show_bug.cgi?id=3376
Sam Lantinga 42065e78 2016-01-02T10:10:34 Updated copyright to 2016
Philipp Wiesemann 0e45984f 2015-06-21T17:33:46 Fixed crash if initialization of EGL failed but was tried again later. The internal function SDL_EGL_LoadLibrary() did not delete and remove a mostly uninitialized data structure if loading the library first failed. A later try to use EGL then skipped initialization and assumed it was previously successful because the data structure now already existed. This led to at least one crash in the internal function SDL_EGL_ChooseConfig() because a NULL pointer was dereferenced to make a call to eglBindAPI().
Sam Lantinga 2c4a6ea0 2015-05-26T06:27:46 Updated the copyright year to 2015
Ryan C. Gordon b72938c8 2015-04-20T12:22:44 Windows: Always set the system timer resolution to 1ms by default. An existing hint lets apps that don't need the timer resolution changed avoid this, to save battery, etc, but this fixes several problems in timing, audio callbacks not firing fast enough, etc. Fixes Bugzilla #2944.
Ryan C. Gordon d10201be 2015-04-12T20:40:06 Implemented SetWindowHitTest() for Wayland (thanks, x414e54!). Fixes Bugzilla #2941.
Alex Szpakowski fe6c797c 2015-04-10T23:30:31 Fixed an iOS view orientation issue when SDL_GL_CreateContext or SDL_CreateRenderer is called.
Philipp Wiesemann ce2d5f70 2015-04-10T23:44:55 Wayland: Removed empty statement.
Philipp Wiesemann 8a573844 2015-04-09T21:11:43 Wayland: Fixed accessing not fully initialized window if no memory available. The CreateWindow() implementation returned 0 on no more memory instead of -1.
Ryan C. Gordon 9a686aaa 2015-04-07T22:49:56 Wayland: changed a few "SetError(); return -1;" to "return SetError()".
Emmanuel Gil Peyrot b620df3e 2015-03-28T19:43:46 Wayland: Specify the output we want to put our window on. Fixes Bugzilla #2803.
Emmanuel Gil Peyrot 89be609a 2015-03-18T01:14:45 Wayland: Properly discover displays and their modes. Fixes Bugzilla #2913.
Edward Rudd b88ca1b4 2015-02-10T16:28:56 the last parameter of XChangeProperty is the number of elements.. and when the element format is 32.. the element is "long" so we have 5 long elements here. Yes this seems confusing as on mac+linux Long is either 32 or 64bits depending on the architecture, but this is how the X11 protocol is defined. Thus 5 is the correct value for the nelts here. Not 5 or 10 depending on the architecture. More info on the confusion https://bugs.freedesktop.org/show_bug.cgi?id=16802
Philipp Wiesemann b48e54aa 2015-01-26T22:00:29 Fixed bug 2802 - [patch] Fix android build compiling in wrong filesystem implementation Jonas Kulla The configure script didn't differentiate between Linux and Android, unconditionally compiling in the unix implementation of SDL_sysfilesystem.c. I'm probably one of the very few people building SDL for android using classic configure + standalone toolchain, so this has gone undetected all along.
Arne Janbu aefcd86d 2015-01-10T13:47:37 Fix build on Linux when wayland is enabled Bug: https://bugzilla.libsdl.org/show_bug.cgi?id=2838
David Ludwig 70438be2 2014-12-03T10:55:23 WinRT: fixed bug whereby SDL would override an app's default orientation WinRT apps can set a default, preferred orientation via a .appxmanifest file. SDL was overriding this on app startup, and making the app use all possible orientations (landscape and portrait). Thanks to Eric Wing for the heads up on this!
Philipp Wiesemann 9c398852 2014-11-22T22:20:40 Corrected header file documentation comment.
Pierre-Loup A. Griffais 24c86b55 2014-09-11T19:24:42 [X11] Reconcile logical keyboard state with physical state on FocusIn since the window system doesn't do it for us like other platforms. This prevents sticky keys and missed keys when going in and out of focus, for example Alt would appear to stick if switching away from an SDL app with Alt-Tab and had to be pressed again. CR: Sam
Sam Lantinga d44f3922 2014-07-07T10:33:32 Fixed bug 2629 - Mac: crash when calling SDL_DestroyWindow with an active OpenGL context Alex Szpakowski Since this commit https://hg.libsdl.org/SDL/rev/59b543340d63 , calling SDL_DestroyWindow will crash the program if the window has an active OpenGL context. This is because the Cocoa_DestroyWindow code sets the window's driverdata to NULL and then calls [context setWindow:NULL], which tries to access the window's driverdata, resulting in a null pointer dereference. I have attached a patch which fixes the issue by moving the line which sets the driverdata to NULL to after the lines which call functions that use the driverdata pointer.
Gabriel Jacobo de0d349e 2014-05-10T16:50:05 Fixes #2512, handle configuration change messages sent by Wayland. Patch by Bryan Cain.
David Ludwig 3dcb451f 2014-04-09T21:29:19 Added a README file regarding WinRT support To note, this file is currently formatted with CRLF line endings, rather than LF, to allow the file to be viewed with Notepad.
Thomas Perl 929fd90e 2014-04-05T17:19:34 Wayland: Resize windows with 0x0 requested size to screen size This makes it in line with other platforms, where SDL_CreateWindow() with width=0, height=0 and SDL_WINDOW_FULLSCREEN opens a fullscreen window.
Sam Lantinga 58edac3e 2014-02-02T00:53:27 Fixed bug 2374 - Update copyright for 2014... Is it that time already??
Ryan C. Gordon 2ddd0c58 2014-01-20T12:53:44 Patched to compile if Wayland is disabled via SDL_config.h (thanks, Martin!). Fixes Bugzilla #2351.
Gabriel Jacobo 272ebb8e 2014-01-09T13:56:21 Dynamic loading support for Wayland
Gabriel Jacobo fce6257c 2013-12-27T09:29:39 Implements touch support on QTWayland. Contributed by Thomas Perl.
Gabriel Jacobo ec1cb49e 2013-12-14T20:18:43 Wayland support Based on the original port to Wayland by: Joel Teichroeb, Benjamin Franzke, Scott Moreau, et al. Additional changes in this commit, done by me: * Wayland uses the common EGL framework * EGL can now create a desktop OpenGL context * testgl2 loads GL functions dynamically, no need to link to libGL anymore * Assorted fixes to the Wayland backend Tested on the Weston Compositor (v1.0.5) that ships with Ubuntu 13.10, running Weston under X. Tests ran: testrendercopyex (all backends), testgl2, testgles2,testintersections