src/video/wayland/SDL_waylandmouse.c


Log

Author Commit Date CI Message
Sam Lantinga b8d85c69 2022-11-30T12:51:59 Update for SDL3 coding style (#6717) I updated .clang-format and ran clang-format 14 over the src and test directories to standardize the code base. In general I let clang-format have it's way, and added markup to prevent formatting of code that would break or be completely unreadable if formatted. The script I ran for the src directory is added as build-scripts/clang-format-src.sh This fixes: #6592 #6593 #6594 (cherry picked from commit 5750bcb174300011b91d1de20edb288fcca70f8c)
Sylvain Becker fb0ce375 2022-11-27T17:38:43 Cleanup add brace (#6545) * Add braces after if conditions * More add braces after if conditions * Add braces after while() conditions * Fix compilation because of macro being modified * Add braces to for loop * Add braces after if/goto * Move comments up * Remove extra () in the 'return ...;' statements * More remove extra () in the 'return ...;' statements * More remove extra () in the 'return ...;' statements after merge * Fix inconsistent patterns are xxx == NULL vs !xxx * More "{}" for "if() break;" and "if() continue;" * More "{}" after if() short statement * More "{}" after "if () return;" statement * More fix inconsistent patterns are xxx == NULL vs !xxx * Revert some modificaion on SDL_RLEaccel.c * SDL_RLEaccel: no short statement * Cleanup 'if' where the bracket is in a new line * Cleanup 'while' where the bracket is in a new line * Cleanup 'for' where the bracket is in a new line * Cleanup 'else' where the bracket is in a new line (cherry picked from commit 6a2200823c66e53bd3cda4a25f0206b834392652 to reduce conflicts merging between SDL2 and SDL3)
Frank Praznik 903301c6 2022-11-16T02:04:59 wayland: Always use integer scaling for cursors. Cursors don't get fractionally scaled, so always scale system cursor sizes to the next whole integer.
David Edmundson 689218eb 2022-11-04T12:07:20 Fix wayland reconnection paths Most of this code is disabled out for now. - For mouse cursors we have a wl_surface for both system and custom cursors which needs recreating. - The other patch is about nullification after deletions
Ethan Lee 571ff1a3 2022-10-30T00:19:09 wayland: Prepare cursor implementation for reconnect support Co-authored-by: David Edmundson <kde@davidedmundson.co.uk>
David Gow ad29875e 2022-04-18T17:03:05 Wayland: Emulate mouse warp using relative mouse mode Several games (including Source and GoldSrc games, and Bioshock Infinite) attempt to "fake" relative mouse mode by repeatedly warping the cursor to the centre of the screen. Since mouse warping is not supported under Wayland, the viewport ends up "stuck" in a rectangular area. Detect this case (mouse warp while the cursor is not visible), and enable relative mouse mode, which tracks the cursor position independently, and so can Warp successfully. This is behind the SDL_HINT_VIDEO_WAYLAND_EMULATE_MOUSE_WARP hint, which is enabled by default, unless the application enables relative mouse mode itself using SDL_SetRelativeMouseMode(SDL_TRUE). Note that there is a behavoural difference, in that relative mouse mode typically doesn't take mouse accelleration into account, but the repeated-warping technique does, so mouse movement can seem very slow with this (unless the game has its own mouse accelleration option, such as in Portal 2).
Taiko2k 1c88a052 2022-09-09T16:03:17 Update Wayland cursors to match X11 cursors
Frank Praznik 0b9868b0 2022-08-02T12:56:56 wayland: Use D-Bus to retrieve the cursor size and theme on GNOME GNOME exposes the cursor size and theme via the org.freedesktop.portal.Settings interface of the xdg-desktop portal, so query these values via D-Bus, if available. The XCURSOR_SIZE/XCURSOR_THEME envvars will be tried first, so as not to override any user specified sizes or themes, then D-Bus, then, failing that, it will fall back to default values.
Sam Lantinga 120c76c8 2022-01-03T09:40:00 Updated copyright for 2022
Sylvain fae70349 2021-11-23T10:33:12 Fix warnings: static, include, un-initialized vairables
Sam Lantinga c97b7218 2021-11-21T12:18:10 Added SDL_PremultiplyAlpha() to premultiply alpha on a block of SDL_PIXELFORMAT_ARGB8888 pixels
David Gow b528d484 2021-10-22T16:59:46 wayland: Wayland cursors should use premultiplied alpha It turns out that Wayland's WL_SHM_FORMAT_ARGB8888 format (and, indeed, all wayland RGBA formats) should be treated as premultiplied. SDL surfaces tend not to be premultiplied, and this is assumed by other backends when dealing with cursors. This change premultiplies the cursor surface in Wayland_CreateCursor() using the new SDL_PremultiplySurfaceAlphaToARGB8888(). In so doing, it also adds support for a wider range of input surfaces, including those with non-ARGB8888 pixel formats, and those which don't have pitch==width. This should fix #4856
Ethan Lee 0fc43504 2021-09-27T16:41:43 wayland: Add support for XCURSOR_THEME/SIZE
Ethan Lee 9b74623b 2021-09-22T13:52:36 wayland: Woops, forgot to assign cursor theme size...
Ethan Lee 8e54698a 2021-09-22T13:26:44 wayland: Add support for high-DPI cursors
Ethan Lee 32f909f7 2021-08-03T13:30:57 wayland: Remove redundant waylanddyn.h includes. All files including waylanddyn.h already include waylandvideo.h first.
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.
Cameron Gutman 8c5b7af2 2021-02-25T19:30:47 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
Sam Lantinga 9130f7c3 2021-01-02T10:25:38 Updated copyright for 2021
Sam Lantinga cb361896 2020-12-09T07:16:22 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.
Ryan C. Gordon 22da9d4d 2020-05-28T14:47:55 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.
Sam Lantinga a8780c6a 2020-01-16T20:49:25 Updated copyright date for 2020
Sam Lantinga 5e13087b 2019-01-04T22:01:14 Updated copyright for 2019
Sam Lantinga e3cc5b2c 2018-01-03T10:03:25 Updated copyright for 2018
Philipp Wiesemann bf8ccf08 2017-05-19T23:30:59 Removed redundant mouse clean up on quit for some platforms. SDL_MouseQuit() already frees cursors and sets fields to NULL.
Sam Lantinga 45b774e3 2017-01-01T18:33:28 Updated copyright for 2017
Sam Lantinga 74e1dd4c 2016-11-11T13:14:00 Define _GNU_SOURCE when building SDL
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.
Philipp Wiesemann 31cbb34e 2016-04-14T21:11:43 Wayland: Removed not needed including and setting of errno. One internal function was setting errno on error but it was not read afterwards.
Philipp Wiesemann a9edc513 2016-03-28T21:03:04 Wayland: Fixed missing error message if creating a custom cursor failed. SDL_GetError() returned no error message because it was written to stderr only.
Philipp Wiesemann 35da1308 2016-03-16T22:09:39 Wayland: Fixed crash if memory mapping failed while creating a custom cursor.
Philipp Wiesemann 676041aa 2016-03-11T22:10:15 Wayland: Fixed drawing created cursors without transparency.
Philipp Wiesemann 167dd4a1 2016-03-11T22:09:50 Wayland: Fixed showing created cursors incorrectly before the first redraw.
Philipp Wiesemann ab8be043 2016-03-02T20:25:09 Wayland: Fixed crash if allocating memory for cursor failed. Also added missing error message if first allocation failed.
Sam Lantinga 42065e78 2016-01-02T10:10:34 Updated copyright to 2016
Ryan C. Gordon e346f142 2015-07-17T21:03:58 SDL_WarpMouseGlobal() should return non-void. There are platforms it isn't implemented on (and currently can't be implemented on!), and there's currently no way for an app to know this. This shouldn't break ABI on apps that moved to a revision between 2.0.3 and 2.0.4.
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.
Alex Szpakowski fe6c797c 2015-04-10T23:30:31 Fixed an iOS view orientation issue when SDL_GL_CreateContext or SDL_CreateRenderer is called.
Ryan C. Gordon 9a686aaa 2015-04-07T22:49:56 Wayland: changed a few "SetError(); return -1;" to "return SetError()".
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.
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
Ryo Munakata 7798b4d6 2014-09-09T17:26:16 video: waylandmouse: handle mmap error properly Signed-off-by: Ryo Munakata <ryomnktml@gmail.com>
Sam Lantinga 45ed5ee4 2014-06-04T10:55:26 Added an API function to warp the mouse cursor in global screen space: SDL_WarpMouseGlobal()
Ryan C. Gordon 60e05040 2014-04-19T02:17:34 Fixed some issues reported on new Ubuntu 14.04 buildbots.
Sam Lantinga 5a6f4d40 2014-04-17T20:51:28 Fixed bug 2485 - [PATCH] Wayland: cursor disappears permanently after window loses mouse focus Bryan Cain Using any SDL application with the Wayland backend under Weston, if the application sets a cursor with SDL_SetCursor, the cursor will work until the mouse pointer leaves the window. When the pointer re-enters the window, there will be no cursor displayed at all. I did some digging, and the reason for this is that SDL attaches the buffer to the cursor surface only once (during cursor creation) and assumes that it will stay attached. This is not how Wayland works, though - once the compositor is done rendering the buffer, it will release it, so it is no longer attached to the surface. When the cursor re-enters the window a second time, SDL sets the cursor to the same surface with no buffer attached, so no cursor is displayed. This is fixed by the attached patch, which makes SDL attach the buffer to the surface when the cursor is set, not when it is created.
Sam Lantinga 59690a4e 2014-04-17T20:21:10 Fixed bug 2482 - Wayland_CreateSystemCursor trying to load nonexistent "wait" cursor Bryan Cain Wayland_CreateSystemCursor tries to load a cursor named "wait" for two of the system cursor categories. This causes a segmentation fault when one of these cursors is used, because "wait" is not an actual cursor name in X11/Wayland cursor themes. I can't attach my patch since I'm on a mobile right now, but I can confirm that simply replacing "wait" with "watch" for both of its uses in Wayland_CreateSystemCursor (in SDL_waylandmouse.c) fixes the bug.
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.
Sam Lantinga 58edac3e 2014-02-02T00:53:27 Fixed bug 2374 - Update copyright for 2014... Is it that time already??
Gabriel Jacobo f52d7f5e 2014-01-28T11:39:37 [Wayland] Fixes segfault when mouse enters window
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 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