XcursorLibraryLoadImages() function is unused and not exported according to
objdump, so its removal should be an ABI compatible change.
Signed-off-by: Vlad Zahorodnii <vlad.zahorodnii@kde.org>
Currently libwayland assumes GNU extensions will be available, but
doesn't define the C standard to use. Instead, let's unconditionally
enable POSIX extensions, and enable GNU extensions on a case-by-case
basis as needed.
Signed-off-by: Simon Ser <contact@emersion.fr>
Make it easier to use Wayland as a Meson subproject by overriding
dependencies we define. This allows to easily build Wayland as a
subproject like so:
subproject('wayland', required: false, default_options: ['documentation=false'])
After this statement, the wayland-* dependencies will use the subproject
instead of the system if available.
Signed-off-by: Simon Ser <contact@emersion.fr>
The ABI of a shared library on Linux is given by a major version, which
is part of the SONAME and is incremented (rarely) on incompatible
changes, and a minor version, which is part of the basename of the
regular file to which the SONAME provides a symlink.
Until now, the ABI minor version was hard-coded, which means we can't
tell which of a pair of Wayland libraries is newer (and therefore
likely to have more symbols and/or fewer bugs).
libwayland-egl already had ABI major version 1, so we can use the
"marketing" version number as the ABI major.minor version number
directly, so Wayland 1.19.90 would produce
libwayland-egl.so.1 -> libwayland-egl.so.1.19.90.
libwayland-cursor and libwayland-server have ABI major version 0,
and OS distributions don't like it when there's a SONAME bump for no
good reason, so use their existing ABI major version together with
the "marketing" minor version:
libwayland-cursor.so.0 -> libwayland-cursor.so.0.19.90.
If the Wayland major version number is incremented to 2, we'll have to
rethink this, so add some error() to break the build if/when that
happens. Assuming that Wayland 2.0 would involve breaking changes,
the best way would probably to bump all the SONAMEs to
libwayland-foo.so.2.
Resolves: https://gitlab.freedesktop.org/wayland/wayland/-/issues/175
Signed-off-by: Simon McVittie <smcv@collabora.com>
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>
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>
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>
The libXcursor fix for CVE-2013-2003 has never been imported into
wayland, leaving it vulnerable to it.
Changing the argument type to an unsigned type is an effective merge of
Ilja Van Sprundel's commit in libXcursor.
Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
The user may install cursor themes manually, and the desktop environment
may provide a special directory for storing them. For instance, GTK puts
those themes into ~/.local/share/icons, and many Linux distributions suggest
using that directory for user-specific themes. However, users of
libwayland-cursor cannot load these themes using the API provided by the
library because the latter does not look into that directory.
This patch adds ~/.local/share/icons to the search path, so user-specific
themes can be loaded through the API provided by libwayland-cursor.
Signed-off-by: Alexander Dunaev <adunaev@igalia.com>
Reviewed-by: Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
Reviewed-by: Simon Ser <contact@emersion.fr>
Without the casts the bytes accesses get converted to int. but int is
not guaranteed to be 4 bytes large. Even when it is 4 bytes large
`bytes[3] << 24` does not fit because int is signed.
Signed-off-by: Valentin Kettner <vakevk@gmail.com>
This type is meant to be 4 bytes large as seen in _XcursorReadUInt which
always reads 4 bytes. An unsigned int is often 4 bytes large but this
isnt' guaranteed so it is cleaner to use the exact type we want.
Signed-off-by: Valentin Kettner <vakevk@gmail.com>
Some filesystems do not support fallocate and return EOPNOTSUPP.
On musl-based distros libwayland-cursor exits abruptly which causes the
application to crash. Unlike glibc, musl does not provide a fallback
mechanism for handling unsupported fallocate. Instead, musl developers
argue that application should handle the case of unsupported system
call.
This commit allows falback to ftruncate in case when EOPNOTSUPP
was recieved.
Signed-off-by: Ihor Antonov <ihor@antonovs.family>
Meson is a next generation build system, simpler than Autotools and also faster
and more portable. Most importantly, it will make integrating ASan easier in
CI.
The goal is to maintain feature parity of the Meson build with the
Autotools build, until such time when we can drop the latter.
Add a script which generates the desired Doxygen configuration for our various
output formats and executes it using that configuration. This is not something
Meson can or should do.
Fixes: https://gitlab.freedesktop.org/wayland/wayland/issues/80
[daniels: Changed to bump version, use GitLab issues URL, remove header
checks not used in any code, remove pre-pkg-config Expat
support, added missing include paths to wayland-egl and
cpp-compile-test, added GitLab CI.
Bumped version, removed unnecessary pkg-config paths.]
[daniels: Properly install into mandir/man3 via some gross
paramaterisation, generate real stamp files.]
Pekka:
- squashed patches
- removed MAKEFLAGS from meson CI
- remove unused PACKAGE* defines
- fix up scanner dependency handling
- instead of host_scanner option, build wayland-scanner twice when cross-compiling
- changed .pc files to match more closely the autotools versions
- reorder doxygen man sources to reduce diff to autotools
- fix pkgconfig.generate syntax warnings (new in Meson)
- bump meson version to 0.47 for configure_file(copy) and run_command(check)
- move doc tool checks into doc/meson.build, needed in more places
- make all doc tools mandatory if building docs
- check dot and doxygen versions
- add build files under doc/publican
- reindent to match Weston Meson style
Simon:
- Remove install arg from configure_file
- Don't build wayland-scanner twice during cross-build
- Fix naming of the threads dependency
- Store tests in dict
- Add missing HAVE_* decls for functions
- Remove unused cc_native variable
- Make doxygen targets a dict
- Make dot_gv a dict
- Use dicts in man_pages
- Make decls use dicts
- Make generated_headers use dicts
- Align Meson version number with autotool's
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
Signed-off-by: Simon Ser <contact@emersion.fr>
This (so-far) Linux-only API lets users create file descriptors purely
in memory, without any backing file on the filesystem and the race
condition which could ensue when unlink()ing it.
It also allows seals to be placed on the file, ensuring to every other
process that we won’t be allowed to shrink the contents, potentially
causing a SIGBUS when they try reading it.
This patch is best viewed with the -w option of git log -p.
Signed-off-by: Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
Reviewed-by: Simon Ser <contact@emersion.fr>
This makes the header self-contained, since the struct is considered
opaque from waylad-cursor POV.
As we're here move the wl_shm fwd. declaration alongside the others.
Making it easier to read and track.
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Yong Bakos <ybakos@humanoriented.com>
It is possible to trigger heap overflows due to an integer overflow
while parsing images.
The integer overflow occurs because the chosen limit 0x10000 for
dimensions is too large for 32 bit systems, because each pixel takes
4 bytes. Properly chosen values allow an overflow which in turn will
lead to less allocated memory than needed for subsequent reads.
See also: https://cgit.freedesktop.org/xorg/lib/libXcursor/commit/?id=4794b5dd34688158fb51a2943032569d3780c4b8
Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=103961
Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
[Pekka: add link to the corresponding libXcursor commit]
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
This mildly confused me during some debugging, so I guess it wouldn't
hurt to make the filename more indicative of where it was actually
created.
Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Yong Bakos <ybakos@humanoriented.com>
Reviewed-by: Giulio Camuffo <giuliocamuffo@gmail.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
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>
The code generates a cursor-data.h file, with licensing information.
Change this from the MIT "X11" license to MIT "Expat" license for
consistency with the rest of Wayland.
Signed-off-by: Bryce Harrington <bryce@osg.samsung.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
The license text for this file mentions Keith Packard specifically,
however it is otherwise identical to all the other MIT X11 licensed code
in Wayland, and so can be changed to the substantially identical MIT
Expat license.
Signed-off-by: Bryce Harrington <bryce@osg.samsung.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Acked-by: Keith Packard <keithp@keithp.com>
The license text for this file mentions SuSE specifically, however it is
otherwise identical to all the other MIT X11 licensed code in Wayland,
and so can be changed to the substantially identical MIT Expat license.
Signed-off-by: Bryce Harrington <bryce@osg.samsung.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Acked-by: Keith Packard <keithp@keithp.com>
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>
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.