mirror of
https://gitlab.freedesktop.org/wayland/wayland.git
synced 2025-10-29 05:40:16 -04:00
Compare commits
7 commits
a50f4a1864
...
72a32cc5f2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
72a32cc5f2 | ||
|
|
d81525a235 | ||
|
|
4673ef7e9c | ||
|
|
77730f10a0 | ||
|
|
264da6a92b | ||
|
|
cd0d1543c0 | ||
|
|
eada8e1379 |
10 changed files with 307 additions and 12 deletions
|
|
@ -43,7 +43,7 @@ include:
|
||||||
# API changes. If you need new features from ci-templates you must bump
|
# API changes. If you need new features from ci-templates you must bump
|
||||||
# this to the current SHA you require from the ci-templates repo, however
|
# this to the current SHA you require from the ci-templates repo, however
|
||||||
# be aware that you may need to account for API changes when doing so.
|
# be aware that you may need to account for API changes when doing so.
|
||||||
ref: 32afe5644697e503af18a736587c8619fa036a72
|
ref: 48c2c583a865bd59be21e8938df247faf460099c
|
||||||
file:
|
file:
|
||||||
- '/templates/debian.yml'
|
- '/templates/debian.yml'
|
||||||
- '/templates/freebsd.yml'
|
- '/templates/freebsd.yml'
|
||||||
|
|
@ -306,11 +306,11 @@ armv7-release-debian-build:
|
||||||
.os-freebsd:
|
.os-freebsd:
|
||||||
variables:
|
variables:
|
||||||
BUILD_OS: freebsd
|
BUILD_OS: freebsd
|
||||||
FDO_DISTRIBUTION_VERSION: "14.2"
|
FDO_DISTRIBUTION_VERSION: "14.3"
|
||||||
FDO_DISTRIBUTION_PACKAGES: 'libxslt meson ninja pkgconf expat libffi libepoll-shim libxml2'
|
FDO_DISTRIBUTION_PACKAGES: 'libxslt meson ninja pkgconf expat libffi libepoll-shim libxml2'
|
||||||
# bump this tag every time you change something which requires rebuilding the
|
# bump this tag every time you change something which requires rebuilding the
|
||||||
# base image
|
# base image
|
||||||
FDO_DISTRIBUTION_TAG: "2025-06-23.1"
|
FDO_DISTRIBUTION_TAG: "2025-07-20.0"
|
||||||
# Don't build documentation since installing the required tools massively
|
# Don't build documentation since installing the required tools massively
|
||||||
# increases the VM image (and therefore container) size.
|
# increases the VM image (and therefore container) size.
|
||||||
MESON_ARGS: "--fatal-meson-warnings -Dwerror=true -Ddocumentation=false"
|
MESON_ARGS: "--fatal-meson-warnings -Dwerror=true -Ddocumentation=false"
|
||||||
|
|
|
||||||
|
|
@ -398,7 +398,7 @@ wl_cursor_theme_load(const char *name, int size, struct wl_shm *shm)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (size < 0 || (size > 0 && INT_MAX / size / 4 < size))
|
if (size < 0 || (size > 0 && INT_MAX / size / 4 < size))
|
||||||
return NULL;
|
goto err;
|
||||||
|
|
||||||
if (!name)
|
if (!name)
|
||||||
name = "default";
|
name = "default";
|
||||||
|
|
@ -409,7 +409,7 @@ wl_cursor_theme_load(const char *name, int size, struct wl_shm *shm)
|
||||||
|
|
||||||
theme->pool = shm_pool_create(shm, size * size * 4);
|
theme->pool = shm_pool_create(shm, size * size * 4);
|
||||||
if (!theme->pool)
|
if (!theme->pool)
|
||||||
goto out_error_pool;
|
goto err;
|
||||||
|
|
||||||
xcursor_load_theme(name, size, load_callback, theme);
|
xcursor_load_theme(name, size, load_callback, theme);
|
||||||
|
|
||||||
|
|
@ -421,7 +421,7 @@ wl_cursor_theme_load(const char *name, int size, struct wl_shm *shm)
|
||||||
|
|
||||||
return theme;
|
return theme;
|
||||||
|
|
||||||
out_error_pool:
|
err:
|
||||||
free(theme);
|
free(theme);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,7 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <ctype.h>
|
||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
@ -438,8 +439,45 @@ xcursor_read_image(FILE *file,
|
||||||
return image;
|
return image;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static struct xcursor_image *
|
||||||
|
xcursor_resize_image (struct xcursor_image *src, int size)
|
||||||
|
{
|
||||||
|
uint32_t dest_y, dest_x;
|
||||||
|
double scale = (double) size / src->size;
|
||||||
|
struct xcursor_image *dest;
|
||||||
|
|
||||||
|
if (size < 0)
|
||||||
|
return NULL;
|
||||||
|
if (size > XCURSOR_IMAGE_MAX_SIZE)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
dest = xcursor_image_create((int) (src->width * scale),
|
||||||
|
(int) (src->height * scale));
|
||||||
|
if (!dest)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
dest->size = (uint32_t) size;
|
||||||
|
dest->xhot = (uint32_t) (src->xhot * scale);
|
||||||
|
dest->yhot = (uint32_t) (src->yhot * scale);
|
||||||
|
dest->delay = src->delay;
|
||||||
|
|
||||||
|
for (dest_y = 0; dest_y < dest->height; dest_y++)
|
||||||
|
{
|
||||||
|
uint32_t src_y = (uint32_t) (dest_y / scale);
|
||||||
|
uint32_t *src_row = src->pixels + (src_y * src->width);
|
||||||
|
uint32_t *dest_row = dest->pixels + (dest_y * dest->width);
|
||||||
|
for (dest_x = 0; dest_x < dest->width; dest_x++)
|
||||||
|
{
|
||||||
|
uint32_t src_x = (uint32_t) (dest_x / scale);
|
||||||
|
dest_row[dest_x] = src_row[src_x];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return dest;
|
||||||
|
}
|
||||||
|
|
||||||
static struct xcursor_images *
|
static struct xcursor_images *
|
||||||
xcursor_xc_file_load_images(FILE *file, int size)
|
xcursor_xc_file_load_images(FILE *file, int size, bool resize)
|
||||||
{
|
{
|
||||||
struct xcursor_file_header *file_header;
|
struct xcursor_file_header *file_header;
|
||||||
uint32_t best_size;
|
uint32_t best_size;
|
||||||
|
|
@ -467,8 +505,15 @@ xcursor_xc_file_load_images(FILE *file, int size)
|
||||||
toc = xcursor_find_image_toc(file_header, best_size, n);
|
toc = xcursor_find_image_toc(file_header, best_size, n);
|
||||||
if (toc < 0)
|
if (toc < 0)
|
||||||
break;
|
break;
|
||||||
images->images[images->nimage] = xcursor_read_image(file, file_header,
|
struct xcursor_image *image = xcursor_read_image(file, file_header, toc);
|
||||||
toc);
|
if (!image)
|
||||||
|
break;
|
||||||
|
if (resize && image->size != (uint32_t) size) {
|
||||||
|
struct xcursor_image *resized_image = xcursor_resize_image(image, size);
|
||||||
|
xcursor_image_destroy(image);
|
||||||
|
image = resized_image;
|
||||||
|
}
|
||||||
|
images->images[images->nimage] = image;
|
||||||
if (!images->images[images->nimage])
|
if (!images->images[images->nimage])
|
||||||
break;
|
break;
|
||||||
images->nimage++;
|
images->nimage++;
|
||||||
|
|
@ -682,6 +727,40 @@ xcursor_theme_inherits(const char *full)
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
xcursor_default_parse_bool(const char *v)
|
||||||
|
{
|
||||||
|
char c0;
|
||||||
|
|
||||||
|
c0 = *v;
|
||||||
|
if (isupper ((int)c0))
|
||||||
|
c0 = (char) tolower (c0);
|
||||||
|
if (c0 == 't' || c0 == 'y' || c0 == '1')
|
||||||
|
return 1;
|
||||||
|
if (c0 == 'f' || c0 == 'n' || c0 == '0')
|
||||||
|
return 0;
|
||||||
|
if (c0 == 'o')
|
||||||
|
{
|
||||||
|
char c1 = v[1];
|
||||||
|
if (isupper ((int)c1))
|
||||||
|
c1 = (char) tolower (c1);
|
||||||
|
if (c1 == 'n')
|
||||||
|
return 1;
|
||||||
|
if (c1 == 'f')
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool
|
||||||
|
xcursor_get_resizable(void)
|
||||||
|
{
|
||||||
|
const char *v = getenv("XCURSOR_RESIZED");
|
||||||
|
if (!v)
|
||||||
|
return false;
|
||||||
|
return xcursor_default_parse_bool(v) > 0;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
load_all_cursors_from_dir(const char *path, int size,
|
load_all_cursors_from_dir(const char *path, int size,
|
||||||
void (*load_callback)(struct xcursor_images *, void *),
|
void (*load_callback)(struct xcursor_images *, void *),
|
||||||
|
|
@ -700,6 +779,8 @@ load_all_cursors_from_dir(const char *path, int size,
|
||||||
if (!dir)
|
if (!dir)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
const bool resize = xcursor_get_resizable();
|
||||||
|
|
||||||
for (ent = readdir(dir); ent; ent = readdir(dir)) {
|
for (ent = readdir(dir); ent; ent = readdir(dir)) {
|
||||||
#ifdef _DIRENT_HAVE_D_TYPE
|
#ifdef _DIRENT_HAVE_D_TYPE
|
||||||
if (ent->d_type != DT_UNKNOWN &&
|
if (ent->d_type != DT_UNKNOWN &&
|
||||||
|
|
@ -718,7 +799,7 @@ load_all_cursors_from_dir(const char *path, int size,
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
images = xcursor_xc_file_load_images(f, size);
|
images = xcursor_xc_file_load_images(f, size, resize);
|
||||||
|
|
||||||
if (images) {
|
if (images) {
|
||||||
images->name = strdup(ent->d_name);
|
images->name = strdup(ent->d_name);
|
||||||
|
|
|
||||||
|
|
@ -46,6 +46,7 @@ have_funcs = [
|
||||||
'memfd_create',
|
'memfd_create',
|
||||||
'mremap',
|
'mremap',
|
||||||
'strndup',
|
'strndup',
|
||||||
|
'gettid',
|
||||||
]
|
]
|
||||||
foreach f: have_funcs
|
foreach f: have_funcs
|
||||||
config_h.set('HAVE_' + f.underscorify().to_upper(), cc.has_function(f))
|
config_h.set('HAVE_' + f.underscorify().to_upper(), cc.has_function(f))
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,8 @@
|
||||||
|
|
||||||
#define _GNU_SOURCE
|
#define _GNU_SOURCE
|
||||||
|
|
||||||
|
#include "../config.h"
|
||||||
|
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
@ -1491,11 +1493,56 @@ wl_closure_queue(struct wl_closure *closure, struct wl_connection *connection)
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
wl_check_env_token(const char *env, const char *token)
|
||||||
|
{
|
||||||
|
const char *ptr = env;
|
||||||
|
size_t token_len;
|
||||||
|
|
||||||
|
if (env == NULL)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
token_len = strlen(token);
|
||||||
|
|
||||||
|
// Scan the string for comma-separated tokens and look for a match.
|
||||||
|
while (true) {
|
||||||
|
const char *end;
|
||||||
|
size_t len;
|
||||||
|
|
||||||
|
// Skip over any leading separators.
|
||||||
|
while (*ptr == ',')
|
||||||
|
ptr++;
|
||||||
|
|
||||||
|
if (*ptr == '\x00')
|
||||||
|
return false;
|
||||||
|
|
||||||
|
end = strchr(ptr + 1, ',');
|
||||||
|
|
||||||
|
// If there isn't another separarator, then the rest of the string
|
||||||
|
// is one token.
|
||||||
|
if (end == NULL)
|
||||||
|
return (strcmp(ptr, token) == 0);
|
||||||
|
|
||||||
|
len = end - ptr;
|
||||||
|
if (len == token_len && memcmp(ptr, token, len) == 0) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Skip to the next token.
|
||||||
|
ptr += len;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
wl_closure_print(struct wl_closure *closure, struct wl_object *target,
|
wl_closure_print(struct wl_closure *closure, struct wl_object *target,
|
||||||
int send, int discarded, uint32_t (*n_parse)(union wl_argument *arg),
|
int send, int discarded, uint32_t (*n_parse)(union wl_argument *arg),
|
||||||
const char *queue_name, int color)
|
const char *queue_name, int color)
|
||||||
{
|
{
|
||||||
|
#if defined(HAVE_GETTID)
|
||||||
|
static int include_tid = -1;
|
||||||
|
#endif // defined(HAVE_GETTID)
|
||||||
int i;
|
int i;
|
||||||
struct argument_details arg;
|
struct argument_details arg;
|
||||||
const char *signature = closure->message->signature;
|
const char *signature = closure->message->signature;
|
||||||
|
|
@ -1516,6 +1563,18 @@ wl_closure_print(struct wl_closure *closure, struct wl_object *target,
|
||||||
color ? WL_DEBUG_COLOR_GREEN : "",
|
color ? WL_DEBUG_COLOR_GREEN : "",
|
||||||
time / 1000, time % 1000);
|
time / 1000, time % 1000);
|
||||||
|
|
||||||
|
#if defined(HAVE_GETTID)
|
||||||
|
if (include_tid < 0) {
|
||||||
|
include_tid = wl_check_env_token(getenv("WAYLAND_DEBUG"), "thread_id");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (include_tid) {
|
||||||
|
fprintf(f, "%sTID#%d ",
|
||||||
|
color ? WL_DEBUG_COLOR_CYAN : "",
|
||||||
|
(int) gettid());
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (queue_name) {
|
if (queue_name) {
|
||||||
fprintf(f, "%s{%s} ",
|
fprintf(f, "%s{%s} ",
|
||||||
color ? WL_DEBUG_COLOR_YELLOW : "",
|
color ? WL_DEBUG_COLOR_YELLOW : "",
|
||||||
|
|
|
||||||
|
|
@ -268,9 +268,16 @@ int
|
||||||
wl_display_dispatch_queue_pending(struct wl_display *display,
|
wl_display_dispatch_queue_pending(struct wl_display *display,
|
||||||
struct wl_event_queue *queue);
|
struct wl_event_queue *queue);
|
||||||
|
|
||||||
|
int
|
||||||
|
wl_display_dispatch_queue_pending_single(struct wl_display *display,
|
||||||
|
struct wl_event_queue *queue);
|
||||||
|
|
||||||
int
|
int
|
||||||
wl_display_dispatch_pending(struct wl_display *display);
|
wl_display_dispatch_pending(struct wl_display *display);
|
||||||
|
|
||||||
|
int
|
||||||
|
wl_display_dispatch_pending_single(struct wl_display *display);
|
||||||
|
|
||||||
int
|
int
|
||||||
wl_display_get_error(struct wl_display *display);
|
wl_display_get_error(struct wl_display *display);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1236,7 +1236,7 @@ wl_display_connect_to_fd(int fd)
|
||||||
no_color = getenv("NO_COLOR");
|
no_color = getenv("NO_COLOR");
|
||||||
force_color = getenv("FORCE_COLOR");
|
force_color = getenv("FORCE_COLOR");
|
||||||
debug = getenv("WAYLAND_DEBUG");
|
debug = getenv("WAYLAND_DEBUG");
|
||||||
if (debug && (strstr(debug, "client") || strstr(debug, "1"))) {
|
if (debug && (wl_check_env_token(debug, "client") || wl_check_env_token(debug, "1"))) {
|
||||||
debug_client = 1;
|
debug_client = 1;
|
||||||
if (isatty(fileno(stderr)))
|
if (isatty(fileno(stderr)))
|
||||||
debug_color = 1;
|
debug_color = 1;
|
||||||
|
|
@ -1882,6 +1882,34 @@ err:
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
dispatch_queue_single(struct wl_display *display, struct wl_event_queue *queue)
|
||||||
|
{
|
||||||
|
if (display->last_error)
|
||||||
|
goto err;
|
||||||
|
|
||||||
|
while (!wl_list_empty(&display->display_queue.event_list)) {
|
||||||
|
dispatch_event(display, &display->display_queue);
|
||||||
|
if (display->last_error)
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!wl_list_empty(&queue->event_list)) {
|
||||||
|
dispatch_event(display, queue);
|
||||||
|
if (display->last_error)
|
||||||
|
goto err;
|
||||||
|
return 1;
|
||||||
|
} else {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
err:
|
||||||
|
errno = display->last_error;
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
/** Prepare to read events from the display's file descriptor to a queue
|
/** Prepare to read events from the display's file descriptor to a queue
|
||||||
*
|
*
|
||||||
* \param display The display context object
|
* \param display The display context object
|
||||||
|
|
@ -2212,6 +2240,34 @@ wl_display_dispatch_queue_pending(struct wl_display *display,
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Dispatch at most one pending event in an event queue
|
||||||
|
*
|
||||||
|
* \param display The display context object
|
||||||
|
* \param queue The event queue to dispatch
|
||||||
|
* \return The number of dispatched events (0 or 1) on success or -1 on failure
|
||||||
|
*
|
||||||
|
* Dispatch at most one pending event for objects assigned to the given
|
||||||
|
* event queue. On failure -1 is returned and errno set appropriately.
|
||||||
|
* If there are no events queued, this function returns immediately.
|
||||||
|
*
|
||||||
|
* \memberof wl_display
|
||||||
|
* \since 1.25.0
|
||||||
|
*/
|
||||||
|
WL_EXPORT int
|
||||||
|
wl_display_dispatch_queue_pending_single(struct wl_display *display,
|
||||||
|
struct wl_event_queue *queue)
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
pthread_mutex_lock(&display->mutex);
|
||||||
|
|
||||||
|
ret = dispatch_queue_single(display, queue);
|
||||||
|
|
||||||
|
pthread_mutex_unlock(&display->mutex);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
/** Process incoming events
|
/** Process incoming events
|
||||||
*
|
*
|
||||||
* \param display The display context object
|
* \param display The display context object
|
||||||
|
|
@ -2272,6 +2328,25 @@ wl_display_dispatch_pending(struct wl_display *display)
|
||||||
&display->default_queue);
|
&display->default_queue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Dispatch at most one pending event in the default event queue.
|
||||||
|
*
|
||||||
|
* \param display The display context object
|
||||||
|
* \return The number of dispatched events (0 or 1) on success or -1 on failure
|
||||||
|
*
|
||||||
|
* Dispatch at most one pending event for objects assigned to the default
|
||||||
|
* event queue. On failure -1 is returned and errno set appropriately.
|
||||||
|
* If there are no events queued, this function returns immediately.
|
||||||
|
*
|
||||||
|
* \memberof wl_display
|
||||||
|
* \since 1.25.0
|
||||||
|
*/
|
||||||
|
WL_EXPORT int
|
||||||
|
wl_display_dispatch_pending_single(struct wl_display *display)
|
||||||
|
{
|
||||||
|
return wl_display_dispatch_queue_pending_single(display,
|
||||||
|
&display->default_queue);
|
||||||
|
}
|
||||||
|
|
||||||
/** Retrieve the last error that occurred on a display
|
/** Retrieve the last error that occurred on a display
|
||||||
*
|
*
|
||||||
* \param display The display context object
|
* \param display The display context object
|
||||||
|
|
|
||||||
|
|
@ -237,6 +237,9 @@ wl_closure_send(struct wl_closure *closure, struct wl_connection *connection);
|
||||||
int
|
int
|
||||||
wl_closure_queue(struct wl_closure *closure, struct wl_connection *connection);
|
wl_closure_queue(struct wl_closure *closure, struct wl_connection *connection);
|
||||||
|
|
||||||
|
bool
|
||||||
|
wl_check_env_token(const char *env, const char *token);
|
||||||
|
|
||||||
void
|
void
|
||||||
wl_closure_print(struct wl_closure *closure,
|
wl_closure_print(struct wl_closure *closure,
|
||||||
struct wl_object *target, int send, int discarded,
|
struct wl_object *target, int send, int discarded,
|
||||||
|
|
|
||||||
|
|
@ -1198,7 +1198,7 @@ wl_display_create(void)
|
||||||
no_color = getenv("NO_COLOR");
|
no_color = getenv("NO_COLOR");
|
||||||
force_color = getenv("FORCE_COLOR");
|
force_color = getenv("FORCE_COLOR");
|
||||||
debug = getenv("WAYLAND_DEBUG");
|
debug = getenv("WAYLAND_DEBUG");
|
||||||
if (debug && (strstr(debug, "server") || strstr(debug, "1"))) {
|
if (debug && (wl_check_env_token(debug, "server") || wl_check_env_token(debug, "1"))) {
|
||||||
debug_server = 1;
|
debug_server = 1;
|
||||||
if (isatty(fileno(stderr)))
|
if (isatty(fileno(stderr)))
|
||||||
debug_color = 1;
|
debug_color = 1;
|
||||||
|
|
|
||||||
|
|
@ -1695,6 +1695,75 @@ TEST(global_remove)
|
||||||
display_destroy(d);
|
display_destroy(d);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
dispatch_single_read_events(struct wl_display *d)
|
||||||
|
{
|
||||||
|
if (wl_display_prepare_read(d) < 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ret = 0;
|
||||||
|
do {
|
||||||
|
ret = wl_display_flush(d);
|
||||||
|
} while (ret < 0 && (errno == EINTR || errno == EAGAIN));
|
||||||
|
assert(ret >= 0);
|
||||||
|
|
||||||
|
struct pollfd pfd[1];
|
||||||
|
pfd[0].fd = wl_display_get_fd(d);
|
||||||
|
pfd[0].events = POLLIN;
|
||||||
|
|
||||||
|
do {
|
||||||
|
ret = poll(pfd, 1, -1);
|
||||||
|
} while (ret < 0 && errno == EINTR);
|
||||||
|
assert(ret > 0);
|
||||||
|
|
||||||
|
wl_display_read_events(d);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
dispatch_single_client(void)
|
||||||
|
{
|
||||||
|
struct client *c = client_connect();
|
||||||
|
|
||||||
|
assert(wl_display_dispatch_pending_single(c->wl_display) == 0);
|
||||||
|
|
||||||
|
struct wl_registry *registry = wl_display_get_registry(c->wl_display);
|
||||||
|
|
||||||
|
dispatch_single_read_events(c->wl_display);
|
||||||
|
|
||||||
|
// [1815110.061] {Default Queue} wl_registry#3.global(1, "test", 1)
|
||||||
|
assert(wl_display_dispatch_pending_single(c->wl_display) == 1);
|
||||||
|
|
||||||
|
dispatch_single_read_events(c->wl_display);
|
||||||
|
|
||||||
|
// [1815110.067] {Default Queue} wl_registry#3.global(2, "wl_seat", 1)
|
||||||
|
assert(wl_display_dispatch_pending_single(c->wl_display) == 1);
|
||||||
|
|
||||||
|
// No more events
|
||||||
|
assert(wl_display_dispatch_pending_single(c->wl_display) == 0);
|
||||||
|
|
||||||
|
wl_registry_destroy(registry);
|
||||||
|
|
||||||
|
client_disconnect(c);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(dispatch_single)
|
||||||
|
{
|
||||||
|
struct display *d = display_create();
|
||||||
|
|
||||||
|
struct wl_global *global = wl_global_create(d->wl_display,
|
||||||
|
&wl_seat_interface,
|
||||||
|
1, d, bind_seat);
|
||||||
|
|
||||||
|
client_create_noarg(d, dispatch_single_client);
|
||||||
|
|
||||||
|
display_run(d);
|
||||||
|
|
||||||
|
wl_global_destroy(global);
|
||||||
|
|
||||||
|
display_destroy(d);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
terminate_display(void *arg)
|
terminate_display(void *arg)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue