Merge branch 'xwayland' into 'master'

Port wayland client and Xwayland

See merge request redox-os/cookbook!648
This commit is contained in:
Jeremy Soller 2025-09-30 19:55:50 -06:00
commit 04d0475ab5
9 changed files with 449 additions and 25 deletions

View File

@ -1,15 +0,0 @@
#TODO missing script for Meson, see https://gitlab.freedesktop.org/wayland/wayland/-/blob/main/README.md?ref_type=heads
[source]
tar = "https://gitlab.freedesktop.org/wayland/wayland/-/releases/1.22.0/downloads/wayland-1.22.0.tar.xz"
[build]
template = "custom"
dependencies = [
"expat",
"libffi",
"libxml2",
]
script = """
DYNAMIC_INIT
cookbook_meson
"""

View File

@ -0,0 +1,20 @@
#TODO: Requires sys/signalfd.h SFD_CLOEXEC, sys/timerfd.h TFD_CLOEXEC, ppoll
#TODO: F_DUPFD_CLOEXEC, MSG_CMSG_CLOEXEC, MSG_NOSIGNAL TFD_TIMER_ABSTIME
[source]
tar = "https://gitlab.freedesktop.org/wayland/wayland/-/releases/1.24.0/downloads/wayland-1.24.0.tar.xz"
patches = [
#FIXME: This patch is just a shim. Remove this patch
"redox.patch"
]
[build]
template = "meson"
dependencies = [
"libffi",
"expat",
"libxml2",
]
mesonflags = [
"-Ddocumentation=false",
"-Dtests=false",
"-Ddtd_validation=false",
]

View File

@ -0,0 +1,205 @@
diff -ruwN source/meson.build source-new/meson.build
--- source/meson.build 2025-07-06 19:11:26.000000000 +0700
+++ source-new/meson.build 2025-10-01 06:32:51.610361685 +0700
@@ -80,8 +80,6 @@
ffi_dep = dependency('libffi')
decls = [
- { 'header': 'sys/signalfd.h', 'symbol': 'SFD_CLOEXEC' },
- { 'header': 'sys/timerfd.h', 'symbol': 'TFD_CLOEXEC' },
{ 'header': 'time.h', 'symbol': 'CLOCK_MONOTONIC' },
]
diff -ruwN source/src/connection.c source-new/src/connection.c
--- source/src/connection.c 2025-07-06 19:11:26.000000000 +0700
+++ source-new/src/connection.c 2025-10-01 07:10:17.676073568 +0700
@@ -490,7 +490,7 @@
do {
len = sendmsg(connection->fd, &msg,
- MSG_NOSIGNAL | MSG_DONTWAIT);
+ MSG_DONTWAIT);
} while (len == -1 && errno == EINTR);
if (len == -1)
@@ -1506,9 +1506,9 @@
char *buffer;
size_t buffer_length;
- f = open_memstream(&buffer, &buffer_length);
- if (f == NULL)
- return;
+ // f = open_memstream(&buffer, &buffer_length);
+ // if (f == NULL)
+ // return;
clock_gettime(CLOCK_REALTIME, &tp);
time = (tp.tv_sec * 1000000L) + (tp.tv_nsec / 1000);
diff -ruwN source/src/event-loop.c source-new/src/event-loop.c
--- source/src/event-loop.c 2025-07-06 19:11:26.000000000 +0700
+++ source-new/src/event-loop.c 2025-10-01 07:07:26.992243929 +0700
@@ -35,8 +35,8 @@
#include <sys/socket.h>
#include <sys/un.h>
#include <sys/epoll.h>
-#include <sys/signalfd.h>
-#include <sys/timerfd.h>
+// #include <sys/signalfd.h>
+// #include <sys/timerfd.h>
#include <unistd.h>
#include "timespec-util.h"
#include "wayland-util.h"
@@ -259,24 +259,13 @@
static int
set_timer(int timerfd, struct timespec deadline) {
- struct itimerspec its;
-
- its.it_interval.tv_sec = 0;
- its.it_interval.tv_nsec = 0;
- its.it_value = deadline;
- return timerfd_settime(timerfd, TFD_TIMER_ABSTIME, &its, NULL);
+ return 0;
}
static int
clear_timer(int timerfd)
{
- struct itimerspec its;
-
- its.it_interval.tv_sec = 0;
- its.it_interval.tv_nsec = 0;
- its.it_value.tv_sec = 0;
- its.it_value.tv_nsec = 0;
- return timerfd_settime(timerfd, 0, &its, NULL);
+ return 0;
}
static void
@@ -307,7 +296,7 @@
wl_timer_heap_ensure_timerfd(struct wl_timer_heap *timers)
{
struct epoll_event ep;
- int timer_fd;
+ int timer_fd = 0;
if (timers->base.fd != -1)
return 0;
@@ -316,17 +305,6 @@
ep.events = EPOLLIN;
ep.data.ptr = timers;
- timer_fd = timerfd_create(CLOCK_MONOTONIC,
- TFD_CLOEXEC | TFD_NONBLOCK);
- if (timer_fd < 0)
- return -1;
-
- if (epoll_ctl(timers->base.loop->epoll_fd,
- EPOLL_CTL_ADD, timer_fd, &ep) < 0) {
- close(timer_fd);
- return -1;
- }
-
timers->base.fd = timer_fd;
return 0;
}
@@ -677,11 +655,12 @@
{
struct wl_event_source_signal *signal_source =
(struct wl_event_source_signal *) source;
- struct signalfd_siginfo signal_info;
+ /*struct signalfd_siginfo signal_info;
int len;
len = read(source->fd, &signal_info, sizeof signal_info);
if (!(len == -1 && errno == EAGAIN) && len != sizeof signal_info)
+ */
/* Is there anything we can do here? Will this ever happen? */
wl_log("signalfd read error: %s\n", strerror(errno));
@@ -730,7 +709,7 @@
sigemptyset(&mask);
sigaddset(&mask, signal_number);
- source->base.fd = signalfd(-1, &mask, SFD_CLOEXEC | SFD_NONBLOCK);
+ // source->base.fd = signalfd(-1, &mask, SFD_CLOEXEC | SFD_NONBLOCK);
sigprocmask(SIG_BLOCK, &mask, NULL);
source->func = func;
diff -ruwN source/src/meson.build source-new/src/meson.build
--- source/src/meson.build 2025-07-06 19:11:26.000000000 +0700
+++ source-new/src/meson.build 2025-10-01 07:03:52.591689534 +0700
@@ -81,8 +81,7 @@
endif
if meson.is_cross_build() or not get_option('scanner')
- scanner_dep = dependency('wayland-scanner', native: true, version: meson.project_version())
- wayland_scanner_for_build = find_program(scanner_dep.get_variable(pkgconfig: 'wayland_scanner'))
+ wayland_scanner_for_build = find_program('wayland-scanner', native: true)
else
wayland_scanner_for_build = wayland_scanner
endif
diff -ruwN source/src/wayland-client.c source-new/src/wayland-client.c
--- source/src/wayland-client.c 2025-07-06 19:11:26.000000000 +0700
+++ source-new/src/wayland-client.c 2025-10-01 07:10:48.899322239 +0700
@@ -1997,14 +1997,6 @@
pfd[0].fd = display->fd;
pfd[0].events = events;
- do {
- if (timeout) {
- clock_gettime(CLOCK_MONOTONIC, &now);
- timespec_sub_saturate(&result, &deadline, &now);
- remaining_timeout = &result;
- }
- ret = ppoll(pfd, 1, remaining_timeout, NULL);
- } while (ret == -1 && errno == EINTR);
return ret;
}
diff -ruwN source/src/wayland-os.c source-new/src/wayland-os.c
--- source/src/wayland-os.c 2025-07-06 19:11:26.000000000 +0700
+++ source-new/src/wayland-os.c 2025-10-01 07:09:01.188805546 +0700
@@ -134,7 +134,7 @@
{
int newfd;
- newfd = wl_fcntl(fd, F_DUPFD_CLOEXEC, minfd);
+ newfd = wl_fcntl(fd, FD_CLOEXEC, minfd);
if (newfd >= 0)
return newfd;
if (errno != EINVAL)
@@ -189,7 +189,7 @@
#else
ssize_t len;
- len = wl_recvmsg(sockfd, msg, flags | MSG_CMSG_CLOEXEC);
+ len = wl_recvmsg(sockfd, msg, flags);
if (len >= 0)
return len;
if (errno != EINVAL)
diff -ruwN source/src/wayland-server.c source-new/src/wayland-server.c
--- source/src/wayland-server.c 2025-07-06 19:11:26.000000000 +0700
+++ source-new/src/wayland-server.c 2025-10-01 07:09:51.131179157 +0700
@@ -39,7 +39,7 @@
#include <dlfcn.h>
#include <sys/time.h>
#include <fcntl.h>
-#include <sys/eventfd.h>
+// #include <sys/eventfd.h>
#include <sys/file.h>
#include <sys/stat.h>
@@ -1206,9 +1206,9 @@
return NULL;
}
- display->terminate_efd = eventfd(0, EFD_CLOEXEC | EFD_NONBLOCK);
- if (display->terminate_efd < 0)
- goto err_eventfd;
+ // display->terminate_efd = eventfd(0, EFD_CLOEXEC | EFD_NONBLOCK);
+ // if (display->terminate_efd < 0)
+ // goto err_eventfd;
display->term_source = wl_event_loop_add_fd(display->loop,
display->terminate_efd,

View File

@ -1,5 +1,7 @@
#TODO missing script for Meson, lacking build instructions
[source]
tar = "https://gitlab.freedesktop.org/wayland/wayland-protocols/-/releases/1.32/downloads/wayland-protocols-1.32.tar.xz"
[build]
template = "custom"
template = "meson"
mesonflags = [
"-Dtests=false"
]

View File

@ -1,10 +1,38 @@
#TODO missing script for Meson, see https://wayland.freedesktop.org/xserver.html#heading_toc_j_3
#TODO wayland-client, fix linux/input, wayland-scanner shim
[source]
tar = "https://www.x.org/releases/individual/xserver/xwayland-23.2.4.tar.xz"
[build]
template = "custom"
dependencies = [
"libepoxy",
"libxtrans",
"libxkbfile",
tar = "https://www.x.org/releases/individual/xserver/xwayland-24.1.8.tar.xz"
patches = [
"redox.patch"
]
[build]
template = "meson"
dependencies = [
"libpthread-stubs",
"libepoxy",
"libxkbfile",
"libxfont2",
"libffi",
"libpng",
"pixman",
"xorgproto",
"xtrans",
"libxau",
"libx11",
"libxcb",
"openssl1",
"freetype2",
"libwayland",
"libfontenc",
"wayland-protocols",
"zlib",
"libxcvt",
"libxdmcp",
"libxshmfence",
]
mesonflags = [
"-Ddrm=false",
"-Dglamor=false",
"-Dglx=false",
"-Dsecure-rpc=false",
"-Dmitshm=false"
]

View File

@ -0,0 +1,158 @@
diff -ruwN source/hw/xwayland/meson.build source-new/hw/xwayland/meson.build
--- source/hw/xwayland/meson.build 2024-01-16 16:38:49.000000000 +0700
+++ source-new/hw/xwayland/meson.build 2025-10-01 07:51:14.456575515 +0700
@@ -30,8 +30,7 @@
'../../mi/miinitext.h',
]
-scanner_dep = dependency('wayland-scanner', native: true)
-scanner = find_program(scanner_dep.get_pkgconfig_variable('wayland_scanner'))
+scanner = find_program('wayland-scanner', native: true)
protocols_dep = dependency('wayland-protocols', version: wayland_protocols_req)
protodir = protocols_dep.get_pkgconfig_variable('pkgdatadir')
@@ -55,11 +54,7 @@
arguments : ['client-header', '@INPUT@', '@OUTPUT@']
)
-if scanner_dep.version().version_compare('>= 1.14.91')
scanner_argument = 'private-code'
-else
- scanner_argument = 'code'
-endif
code = generator(scanner,
output : '@BASENAME@-protocol.c',
diff -ruwN source/hw/xwayland/xwayland-glamor.h source-new/hw/xwayland/xwayland-glamor.h
--- source/hw/xwayland/xwayland-glamor.h 2024-01-16 16:38:49.000000000 +0700
+++ source-new/hw/xwayland/xwayland-glamor.h 2025-10-01 08:01:01.409102814 +0700
@@ -31,7 +31,7 @@
#include <sys/types.h>
#include <wayland-client.h>
-#include <xf86drm.h>
+// #include <xf86drm.h>
#include "xwayland-types.h"
@@ -103,7 +103,7 @@
/* Called to get the DRM device of the primary GPU that this backend
* is set up on.
*/
- drmDevice *(*get_main_device)(struct xwl_screen *xwl_screen);
+ // drmDevice *(*get_main_device)(struct xwl_screen *xwl_screen);
/* Direct hook to create the backing pixmap for a window */
PixmapPtr (*create_pixmap_for_window)(struct xwl_window *xwl_window);
diff -ruwN source/hw/xwayland/xwayland-input.c source-new/hw/xwayland/xwayland-input.c
--- source/hw/xwayland/xwayland-input.c 2024-01-16 16:38:49.000000000 +0700
+++ source-new/hw/xwayland/xwayland-input.c 2025-10-01 08:02:59.681082380 +0700
@@ -26,7 +26,7 @@
#include <xwayland-config.h>
-#include <linux/input.h>
+// #include <linux/input.h>
#include <sys/mman.h>
#include <inputstr.h>
@@ -758,6 +758,7 @@
xwl_seat->xwl_screen->serial = serial;
switch (button) {
+/*
case BTN_LEFT:
index = 1;
break;
@@ -768,10 +769,9 @@
index = 3;
break;
default:
- /* Skip indexes 4-7: they are used for vertical and horizontal scroll.
- The rest of the buttons go in order: BTN_SIDE becomes 8, etc. */
index = 8 + button - BTN_SIDE;
break;
+*/
}
valuator_mask_zero(&mask);
@@ -1057,7 +1057,7 @@
state_rec = xwl_seat->keyboard->key->xkbInfo->state;
xkb_state = (XkbStateFieldFromRec(&state_rec) & 0xff);
-
+ /*
if (((key == KEY_LEFTSHIFT || key == KEY_RIGHTSHIFT) && (xkb_state & ControlMask)) ||
((key == KEY_LEFTCTRL || key == KEY_RIGHTCTRL) && (xkb_state & ShiftMask))) {
@@ -1072,6 +1072,7 @@
if (xwl_window)
xwl_window_rootful_update_title(xwl_window);
}
+ */
}
static void
diff -ruwN source/hw/xwayland/xwayland-window.c source-new/hw/xwayland/xwayland-window.c
--- source/hw/xwayland/xwayland-window.c 2024-01-16 16:38:49.000000000 +0700
+++ source-new/hw/xwayland/xwayland-window.c 2025-10-01 08:00:07.858324820 +0700
@@ -1102,7 +1102,7 @@
for (int j = 0; j < dev_formats->num_formats; j++)
free(dev_formats->formats[j].modifiers);
free(dev_formats->formats);
- drmFreeDevice(&dev_formats->drm_dev);
+ // drmFreeDevice(&dev_formats->drm_dev);
}
void
diff -ruwN source/hw/xwayland/xwayland-window.h source-new/hw/xwayland/xwayland-window.h
--- source/hw/xwayland/xwayland-window.h 2024-01-16 16:38:49.000000000 +0700
+++ source-new/hw/xwayland/xwayland-window.h 2025-10-01 08:00:40.464798537 +0700
@@ -38,7 +38,7 @@
#include <propertyst.h>
#include <validate.h>
#include <wayland-util.h>
-#include <xf86drm.h>
+// #include <xf86drm.h>
#include "xwayland-types.h"
@@ -55,7 +55,7 @@
};
struct xwl_device_formats {
- drmDevice *drm_dev;
+ // drmDevice *drm_dev;
int supports_scanout;
uint32_t num_formats;
struct xwl_format *formats;
@@ -75,7 +75,7 @@
struct xwl_dmabuf_feedback {
struct zwp_linux_dmabuf_feedback_v1 *dmabuf_feedback;
struct xwl_format_table format_table;
- drmDevice *main_dev;
+ // drmDevice *main_dev;
/*
* This will be filled in during wl events and copied to
* dev_formats on dmabuf_feedback.tranche_done
diff -ruwN source/os/access.c source-new/os/access.c
--- source/os/access.c 2024-01-16 16:38:49.000000000 +0700
+++ source-new/os/access.c 2025-10-01 07:22:43.931644468 +0700
@@ -446,7 +446,7 @@
int family;
register HOST *host;
-#ifndef WIN32
+#if !defined(WIN32) && !defined(__redox__)
struct utsname name;
#else
struct {
@@ -477,7 +477,7 @@
* uname() lets me access to the whole string (it smashes release, you
* see), whereas gethostname() kindly truncates it for me.
*/
-#ifndef WIN32
+#if !defined(WIN32) && !defined(__redox__)
uname(&name);
#else
gethostname(name.nodename, sizeof(name.nodename));

View File

@ -0,0 +1,6 @@
# TODO: Port sys/ioccom.h just like BSD?
[source]
tar = "https://gitlab.freedesktop.org/mesa/libdrm/-/archive/libdrm-2.4.125/libdrm-libdrm-2.4.125.tar.gz"
[build]
template = "meson"

View File

@ -0,0 +1,16 @@
[source]
tar = "https://www.x.org/releases/individual/lib/libxshmfence-1.3.tar.gz"
script = """
DYNAMIC_INIT
autotools_recursive_regenerate
"""
[build]
dependencies = [
"x11proto",
]
template = "custom"
script = """
DYNAMIC_INIT
cookbook_configure
"""

View File

@ -0,0 +1,4 @@
[source]
tar = "https://www.x.org/archive/individual/proto/xorgproto-2024.1.tar.xz"
[build]
template = "meson"