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>
If posix_fallocate is available, use it instead of ftruncate. Unlike
ftruncate, when posix_fallocate succeeds, it guarantees that you cannot
run out of disk space, when later writing to the mmap()'ed file.
With posix_fallocate, if os_create_anonymous_file() succeeds, the
program cannot get a SIGBUS later from accessing this file via mmap. If
there is insufficient disk space, the function fails and errno is set to
ENOSPC.
This is useful on systems, that limit the available buffer space by
having XDG_RUNTIME_DIR on a small tmpfs.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
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.
strlen() doesn't include the terminating NUL. Therefore when allocating a
block of memory to hold something equivalent to the length of the string we
must increment to take the NUL byte into consideration.
Signed-off-by: Rob Bradford <rob@linux.intel.com>
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).
This patch adds a few more directories to search for xcursor themes.
Along with the weston patch, this adds the ability to configure weston
to use an X11 cursor theme. Previously, wayland cursor would just look
in the icons and pixmaps directories for cursor images to load. This
adds the ability to also search in the x cursors directory.
- 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>
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>
XFS doesn't return the file type with opendir(), and instead only
returns it when you stat() the file itself. c66f2602 introduced a check
to ensure that only files and symlinks were loaded, while not checking
for DT_UNKNOWN. Properly handle DT_UNKNOWN by just proceeding anyway.
Signed-off-by: Daniel Stone <daniel@fooishbar.org>
Some distros (e.g. gentoo) install cursor themes in non-standard
directories. Add option --with-icondir to configure.sh that sets the
directory in which to look for cursors.
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.
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.