xserver: Branch 'xwayland-24.1' - 15 commits
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Tue Aug 6 09:25:56 UTC 2024
Xi/listdev.c | 2 -
Xi/xiquerydevice.c | 2 -
dix/extension.c | 2 -
dix/main.c | 2 -
dix/privates.c | 2 -
glamor/glamor_egl.c | 2 -
glamor/glamor_program.c | 4 +-
glamor/glamor_transfer.c | 4 +-
glamor/glamor_xv.c | 52 +++++++++++++++++++----------
hw/xwayland/xwayland-glamor-gbm.c | 20 +++++++----
hw/xwayland/xwayland-input.c | 11 ++++--
hw/xwayland/xwayland-present.c | 24 ++++++++-----
hw/xwayland/xwayland-window-buffers.c | 2 +
hw/xwayland/xwayland-window.c | 16 ++++++++-
hw/xwayland/xwayland-xtest.c | 59 ++++++++++++++++++++++++----------
meson.build | 6 ++-
os/access.c | 2 -
xfixes/cursor.c | 8 ++--
18 files changed, 146 insertions(+), 74 deletions(-)
New commits:
commit 4262fb182b2b51fd0ec8bec30671eb3babe94cb0
Author: Ian Douglas Scott <idscott at system76.com>
Date: Thu May 9 15:02:06 2024 -0700
xwayland: Release keys on keyboard `enter` event if `leave` wasn't received
The code here assumed a `leave` event always occurs between two `enter`
events. On Sway (and presumably other compositors) this happens even if
the client has destroyed the `wl_surface`, but the client gets a null
`surface` here. (Which presumably on on the wire is the id of the
destroyed surface.)
This seems like a bad thing to rely on, and is easy to avoid. But if
this is correct to assume, the Wayland protocol should be explicit about
this.
(cherry picked from commit 386b54fbe95711e6ecb5c23cfdbf25a1571acf7b)
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1635>
diff --git a/hw/xwayland/xwayland-input.c b/hw/xwayland/xwayland-input.c
index d23f284b9..5e4b78469 100644
--- a/hw/xwayland/xwayland-input.c
+++ b/hw/xwayland/xwayland-input.c
@@ -1213,6 +1213,10 @@ keyboard_handle_enter(void *data, struct wl_keyboard *keyboard,
xwl_seat->xwl_screen->serial = serial;
xwl_seat->keyboard_focus = surface;
+ /* If `leave` wasn't sent (for a destroyed surface), release keys here. */
+ wl_array_for_each(k, &xwl_seat->keys)
+ QueueKeyboardEvents(xwl_seat->keyboard, LeaveNotify, *k + 8);
+
wl_array_copy(&xwl_seat->keys, keys);
wl_array_for_each(k, &xwl_seat->keys)
QueueKeyboardEvents(xwl_seat->keyboard, EnterNotify, *k + 8);
@@ -1227,6 +1231,7 @@ xwl_seat_leave_kbd(struct xwl_seat *xwl_seat)
wl_array_for_each(k, &xwl_seat->keys)
QueueKeyboardEvents(xwl_seat->keyboard, LeaveNotify, *k + 8);
+ xwl_seat->keys.size = 0;
xwl_seat->keyboard_focus = NULL;
commit 54a591b9b8b8e2cd49fd02be945e9e0912b874c1
Author: Olivier Fourdan <ofourdan at redhat.com>
Date: Thu Aug 1 14:18:48 2024 +0200
xwayland: Do not include sys/eventfd.h without DRI3
Now that we won't enable DRI3 if <sys/eventfd.h> is not available, there
is not point in trying to include that header without DRI3.
That allows to build Xwayland with GLAMOR enabled (without DRI3) on
platforms which do not support eventfd.
Signed-off-by: Olivier Fourdan <ofourdan at redhat.com>
(cherry picked from commit 23c295ea8b68e5765163f997d5cbb14375b1df3f)
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1635>
diff --git a/hw/xwayland/xwayland-glamor-gbm.c b/hw/xwayland/xwayland-glamor-gbm.c
index 8872bc848..92241bd1e 100644
--- a/hw/xwayland/xwayland-glamor-gbm.c
+++ b/hw/xwayland/xwayland-glamor-gbm.c
@@ -33,7 +33,9 @@
#include <fcntl.h>
#include <errno.h>
#include <poll.h>
+#ifdef DRI3
#include <sys/eventfd.h>
+#endif /* DRI3 */
#include <sys/stat.h>
#include <xf86drm.h>
#include <drm_fourcc.h>
diff --git a/hw/xwayland/xwayland-present.c b/hw/xwayland/xwayland-present.c
index 55524a727..d29411d2c 100644
--- a/hw/xwayland/xwayland-present.c
+++ b/hw/xwayland/xwayland-present.c
@@ -31,7 +31,9 @@
#endif
#include <windowstr.h>
#include <present.h>
+#ifdef DRI3
#include <sys/eventfd.h>
+#endif /* DRI3 */
#include "xwayland-present.h"
#include "xwayland-screen.h"
diff --git a/hw/xwayland/xwayland-window-buffers.c b/hw/xwayland/xwayland-window-buffers.c
index 2bf6c978c..a470ef313 100644
--- a/hw/xwayland/xwayland-window-buffers.c
+++ b/hw/xwayland/xwayland-window-buffers.c
@@ -39,7 +39,9 @@
#include "dri3.h"
#include <poll.h>
+#ifdef DRI3
#include <sys/eventfd.h>
+#endif
#include "linux-drm-syncobj-v1-client-protocol.h"
#define BUFFER_TIMEOUT 1 * 1000 /* ms */
commit 4d88af2228c8d70ded3e887df1f7fa0b290b2e3a
Author: Olivier Fourdan <ofourdan at redhat.com>
Date: Tue May 7 13:42:22 2024 +0200
xwayland: Do not enable DRI3 without eventfd
DRI3 version 1.4 which supports explicit buffers synchronization relies
on the eventfd interface.
As result, building would fail with DRI3 enabled on platforms without
the eventfd interface.
Check for the availability of the sys/eventfd.h header and disable DRI3
support if missing.
Signed-off-by: Olivier Fourdan <ofourdan at redhat.com>
(cherry picked from commit 96bdc156a1c42b884e54960dbdb64a5f0804dfc3)
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1635>
diff --git a/meson.build b/meson.build
index 05d96a73a..4743d63e1 100644
--- a/meson.build
+++ b/meson.build
@@ -332,14 +332,18 @@ endif
libdrm_dep = dependency('libdrm', version: libdrm_req, required: false)
+have_eventfd = cc.has_header('sys/eventfd.h')
if get_option('dri3') == 'auto'
- build_dri3 = dri3proto_dep.found() and xshmfence_dep.found() and libdrm_dep.found()
+ build_dri3 = dri3proto_dep.found() and xshmfence_dep.found() and libdrm_dep.found() and have_eventfd
else
build_dri3 = get_option('dri3') == 'true'
if build_dri3
if not xshmfence_dep.found()
error('DRI3 requested, but xshmfence not found')
endif
+ if not have_eventfd
+ error('DRI3 requested, but sys/eventfd.h not found')
+ endif
endif
endif
commit 2a360e5c0f5ae5a2874c45d8555fba63e85ddcac
Author: Olivier Fourdan <ofourdan at redhat.com>
Date: Tue May 7 11:37:02 2024 +0200
xwayland: Fix build without DRI3 enabled
Signed-off-by: Olivier Fourdan <ofourdan at redhat.com>
Closes: https://gitlab.freedesktop.org/xorg/xserver/-/issues/1668
(cherry picked from commit a58352b985bb9cdca8ce8b215643c5e862427e51)
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1635>
diff --git a/hw/xwayland/xwayland-glamor-gbm.c b/hw/xwayland/xwayland-glamor-gbm.c
index 6a73efe04..8872bc848 100644
--- a/hw/xwayland/xwayland-glamor-gbm.c
+++ b/hw/xwayland/xwayland-glamor-gbm.c
@@ -234,9 +234,9 @@ xwl_glamor_gbm_create_pixmap_for_bo(ScreenPtr screen, struct gbm_bo *bo,
xwl_pixmap->bo = bo;
xwl_pixmap->buffer = NULL;
xwl_pixmap->implicit_modifier = implicit_modifier;
-#ifdef XWL_HAS_GLAMOR
+#if defined(XWL_HAS_GLAMOR) && defined(DRI3)
xwl_pixmap->efd = -1;
-#endif /* XWL_HAS_GLAMOR */
+#endif /* defined(XWL_HAS_GLAMOR) && defined(DRI3) */
#ifdef GBM_BO_FD_FOR_PLANE
if (xwl_gbm->dmabuf_capable) {
@@ -679,6 +679,7 @@ xwl_auth_state_client_callback(CallbackListPtr *pcbl, void *unused, void *data)
}
}
+#ifdef DRI3
static void
sync_callback(void *data, struct wl_callback *callback, uint32_t serial)
{
@@ -741,6 +742,7 @@ xwl_dri3_open_client(ClientPtr client,
return Success;
}
+#endif /* DRI3 */
PixmapPtr
glamor_pixmap_from_fds(ScreenPtr screen, CARD8 num_fds, const int *fds,
@@ -981,6 +983,7 @@ xwl_glamor_dmabuf_import_sync_file(PixmapPtr pixmap, int sync_file)
close(sync_file);
}
+#ifdef DRI3
struct xwl_dri3_syncobj
{
struct dri3_syncobj base;
@@ -1239,6 +1242,7 @@ static dri3_screen_info_rec xwl_dri3_info = {
.get_drawable_modifiers = xwl_glamor_get_drawable_modifiers,
.import_syncobj = NULL, /* need to check for kernel support */
};
+#endif /* DRI3 */
static const char *
get_render_node_path_for_device(const drmDevicePtr drm_device,
@@ -1768,7 +1772,7 @@ xwl_glamor_gbm_init_egl(struct xwl_screen *xwl_screen)
}
/* NVIDIA driver does not support implicit sync */
xwl_gbm->implicit_sync = !strstr(egl_vendor, "NVIDIA");
-
+#ifdef DRI3
if (xwl_gbm_supports_syncobjs(xwl_screen) &&
epoxy_has_egl_extension(xwl_screen->egl_display,
"ANDROID_native_fence_sync"))
@@ -1779,7 +1783,7 @@ xwl_glamor_gbm_init_egl(struct xwl_screen *xwl_screen)
wp_linux_drm_syncobj_manager_v1_destroy(xwl_screen->explicit_sync);
xwl_screen->explicit_sync = NULL;
}
-
+#endif /* DRI3 */
return TRUE;
error:
if (xwl_screen->egl_display != EGL_NO_DISPLAY) {
@@ -1796,7 +1800,7 @@ Bool
xwl_glamor_gbm_init_screen(struct xwl_screen *xwl_screen)
{
struct xwl_gbm_private *xwl_gbm = xwl_gbm_get(xwl_screen);
-
+#ifdef DRI3
if (xwl_gbm->supports_syncobjs) {
xwl_dri3_info.version = 4;
xwl_dri3_info.import_syncobj = xwl_dri3_import_syncobj;
@@ -1806,7 +1810,7 @@ xwl_glamor_gbm_init_screen(struct xwl_screen *xwl_screen)
ErrorF("Failed to initialize dri3\n");
goto error;
}
-
+#endif /* DRI3 */
if (xwl_gbm->fd_render_node)
goto skip_drm_auth;
diff --git a/hw/xwayland/xwayland-present.c b/hw/xwayland/xwayland-present.c
index 60427cca0..55524a727 100644
--- a/hw/xwayland/xwayland-present.c
+++ b/hw/xwayland/xwayland-present.c
@@ -328,7 +328,7 @@ xwl_present_free_event(struct xwl_present_event *event)
static void
xwl_present_free_idle_vblank(present_vblank_ptr vblank)
{
-#ifdef XWL_HAS_GLAMOR
+#if defined(XWL_HAS_GLAMOR) && defined(DRI3)
if (vblank->release_syncobj) {
/* transfer implicit fence to release syncobj */
int fence_fd = xwl_glamor_dmabuf_export_sync_file(vblank->pixmap);
@@ -336,7 +336,7 @@ xwl_present_free_idle_vblank(present_vblank_ptr vblank)
vblank->release_point,
fence_fd);
} else
-#endif /* XWL_HAS_GLAMOR */
+#endif /* defined(XWL_HAS_GLAMOR) && defined(DRI3) */
present_pixmap_idle(vblank->pixmap, vblank->window,
vblank->serial, vblank->idle_fence);
xwl_present_free_event(xwl_present_event_from_vblank(vblank));
@@ -393,7 +393,9 @@ static void
xwl_present_flip_notify_vblank(present_vblank_ptr vblank, uint64_t ust, uint64_t crtc_msc)
{
WindowPtr window = vblank->window;
+#ifdef DRI3
struct xwl_screen *xwl_screen = xwl_screen_get(window->drawable.pScreen);
+#endif /* DRI3 */
struct xwl_present_window *xwl_present_window = xwl_present_window_priv(window);
uint8_t mode = PresentCompleteModeFlip;
@@ -507,7 +509,7 @@ xwl_present_buffer_release(void *data)
vblank = &event->vblank;
-#ifdef XWL_HAS_GLAMOR
+#if defined(XWL_HAS_GLAMOR) && defined(DRI3)
if (vblank->release_syncobj) {
/* transfer implicit fence to release syncobj */
int fence_fd = xwl_glamor_dmabuf_export_sync_file(vblank->pixmap);
@@ -515,7 +517,7 @@ xwl_present_buffer_release(void *data)
vblank->release_point,
fence_fd);
} else
-#endif /* XWL_HAS_GLAMOR */
+#endif /* defined(XWL_HAS_GLAMOR) && defined(DRI3) */
present_pixmap_idle(vblank->pixmap, vblank->window, vblank->serial, vblank->idle_fence);
xwl_present_window = xwl_present_window_priv(vblank->window);
@@ -881,7 +883,7 @@ xwl_present_flip(present_vblank_ptr vblank, RegionPtr damage)
event->pixmap = pixmap;
-#ifdef XWL_HAS_GLAMOR
+#if defined(XWL_HAS_GLAMOR) && defined(DRI3)
if (vblank->acquire_syncobj && vblank->release_syncobj) {
if (xwl_window->xwl_screen->explicit_sync) {
xwl_glamor_dri3_syncobj_passthrough(xwl_window,
@@ -898,7 +900,7 @@ xwl_present_flip(present_vblank_ptr vblank, RegionPtr damage)
xwl_glamor_dmabuf_import_sync_file(vblank->pixmap, fence_fd);
}
}
-#endif /* XWL_HAS_GLAMOR */
+#endif /* defined(XWL_HAS_GLAMOR) && defined(DRI3) */
if (implicit_sync) {
xwl_pixmap_set_buffer_release_cb(pixmap, xwl_present_buffer_release, event);
@@ -950,7 +952,7 @@ xwl_present_flip(present_vblank_ptr vblank, RegionPtr damage)
return TRUE;
}
-#ifdef XWL_HAS_GLAMOR
+#if defined(XWL_HAS_GLAMOR) && defined(DRI3)
static void
xwl_present_acquire_fence_avail(int fd, int xevents, void *data)
{
@@ -962,13 +964,13 @@ xwl_present_acquire_fence_avail(int fd, int xevents, void *data)
xwl_present_re_execute(vblank);
}
-#endif /* XWL_HAS_GLAMOR */
+#endif /* defined(XWL_HAS_GLAMOR) && defined(DRI3) */
static Bool
xwl_present_wait_acquire_fence_avail(struct xwl_screen *xwl_screen,
present_vblank_ptr vblank)
{
-#ifdef XWL_HAS_GLAMOR
+#if defined(XWL_HAS_GLAMOR) && defined(DRI3)
/* If the compositor does not support explicit sync we need to wait for the
* acquire fence to be submitted before flipping. */
if (vblank->flip && !xwl_screen->explicit_sync &&
@@ -982,7 +984,7 @@ xwl_present_wait_acquire_fence_avail(struct xwl_screen *xwl_screen,
vblank->efd);
return TRUE;
}
-#endif /* XWL_HAS_GLAMOR */
+#endif /* defined(XWL_HAS_GLAMOR) && defined(DRI3) */
return FALSE;
}
commit a2446275c960029a57a9376809aa4832688ebada
Author: Nicolas Dufresne <nicolas.dufresne at collabora.com>
Date: Tue Jul 30 15:53:25 2024 -0400
glamor: xv: Rewrite UYVY shader to match NV12/I420 CSC
This rewrites the shader so that we use the same (more flexible) CSC as
we have for I420 and NV12. This also fixes the reverse of odd/even which
caused chroma shift.
Signed-off-by: Nicolas Dufresne <nicolas.dufresne at collabora.com>
(cherry picked from commit 39c8a6f367154b1110a1e6845566a3388be4f90e)
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1635>
diff --git a/glamor/glamor_xv.c b/glamor/glamor_xv.c
index d4e7ced69..328769ab1 100644
--- a/glamor/glamor_xv.c
+++ b/glamor/glamor_xv.c
@@ -141,24 +141,22 @@ static const glamor_facet glamor_facet_xv_uyvy = {
"in vec2 tcs;\n"
),
.fs_exec = (
- " vec3 uyv;\n"
- " vec4 frameOut = texture2D(sampler, tcs.st);\n"
- "\n"
- " vec4 prevPixel = texture2D(sampler, vec2(tcs.s - texelSize.x, tcs.t));\n"
- " vec4 nextPixel = texture2D(sampler, vec2(tcs.s + texelSize.x, tcs.t));\n"
- "\n"
- " float delta = 0.50;\n"
- "\n"
- " int even = int(mod(tcs.x / texelSize.x, 2.0));\n"
- "\n"
- " uyv.rgb = float(even)*vec3(frameOut.rg, nextPixel.r) + (1.0-float(even))*vec3(prevPixel.r, frameOut.gr);\n"
- "\n"
- " frameOut.r = uyv.g + 1.403*(uyv.r - delta);\n"
- " frameOut.g = uyv.g - 0.714*(uyv.r - delta) - 0.344*(uyv.b - delta);\n"
- " frameOut.b = uyv.g + 1.773*(uyv.b - delta);\n"
- " frameOut.a = 1.0;\n"
- " frag_color = frameOut;\n"
- ),
+ " vec4 temp1;\n"
+ " vec2 xy = texture(sampler, tcs.st).xy;\n"
+ " vec2 prev_xy = texture(sampler, vec2(tcs.s - texelSize.x, tcs.t)).xy;\n"
+ " vec2 next_xy = texture(sampler, vec2(tcs.s + texelSize.x, tcs.t)).xy;\n"
+ "\n"
+ " vec3 sample_yuv;\n"
+ " int odd = int(mod(tcs.x / texelSize.x, 2.0));\n"
+ " int even = 1 - odd;\n"
+ " sample_yuv.yxz = float(even)*vec3(xy, next_xy.x) + float(odd)*vec3(prev_xy.x, xy.yx);\n"
+ "\n"
+ " temp1.xyz = offsetyco.www * vec3(sample_yuv.x) + offsetyco.xyz;\n"
+ " temp1.xyz = ucogamma.xyz * vec3(sample_yuv.y) + temp1.xyz;\n"
+ " temp1.xyz = clamp(vco.xyz * vec3(sample_yuv.z) + temp1.xyz, 0.0, 1.0);\n"
+ " temp1.w = 1.0;\n"
+ " frag_color = temp1;\n"
+ ),
};
static const glamor_facet glamor_facet_xv_rgb_raw = {
commit 978093d1a5362d33246a45eaf5fc7ca1eee6a7a6
Author: Konstantin <ria.freelander at gmail.com>
Date: Wed Jul 31 11:12:38 2024 +0300
glamor: xv: fix UYVY alignment
UYVY videos should be aligned by 2 to avoid breakups in the shader
Fixes: 832b392f7 - glamor: xv: enable UYVY acceleration
Suggested-by: Nicolas Dufresne <nicolas.dufresne at collabora.com>
Signed-off-by: Konstantin <ria.freelander at gmail.com>
(cherry picked from commit eb26f3236804389f2006388936322dc8115d00e0)
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1635>
diff --git a/glamor/glamor_xv.c b/glamor/glamor_xv.c
index 40b9ca4ea..d4e7ced69 100644
--- a/glamor/glamor_xv.c
+++ b/glamor/glamor_xv.c
@@ -379,9 +379,16 @@ glamor_xv_query_image_attributes(int id,
offsets[0] = 0;
size *= *h;
break;
- case FOURCC_RGB565:
case FOURCC_UYVY:
/* UYVU is single-plane really, all tranformation is processed inside a shader */
+ size = ALIGN(*w, 2) * 2;
+ if (pitches)
+ pitches[0] = size;
+ if (offsets)
+ offsets[0] = 0;
+ size *= *h;
+ break;
+ case FOURCC_RGB565:
size = *w * 2;
if (pitches)
pitches[0] = size;
@@ -787,6 +794,15 @@ glamor_xv_put_image(glamor_port_private *port_priv,
buf + s2offset, srcPitch);
break;
case FOURCC_UYVY:
+ srcPitch = ALIGN(width, 2) * 2;
+ full_box.x1 = 0;
+ full_box.y1 = 0;
+ full_box.x2 = width;
+ full_box.y2 = height;
+ glamor_upload_boxes(&port_priv->src_pix[0]->drawable, &full_box, 1,
+ 0, 0, 0, 0,
+ buf, srcPitch);
+ break;
case FOURCC_RGB565:
srcPitch = width * 2;
full_box.x1 = 0;
commit 4543d4a25a5f8d5730aee5d0f22fdf595f4d9141
Author: Konstantin <ria.freelander at gmail.com>
Date: Thu Sep 21 16:45:08 2023 +0300
glamor: check BPP by render_format.
Check actual BPP by render_format in upload_boxes, not by drawable BPP.
It is required when we used different BPP formats for storing and
rendering (for example, in the case of UYVY).
The problem of UYVY size lies inside method of glamor downloading boxes.
When we set GLAMOR_CREATE_FORMAT_CBCR, it actually uses 16-bit GL and
Pixman formats, but before this change in glamor_download_boxes, that
function deduces GL and Pixman formats from BPP, which is wrong in this
case (will be deduced to 32).
When GL and Pixman format BPP is identical to drawable BPP, this change
does nothing, but when it is different - it will prioritize Pixman
format, not the format deduced from BPP.
Closes: https://gitlab.freedesktop.org/xorg/xserver/-/issues/1730
Signed-off-by: Konstantin Pugin <ria.freelander at gmail.com>
(cherry picked from commit 75f56b79234bf428455fa0bef741a86fc5919889)
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1635>
diff --git a/glamor/glamor_transfer.c b/glamor/glamor_transfer.c
index 9404e899c..77c60d06f 100644
--- a/glamor/glamor_transfer.c
+++ b/glamor/glamor_transfer.c
@@ -37,8 +37,8 @@ glamor_upload_boxes(DrawablePtr drawable, BoxPtr in_boxes, int in_nbox,
PixmapPtr pixmap = glamor_get_drawable_pixmap(drawable);
glamor_pixmap_private *priv = glamor_get_pixmap_private(pixmap);
int box_index;
- int bytes_per_pixel = drawable->bitsPerPixel >> 3;
const struct glamor_format *f = glamor_format_for_pixmap(pixmap);
+ int bytes_per_pixel = PICT_FORMAT_BPP(f->render_format) >> 3;
char *tmp_bits = NULL;
if (glamor_drawable_effective_depth(drawable) == 24 && pixmap->drawable.depth == 32)
@@ -145,8 +145,8 @@ glamor_download_boxes(DrawablePtr drawable, BoxPtr in_boxes, int in_nbox,
PixmapPtr pixmap = glamor_get_drawable_pixmap(drawable);
glamor_pixmap_private *priv = glamor_get_pixmap_private(pixmap);
int box_index;
- int bytes_per_pixel = drawable->bitsPerPixel >> 3;
const struct glamor_format *f = glamor_format_for_pixmap(pixmap);
+ int bytes_per_pixel = PICT_FORMAT_BPP(f->render_format) >> 3;
glamor_make_current(glamor_priv);
commit 8937d47d08a1b77cb980a31cfc73fb0ac0544723
Author: Olivier Fourdan <ofourdan at redhat.com>
Date: Mon Jul 29 17:43:45 2024 +0200
xwayland/ei: Dequeue events when all caps are available
Currently, we would start dequeuing events as soon as a device is
resumed, regardless of its capabilities.
If the capabilities are not available, we would just fallback to the
regular XTEST code path and not use input emulation.
As a result, it is very likely that we shall lose the first events until
the compositor resumes first a device with the requested capabilities.
To avoid that issue, start emulating only once we have the requested
capabilities, if they match the seat capabilities.
Closes: https://gitlab.freedesktop.org/xorg/xserver/-/issues/1732
Signed-off-by: Olivier Fourdan <ofourdan at redhat.com>
(cherry picked from commit 0525b9a5b9c40ec4dd384b8878cda85ef7401b94)
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1635>
diff --git a/hw/xwayland/xwayland-xtest.c b/hw/xwayland/xwayland-xtest.c
index 9045681f8..e947a35e7 100644
--- a/hw/xwayland/xwayland-xtest.c
+++ b/hw/xwayland/xwayland-xtest.c
@@ -741,6 +741,20 @@ xwl_ei_update_caps(struct xwl_ei_client *xwl_ei_client,
}
}
+static bool
+xwl_ei_devices_are_ready(struct xwl_ei_client *xwl_ei_client)
+{
+ if ((xwl_ei_client->accept_keyboard ||
+ !ei_seat_has_capability(xwl_ei_client->ei_seat, EI_DEVICE_CAP_KEYBOARD)) &&
+ (xwl_ei_client->accept_pointer ||
+ !ei_seat_has_capability(xwl_ei_client->ei_seat, EI_DEVICE_CAP_POINTER)) &&
+ (xwl_ei_client->accept_abs ||
+ !ei_seat_has_capability(xwl_ei_client->ei_seat, EI_DEVICE_CAP_POINTER_ABSOLUTE)))
+ return true;
+
+ return false;
+}
+
static void
xwl_handle_ei_event(int fd, int ready, void *data)
{
@@ -850,8 +864,10 @@ xwl_handle_ei_event(int fd, int ready, void *data)
/* Server has accepted our device (or resumed them),
* we can now start sending events */
/* FIXME: Maybe add a timestamp and discard old events? */
- xwl_ei_start_emulating(xwl_ei_client);
- xwl_dequeue_emulated_events(xwl_ei_client);
+ if (xwl_ei_devices_are_ready(xwl_ei_client)) {
+ xwl_ei_start_emulating(xwl_ei_client);
+ xwl_dequeue_emulated_events(xwl_ei_client);
+ }
if (!xwl_ei_client->client &&
xorg_list_is_empty(&xwl_ei_client->pending_emulated_events))
/* All events dequeued and client has disconnected in the meantime */
commit a1651d41e7d069936de92535160814b7416d38ec
Author: Olivier Fourdan <ofourdan at redhat.com>
Date: Mon Jul 29 17:41:42 2024 +0200
xwayland/ei: Move code to helper function
This is a small code refactoring to help with clarity, simply move the
code from the switch case for device resume to a dedicated function.
No functional change.
Signed-off-by: Olivier Fourdan <ofourdan at redhat.com>
(cherry picked from commit 68ec297ee9821d4ce86f7824a37496569f2343d6)
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1635>
diff --git a/hw/xwayland/xwayland-xtest.c b/hw/xwayland/xwayland-xtest.c
index 40ab866a0..9045681f8 100644
--- a/hw/xwayland/xwayland-xtest.c
+++ b/hw/xwayland/xwayland-xtest.c
@@ -723,6 +723,24 @@ xwl_dequeue_emulated_events(struct xwl_ei_client *xwl_ei_client)
return true;
}
+static void
+xwl_ei_update_caps(struct xwl_ei_client *xwl_ei_client,
+ struct ei_device *ei_device)
+{
+ struct xwl_abs_device *abs;
+
+ if (ei_device == xwl_ei_client->ei_pointer)
+ xwl_ei_client->accept_pointer = true;
+
+ if (ei_device == xwl_ei_client->ei_keyboard)
+ xwl_ei_client->accept_keyboard = true;
+
+ xorg_list_for_each_entry(abs, &xwl_ei_client->abs_devices, link) {
+ if (ei_device == abs->device)
+ xwl_ei_client->accept_abs = true;
+ }
+}
+
static void
xwl_handle_ei_event(int fd, int ready, void *data)
{
@@ -828,20 +846,7 @@ xwl_handle_ei_event(int fd, int ready, void *data)
break;
case EI_EVENT_DEVICE_RESUMED:
debug_ei("Device resumed\n");
- if (ei_device == xwl_ei_client->ei_pointer)
- xwl_ei_client->accept_pointer = true;
- if (ei_device == xwl_ei_client->ei_keyboard)
- xwl_ei_client->accept_keyboard = true;
- {
- struct xwl_abs_device *abs;
-
- xorg_list_for_each_entry(abs, &xwl_ei_client->abs_devices,
- link) {
- if (ei_device == abs->device)
- xwl_ei_client->accept_abs = true;
- }
- }
-
+ xwl_ei_update_caps(xwl_ei_client, ei_device);
/* Server has accepted our device (or resumed them),
* we can now start sending events */
/* FIXME: Maybe add a timestamp and discard old events? */
commit b3635ba69e7d8d965bf5e8ce66e8da5b9365a7cd
Author: Olivier Fourdan <ofourdan at redhat.com>
Date: Mon Jul 29 11:54:15 2024 +0200
glamor: Fix possible double-free
If glamor_link_glsl_prog() fails, we may jump to the failed code path
which frees the variable vs_prog_string and fs_prog_string.
But those variables were already freed just before, so in that case we
end up freeing the memory twice.
Simply move the free at the end of the success code path so we are sure
to free the values only once, either in the successful of failed code
paths.
Fixes: 2906ee5e4 - glamor: Fix leak in glamor_build_program()
Signed-off-by: Olivier Fourdan <ofourdan at redhat.com>
(cherry picked from commit 34ea020344ef5f2ea8ffce78c7e1abd6436b21ec)
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1635>
diff --git a/glamor/glamor_program.c b/glamor/glamor_program.c
index 21f8987d9..a02584fad 100644
--- a/glamor/glamor_program.c
+++ b/glamor/glamor_program.c
@@ -359,8 +359,6 @@ glamor_build_program(ScreenPtr screen,
vs_prog = glamor_compile_glsl_prog(GL_VERTEX_SHADER, vs_prog_string);
fs_prog = glamor_compile_glsl_prog(GL_FRAGMENT_SHADER, fs_prog_string);
- free(vs_prog_string);
- free(fs_prog_string);
glAttachShader(prog->prog, vs_prog);
glDeleteShader(vs_prog);
glAttachShader(prog->prog, fs_prog);
@@ -394,6 +392,8 @@ glamor_build_program(ScreenPtr screen,
prog->atlas_uniform = glamor_get_uniform(prog, glamor_program_location_atlas, "atlas");
free(version_string);
+ free(vs_prog_string);
+ free(fs_prog_string);
free(fs_vars);
free(vs_vars);
return TRUE;
commit fac3486a666009e67394741e1ad30c1b694ce71e
Author: Olivier Fourdan <ofourdan at redhat.com>
Date: Wed Jul 24 10:52:59 2024 +0200
xwayland/ei: Log the type name of unhandled events
Currently, we would log only the event type, use the libei API to also
log the name in plain text, so we can quickly identify the events we're
missing out.
Signed-off-by: Olivier Fourdan <ofourdan at redhat.com>
(cherry picked from commit 1a42fe40d04d8bb18e7b9db6f6a40e552462f980)
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1635>
diff --git a/hw/xwayland/xwayland-xtest.c b/hw/xwayland/xwayland-xtest.c
index af7d02c07..40ab866a0 100644
--- a/hw/xwayland/xwayland-xtest.c
+++ b/hw/xwayland/xwayland-xtest.c
@@ -857,7 +857,7 @@ xwl_handle_ei_event(int fd, int ready, void *data)
/* Don't care */
break;
default:
- error_ei("Unhandled event %d\n", type);
+ error_ei("Unhandled event %s (%d)\n", ei_event_type_to_string(type), type);
break;
}
ei_event_unref(e);
commit ce7fb8139aa846a73b68607f97b8754ae13fb00f
Author: Olivier Fourdan <ofourdan at redhat.com>
Date: Wed Jul 24 10:48:51 2024 +0200
xwayland/ei: Handle EI_EVENT_KEYBOARD_MODIFIERS
Although we do not do anything with that event, handle it so we don't
end up in the "Unhandled event" territory.
Closes: https://gitlab.freedesktop.org/xorg/xserver/-/issues/1722
Fixes: a133334270 - xwayland: Add XTEST support using EIS
Signed-off-by: Olivier Fourdan <ofourdan at redhat.com>
(cherry picked from commit bfabd3bdab6b357a79ea092a03383bbaf1321866)
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1635>
diff --git a/hw/xwayland/xwayland-xtest.c b/hw/xwayland/xwayland-xtest.c
index 1b870aa63..af7d02c07 100644
--- a/hw/xwayland/xwayland-xtest.c
+++ b/hw/xwayland/xwayland-xtest.c
@@ -852,6 +852,10 @@ xwl_handle_ei_event(int fd, int ready, void *data)
/* All events dequeued and client has disconnected in the meantime */
xwl_ei_stop_emulating(xwl_ei_client);
break;
+ case EI_EVENT_KEYBOARD_MODIFIERS:
+ debug_ei("Ignored event %s (%d)\n", ei_event_type_to_string(type), type);
+ /* Don't care */
+ break;
default:
error_ei("Unhandled event %d\n", type);
break;
commit 98326b8c9fcfd3bac82d91f064954fefe759bdd0
Author: Olivier Fourdan <ofourdan at redhat.com>
Date: Wed Jul 24 15:19:41 2024 +0200
xwayland: Make sure output is suitable for fullscreen
Since commit d370f1e58, Xwayland can optionally be started rootful and
fullscreen.
To do so, it will setup a viewport to scale the root window to match the
size of the output.
However, if the rootful Xwayland window receives an xdg-surface configure
event before the output definition is complete, as with e.g. the labwc
Wayland compositor, we might end up trying to setup a viewport with a
destination size of 0x0 which is a protocol violation, and that kills
Xwayland.
To avoid that issue, only setup the viewport if the output size is
meaningful.
Also, please note that once the output definition is complete, i.e. when
the "done" event is eventually received, we shall recompute the size for
fullscreen again, hence achieving the desired fullscreen state.
Fixes: d370f1e58 - xwayland: add fullscreen mode for rootful
Closes: https://gitlab.freedesktop.org/xorg/xserver/-/issues/1717
Signed-off-by: Olivier Fourdan <ofourdan at redhat.com>
(cherry picked from commit 66f5e7e96a00b1ed9d8c11b4661e8e8370b1adf0)
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1635>
diff --git a/hw/xwayland/xwayland-window.c b/hw/xwayland/xwayland-window.c
index c1566a608..ca9eaaaf4 100644
--- a/hw/xwayland/xwayland-window.c
+++ b/hw/xwayland/xwayland-window.c
@@ -494,6 +494,18 @@ window_get_client_toplevel(WindowPtr window)
return window;
}
+static Bool
+is_output_suitable_for_fullscreen(struct xwl_output *xwl_output)
+{
+ if (xwl_output == NULL)
+ return FALSE;
+
+ if (xwl_output->width == 0 || xwl_output->height == 0)
+ return FALSE;
+
+ return TRUE;
+}
+
static struct xwl_output *
xwl_window_get_output(struct xwl_window *xwl_window)
{
@@ -501,11 +513,11 @@ xwl_window_get_output(struct xwl_window *xwl_window)
struct xwl_output *xwl_output;
xwl_output = xwl_output_get_output_from_name(xwl_screen, xwl_screen->output_name);
- if (xwl_output)
+ if (is_output_suitable_for_fullscreen(xwl_output))
return xwl_output;
xwl_output = xwl_output_from_wl_output(xwl_screen, xwl_window->wl_output);
- if (xwl_output)
+ if (is_output_suitable_for_fullscreen(xwl_output))
return xwl_output;
return xwl_screen_get_first_output(xwl_screen);
commit ca52da8cba2b2558de5d50559e74b0d923311a86
Author: Alan Coopersmith <alan.coopersmith at oracle.com>
Date: Sun Jul 14 11:24:00 2024 -0700
Move sizeof to second argument in calloc calls
Clears -Wcalloc-transposed-args warnings from gcc 14.1, such as:
../dix/main.c:165:42: warning: ‘calloc’ sizes specified with ‘sizeof’ in the
earlier argument and not in the later argument [-Wcalloc-transposed-args]
165 | serverClient = calloc(sizeof(ClientRec), 1);
| ^~~~~~~~~
../dix/main.c:165:42: note: earlier argument should specify number of
elements, later size of each element
Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>
(cherry picked from commit 522f469fe9af2a2455c86c7784f0c6cce6781c10)
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1635>
diff --git a/Xi/listdev.c b/Xi/listdev.c
index c15e61b37..e5c3d5e7b 100644
--- a/Xi/listdev.c
+++ b/Xi/listdev.c
@@ -350,7 +350,7 @@ ProcXListInputDevices(ClientPtr client)
};
/* allocate space for saving skip value */
- skip = calloc(sizeof(Bool), inputInfo.numDevices);
+ skip = calloc(inputInfo.numDevices, sizeof(Bool));
if (!skip)
return BadAlloc;
diff --git a/Xi/xiquerydevice.c b/Xi/xiquerydevice.c
index e4731a119..bfcefcd17 100644
--- a/Xi/xiquerydevice.c
+++ b/Xi/xiquerydevice.c
@@ -88,7 +88,7 @@ ProcXIQueryDevice(ClientPtr client)
len += SizeDeviceInfo(dev);
}
else {
- skip = calloc(sizeof(Bool), inputInfo.numDevices);
+ skip = calloc(inputInfo.numDevices, sizeof(Bool));
if (!skip)
return BadAlloc;
diff --git a/dix/extension.c b/dix/extension.c
index dbe6c0a97..833a6170f 100644
--- a/dix/extension.c
+++ b/dix/extension.c
@@ -89,7 +89,7 @@ AddExtension(const char *name, int NumEvents, int NumErrors,
return ((ExtensionEntry *) NULL);
}
- ext = calloc(sizeof(ExtensionEntry), 1);
+ ext = calloc(1, sizeof(ExtensionEntry));
if (!ext)
return NULL;
if (!dixAllocatePrivates(&ext->devPrivates, PRIVATE_EXTENSION)) {
diff --git a/dix/main.c b/dix/main.c
index 827f5f260..4980bd6cb 100644
--- a/dix/main.c
+++ b/dix/main.c
@@ -156,7 +156,7 @@ dix_main(int argc, char *argv[], char *envp[])
CreateWellKnownSockets();
for (i = 1; i < LimitClients; i++)
clients[i] = NullClient;
- serverClient = calloc(sizeof(ClientRec), 1);
+ serverClient = calloc(1, sizeof(ClientRec));
if (!serverClient)
FatalError("couldn't create server client");
InitClient(serverClient, 0, (void *) NULL);
diff --git a/dix/privates.c b/dix/privates.c
index 3df845531..2bfedb93b 100644
--- a/dix/privates.c
+++ b/dix/privates.c
@@ -413,7 +413,7 @@ dixRegisterScreenPrivateKey(DevScreenPrivateKey screenKey, ScreenPtr pScreen,
assert(key->type == type);
return TRUE;
}
- key = calloc(sizeof(DevPrivateKeyRec), 1);
+ key = calloc(1, sizeof(DevPrivateKeyRec));
if (!key)
return FALSE;
if (!dixRegisterPrivateKey(key, type, size)) {
diff --git a/glamor/glamor_egl.c b/glamor/glamor_egl.c
index 844dbbe71..86455c407 100644
--- a/glamor/glamor_egl.c
+++ b/glamor/glamor_egl.c
@@ -1089,7 +1089,7 @@ glamor_egl_init(ScrnInfoPtr scrn, int fd)
Bool force_es = FALSE;
const char *glvnd_vendor = NULL;
- glamor_egl = calloc(sizeof(*glamor_egl), 1);
+ glamor_egl = calloc(1, sizeof(*glamor_egl));
if (glamor_egl == NULL)
return FALSE;
if (xf86GlamorEGLPrivateIndex == -1)
diff --git a/hw/xwayland/xwayland-glamor-gbm.c b/hw/xwayland/xwayland-glamor-gbm.c
index ebc990b57..6a73efe04 100644
--- a/hw/xwayland/xwayland-glamor-gbm.c
+++ b/hw/xwayland/xwayland-glamor-gbm.c
@@ -1850,7 +1850,7 @@ xwl_glamor_init_gbm(struct xwl_screen *xwl_screen)
if (!dixRegisterPrivateKey(&xwl_gbm_private_key, PRIVATE_SCREEN, 0))
return FALSE;
- xwl_gbm = calloc(sizeof(*xwl_gbm), 1);
+ xwl_gbm = calloc(1, sizeof(*xwl_gbm));
if (!xwl_gbm) {
ErrorF("glamor: Not enough memory to setup GBM, disabling\n");
return FALSE;
diff --git a/hw/xwayland/xwayland-input.c b/hw/xwayland/xwayland-input.c
index 4b8f22a03..d23f284b9 100644
--- a/hw/xwayland/xwayland-input.c
+++ b/hw/xwayland/xwayland-input.c
@@ -2870,7 +2870,7 @@ tablet_seat_handle_add_tablet(void *data, struct zwp_tablet_seat_v2 *tablet_seat
struct xwl_seat *xwl_seat = data;
struct xwl_tablet *xwl_tablet;
- xwl_tablet = calloc(sizeof *xwl_tablet, 1);
+ xwl_tablet = calloc(1, sizeof *xwl_tablet);
if (xwl_tablet == NULL) {
ErrorF("%s ENOMEM\n", __func__);
return;
@@ -2901,7 +2901,7 @@ tablet_seat_handle_add_tool(void *data, struct zwp_tablet_seat_v2 *tablet_seat,
struct xwl_screen *xwl_screen = xwl_seat->xwl_screen;
struct xwl_tablet_tool *xwl_tablet_tool;
- xwl_tablet_tool = calloc(sizeof *xwl_tablet_tool, 1);
+ xwl_tablet_tool = calloc(1, sizeof *xwl_tablet_tool);
if (xwl_tablet_tool == NULL) {
ErrorF("%s ENOMEM\n", __func__);
return;
@@ -2924,7 +2924,7 @@ tablet_seat_handle_add_pad(void *data, struct zwp_tablet_seat_v2 *tablet_seat,
struct xwl_seat *xwl_seat = data;
struct xwl_tablet_pad *xwl_tablet_pad;
- xwl_tablet_pad = calloc(sizeof *xwl_tablet_pad, 1);
+ xwl_tablet_pad = calloc(1, sizeof *xwl_tablet_pad);
if (xwl_tablet_pad == NULL) {
ErrorF("%s ENOMEM\n", __func__);
return;
diff --git a/xfixes/cursor.c b/xfixes/cursor.c
index 83282ff0e..c34dd9f0f 100644
--- a/xfixes/cursor.c
+++ b/xfixes/cursor.c
@@ -379,8 +379,8 @@ ProcXFixesGetCursorImage(ClientPtr client)
width = pCursor->bits->width;
height = pCursor->bits->height;
npixels = width * height;
- rep = calloc(sizeof(xXFixesGetCursorImageReply) + npixels * sizeof(CARD32),
- 1);
+ rep = calloc(1,
+ sizeof(xXFixesGetCursorImageReply) + npixels * sizeof(CARD32));
if (!rep)
return BadAlloc;
@@ -531,8 +531,8 @@ ProcXFixesGetCursorImageAndName(ClientPtr client)
name = pCursor->name ? NameForAtom(pCursor->name) : "";
nbytes = strlen(name);
nbytesRound = pad_to_int32(nbytes);
- rep = calloc(sizeof(xXFixesGetCursorImageAndNameReply) +
- npixels * sizeof(CARD32) + nbytesRound, 1);
+ rep = calloc(1, sizeof(xXFixesGetCursorImageAndNameReply) +
+ npixels * sizeof(CARD32) + nbytesRound);
if (!rep)
return BadAlloc;
commit c0bd91f49e670c1e56112d0d74501c2c7cc5ade2
Author: Joaquim Monteiro <joaquim.monteiro at protonmail.com>
Date: Sun Jun 23 21:17:25 2024 +0100
os: Fix assignment with incompatible pointer type
struct hostent->h_addr_list is of type char**, not const char**.
GCC considers this an error when in C99 mode or later.
Signed-off-by: Joaquim Monteiro <joaquim.monteiro at protonmail.com>
(cherry picked from commit 0ddcd8785199c08d9bded3c767a3b1227c670999)
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1635>
diff --git a/os/access.c b/os/access.c
index cf784248d..08a99bda4 100644
--- a/os/access.c
+++ b/os/access.c
@@ -1866,7 +1866,7 @@ siHostnameAddrMatch(int family, void *addr, int len,
char hostname[SI_HOSTNAME_MAXLEN];
int f, hostaddrlen;
void *hostaddr;
- const char **addrlist;
+ char **addrlist;
if (siAddrLen >= sizeof(hostname))
return FALSE;
More information about the xorg-commit
mailing list