Compare commits

...

7 commits
main ... 1.23.1

Author SHA1 Message Date
Simon Ser
a9fec8dd65 build: bump version to 1.23.1 for the bugfix release
Signed-off-by: Simon Ser <contact@emersion.fr>
2024-08-24 17:43:55 +02:00
Joaquim Monteiro
cc34a7a4f1 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>
(cherry picked from commit 0239b082b9)
2024-08-24 17:43:43 +02:00
Kirill Primak
7e2ec4606e 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>
(cherry picked from commit a6a4e081da)
2024-08-24 17:43:43 +02:00
Sebastian Wick
c5c418de03 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>
(cherry picked from commit f6f0a3cdec)
2024-08-24 17:43:43 +02:00
Simon Ser
619d99cbba tests: add enum bitfield test
Signed-off-by: Simon Ser <contact@emersion.fr>
(cherry picked from commit fa1811ce3e)
2024-08-24 17:43:43 +02:00
Simon Ser
f72f2aec55 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>
(cherry picked from commit c669d99259)
2024-08-24 17:43:43 +02:00
Simon Ser
2b8f9401ee scanner: extract validator function emission to helper function
This function will grow in the next commit.

Signed-off-by: Simon Ser <contact@emersion.fr>
(cherry picked from commit caaa308c0d)
2024-08-24 17:43:43 +02:00
13 changed files with 275 additions and 98 deletions

View file

@ -1,6 +1,6 @@
project(
'wayland', 'c',
version: '1.23.0',
version: '1.23.1',
license: 'MIT',
meson_version: '>= 0.57.0',
default_options: [
@ -131,7 +131,9 @@ if get_option('scanner')
'wayland-scanner.mk',
'protocol/wayland.xml',
'protocol/wayland.dtd',
])
],
install_dir: join_paths(get_option('prefix'), get_option('datadir'), 'wayland'),
)
install_data(
[ 'wayland-scanner.m4' ],

View file

@ -1378,6 +1378,50 @@ emit_event_wrappers(struct wl_list *message_list, struct interface *interface)
}
}
static void
emit_validator(struct interface *interface, struct enumeration *e)
{
struct entry *entry;
printf("/**\n"
" * @ingroup iface_%s\n"
" * Validate a %s %s value.\n"
" *\n"
" * @return true on success, false on error.\n"
" * @ref %s_%s\n"
" */\n"
"static inline bool\n"
"%s_%s_is_valid(uint32_t value, uint32_t version) {\n",
interface->name, interface->name, e->name,
interface->name, e->name,
interface->name, e->name);
if (e->bitfield) {
printf(" uint32_t valid = 0;\n");
wl_list_for_each(entry, &e->entry_list, link) {
printf(" if (version >= %d)\n"
" valid |= %s_%s_%s;\n",
entry->since,
interface->uppercase_name, e->uppercase_name,
entry->uppercase_name);
}
printf(" return (value & ~valid) == 0;\n");
} else {
printf(" switch (value) {\n");
wl_list_for_each(entry, &e->entry_list, link) {
printf(" case %s%s_%s_%s:\n"
" return version >= %d;\n",
entry->value[0] == '-' ? "(uint32_t)" : "",
interface->uppercase_name, e->uppercase_name,
entry->uppercase_name, entry->since);
}
printf(" default:\n"
" return false;\n"
" }\n");
}
printf("}\n");
}
static void
emit_enumerations(struct interface *interface, bool with_validators)
{
@ -1439,32 +1483,8 @@ emit_enumerations(struct interface *interface, bool with_validators)
}
if (with_validators) {
printf("/**\n"
" * @ingroup iface_%s\n"
" * Validate a %s %s value.\n"
" *\n"
" * @return true on success, false on error.\n"
" * @ref %s_%s\n"
" */\n"
"static inline bool\n"
"%s_%s_is_valid(uint32_t value, uint32_t version) {\n"
" switch (value) {\n",
interface->name, interface->name, e->name,
interface->name, e->name,
interface->name, e->name);
wl_list_for_each(entry, &e->entry_list, link) {
printf(" case %s%s_%s_%s:\n"
" return version >= %d;\n",
entry->value[0] == '-' ? "(uint32_t)" : "",
interface->uppercase_name, e->uppercase_name,
entry->uppercase_name, entry->since);
}
printf(" default:\n"
" return false;\n"
" }\n"
"}\n");
}
if (with_validators)
emit_validator(interface, e);
printf("#endif /* %s_%s_ENUM */\n\n",
interface->uppercase_name, e->uppercase_name);

View file

@ -921,10 +921,14 @@ wl_proxy_marshal_array_flags(struct wl_proxy *proxy, uint32_t opcode,
if (debug_client) {
struct wl_event_queue *queue;
const char *queue_name = NULL;
queue = wl_proxy_get_queue(proxy);
if (queue)
queue_name = wl_event_queue_get_name(queue);
wl_closure_print(closure, &proxy->object, true, false, NULL,
wl_event_queue_get_name(queue));
queue_name);
}
if (wl_closure_send(closure, proxy->display->connection)) {

View file

@ -674,10 +674,11 @@ wl_display_init_shm(struct wl_display *display);
uint32_t *
wl_display_add_shm_format(struct wl_display *display, uint32_t format);
WL_DEPRECATED
struct wl_shm_buffer *
wl_shm_buffer_create(struct wl_client *client,
uint32_t id, int32_t width, int32_t height,
int32_t stride, uint32_t format) WL_DEPRECATED;
int32_t stride, uint32_t format);
void
wl_log_set_handler_server(wl_log_func_t handler);

View file

@ -2483,9 +2483,10 @@ wl_priv_signal_final_emit(struct wl_priv_signal *signal, void *data)
/** \cond */ /* Deprecated functions below. */
WL_DEPRECATED
uint32_t
wl_client_add_resource(struct wl_client *client,
struct wl_resource *resource) WL_DEPRECATED;
struct wl_resource *resource);
WL_EXPORT uint32_t
wl_client_add_resource(struct wl_client *client,
@ -2514,11 +2515,12 @@ wl_client_add_resource(struct wl_client *client,
return resource->object.id;
}
WL_DEPRECATED
struct wl_resource *
wl_client_add_object(struct wl_client *client,
const struct wl_interface *interface,
const void *implementation,
uint32_t id, void *data) WL_DEPRECATED;
uint32_t id, void *data);
WL_EXPORT struct wl_resource *
wl_client_add_object(struct wl_client *client,
@ -2537,10 +2539,11 @@ wl_client_add_object(struct wl_client *client,
return resource;
}
WL_DEPRECATED
struct wl_resource *
wl_client_new_object(struct wl_client *client,
const struct wl_interface *interface,
const void *implementation, void *data) WL_DEPRECATED;
const void *implementation, void *data);
WL_EXPORT struct wl_resource *
wl_client_new_object(struct wl_client *client,
@ -2599,10 +2602,11 @@ wl_client_get_user_data(struct wl_client *client)
return client->data;
}
WL_DEPRECATED
struct wl_global *
wl_display_add_global(struct wl_display *display,
const struct wl_interface *interface,
void *data, wl_global_bind_func_t bind) WL_DEPRECATED;
void *data, wl_global_bind_func_t bind);
WL_EXPORT struct wl_global *
wl_display_add_global(struct wl_display *display,
@ -2612,9 +2616,10 @@ wl_display_add_global(struct wl_display *display,
return wl_global_create(display, interface, interface->version, data, bind);
}
WL_DEPRECATED
void
wl_display_remove_global(struct wl_display *display,
struct wl_global *global) WL_DEPRECATED;
struct wl_global *global);
WL_EXPORT void
wl_display_remove_global(struct wl_display *display, struct wl_global *global)

View file

@ -70,30 +70,35 @@ struct wl_resource {
void *data;
};
WL_DEPRECATED
uint32_t
wl_client_add_resource(struct wl_client *client,
struct wl_resource *resource) WL_DEPRECATED;
struct wl_resource *resource);
WL_DEPRECATED
struct wl_resource *
wl_client_add_object(struct wl_client *client,
const struct wl_interface *interface,
const void *implementation,
uint32_t id, void *data) WL_DEPRECATED;
uint32_t id, void *data);
WL_DEPRECATED
struct wl_resource *
wl_client_new_object(struct wl_client *client,
const struct wl_interface *interface,
const void *implementation, void *data) WL_DEPRECATED;
const void *implementation, void *data);
WL_DEPRECATED
struct wl_global *
wl_display_add_global(struct wl_display *display,
const struct wl_interface *interface,
void *data,
wl_global_bind_func_t bind) WL_DEPRECATED;
wl_global_bind_func_t bind);
WL_DEPRECATED
void
wl_display_remove_global(struct wl_display *display,
struct wl_global *global) WL_DEPRECATED;
struct wl_global *global);
#endif

View file

@ -2396,18 +2396,16 @@ enum wl_data_device_manager_dnd_action {
*/
static inline bool
wl_data_device_manager_dnd_action_is_valid(uint32_t value, uint32_t version) {
switch (value) {
case WL_DATA_DEVICE_MANAGER_DND_ACTION_NONE:
return version >= 1;
case WL_DATA_DEVICE_MANAGER_DND_ACTION_COPY:
return version >= 1;
case WL_DATA_DEVICE_MANAGER_DND_ACTION_MOVE:
return version >= 1;
case WL_DATA_DEVICE_MANAGER_DND_ACTION_ASK:
return version >= 1;
default:
return false;
}
uint32_t valid = 0;
if (version >= 1)
valid |= WL_DATA_DEVICE_MANAGER_DND_ACTION_NONE;
if (version >= 1)
valid |= WL_DATA_DEVICE_MANAGER_DND_ACTION_COPY;
if (version >= 1)
valid |= WL_DATA_DEVICE_MANAGER_DND_ACTION_MOVE;
if (version >= 1)
valid |= WL_DATA_DEVICE_MANAGER_DND_ACTION_ASK;
return (value & ~valid) == 0;
}
#endif /* WL_DATA_DEVICE_MANAGER_DND_ACTION_ENUM */
@ -2560,28 +2558,26 @@ enum wl_shell_surface_resize {
*/
static inline bool
wl_shell_surface_resize_is_valid(uint32_t value, uint32_t version) {
switch (value) {
case WL_SHELL_SURFACE_RESIZE_NONE:
return version >= 1;
case WL_SHELL_SURFACE_RESIZE_TOP:
return version >= 1;
case WL_SHELL_SURFACE_RESIZE_BOTTOM:
return version >= 1;
case WL_SHELL_SURFACE_RESIZE_LEFT:
return version >= 1;
case WL_SHELL_SURFACE_RESIZE_TOP_LEFT:
return version >= 1;
case WL_SHELL_SURFACE_RESIZE_BOTTOM_LEFT:
return version >= 1;
case WL_SHELL_SURFACE_RESIZE_RIGHT:
return version >= 1;
case WL_SHELL_SURFACE_RESIZE_TOP_RIGHT:
return version >= 1;
case WL_SHELL_SURFACE_RESIZE_BOTTOM_RIGHT:
return version >= 1;
default:
return false;
}
uint32_t valid = 0;
if (version >= 1)
valid |= WL_SHELL_SURFACE_RESIZE_NONE;
if (version >= 1)
valid |= WL_SHELL_SURFACE_RESIZE_TOP;
if (version >= 1)
valid |= WL_SHELL_SURFACE_RESIZE_BOTTOM;
if (version >= 1)
valid |= WL_SHELL_SURFACE_RESIZE_LEFT;
if (version >= 1)
valid |= WL_SHELL_SURFACE_RESIZE_TOP_LEFT;
if (version >= 1)
valid |= WL_SHELL_SURFACE_RESIZE_BOTTOM_LEFT;
if (version >= 1)
valid |= WL_SHELL_SURFACE_RESIZE_RIGHT;
if (version >= 1)
valid |= WL_SHELL_SURFACE_RESIZE_TOP_RIGHT;
if (version >= 1)
valid |= WL_SHELL_SURFACE_RESIZE_BOTTOM_RIGHT;
return (value & ~valid) == 0;
}
#endif /* WL_SHELL_SURFACE_RESIZE_ENUM */
@ -2609,12 +2605,10 @@ enum wl_shell_surface_transient {
*/
static inline bool
wl_shell_surface_transient_is_valid(uint32_t value, uint32_t version) {
switch (value) {
case WL_SHELL_SURFACE_TRANSIENT_INACTIVE:
return version >= 1;
default:
return false;
}
uint32_t valid = 0;
if (version >= 1)
valid |= WL_SHELL_SURFACE_TRANSIENT_INACTIVE;
return (value & ~valid) == 0;
}
#endif /* WL_SHELL_SURFACE_TRANSIENT_ENUM */
@ -3486,16 +3480,14 @@ enum wl_seat_capability {
*/
static inline bool
wl_seat_capability_is_valid(uint32_t value, uint32_t version) {
switch (value) {
case WL_SEAT_CAPABILITY_POINTER:
return version >= 1;
case WL_SEAT_CAPABILITY_KEYBOARD:
return version >= 1;
case WL_SEAT_CAPABILITY_TOUCH:
return version >= 1;
default:
return false;
}
uint32_t valid = 0;
if (version >= 1)
valid |= WL_SEAT_CAPABILITY_POINTER;
if (version >= 1)
valid |= WL_SEAT_CAPABILITY_KEYBOARD;
if (version >= 1)
valid |= WL_SEAT_CAPABILITY_TOUCH;
return (value & ~valid) == 0;
}
#endif /* WL_SEAT_CAPABILITY_ENUM */
@ -4567,14 +4559,12 @@ enum wl_output_mode {
*/
static inline bool
wl_output_mode_is_valid(uint32_t value, uint32_t version) {
switch (value) {
case WL_OUTPUT_MODE_CURRENT:
return version >= 1;
case WL_OUTPUT_MODE_PREFERRED:
return version >= 1;
default:
return false;
}
uint32_t valid = 0;
if (version >= 1)
valid |= WL_OUTPUT_MODE_CURRENT;
if (version >= 1)
valid |= WL_OUTPUT_MODE_PREFERRED;
return (value & ~valid) == 0;
}
#endif /* WL_OUTPUT_MODE_ENUM */

View file

@ -106,6 +106,29 @@ enum intf_A_foo {
#define INTF_A_FOO_DEPRECATED_SINCE_VERSION 2
#endif /* INTF_A_FOO_ENUM */
#ifndef INTF_A_BAR_ENUM
#define INTF_A_BAR_ENUM
enum intf_A_bar {
/**
* this is the first
*/
INTF_A_BAR_FIRST = 0x01,
/**
* this is the second
*/
INTF_A_BAR_SECOND = 0x02,
/**
* this is the third
* @since 2
*/
INTF_A_BAR_THIRD = 0x04,
};
/**
* @ingroup iface_intf_A
*/
#define INTF_A_BAR_THIRD_SINCE_VERSION 2
#endif /* INTF_A_BAR_ENUM */
/**
* @ingroup iface_intf_A
* @struct intf_A_listener

View file

@ -106,6 +106,29 @@ enum intf_A_foo {
#define INTF_A_FOO_DEPRECATED_SINCE_VERSION 2
#endif /* INTF_A_FOO_ENUM */
#ifndef INTF_A_BAR_ENUM
#define INTF_A_BAR_ENUM
enum intf_A_bar {
/**
* this is the first
*/
INTF_A_BAR_FIRST = 0x01,
/**
* this is the second
*/
INTF_A_BAR_SECOND = 0x02,
/**
* this is the third
* @since 2
*/
INTF_A_BAR_THIRD = 0x04,
};
/**
* @ingroup iface_intf_A
*/
#define INTF_A_BAR_THIRD_SINCE_VERSION 2
#endif /* INTF_A_BAR_ENUM */
/**
* @ingroup iface_intf_A
* @struct intf_A_listener

View file

@ -133,6 +133,47 @@ intf_A_foo_is_valid(uint32_t value, uint32_t version) {
}
#endif /* INTF_A_FOO_ENUM */
#ifndef INTF_A_BAR_ENUM
#define INTF_A_BAR_ENUM
enum intf_A_bar {
/**
* this is the first
*/
INTF_A_BAR_FIRST = 0x01,
/**
* this is the second
*/
INTF_A_BAR_SECOND = 0x02,
/**
* this is the third
* @since 2
*/
INTF_A_BAR_THIRD = 0x04,
};
/**
* @ingroup iface_intf_A
*/
#define INTF_A_BAR_THIRD_SINCE_VERSION 2
/**
* @ingroup iface_intf_A
* Validate a intf_A bar value.
*
* @return true on success, false on error.
* @ref intf_A_bar
*/
static inline bool
intf_A_bar_is_valid(uint32_t value, uint32_t version) {
uint32_t valid = 0;
if (version >= 1)
valid |= INTF_A_BAR_FIRST;
if (version >= 1)
valid |= INTF_A_BAR_SECOND;
if (version >= 2)
valid |= INTF_A_BAR_THIRD;
return (value & ~valid) == 0;
}
#endif /* INTF_A_BAR_ENUM */
/**
* @ingroup iface_intf_A
* @struct intf_A_interface

View file

@ -133,6 +133,47 @@ intf_A_foo_is_valid(uint32_t value, uint32_t version) {
}
#endif /* INTF_A_FOO_ENUM */
#ifndef INTF_A_BAR_ENUM
#define INTF_A_BAR_ENUM
enum intf_A_bar {
/**
* this is the first
*/
INTF_A_BAR_FIRST = 0x01,
/**
* this is the second
*/
INTF_A_BAR_SECOND = 0x02,
/**
* this is the third
* @since 2
*/
INTF_A_BAR_THIRD = 0x04,
};
/**
* @ingroup iface_intf_A
*/
#define INTF_A_BAR_THIRD_SINCE_VERSION 2
/**
* @ingroup iface_intf_A
* Validate a intf_A bar value.
*
* @return true on success, false on error.
* @ref intf_A_bar
*/
static inline bool
intf_A_bar_is_valid(uint32_t value, uint32_t version) {
uint32_t valid = 0;
if (version >= 1)
valid |= INTF_A_BAR_FIRST;
if (version >= 1)
valid |= INTF_A_BAR_SECOND;
if (version >= 2)
valid |= INTF_A_BAR_THIRD;
return (value & ~valid) == 0;
}
#endif /* INTF_A_BAR_ENUM */
/**
* @ingroup iface_intf_A
* @struct intf_A_interface

View file

@ -58,5 +58,12 @@
<entry name="negative" value="-1" since="2" summary="this is a negative value"/>
<entry name="deprecated" value="3" since="2" deprecated-since="3" summary="this is a deprecated value"/>
</enum>
<enum name="bar" bitfield="true">
<entry name="first" value="0x01" summary="this is the first"/>
<entry name="second" value="0x02" summary="this is the second"/>
<entry name="third" value="0x04" since="2" summary="this is the third"/>
</enum>
</interface>
</protocol>

View file

@ -10,4 +10,19 @@ main(int argc, char *argv[]) {
assert(intf_A_foo_is_valid(INTF_A_FOO_THIRD, 2));
assert(intf_A_foo_is_valid(INTF_A_FOO_NEGATIVE, 2));
assert(intf_A_bar_is_valid(INTF_A_BAR_FIRST, 1));
assert(intf_A_bar_is_valid(INTF_A_BAR_FIRST, 2));
assert(intf_A_bar_is_valid(INTF_A_BAR_SECOND, 1));
assert(intf_A_bar_is_valid(INTF_A_BAR_SECOND, 2));
assert(intf_A_bar_is_valid(INTF_A_BAR_FIRST | INTF_A_BAR_SECOND, 1));
assert(intf_A_bar_is_valid(INTF_A_BAR_FIRST | INTF_A_BAR_SECOND, 2));
assert(!intf_A_bar_is_valid(INTF_A_BAR_THIRD, 1));
assert(!intf_A_bar_is_valid(INTF_A_BAR_FIRST | INTF_A_BAR_THIRD, 1));
assert(intf_A_bar_is_valid(INTF_A_BAR_THIRD, 2));
assert(intf_A_bar_is_valid(INTF_A_BAR_FIRST | INTF_A_BAR_THIRD, 2));
assert(!intf_A_bar_is_valid(0xFF, 1));
assert(!intf_A_bar_is_valid(0xFF, 2));
}