Commit graph

2617 commits

Author SHA1 Message Date
Sebastian Wick
9d5de6062b timespec: Pull in timespec_after and timespec_add from mesa
Signed-off-by: Sebastian Wick <sebastian.wick@redhat.com>
2025-02-04 14:09:51 +00:00
Sebastian Wick
37469d5ced timespec: Pull in timespec.h from weston
Signed-off-by: Sebastian Wick <sebastian.wick@redhat.com>
2025-02-04 14:09:51 +00:00
Sebastian Wick
bdba21ec92 server: add const qualifier to function arguments where possible
Makes it possible to e.g. `call wl_client_get_credentials` with a `const
struct wl_client *` from a global filter callback.

Signed-off-by: Sebastian Wick <sebastian.wick@redhat.com>
2025-01-22 14:28:50 +00:00
Daniel Stone
597a6b94f5 ci: Update ci-templates
This includes an explicit way to specify the container architecture,
which fixes our rebuilds on ARMv7.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2025-01-21 16:43:45 +00:00
Haihua Hu
f246e619d1 util: reduce error of wl_fixed_from_double()
when cast double to fixed pointer, there will be big
error, eg 1919.9998 to 1919. Call round before cast
to get nearest value 1920 of 1919.9998

Signed-off-by: Haihua Hu <jared.hu@nxp.com>
2025-01-09 09:58:32 +09:00
Demi Marie Obenour
9cb3d7aa9d connection: Fix wrong format string
Prevents undefined behavior if there is not enough space in the buffer
for a queued message.

Signed-off-by: Demi Marie Obenour <demi@invisiblethingslab.com>
2024-11-30 16:02:55 -05:00
Demi Marie Obenour
290c36bc50 tests: Avoid calling function with wrong type
Calling a function with the wrong type is immediate undefined behavior,
even if the ABI says it should be harmless.  UBSAN picks it up
immediately, and any decent control-flow integrity mechanism will as
well.

Signed-off-by: Demi Marie Obenour <demi@invisiblethingslab.com>
2024-11-30 11:31:36 -05:00
Demi Marie Obenour
4273a5edc8 connection: Avoid undefined pointer arithmetic
Creating a pointer that is more than one element past the end of an
array is undefined behavior, even if the pointer is not dereferenced.
Avoid this undefined behavior by using `p >= end` instead of
`p + 1 > end` and `SOMETHING > end - p` instead of
`p + SOMETHING > end`.

Signed-off-by: Demi Marie Obenour <demi@invisiblethingslab.com>
2024-11-29 19:19:45 -05:00
Julian Orth
10df74c240 protocol: add wl_fixes interface
This commit describes a new wl_fixes interface that can be used to
destroy wl_registry objects.

Users of libwayland-client should use it as follows:

- call wl_fixes_destroy_registry(registry)
- call wl_registry_destroy(registry)

Users of libwayland-server should, in their implementation of the
request, call wl_resource_destroy(registry).

It should be similar in other protocol implementations.

Signed-off-by: Julian Orth <ju.orth@gmail.com>
2024-11-18 09:25:20 +00:00
YaoBing Xiao
f67db75ec1 cursor: add check to ensure wl_shm_create_pool succeeded
Signed-off-by: YaoBing Xiao <xiaoyaobing@uniontech.com>
2024-10-18 16:49:45 +08:00
Simon Ser
38f91fe6ad protocol: document that wl_surface.offset is role-specific
This request doesn't make sense for all surface roles. For instance,
for maximized/tiled/fullscreen xdg_toplevel, for xdg_popup, for
layer-shell surfaces, etc.

Signed-off-by: Simon Ser <contact@emersion.fr>
2024-10-05 14:06:51 +00:00
Andri Yngvason
1b0d45e9c6 Add wl_keyboard key repeat events
This allows the compositor to take over the responsibility of repeating
keys.

Signed-off-by: Andri Yngvason <andri@yngvason.is>
2024-09-23 15:23:45 +00:00
Julian Orth
7c6259e9ad protocol: clients should not emulate key-press events on enter
The previous change introducing the logical state caused some confusion.
Clarify that most application should not use the list of pressed keys.

Signed-off-by: Julian Orth <ju.orth@gmail.com>
2024-09-10 07:36:48 +00:00
Demi Marie Obenour
6c4a695045 connection: Reject strings containing NUL bytes
libwayland cannot construct these messages as it uses strlen() to
determine string lengths.  libwayland is also guaranteed to misinterpret
these messages, since message handlers only get a pointer and no length.
Therefore, reject strings containing NUL bytes.

Also remove a redundant check from the unmarshalling code.  The
zero-length case has already been checked for.

Signed-off-by: Demi Marie Obenour <demi@invisiblethingslab.com>
2024-08-18 17:08:56 +00:00
Joaquim Monteiro
0239b082b9
meson: Fix use of install_data() without specifying install_dir
This was broken (when in a subproject) before Meson 1.3.0, and so
Meson warns against this unless the project targets 1.3.0 or newer.

Signed-off-by: Joaquim Monteiro <joaquim.monteiro@protonmail.com>
2024-08-15 14:13:57 +01:00
Fangzhou Ge
5b692b50b9 client: Log the object and methods when marshalling or sending fails
The log that appears before a display_error can be captured as crash
signature. Useful to know what it is.

This is cherry-picked from chromium https://crrev.com/c/4697877

Signed-off-by: Fangzhou Ge <fangzhoug@chromium.org>
2024-08-12 15:49:14 -04:00
Simon Ser
efa648056a ci: use detached MR pipelines
See the freedesktop wiki [1]. This allows external contributors to
have CI run properly.

[1]: https://gitlab.freedesktop.org/freedesktop/freedesktop/-/wikis/GitLab-CI#for-project-developers

Signed-off-by: Simon Ser <contact@emersion.fr>
2024-08-09 20:46:58 +00:00
Derek Foreman
58bb6c7211 src: Finish assert() clean-up
From cleanup commit 0cecde304:
assert()s can be compiled away by #defining NDEBUG. Some build systems
do this. Using wl_abort gives a human readable error message and it
isn't compiled away.

That commit missed one final assert, presumably due to missing it with
grep because of a coding style issue. Fix that up, and remove inclusion
of <assert.h> as appropriate.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2024-08-09 20:38:52 +00:00
Sebastian Wick
2bbd80c8df doc: Require strings to be UTF-8
Nothing checks this yet but this gives us the opportunity to do so when
we want.

Signed-off-by: Sebastian Wick <sebastian.wick@redhat.com>
2024-08-09 20:33:05 +00:00
Kirill Primak
65454cf7db server: expose wl_resource_post_error_vargs()
Signed-off-by: Kirill Primak <vyivel@eclair.cafe>
2024-08-09 20:29:24 +00:00
Kirill Primak
64248963d3 server: add wl_resource_post_error() docs
Signed-off-by: Kirill Primak <vyivel@eclair.cafe>
2024-08-09 20:29:24 +00:00
Kirill Primak
a6a4e081da Put WL_DEPRECATED in front of the function declarations
This fixes the following clang error when using C23:

../src/wayland-server-core.h:680:41: error: 'deprecated' attribute cannot be applied to types
  680 |                      int32_t stride, uint32_t format) WL_DEPRECATED;
      |                                                       ^
../src/wayland-util.h:52:25: note: expanded from macro 'WL_DEPRECATED'
   52 | #define WL_DEPRECATED [[deprecated]]
      |                         ^

Signed-off-by: Kirill Primak <vyivel@eclair.cafe>
2024-08-09 20:25:11 +00:00
Sebastian Wick
f6f0a3cdec client: Handle proxies with no queue
wl_proxy_get_queue can return NULL if the queue of the proxy was already
destroyed with wl_event_queue_destroy. In this case, the queue also has
no name anymore.

Fixes: b42218f ("client: Allow setting names for queues")
Signed-off-by: Sebastian Wick <sebastian.wick@redhat.com>
2024-07-26 18:33:28 +02:00
meltq
0cecde304f src: switch asserts to wl_abort
assert()s can be compiled away by #defining NDEBUG. Some build systems
do this. Using wl_abort gives a human readable error message and it
isn't compiled away. This commit closes issue #230.

Signed-off-by: meltq <tejasvipin76@gmail.com>
2024-07-11 17:44:04 +00:00
Simon Ser
fa1811ce3e tests: add enum bitfield test
Signed-off-by: Simon Ser <contact@emersion.fr>
2024-07-09 18:22:10 +02:00
Simon Ser
c669d99259 scanner: fix validator for bitfields
Bitfields are valid if the value only contains bits inside of
the supported entries for the given version.

Signed-off-by: Simon Ser <contact@emersion.fr>
2024-07-09 18:22:10 +02:00
Simon Ser
caaa308c0d scanner: extract validator function emission to helper function
This function will grow in the next commit.

Signed-off-by: Simon Ser <contact@emersion.fr>
2024-07-09 18:22:10 +02:00
Simon Ser
1d5772b7b9 build: re-open main branch for regular development
Signed-off-by: Simon Ser <contact@emersion.fr>
2024-05-30 21:07:24 +02:00
Simon Ser
a156431ea6 build: bump to version 1.23.0 for the official release
Signed-off-by: Simon Ser <contact@emersion.fr>
2024-05-30 20:59:51 +02:00
Hugo Osvaldo Barrera
26c419e046 protocol: clarify divergence in compositor behaviour
This is intended to only document the current situation. Whether further
behaviour will be defined is out of scope and left for protocol v7.

See: https://gitlab.freedesktop.org/wayland/wayland/-/merge_requests/363
Signed-off-by: Hugo Osvaldo Barrera <hugo@whynothugo.nl>
2024-05-29 14:23:38 +02:00
Simon Ser
0b1626f473 build: bump to version 1.22.93 for the RC1 release
Signed-off-by: Simon Ser <contact@emersion.fr>
2024-05-23 18:12:41 +02:00
Simon Ser
4bade62938 server: document wl_display_add_socket_fd() ownership
wl_socket_destroy() will close the socket.

Signed-off-by: Simon Ser <contact@emersion.fr>
2024-05-22 08:55:03 +00:00
Vlad Zahorodnii
17965d99e8 server: Clarify fd ownership in wl_client_create()
It's unclear whether one needs to call close() if wl_client_create()
fails. Hopefully this change makes it more clear.

Signed-off-by: Vlad Zahorodnii <vlad.zahorodnii@kde.org>
2024-05-16 12:57:42 +03:00
Simon Ser
f870320958 build: bump to version 1.22.92 for the beta release
Signed-off-by: Simon Ser <contact@emersion.fr>
2024-05-09 16:50:40 +02:00
Julian Orth
9e4f256927 protocol: explicitly describe wl_keyboard state
And the allowed state transitions.

There has been some confusion regarding which state transitions are
allowed. This change should clarify this.

Signed-off-by: Julian Orth <ju.orth@gmail.com>
2024-05-09 14:43:19 +00:00
Simon Ser
6963320218 build: bump to version 1.22.91 for the alpha release
Signed-off-by: Simon Ser <contact@emersion.fr>
2024-04-25 17:46:07 +02:00
Derek Foreman
e60c631ff2 client: print debug events that have no listener
Currently WAYLAND_DEBUG text ignores events that have no listener.

It can be helpful to know when you're receiving unhandled events,
as you may have forgotten to add a listener, or adding a dispatch
may have magically seemed to fix code that doesn't appear to be
dispatching anything.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2024-04-24 16:40:18 +00:00
Sebastian Wick
9069af78a7 protocol: define content updates and their internal queue
Multiple protocols use the term content update without a fill
definition. It makes sense to define it in the core protocol so that not
every other protocol has to define it.

This is supposed to retain the current semantics and only changes the
documentation while defining new terms.

Signed-off-by: Sebastian Wick <sebastian.wick@redhat.com>
2024-04-24 16:32:06 +00:00
Simon Ser
6e1db53916 client: fix invalid doc command for WL_MARSHAL_FLAG_DESTROY
Fixes the following warning:

    src/wayland-client-core.h:125: warning: Found non-existing group 'wl_proxy' for the command '@ingroup', ignoring command

"\memberof" cannot be used here because it only works on functions.
The docs for "\memberof" say that "\relates" works in a similar way.

While at it, use a "\" command instead of a "@" command for
consistency with the rest of the file.

Signed-off-by: Simon Ser <contact@emersion.fr>
2024-04-24 16:27:50 +00:00
Simon Ser
80c65f862f tests: add deprecated-since attributes
Add a new event and enum entry to small.xml with a deprecated-since
attribute to exercise the scanner code generation.

Signed-off-by: Simon Ser <contact@emersion.fr>
2024-04-24 16:18:28 +00:00
Simon Ser
da8e1bbc45 protocol: mark wl_pointer.axis_discrete as deprecated
Since version 8, this event isn't sent anymore.

Signed-off-by: Simon Ser <contact@emersion.fr>
2024-04-24 16:18:28 +00:00
Simon Ser
ee12e69b8f Add support for the deprecated-since XML attribute
This marks a request, event or enum entry as deprecated since a
given version.

Note that it's not clear what it means if an entry is deprecated
at some version, and the enum is used from some completely different
interface than where it was defined. However, that's a more general
issue with enums, see:
https://gitlab.freedesktop.org/wayland/wayland/-/issues/435

Signed-off-by: Simon Ser <contact@emersion.fr>
References: https://gitlab.freedesktop.org/wayland/wayland/-/issues/89
2024-04-24 16:18:28 +00:00
Chloé Vulquin
16aee2ec38 xcursor: catch theme inheritance loops
As of currently, when an xcursor theme depends on itself or another theme
that will eventually depend on it, `xcursor_load_theme` will recurse
infinitely while processing the inherits.

This change introduces a stack-allocated linked list of visited nodes
by name, and skips any already visited nodes in the inherit list.

Side effects:
* Since the linked list is stack-allocated, there is a potential for an
  overflow if there is a very long list of dependencies. If this turns out
  to be a legitimate concern, the linked list is trivial to convert to
  being heap-allocated.
* There is an existing linked list (technically doubly linked list)
  implementation in the wayland codebase. As of currently, the xcursor
  codebase does not refer to it. Consequently, this change writes a
  minimal single linked list implementation to utilize directly.

This changeset fixes #317.

Signed-off-by: Chloé Vulquin <toast@bunkerlabs.net>
2024-04-24 12:28:38 +02:00
Simon Ser
b258d5f361 scanner: add validators for enums
Right now compositors need to manually check that enum values sent
by the client are valid. In particular:

- Check that the value sent by the client is not outside of the enum.
- Check that the version of the enum entry is consistent with the
  object version.

Automatically generate validator functions to perform these tasks.

Signed-off-by: Simon Ser <contact@emersion.fr>
Closes: https://gitlab.freedesktop.org/wayland/wayland/-/issues/104
2024-04-23 09:17:02 +00:00
Julian Orth
5eeaac6e11 Clarify behavior of buffer transformations
The new text describes how

- Mutter
- Plasma
- Sway 1.8
- Jay

behave.

Sway 1.9 flipped the behavior of 90 degree and 270 degree
set_buffer_transform requests. [mpv] also changed the behavior of its
vo_wayland_dmabuf backend which makes it only work correctly on sway
1.9.

[mpv]: https://github.com/mpv-player/mpv/pull/12509

It seems that the previous text was open to interpretation or at least
caused some amount of confusion.

Signed-off-by: Julian Orth <ju.orth@gmail.com>
2024-04-23 09:08:09 +00:00
Colin Kinloch
af1dc3ef4b protocol: Undefine wl_display_sync callback data
Signed-off-by: Colin Kinloch <colin.kinloch@collabora.com>
2024-04-23 08:43:44 +00:00
6t8k
03e304544b
cursor: memfd_create: try MFD_NOEXEC_SEAL
Effective from Linux 6.3 onward, this creates the memfd without execute
permissions and prevents that setting from ever being changed. A
run-time fallback is made to not using MFD_NOEXEC_SEAL when a
libwayland-cursor compiled on Linux >= 6.3 is run on Linux < 6.3.

This is a defense-in-depth security measure and silences a respective
kernel warning; see: https://lwn.net/Articles/918106/

This implementation is adopted from dnkl's `foot` terminal emulator.

Signed-off-by: 6t8k <6t8k@noreply.codeberg.org>
2024-04-21 19:17:46 +02:00
Simon Ser
c5d145a602 ci: turn on -Dwerror=true for FreeBSD
It was turned on for Linux only.

Signed-off-by: Simon Ser <contact@emersion.fr>
2024-04-09 00:48:18 +00:00
Simon Ser
37699a98b1 ci: use --fatal-meson-warnings
Turns Meson warnings into errors. Useful to avoid missing warnings.

Signed-off-by: Simon Ser <contact@emersion.fr>
2024-04-09 00:48:18 +00:00
Simon Ser
e7df1f2af2 build: bump minimum Meson version to 0.57
Fixes the following warning:

    tests/meson.build:91: WARNING: Project targets '>= 0.56.0' but uses feature introduced in '0.57.0': env arg in run_target.

Signed-off-by: Simon Ser <contact@emersion.fr>
2024-04-09 00:48:18 +00:00