platform/upstream/wayland.git
15 months agolog: add debugging logs
Amarnath [Thu, 5 Jan 2017 11:10:42 +0000 (16:40 +0530)]
log: add debugging logs

commit 72b8e3b37c109aebeab15e9692fc9e98131eabd6
Author: Dipen Somani <dipen.somani@samsung.com>
Debug logs added to identify the failure cause of wl_display_connect()

commit 83cf12e7ca426c69571d952716625707009d2ac6
Author: Bhavi Dhingra <b.dhingra@samsung.com>
Adding debug information about pending requests from client, before it is aborted, if sendmsg() fails due to EAGAIN error

commit 4f1f607365c017c864aef54713dbd11a02d514e1
Author: Dipen Somani <dipen.somani@samsung.com>
wayland-server: Added debug logs for client disconnection

commit 2ee9534c137a0d3a7b5f81422eedd0f2ccded5c7
Author: Dipen Somani <dipen.somani@samsung.com>
Wayland-server: Added warning logs if application binds with a lower version of the interface than that of the event.

commit f6c29ea10a9f09be82c195608d485287bb12006b
Author: ritesh.u <ritesh.u@samsung.com>
wayland-server: Error log for client disconnection on hangup/error flag set

Change-Id: Ie255b6637226c5e3ad3593d22aa9ec4905fb947f

15 months agoprotocol: add destructor to the registry
Sangjin Lee [Wed, 9 Aug 2017 07:20:46 +0000 (16:20 +0900)]
protocol: add destructor to the registry

In some user side library, it create wl_registry for check global resource to many times.
it also destory the wl_registry when finished but in wayland server, the registry resource remained
untill client is destroy. So memory in server side is increase.
This is the reason why add destructor to wl_registry.

Change-Id: I473e70eb3ef60e6604be4cc0314f3ef95f1f59c4

15 months agowayland-egl: Added APIs for setting buffer transform and frontbuffer rendering.
joonbum.ko [Thu, 15 Jun 2017 10:03:43 +0000 (19:03 +0900)]
wayland-egl: Added APIs for setting buffer transform and frontbuffer rendering.

 - Added APIs
  wl_egl_window_set_buffer_transform(struct wl_egl_window *egl_window, int wl_output_transform)
  wl_egl_window_set_frontbuffer_mode(struct wl_egl_window *egl_window, int set)
  wl_egl_window_set_window_transform(struct wl_egl_window *egl_window, int window_transform)

Change-Id: Ife7ea6e6982fe223b4369c15c9b425dd00832122
Signed-off-by: joonbum.ko <joonbum.ko@samsung.com>
15 months agowayland-cursor: fix cursor image broken problem
Sung-Jin Park [Wed, 17 May 2017 05:29:50 +0000 (14:29 +0900)]
wayland-cursor: fix cursor image broken problem

This fixes a bug related to recreate/use a new shm pool for cursor(s).
When recreating a shm pool, we usually need to copy the existing contents
in the old shm pool to the new shm pool. Otherwise, cursor images in the
old shm pool will be lost and they will be displayed abnormaly.

Change-Id: Id7515f9d15d8406c3dfb1ad52072a2442ce0c1aa
Signed-off-by: Sung-Jin Park <sj76.park@samsung.com>
15 months agowayland-cursor: fix a dereference about theme->pool
JengHyun Kang [Wed, 19 Apr 2017 08:27:06 +0000 (17:27 +0900)]
wayland-cursor: fix a dereference about theme->pool

Change-Id: If998c79832ccb68bb5ba650e6564bca139638f1e

15 months agowayland-cursor: fix to recreate to shm pool when it's not enough to contain a new...
Sung-Jin Park [Wed, 5 Apr 2017 08:02:22 +0000 (17:02 +0900)]
wayland-cursor: fix to recreate to shm pool when it's not enough to contain a new cursor

Change-Id: I9028c891ecbcabdb815c070ca414124f2206e392
Signed-off-by: Sung-Jin Park <sj76.park@samsung.com>
15 months agoserver: checking if the process has the super-user right to read /proc/cmdline
Boram Park [Thu, 2 Mar 2017 08:44:09 +0000 (17:44 +0900)]
server: checking if the process has the super-user right to read /proc/cmdline

Change-Id: Ib1b3564c98e1cd398e9b764dfb82402a6a53eec4

15 months agoAdd null check to prevent crash in case connection is deleted.
Debi Prasanna Mohanty [Mon, 27 Feb 2017 17:06:57 +0000 (22:36 +0530)]
Add null check to prevent crash in case connection is deleted.

Change-Id: Ib4b2f80620b0e5fd08899c62e4df27f7afc10a05
Signed-off-by: Debi Prasanna Mohanty <debi.m@samsung.com>
15 months agolog: add debugging logs
Boram Park [Sun, 19 Feb 2017 12:16:22 +0000 (21:16 +0900)]
log: add debugging logs

b50bff1a3e2376c4512af8295d6f6f45fda46170 log: add more logs for debugging
e00cbc1c23df2164f5e9bc4a6c0201c9b6424c5d log: add logs for tracing events in multi thread
06580d8ddac98f06f54d06bc4f1fe6bdc90f222f log: add error logs for debugging
bbb9077f93887bed9357ba9253f51e73720d1ed1 print protocol error logs

Change-Id: Ibde99add3590e032c8fada839f74b5a5c417f80d

15 months agoclient: add mutex lock/unlock for proxy
Boram Park [Sun, 19 Feb 2017 11:57:10 +0000 (20:57 +0900)]
client: add mutex lock/unlock for proxy

Actually this is not the perfect solution to protect wayland client resources in
multi-threads. They SHOULD be protected by applications. For example, during polling
the display fd, if a thread calls wl_display_disconnect, it will make issues. However,
adding mutex lock/unlock looks worth to protect wayland client resources inside of
wayland library at least.

Change-Id: I26b5f9598ccaaf5620a64a84af49f8637a360acb

15 months agoconnection: add some sanity-check
Boram Park [Sun, 19 Feb 2017 10:47:31 +0000 (19:47 +0900)]
connection: add some sanity-check

Change-Id: Iafcb073744cc95d44a6ac2a89980596da3b5ceee

15 months agowayland-cursor.c: Load cursors only on demand to save application load time and fix...
ritesh.u [Wed, 28 Dec 2016 14:46:33 +0000 (20:16 +0530)]
wayland-cursor.c: Load cursors only on demand to save application load time and fix for theme inheritance functionality

Change-Id: I73aa858e36b97a71d438365980e4ee49aea9b9bd
Signed-off-by: ritesh.u <ritesh.u@samsung.com>
15 months agowayland-cursor: added wl_cursor_theme_get_name for get cursor theme name
Junseok Kim [Fri, 11 Feb 2022 03:45:07 +0000 (12:45 +0900)]
wayland-cursor: added wl_cursor_theme_get_name for get cursor theme name

Change-Id: Ib0ac1d2d767512fc400b52afa1d1c2291d648051

15 months agowayland-egl: Add wl_egl_window_set_rotation / wl_egl_window_get_capabilities apis...
Mun, Gwan-gyeong [Wed, 9 Nov 2016 08:19:56 +0000 (17:19 +0900)]
wayland-egl: Add wl_egl_window_set_rotation / wl_egl_window_get_capabilities apis for prerotation of egl_window.

Change-Id: Id8b0bce697347efa7f5256bda217cc2e3eef045f

15 months agoflush forcely if closure has fds
Boram Park [Wed, 11 Apr 2018 01:20:01 +0000 (10:20 +0900)]
flush forcely if closure has fds

This patch is quite different with the original patch. The original patch did
two things. One is flushing forcely if closure has fds. Another is closing fds
remained in connection fds_in array.

Now closing fds is patched in wayland 1.15.0. So, we just remain the force flushing
patch.

Below is the original patch message

[original patch message]

commit d83694a742291e283f88b4db43ad5d9a9acf75bc
Author: Sangjin Lee <lsj119@samsung.com>

wayland-client: fix invalid fd about destroyed proxy

If server sends fds but the proxy was destroyed,
then that fds remain in connetion fds_in array.
so they can be misused by other proxy.

The simple solution is to separate the message including fds from the other messages
and In queueing process in clients, if received message of proxy is invaild,
just consume the fds_in array.

Change-Id: I07dd9cf87f2b8cf6265bdbdb046ed0593faaa89c

15 months agoscanner: Ensuring XMLCALL macro is only defined once to avoid build error on i586.
Gwanglim Lee [Wed, 1 Jun 2016 02:46:45 +0000 (11:46 +0900)]
scanner: Ensuring XMLCALL macro is only defined once to avoid build error on i586.

XMLCALL exportable macro is defined in two header files on i586.
(expat_external.h and xmlexports.h)
In order to avoid redefined error, we should put undef that macro.

Change-Id: I9270d4038443978548d197a8196b40eb5db7e065

15 months agotests: fix warnings
Gwanglim Lee [Fri, 27 May 2016 04:47:37 +0000 (13:47 +0900)]
tests: fix warnings

add checking values for read and write.
correct order of declaration for struct wl_closure.

Change-Id: I99e40210e387562ed2dbd050b7219e35d303c668

15 months agouse a environment "TIZEN_WAYLAND_SHM_DIR" as a path of shared memory.
Seunghun Lee [Tue, 15 Mar 2016 08:52:11 +0000 (17:52 +0900)]
use a environment "TIZEN_WAYLAND_SHM_DIR" as a path of shared memory.

allow to locate the shm file in the Tizen specific directory.

Change-Id: If11af6064b6a94fe1d7940cc76d7c59e7ba1bf48

15 months agoserver: Add new api to get wayland clients' resource
Ju Yeon Lee [Mon, 21 Dec 2015 11:11:22 +0000 (20:11 +0900)]
server: Add new api to get wayland clients' resource

allows us to get connected clients and their resources
could be utilized more efficient sever resource usage and debug resource leakage
added tests 'clients-resource-test' for presenting howto.

Change-Id: I53647d3095b51d8f435eaaad0fedb6e13dedfb3b

15 months agoadd apis to enable/disable wayland debug at runtime both for server/client
Sung-Jin Park [Fri, 13 Nov 2015 09:55:17 +0000 (18:55 +0900)]
add apis to enable/disable wayland debug at runtime both for server/client

Change-Id: Ibcb9da8db2185d0d2a9f225e0f6d80e5a30e9cd4

15 months agopackaging: add packaging directory
Boram Park [Wed, 11 Apr 2018 01:33:29 +0000 (10:33 +0900)]
packaging: add packaging directory

Change-Id: I3703dd75576b486c7982f0d1e8ef0b63b18162fe

15 months agoreadme: convert to Markdown
Simon Ser [Mon, 13 Feb 2023 18:57:15 +0000 (19:57 +0100)]
readme: convert to Markdown

Gives us nice links and code blocks.

Signed-off-by: Simon Ser <contact@emersion.fr>
15 months agoreadme: reword website description
Simon Ser [Mon, 13 Feb 2023 18:55:42 +0000 (19:55 +0100)]
readme: reword website description

The website is most useful for docs. Build instructions have been
mostly dropped from it: they're better described in downstream
projects' READMEs.

Signed-off-by: Simon Ser <contact@emersion.fr>
15 months agoreadme: drop paragraph about Weston
Simon Ser [Mon, 13 Feb 2023 18:54:13 +0000 (19:54 +0100)]
readme: drop paragraph about Weston

There are many Wayland compositors nowadays.

Signed-off-by: Simon Ser <contact@emersion.fr>
15 months agowayland-server: Add method to get global name
Andri Yngvason [Mon, 21 Nov 2022 22:08:15 +0000 (22:08 +0000)]
wayland-server: Add method to get global name

This is useful for protocol designs where globals need to be referenced
in some manner.

Signed-off-by: Andri Yngvason <andri@yngvason.is>
15 months agoprotocol: add wl_surface.preferred_buffer_transform
Simon Ser [Sat, 26 Nov 2022 12:26:34 +0000 (13:26 +0100)]
protocol: add wl_surface.preferred_buffer_transform

Same as the new wl_surface.preferred_buffer_scale event but for
transform.

No version bump needed since the previous commit did that.

Signed-off-by: Simon Ser <contact@emersion.fr>
15 months agoprotocol: add wl_surface.preferred_buffer_scale
Simon Ser [Mon, 28 Mar 2022 17:58:04 +0000 (19:58 +0200)]
protocol: add wl_surface.preferred_buffer_scale

Right now, clients need to bind to wl_output globals, listen to wl_output.scale,
listen to wl_surface.enter/leave, pick the highest scale factor.

This is an issue because it breaks Wayland's "policy, not mechanism" motto.
Clients take the decision of which scale to use depending on the outputs they're
on, compositors have no say in this (apart from faking output events, which
isn't great).

This commit introduces a new wl_surface.preferred_buffer_scale event to allow
compositors to directly indicate the preferred scale factor for each surface.

This unlocks features which require dynamically changing the scale such as:

- Accessibility features such as screen magnifier
- In a VR environment, render surfaces close to the eye at a higher scale
- HiDPI screenshots on LoDPI screens

Signed-off-by: Simon Ser <contact@emersion.fr>
Closes: https://gitlab.freedesktop.org/wayland/wayland/-/issues/271

16 months agoserver: rename wl_display.id to next_global_name
Simon Ser [Tue, 24 Jan 2023 22:55:29 +0000 (23:55 +0100)]
server: rename wl_display.id to next_global_name

This is much more descriptive. This value is a counter incremented
each time a new global is created.

Signed-off-by: Simon Ser <contact@emersion.fr>
16 months agoserver: fail on global name overflow
Simon Ser [Tue, 24 Jan 2023 22:51:57 +0000 (23:51 +0100)]
server: fail on global name overflow

display->id is initialized to 1, making 0 a convenient value to
indicate an invalid global name. Make sure to not return a zero
global name on overflow. Moreover, if we wrap around, we might
cycle back to a global name which is already in-use.

Signed-off-by: Simon Ser <contact@emersion.fr>
16 months agoprotocol: wl_subsurface::destroy does not remove the role
Mikhail Gusarov [Thu, 20 Oct 2022 21:31:33 +0000 (23:31 +0200)]
protocol: wl_subsurface::destroy does not remove the role

Role assigned to wl_surface cannot be removed.
Delete contradicting text from wl_subsurface::destroy documentation.

Signed-off-by: Mikhail Gusarov <dottedmag@dottedmag.net>
16 months agorelease.sh: Don't push *all* tags
Marius Vlad [Wed, 14 Dec 2022 12:33:42 +0000 (14:33 +0200)]
release.sh: Don't push *all* tags

Rather than trying to push all possible tags just push the one
created for that release.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
17 months agoscanner: Fix undefined behavior around qsort
Fergus Dall [Thu, 22 Sep 2022 21:58:13 +0000 (07:58 +1000)]
scanner: Fix undefined behavior around qsort

According to clang, qsort cannot be passed a null pointer, even if the size is
specified to be zero. The scanner can hit this while trying to sort forward
declarations if it happens to be building a protocol file that doesn't require
any, either in the header or the source.

Signed-off-by: Fergus Dall <sidereal@google.com>
18 months agoprotocol: add note about wl_buffer/wl_callback version
Simon Ser [Mon, 5 Dec 2022 17:29:23 +0000 (18:29 +0100)]
protocol: add note about wl_buffer/wl_callback version

This is an exception which can be confusing. Add an explicit note
about it in the protocol text.

Signed-off-by: Simon Ser <contact@emersion.fr>
18 months agoprotocol: add defunct_role_object error
Kirill Primak [Sat, 15 Oct 2022 17:26:42 +0000 (20:26 +0300)]
protocol: add defunct_role_object error

This commit adds wl_surface.defunct_role_object error, which has
semantics similar to xdg_wm_base.defunct_surfaces error, and is sent
when a client destroys a surface while the corresponding role object
still exists.

Signed-off-by: Kirill Primak <vyivel@eclair.cafe>
18 months agoprotocol: remove wl_subsurface lifetime contradiction
Kirill Primak [Sat, 15 Oct 2022 17:05:34 +0000 (20:05 +0300)]
protocol: remove wl_subsurface lifetime contradiction

This statement assumes that a wl_surface can be destroyed before the
corresponding wl_subsurface, which is not true, as wl_surface
description explicitly states that the role object must be destroyed
before the wl_surface itself.

Signed-off-by: Kirill Primak <vyivel@eclair.cafe>
19 months agotests: Ensure resource vs. client destroy handler order
Daniel Stone [Thu, 21 Jul 2022 10:18:48 +0000 (11:18 +0100)]
tests: Ensure resource vs. client destroy handler order

Make sure that the client destroy handler runs strictly before the
resource destroy handler, which runs strictly before the client
late-destroy handler.

Signed-off-by: Daniel Stone <daniels@collabora.com>
19 months agowayland-server: Add wl_client_add_destroy_late_listener
Daniel Stone [Thu, 21 Jul 2022 10:07:04 +0000 (11:07 +0100)]
wayland-server: Add wl_client_add_destroy_late_listener

A late-destroy listener for a client is called after all the client's
resources have been destroyed and the destroy callbacks emitted. This
lives in parallel to the existing client destroy listener, called
immediately before the client's objects get destroyed.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Fixes: wayland/wayland#207

19 months agotests: Use bool for client test
Daniel Stone [Thu, 21 Jul 2022 09:50:30 +0000 (10:50 +0100)]
tests: Use bool for client test

A 0/1-only int is a bool.

Signed-off-by: Daniel Stone <daniels@collabora.com>
20 months agoprotocol: add wl_compositor.error.bad_parent
Simon Ser [Mon, 5 Sep 2022 07:18:47 +0000 (09:18 +0200)]
protocol: add wl_compositor.error.bad_parent

This forbids loops in sub-surface trees.

Signed-off-by: Simon Ser <contact@emersion.fr>
20 months agoprotocol: mention protocol error name in wl_subcompositor.get_subsurface
Simon Ser [Mon, 5 Sep 2022 07:11:18 +0000 (09:11 +0200)]
protocol: mention protocol error name in wl_subcompositor.get_subsurface

Let's be explicit here.

Signed-off-by: Simon Ser <contact@emersion.fr>
20 months agoci: upgrade images
Simon Ser [Thu, 8 Sep 2022 09:41:15 +0000 (11:41 +0200)]
ci: upgrade images

Upgrade Debian to bullseye and FreeBSD to 13.1. FreeBSD 13.0 is
not supported anymore, and this ensures we still build on fresh
images.

Signed-off-by: Simon Ser <contact@emersion.fr>
20 months agoci: set ASAN_OPTIONS=detect_odr_violation=0
Simon Ser [Thu, 8 Sep 2022 10:26:12 +0000 (12:26 +0200)]
ci: set ASAN_OPTIONS=detect_odr_violation=0

Signed-off-by: Simon Ser <contact@emersion.fr>
References: https://gitlab.freedesktop.org/wayland/wayland/-/merge_requests/154

20 months agocursor: make param names match with documentation
Simon Ser [Thu, 8 Sep 2022 08:38:54 +0000 (10:38 +0200)]
cursor: make param names match with documentation

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>
20 months agoserver: don't document void return values
Simon Ser [Thu, 8 Sep 2022 08:37:52 +0000 (10:37 +0200)]
server: don't document void return values

Fixes the following warnings:

    src/wayland-server.c:1152: warning: documented empty return type of wl_display::wl_display_destroy
    src/wayland-server.c:1193: warning: documented empty return type of wl_display::wl_display_set_global_filter

Signed-off-by: Simon Ser <contact@emersion.fr>
20 months agoutil: name function typedef arguments
Simon Ser [Thu, 8 Sep 2022 08:36:28 +0000 (10:36 +0200)]
util: name function typedef arguments

Doxygen doesn't support documenting unnamed function arguments.

Fixes the following warnings:

    src/wayland-util.h:697: warning: argument 'const' of command @param is not found in the argument list of wl_dispatcher_func_t(const void *, void *, uint32_t, const struct wl_message *, union wl_argument *)
    src/wayland-util.h:697: warning: argument 'void' of command @param is not found in the argument list of wl_dispatcher_func_t(const void *, void *, uint32_t, const struct wl_message *, union wl_argument *)
    src/wayland-util.h:697: warning: argument 'void' of command @param is not found in the argument list of wl_dispatcher_func_t(const void *, void *, uint32_t, const struct wl_message *, union wl_argument *)
    src/wayland-util.h:697: warning: argument 'uint32_t' of command @param is not found in the argument list of wl_dispatcher_func_t(const void *, void *, uint32_t, const struct wl_message *, union wl_argument *)
    src/wayland-util.h:697: warning: argument 'const' of command @param is not found in the argument list of wl_dispatcher_func_t(const void *, void *, uint32_t, const struct wl_message *, union wl_argument *)
    src/wayland-util.h:697: warning: argument 'struct' of command @param is not found in the argument list of wl_dispatcher_func_t(const void *, void *, uint32_t, const struct wl_message *, union wl_argument *)
    src/wayland-util.h:697: warning: argument 'wl_message' of command @param is not found in the argument list of wl_dispatcher_func_t(const void *, void *, uint32_t, const struct wl_message *, union wl_argument *)
    src/wayland-util.h:697: warning: argument 'union' of command @param is not found in the argument list of wl_dispatcher_func_t(const void *, void *, uint32_t, const struct wl_message *, union wl_argument *)
    src/wayland-util.h:697: warning: argument 'wl_argument' of command @param is not found in the argument list of wl_dispatcher_func_t(const void *, void *, uint32_t, const struct wl_message *, union wl_argument *)
    src/wayland-util.h:725: warning: argument 'const' of command @param is not found in the argument list of wl_log_func_t(const char *, va_list)
    src/wayland-util.h:725: warning: argument 'char' of command @param is not found in the argument list of wl_log_func_t(const char *, va_list)
    src/wayland-util.h:725: warning: argument 'va_list' of command @param is not found in the argument list of wl_log_func_t(const char *, va_list)
    src/wayland-util.h:697: warning: argument 'const' of command @param is not found in the argument list of wl_dispatcher_func_t(const void *, void *, uint32_t, const struct wl_message *, union wl_argument *)
    src/wayland-util.h:697: warning: argument 'void' of command @param is not found in the argument list of wl_dispatcher_func_t(const void *, void *, uint32_t, const struct wl_message *, union wl_argument *)
    src/wayland-util.h:697: warning: argument 'void' of command @param is not found in the argument list of wl_dispatcher_func_t(const void *, void *, uint32_t, const struct wl_message *, union wl_argument *)
    src/wayland-util.h:697: warning: argument 'uint32_t' of command @param is not found in the argument list of wl_dispatcher_func_t(const void *, void *, uint32_t, const struct wl_message *, union wl_argument *)
    src/wayland-util.h:697: warning: argument 'const' of command @param is not found in the argument list of wl_dispatcher_func_t(const void *, void *, uint32_t, const struct wl_message *, union wl_argument *)
    src/wayland-util.h:697: warning: argument 'struct' of command @param is not found in the argument list of wl_dispatcher_func_t(const void *, void *, uint32_t, const struct wl_message *, union wl_argument *)
    src/wayland-util.h:697: warning: argument 'wl_message' of command @param is not found in the argument list of wl_dispatcher_func_t(const void *, void *, uint32_t, const struct wl_message *, union wl_argument *)
    src/wayland-util.h:697: warning: argument 'union' of command @param is not found in the argument list of wl_dispatcher_func_t(const void *, void *, uint32_t, const struct wl_message *, union wl_argument *)
    src/wayland-util.h:697: warning: argument 'wl_argument' of command @param is not found in the argument list of wl_dispatcher_func_t(const void *, void *, uint32_t, const struct wl_message *, union wl_argument *)
    src/wayland-util.h:725: warning: argument 'const' of command @param is not found in the argument list of wl_log_func_t(const char *, va_list)
    src/wayland-util.h:725: warning: argument 'char' of command @param is not found in the argument list of wl_log_func_t(const char *, va_list)
    src/wayland-util.h:725: warning: argument 'va_list' of command @param is not found in the argument list of wl_log_func_t(const char *, va_list)

Signed-off-by: Simon Ser <contact@emersion.fr>
21 months agobuild: Make release.sh generic
Olivier Fourdan [Tue, 6 Sep 2022 13:05:37 +0000 (15:05 +0200)]
build: Make release.sh generic

The "release.sh" script is a convenient and documented way to release
Wayland packages.

Unfortunately, the actual package name is hardcoded, meaning that to
reuse that script in other Wayland projects, one needs to duplicate the
script and amend it.

Use meson to determine the actual project name, so that the same script
can be invoked from any relevant Wayland project.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
22 months agoserver: Extend display name string size
Carlos Garnacho [Thu, 4 Aug 2022 22:35:40 +0000 (00:35 +0200)]
server: Extend display name string size

Typically this is a number between 0 and 32. Just that the compiler doesn't
know that well. Make the string buffer a bit larger, so that it fits the
longer integers. Fixes build warnings like:

../subprojects/wayland/src/wayland-server.c: In function ‘wl_display_add_socket_auto’:
../subprojects/wayland/src/wayland-server.c:1649:70: error: ‘%d’ directive output may be truncated writing between 1 and 11 bytes into a region of size 8 [-Werror=format-truncation=]
 1649 |                 snprintf(display_name, sizeof display_name, "wayland-%d", displayno);
      |                                                                      ^~
../subprojects/wayland/src/wayland-server.c:1649:61: note: directive argument in the range [-2147483647, 32]
 1649 |                 snprintf(display_name, sizeof display_name, "wayland-%d", displayno);
      |                                                             ^~~~~~~~~~~~
../subprojects/wayland/src/wayland-server.c:1649:17: note: ‘snprintf’ output between 10 and 20 bytes into a destination of size 16
 1649 |                 snprintf(display_name, sizeof display_name, "wayland-%d", displayno);
      |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors

Seen in GTK CI.

Signed-off-by: Carlos Garnacho <carlosg@gnome.org>
22 months agoDocument which type are nullable, and wire format for null value
Ian Douglas Scott [Wed, 13 Jul 2022 04:23:55 +0000 (21:23 -0700)]
Document which type are nullable, and wire format for null value

Signed-off-by: Ian Douglas Scott <idscott@system76.com>
22 months agoDo not allow nullable `new_id`
Ian Douglas Scott [Thu, 14 Jul 2022 15:36:21 +0000 (08:36 -0700)]
Do not allow nullable `new_id`

The usefulness of this is limited, and `libwayland-client` doesn't
provide a way to pass a null `new_id` since the id is generated by the
library and given to the caller as the return value.

Signed-off-by: Ian Douglas Scott <idscott@system76.com>
22 months agoDo not allow nullable arrays, which were not correctly implemented
Ian Douglas Scott [Tue, 12 Jul 2022 16:12:33 +0000 (09:12 -0700)]
Do not allow nullable arrays, which were not correctly implemented

Nullable arrays, which are not used anywhere, were marshalled the same
way as an empty non-null array. The demarshalling logic did not
recognize anything as a null array. Given this, it seems better to just
explicitly not support it.

Fixes https://gitlab.freedesktop.org/wayland/wayland/-/issues/306.

Signed-off-by: Ian Douglas Scott <idscott@system76.com>
22 months agoAdd release.sh
Simon Ser [Sat, 28 May 2022 08:07:12 +0000 (10:07 +0200)]
Add release.sh

Replace xorg-util-modular's release script with our own, tailored
for Wayland only. Does the same thing but in 71 lines of code
instead of 1k. Creates a GitLab release via glab instead of trying
to upload to a web server via ssh.

Signed-off-by: Simon Ser <contact@emersion.fr>
23 months agobuild: re-open main branch for regular development
Simon Ser [Thu, 30 Jun 2022 22:11:50 +0000 (00:11 +0200)]
build: re-open main branch for regular development

23 months agobuild: bump to version 1.21.0 for the official release upstream_work_20230216 1.21.0 upstream/1.21.0
Simon Ser [Thu, 30 Jun 2022 21:59:11 +0000 (23:59 +0200)]
build: bump to version 1.21.0 for the official release

23 months agoprotocol: minor clarification for axis_discrete events
Peter Hutterer [Fri, 24 Jun 2022 03:45:58 +0000 (13:45 +1000)]
protocol: minor clarification for axis_discrete events

Explicitly spell out that multiple axis_discrete events *for the same axis*
within the same wl_pointer.frame are not permitted.

References: https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/911#note_1438099

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
23 months agoutil: set errno when hitting WL_MAP_MAX_OBJECTS
Simon Ser [Tue, 28 Jun 2022 09:59:26 +0000 (11:59 +0200)]
util: set errno when hitting WL_MAP_MAX_OBJECTS

Callers may check errno when wl_map_insert_* functions return an
error (since [1]). Make sure it's always set to a meaningful value
when returning an error, otherwise callers might end up checking an
errno coming from a completely different function.

[1]: https://gitlab.freedesktop.org/wayland/wayland/-/merge_requests/205

Signed-off-by: Simon Ser <contact@emersion.fr>
Fixes: b19488c7154b ("util: Limit size of wl_map")

23 months agobuild: bump to version 1.20.93 for the RC1 release 1.20.93
Simon Ser [Thu, 23 Jun 2022 19:59:18 +0000 (21:59 +0200)]
build: bump to version 1.20.93 for the RC1 release

23 months agoserver: warn about global filtering consistency
Simon Ser [Wed, 15 Jun 2022 08:37:18 +0000 (10:37 +0200)]
server: warn about global filtering consistency

The filtering needs to be static given a client and a global,
otherwise libwayland will misbehave.

Signed-off-by: Simon Ser <contact@emersion.fr>
References: https://gitlab.freedesktop.org/wayland/wayland/-/merge_requests/241#note_1421888

23 months agoserver: add PID race condition disclaimer to wl_client_get_credentials
Simon Ser [Tue, 31 May 2022 17:23:38 +0000 (19:23 +0200)]
server: add PID race condition disclaimer to wl_client_get_credentials

PIDs are re-used and cannot be used to reliably check the identity of
a Wayland client.

Signed-off-by: Simon Ser <contact@emersion.fr>
23 months agotests: add a test for dynamic filtered globals
Simon Ser [Thu, 12 May 2022 17:30:38 +0000 (19:30 +0200)]
tests: add a test for dynamic filtered globals

Ensure dynamically created and destroyed globals which are filtered
don't trigger any global/global_remove event.

Signed-off-by: Simon Ser <contact@emersion.fr>
23 months agoserver: check visibility before sending global/global_remove
Simon Ser [Thu, 12 May 2022 17:29:11 +0000 (19:29 +0200)]
server: check visibility before sending global/global_remove

See the previous discussion at [1]: libwayland incorrectly skips
the visibility checks when sending global/global_remove events.
The check is only performed when a client performs a
wl_display.get_registry request.

[1]: https://gitlab.freedesktop.org/wayland/wayland/-/merge_requests/148

Signed-off-by: Simon Ser <contact@emersion.fr>
23 months agocursor/os-compatibility: handle EINTR gracefully
Olivier Fourdan [Mon, 30 May 2022 07:14:04 +0000 (09:14 +0200)]
cursor/os-compatibility: handle EINTR gracefully

If os_resize_anonymous_file() called from os_create_anonymous_file()
fails with EINTR (Interrupted system call), then the buffer allocation
fails.

To avoid that, retry posix_fallocate() on EINTR.

However, in the presence of an alarm, the interrupt may trigger
repeatedly and prevent a large posix_fallocate() to ever complete
successfully, so we need to first block SIGALRM to prevent this.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
23 months agobuild: bump to version 1.20.92 for the beta release 1.20.92
Simon Ser [Thu, 9 Jun 2022 18:52:32 +0000 (20:52 +0200)]
build: bump to version 1.20.92 for the beta release

Signed-off-by: Simon Ser <contact@emersion.fr>
23 months agoclient: Lock display when setting a proxy event queue
Alexandros Frantzis [Thu, 26 May 2022 09:18:28 +0000 (12:18 +0300)]
client: Lock display when setting a proxy event queue

Assignments to a wl_proxy's queue member are currently not synchronized
with potential reads of that member during event reading/queuing.
Assuming atomic pointer value reads and writes (which is a reasonable
assumption), and using the documented best practices to handle event
queue changes, a queue change should still be safe to perform.

That being said, such implicitly atomic accesses are difficult to assess
for correctness, especially since they do not introduce memory barriers.

To make the code more obviously correct, and handle any potential races
we are not currently aware of, this commit updates wl_proxy_set_queue()
to set the proxy's event queue under the display lock (all other
proxy queue accesses are already done under the display lock).

Signed-off-by: Alexandros Frantzis <alexandros.frantzis@collabora.com>
Suggested-by: Pekka Paalanen <pekka.paalanen@collabora.com>
23 months agoclient: Document best practices for event queue changes
Alexandros Frantzis [Thu, 26 May 2022 09:05:15 +0000 (12:05 +0300)]
client: Document best practices for event queue changes

Document the proper way to deal with event queue changes, in order to
guarantee proper handing of all events which were queued before the
queue change takes effect, especially in multi-threaded setups.

Make a special note about queue changes of newly created proxies,
which require the use of a proxy wrapper for thread safety.

Signed-off-by: Alexandros Frantzis <alexandros.frantzis@collabora.com>
Suggested-by: Pekka Paalanen <pekka.paalanen@collabora.com>
23 months agoCheck that XDG base directories paths are absolute
Antonin Décimo [Fri, 11 Mar 2022 13:08:49 +0000 (14:08 +0100)]
Check that XDG base directories paths are absolute

The [spec][1] reads:

> All paths set in these environment variables must be absolute. If an
> implementation encounters a relative path in any of these variables it should
> consider the path invalid and ignore it.

and

> If $XDG_DATA_HOME is either not set or empty, a default equal to
> $HOME/.local/share should be used.

Testing that the path is absolute also entails that is is non-empty.

[1]: https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html

Signed-off-by: Antonin Décimo <antonin.decimo@gmail.com>
2 years agocursor/os-compatibility: fix trailing space
Simon Ser [Sat, 4 Jun 2022 20:58:50 +0000 (22:58 +0200)]
cursor/os-compatibility: fix trailing space

Signed-off-by: Simon Ser <contact@emersion.fr>
2 years agocursor/os-compatibility: remove strcpy/strcat usage
Simon Ser [Sat, 4 Jun 2022 20:56:36 +0000 (22:56 +0200)]
cursor/os-compatibility: remove strcpy/strcat usage

These functions don't perform bounds checking, so they are easy to
misuse and complicate audits.

Signed-off-by: Simon Ser <contact@emersion.fr>
2 years agocursor: move xcursor_theme_inherits declarations at the top
Simon Ser [Fri, 27 May 2022 15:52:35 +0000 (17:52 +0200)]
cursor: move xcursor_theme_inherits declarations at the top

Per code style, declarations need to be at the start of the block.

And make l const while at it.

Signed-off-by: Simon Ser <contact@emersion.fr>
2 years agocursor: drop xcursor_add_path_elt
Simon Ser [Fri, 27 May 2022 15:49:10 +0000 (17:49 +0200)]
cursor: drop xcursor_add_path_elt

Just use snprintf instead. It doesn't really matter if we have
some duplicate slashes in filenames.

Signed-off-by: Simon Ser <contact@emersion.fr>
2 years agocursor: drop unused XCursor comment declarations
Simon Ser [Fri, 27 May 2022 15:17:42 +0000 (17:17 +0200)]
cursor: drop unused XCursor comment declarations

Signed-off-by: Simon Ser <contact@emersion.fr>
2 years agocursor: fix indentation of xcursor_load_theme declaration
Simon Ser [Fri, 27 May 2022 15:16:17 +0000 (17:16 +0200)]
cursor: fix indentation of xcursor_load_theme declaration

Signed-off-by: Simon Ser <contact@emersion.fr>
2 years agocursor: simplify xcursor_library_path
Simon Ser [Fri, 27 May 2022 15:14:24 +0000 (17:14 +0200)]
cursor: simplify xcursor_library_path

- Use early returns
- De-duplicate XDG_DATA_HOME code-paths
- Don't crash on allocation failure
- Use size_t when appropriate
- Fix indentation

Signed-off-by: Simon Ser <contact@emersion.fr>
2 years agocursor: remove unnecessary ifs in xcursor_load_theme
Simon Ser [Fri, 27 May 2022 15:09:48 +0000 (17:09 +0200)]
cursor: remove unnecessary ifs in xcursor_load_theme

load_all_cursors_from_dir and xcursor_theme_inherits already have
the NULL checks we want.

Signed-off-by: Simon Ser <contact@emersion.fr>
2 years agocursor: drop xcursor_images_set_name
Simon Ser [Fri, 27 May 2022 15:07:08 +0000 (17:07 +0200)]
cursor: drop xcursor_images_set_name

We don't ever need to set the name multiple times for a single
struct xcursor_images, so we can just set the field directly. Also
replace the hand-rolled logic with strdup.

Signed-off-by: Simon Ser <contact@emersion.fr>
2 years agocursor: use getline instead of fgets
Simon Ser [Fri, 27 May 2022 14:54:49 +0000 (16:54 +0200)]
cursor: use getline instead of fgets

This avoids storing 8KiB on the stack, and removes the line length
limit.

Signed-off-by: Simon Ser <contact@emersion.fr>
2 years agocursor: remove unnecessary parentheses in load_all_cursors_from_dir
Simon Ser [Fri, 27 May 2022 14:03:16 +0000 (16:03 +0200)]
cursor: remove unnecessary parentheses in load_all_cursors_from_dir

Signed-off-by: Simon Ser <contact@emersion.fr>
2 years agocursor: remove xcursor_file_load_images wrapper
Simon Ser [Fri, 27 May 2022 14:01:42 +0000 (16:01 +0200)]
cursor: remove xcursor_file_load_images wrapper

It's just calling xcursor_xc_file_load_images.

Signed-off-by: Simon Ser <contact@emersion.fr>
2 years agobuild: bump to version 1.20.91 for the alpha release 1.20.91
Simon Ser [Thu, 26 May 2022 18:15:35 +0000 (20:15 +0200)]
build: bump to version 1.20.91 for the alpha release

Signed-off-by: Simon Ser <contact@emersion.fr>
2 years agoMeson: Override wayland-scanner if it can be run
Xavier Claessens [Mon, 4 Apr 2022 13:34:33 +0000 (09:34 -0400)]
Meson: Override wayland-scanner if it can be run

This allows projects to use Wayland as a Meson subproject and get the
wayland-scanner executable when doing find_program('wayland-scanner').

Signed-off-by: Xavier Claessens <xavier.claessens@collabora.com>
2 years agoutil: fix code block language in docs
Simon Ser [Thu, 5 May 2022 10:18:16 +0000 (12:18 +0200)]
util: fix code block language in docs

Without {.xml}, Doxygen interprets the code as C. See [1] for
details.

[1]: https://www.doxygen.nl/manual/commands.html#cmdcode

Signed-off-by: Simon Ser <contact@emersion.fr>
2 years agocursor: rename local variables to snake case
Simon Ser [Thu, 21 Apr 2022 10:01:19 +0000 (12:01 +0200)]
cursor: rename local variables to snake case

Signed-off-by: Simon Ser <contact@emersion.fr>
2 years agocursor: drop xcursor_file abstraction
Simon Ser [Thu, 21 Apr 2022 09:57:31 +0000 (11:57 +0200)]
cursor: drop xcursor_file abstraction

Just use FILE * directly instead.

Signed-off-by: Simon Ser <contact@emersion.fr>
2 years agocursor: refactor xcursor_theme_inherits
Simon Ser [Thu, 21 Apr 2022 09:53:24 +0000 (11:53 +0200)]
cursor: refactor xcursor_theme_inherits

Use early returns and breaks to avoid dealing with very long
indentation lines.

Signed-off-by: Simon Ser <contact@emersion.fr>
2 years agocursor: convert macros to functions
Simon Ser [Thu, 21 Apr 2022 09:48:49 +0000 (11:48 +0200)]
cursor: convert macros to functions

Improves readability since there's no need for so many parentheses
anymore, adds type safety. The compiler will inline the function
automatically as necessary.

Signed-off-by: Simon Ser <contact@emersion.fr>
2 years agocursor: rename functions to snake case
Simon Ser [Thu, 21 Apr 2022 09:45:20 +0000 (11:45 +0200)]
cursor: rename functions to snake case

Signed-off-by: Simon Ser <contact@emersion.fr>
2 years agocursor: fix whitespace in function args definitions
Simon Ser [Thu, 21 Apr 2022 09:31:45 +0000 (11:31 +0200)]
cursor: fix whitespace in function args definitions

Signed-off-by: Simon Ser <contact@emersion.fr>
2 years agocursor: remove struct typedefs, rename to snake case
Simon Ser [Thu, 21 Apr 2022 09:29:08 +0000 (11:29 +0200)]
cursor: remove struct typedefs, rename to snake case

Signed-off-by: Simon Ser <contact@emersion.fr>
2 years agocursor: fix spacing around conditions and loops
Simon Ser [Thu, 21 Apr 2022 09:17:12 +0000 (11:17 +0200)]
cursor: fix spacing around conditions and loops

Signed-off-by: Simon Ser <contact@emersion.fr>
2 years agocursor: fix indentation
Simon Ser [Sun, 17 Apr 2022 15:40:55 +0000 (17:40 +0200)]
cursor: fix indentation

Use tabs.

Signed-off-by: Simon Ser <contact@emersion.fr>
2 years agocursor: remove unnecessary if before free
Simon Ser [Sun, 17 Apr 2022 15:30:05 +0000 (17:30 +0200)]
cursor: remove unnecessary if before free

free(NULL) is valid and is a no-op.

Signed-off-by: Simon Ser <contact@emersion.fr>
2 years agocursor: fix variable declaration style
Simon Ser [Sun, 17 Apr 2022 15:28:44 +0000 (17:28 +0200)]
cursor: fix variable declaration style

Use a single space between type and variable name.

Signed-off-by: Simon Ser <contact@emersion.fr>
2 years agocursor: fix struct declaration style
Simon Ser [Sun, 17 Apr 2022 15:20:33 +0000 (17:20 +0200)]
cursor: fix struct declaration style

Use tabs for indentation, don't use tabs to align field names.

Signed-off-by: Simon Ser <contact@emersion.fr>
2 years agocursor: fix define style
Simon Ser [Sun, 17 Apr 2022 15:19:31 +0000 (17:19 +0200)]
cursor: fix define style

Don't use tabs, don't align.

Signed-off-by: Simon Ser <contact@emersion.fr>
2 years agocursor: drop whitespace before parens in function calls
Simon Ser [Sun, 17 Apr 2022 15:10:53 +0000 (17:10 +0200)]
cursor: drop whitespace before parens in function calls

This is in line with the rest of the Wayland code style.

Signed-off-by: Simon Ser <contact@emersion.fr>
2 years agocursor: drop XCURSOR_LIB_* defines
Simon Ser [Sun, 17 Apr 2022 15:02:49 +0000 (17:02 +0200)]
cursor: drop XCURSOR_LIB_* defines

These are unused.

Signed-off-by: Simon Ser <contact@emersion.fr>
2 years agocursor: drop XcursorTrue and XcursorFalse
Simon Ser [Sun, 17 Apr 2022 15:01:18 +0000 (17:01 +0200)]
cursor: drop XcursorTrue and XcursorFalse

Just use <stdbool.h> instead.

Signed-off-by: Simon Ser <contact@emersion.fr>
2 years agocursor: remove private Xcursor int typedefs
Simon Ser [Sun, 17 Apr 2022 14:57:15 +0000 (16:57 +0200)]
cursor: remove private Xcursor int typedefs

Just use the types directly instead.

Signed-off-by: Simon Ser <contact@emersion.fr>
2 years agoserver: add wl_global_get_version
Simon Ser [Thu, 12 May 2022 17:01:26 +0000 (19:01 +0200)]
server: add wl_global_get_version

Add a helper to check the advertised version of a global. This can
be handy when checking whether a compositor feature is supported,
instead of having to store the version passed to wl_global_create
separately.

Signed-off-by: Simon Ser <contact@emersion.fr>
2 years agoutil: Limit size of wl_map
Derek Foreman [Fri, 28 Jan 2022 19:18:37 +0000 (13:18 -0600)]
util: Limit size of wl_map

Since server IDs are basically indistinguishable from really big client
IDs at many points in the source, it's theoretically possible to overflow
a map and either overflow server IDs into the client ID space, or grow
client IDs into the server ID space. This would currently take a massive
amount of RAM, but the definition of massive changes yearly.

Prevent this by placing a ridiculous but arbitrary upper bound on the
number of items we can put in a map: 0xF00000, somewhere over 15 million.
This should satisfy pathological clients without restriction, but stays
well clear of the 0xFF000000 transition point between server and client
IDs. It will still take an improbable amount of RAM to hit this, and a
client could still exhaust all RAM in this way, but our goal is to prevent
overflow and undefined behaviour.

Fixes #224

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2 years agodocs/publican: ensure output encoding is UTF-8
Simon Ser [Tue, 10 May 2022 15:21:11 +0000 (17:21 +0200)]
docs/publican: ensure output encoding is UTF-8

Without this, DocBook picks the output encoding and on some setups
we end up with ISO-8859-1. Tested by booting a fresh Alpine VM,
verifying that the generated HTML is using the incorrect charset,
applying the patch, and verifying that the generated HTML is fixed.

Signed-off-by: Simon Ser <contact@emersion.fr>