aboutsummaryrefslogtreecommitdiffstats
path: root/cursor/wayland-cursor.c
Commit message (Collapse)AuthorAgeFilesLines
* cursor: Free theme when size check fails to avoid memory leakYaoBing Xiao2025-08-031-3/+3
| | | | Signed-off-by: YaoBing Xiao <xiaoyaobing@uniontech.com>
* cursor: Properly check realloc for errorsTobias Stoeckmann2025-06-081-6/+7
| | | | | | | Do not override realloc's input pointer before checking for errors, otherwise it's not possible to keep old value, as intended. Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
* cursor: Gracefully handle huge cursor filesTobias Stoeckmann2025-06-081-2/+12
| | | | | | | | | | If cursor files require more than INT_MAX bytes, it is possible to trigger out of boundary writes. Since these sizes are most likely not desired anyway, gracefully handle these situations like out of memory errors. Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
* cursor: add check to ensure wl_shm_create_pool succeededYaoBing Xiao2024-10-181-0/+5
| | | | Signed-off-by: YaoBing Xiao <xiaoyaobing@uniontech.com>
* cursor: make param names match with documentationSimon Ser2022-09-131-24/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There was a mismatch here. Use a good-looking function param name because that's what will show up in docs. Use an abbreviation inside the function. Fixes the following warnings: cursor/wayland-cursor.c:504: warning: argument 'cursor' of command @param is not found in the argument list of wl_cursor_frame(struct wl_cursor *_cursor, uint32_t time) cursor/wayland-cursor.c:504: warning: The following parameter of wl_cursor_frame(struct wl_cursor *_cursor, uint32_t time) is not documented: parameter '_cursor' cursor/wayland-cursor.c:452: warning: argument 'cursor' of command @param is not found in the argument list of wl_cursor_frame_and_duration(struct wl_cursor *_cursor, uint32_t time, uint32_t *duration) cursor/wayland-cursor.c:452: warning: The following parameter of wl_cursor_frame_and_duration(struct wl_cursor *_cursor, uint32_t time, uint32_t *duration) is not documented: parameter '_cursor' cursor/wayland-cursor.c:147: warning: argument 'image' of command @param is not found in the argument list of wl_cursor_image_get_buffer(struct wl_cursor_image *_img) cursor/wayland-cursor.c:147: warning: The following parameter of wl_cursor_image_get_buffer(struct wl_cursor_image *_img) is not documented: parameter '_img' cursor/wayland-cursor.c:504: warning: argument 'cursor' of command @param is not found in the argument list of wl_cursor_frame(struct wl_cursor *_cursor, uint32_t time) cursor/wayland-cursor.c:504: warning: The following parameter of wl_cursor_frame(struct wl_cursor *_cursor, uint32_t time) is not documented: parameter '_cursor' cursor/wayland-cursor.c:452: warning: argument 'cursor' of command @param is not found in the argument list of wl_cursor_frame_and_duration(struct wl_cursor *_cursor, uint32_t time, uint32_t *duration) cursor/wayland-cursor.c:452: warning: The following parameter of wl_cursor_frame_and_duration(struct wl_cursor *_cursor, uint32_t time, uint32_t *duration) is not documented: parameter '_cursor' cursor/wayland-cursor.c:147: warning: argument 'image' of command @param is not found in the argument list of wl_cursor_image_get_buffer(struct wl_cursor_image *_img) cursor/wayland-cursor.c:147: warning: The following parameter of wl_cursor_image_get_buffer(struct wl_cursor_image *_img) is not documented: parameter '_img' Signed-off-by: Simon Ser <contact@emersion.fr>
* cursor: rename functions to snake caseSimon Ser2022-05-231-2/+2
| | | | Signed-off-by: Simon Ser <contact@emersion.fr>
* cursor: remove struct typedefs, rename to snake caseSimon Ser2022-05-231-2/+2
| | | | Signed-off-by: Simon Ser <contact@emersion.fr>
* cursor: use MAP_FAILED instead of hardcoded constantSimon Ser2022-05-061-1/+1
| | | | Signed-off-by: Simon Ser <contact@emersion.fr>
* cursor: remove unused wl_cursor_theme.nameSimon Ser2021-08-061-10/+0
| | | | | | | Let's just delete this field since it's not used anywhere and not exposed in our public API. Signed-off-by: Simon Ser <contact@emersion.fr>
* cursor: rename load_default_theme to load_fallback_themeSimon Ser2021-08-051-2/+2
| | | | | | | | | | The theme getting loaded by this function is not to be confused with the theme named "default" located on the filesystem. Instead, it's a minimal theme directly bundled into libwayland-cursor. Make this clearer by naming this theme "fallback". Signed-off-by: Simon Ser <contact@emersion.fr>
* cursor: Try to fall back to a default xcursor theme firstOlivier Tilloy2021-08-051-0/+3
| | | | | | | | | | | | | | The use case is systems where for some reason the current xcursor theme cannot be accessed (an application packaged as a strictly confined snap, for example). Before falling back to wayland's default cursor theme, it is worth trying the xcursor theme called "default", which hopefully looks better than the former. Fixes: https://gitlab.gnome.org/Community/Ubuntu/gnome-sdk/-/issues/6 Signed-off-by: Olivier Tilloy <olivier.tilloy@canonical.com>
* cursor: fix crash with weird input filesTobias Stoeckmann2021-06-021-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If a cursor file contains multiple images for the same size, this typically indicates an animation. The compositor weston uses wl_cursor_frame_and_duration to figure out at which time a specific image should be shown. The total delay is the sum of all image delays. But if all images have a delay of 0, the total delay is 0 as well. The code does not check for this special condition and triggers a floating point exception by eventually performing a modulo operation with 0. This, of course, could also happen if the sum of all image delays triggers an unsigned int overflow. But since a comment in the code already indicates that it does not try to "fix" handling of weird files, I would argue that it's "okay" if that happens. At least the program won't crash. Proof of Concept: install -D ~/.icons/poc/cursors base64 -d > ~/.icons/poc/cursors/left_ptr << EOF WGN1chAAAAAAAAEAAgAAAAIA/f8BAAAAKAAAAAIA/f8BAAAAKAAAACQAAAACAP3/AQAAAAEAAAAB AAAAAQAAAAEAAAABAAAAAAAAAAAAAAA= EOF cat > /tmp/weston.ini << EOF [shell] cursor-theme=poc EOF weston -c /tmp/weston.ini Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
* cursor/os-compatibility: move resizing into a separate functionJan Beich2020-02-231-11/+1
| | | | Signed-off-by: Jan Beich <jbeich@FreeBSD.org>
* cursor: ignore posix_fallocate in shm_pool_resize if not supported by FSJan Beich2020-02-231-4/+8
| | | | Signed-off-by: Jan Beich <jbeich@FreeBSD.org>
* (multiple): Include stdint.hYong Bakos2016-07-251-0/+1
| | | | | | | | | | Some headers and source files have been using types such as uint32_t without explicitly including stdint.h. Explicitly include stdint.h where appropriate. Signed-off-by: Yong Bakos <ybakos@humanoriented.com> Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
* cursor: Update boilerplate from MIT X11 license to MIT Expat licenseBryce Harrington2015-06-121-16/+19
| | | | | Signed-off-by: Bryce Harrington <bryce@osg.samsung.com> Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
* cursor: free the array from which images are linkedEmmanuel Gil Peyrot2015-03-181-0/+1
|
* cursor: add wl_cursor_frame_and_durationDerek Foreman2015-03-051-3/+42
| | | | | | | | It's useful to know how long the current cursor frame should be displayed so we can wait that long to change it. Signed-off-by: Derek Foreman <derekf@osg.samsung.com> Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
* Add error handling for wl_cursorsHardening2014-04-011-7/+13
| | | | | | This patch adds some error management in wayland cursors Reviewed-by: Bryce Harrington <b.harrington@samsung.com>
* cursor: check for memory allocation errorsU. Artie Eoff2014-01-151-1/+13
| | | | Signed-off-by: U. Artie Eoff <ullysses.a.eoff@intel.com>
* cursor: free theme->name tooU. Artie Eoff2014-01-151-0/+1
| | | | Signed-off-by: U. Artie Eoff <ullysses.a.eoff@intel.com>
* cursor: handle running out of buffer spacePekka Paalanen2013-12-021-16/+51
| | | | | | | | | | | | | | | | | | | | | If posix_fallocate is available, use it to detect when we are running out of buffer space. Propagate the failure properly through the various functions, stopping loading cursors but keeping the cursors that were already successfully loaded. This may result in an animated cursor not having all of its images, or a cursor theme not having all of its cursors. When that happens, the failure is NOT communicated to the application. Instead, the application will get NULL from wl_cursor_theme_get_cursor() for a cursor that was not loaded successfully. If an animated cursor is missing only some images, the animation is truncated but the cursor is still available. This patch relies on the commit "os: use posix_fallocate in creating sharable buffers" for defining HAVE_POSIX_FALLOCATE. Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
* Move ARRAY_LENGTH out of public headersKristian Høgsberg2012-10-191-0/+2
| | | | | | | | Exporting unprefixed symbols is a pretty bad idea so don't do that. Instea of redefining it WL_ARRAY_LENGTH, we just move the define to our private header. The scanner generates code that uses ARRAY_LENGTH, but we can just make it count the number elements and emit an integer constant instead.
* Ensure cursor_data.c is included in distribution tarballsMatt Roper2012-10-091-1/+1
| | | | Signed-off-by: Matt Roper <matthew.d.roper@intel.com>
* cursor: Add a default cursor themePhilipp Brüschweiler2012-09-101-1/+70
| | | | | | | This theme is loaded when the specified cursor theme can not be found. These cursors are extracted from the xorg sources and transformed into raw ARGB data by a small helper program (commited separately).
* cursor: fix fd leak and a segfaultPekka Paalanen2012-07-101-0/+6
| | | | | | | | | - don't leak fd in shm_pool_destroy() - return NULL from wl_cursor_theme_load() if pool fails Tha last one fixes a segfault, when shm_pool_create() has failed. Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
* cursor: use os_create_anonymous_file()Pekka Paalanen2012-07-101-6/+3
| | | | | | | Copy the implementation of os_create_anonymous_file() here from weston, so we can use it instead of hardcoding a path to /tmp. Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
* wayland-cursor: Add error handling for shm_pool_create()Martin Olsson2012-07-091-9/+11
|
* cursor: Add function for calculating current frame in cursor animationAnder Conselvan de Oliveira2012-06-151-7/+42
| | | | | | Given a pointer to struct wl_cursor and an elapsed time in ms., wl_cursor_frame() will return the index of the cursor image the should be displayed.
* wayland-cursor: load all cursors from a theme on wl_cursor_theme_loadAnder Conselvan de Oliveira2012-05-251-53/+34
|
* wayland-cursor: remove enum wl_cursor_typeAnder Conselvan de Oliveira2012-05-251-19/+2
| | | | | | | Defining a list of all cursors a theme, client or toolkit should have is not the purpose of libwayland-cursor. The cursor type enum existed for making lookups faster, but this kind of optmization belongs in the toolkits.
* Introduce libwayland-cursor, a cursor helper libraryAnder Conselvan de Oliveira2012-05-221-0/+356
The purpose of this library is to be the equivalent of libXcursor in the X world. This library is compatible with X cursor themes and loads them directly into an shm pool making it easy for the clients to get buffer for each cursor image. The code for handling the X cursor theme was taken from libXcursor. The files cursor/xcursor.[ch] are a stripped down version of that library containing only the interfaces necessary for implementing the wayland counterpart.