Files
odfstudio/external/skia/fix-xputimage-depth.patch.1
Māris Nartišs eb1fabd39f tdf#168138 skia: fix XPutImage BadMatch on 32-bit X11 windows
RasterWindowContext_xlib::onSwapBuffers() hardcoded image.depth=24,
but LibreOffice's BestVisual() prefers 32-bit TrueColor visuals when
available, making window drawables depth=32. XPutImage requires
XImage.depth to exactly match the target drawable's depth, so a
mismatch causes an asynchronous X11 BadMatch error and crash at the
next X11 call.

Fix by querying the actual window depth via XGetWindowAttributes
in the constructor and using it instead of the hardcoded 24.

Change-Id: I202a350ed1159e8322c00821df2c6c5e7391382b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/199648
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Tested-by: Jenkins
2026-02-19 14:05:28 +01:00

48 lines
1.8 KiB
Groff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: LibreOffice
Date: Wed, 18 Feb 2026 00:00:00 +0000
Subject: [PATCH] Fix XPutImage BadMatch on 32-bit X11 windows
RasterWindowContext_xlib::onSwapBuffers() hardcoded image.depth = 24,
but the target X11 window may have depth 32 (when BestVisual() selects
a 32-bit TrueColor visual, which is preferred for compositing).
XPutImage requires image.depth to exactly match the drawable's depth;
mismatched depth results in a BadMatch X11 error.
Fix: query the actual window depth once during construction via
XGetWindowAttributes and store it as fDepth, then use fDepth instead of
the hardcoded 24 in onSwapBuffers.
---
tools/window/unix/RasterWindowContext_unix.cpp | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
--- skia.org/tools/window/unix/RasterWindowContext_unix.cpp
+++ skia/tools/window/unix/RasterWindowContext_unix.cpp
@@ -34,6 +34,7 @@
Display* fDisplay;
XWindow fWindow;
GC fGC;
+ int fDepth;
};
RasterWindowContext_xlib::RasterWindowContext_xlib(Display* display,
@@ -43,6 +44,9 @@
std::unique_ptr<const DisplayParams> params)
: RasterWindowContext(std::move(params)), fDisplay(display), fWindow(window) {
fGC = XCreateGC(fDisplay, fWindow, 0, nullptr);
+ XWindowAttributes attrs;
+ XGetWindowAttributes(fDisplay, fWindow, &attrs);
+ fDepth = attrs.depth;
this->resize(width, height);
fWidth = width;
fHeight = height;
@@ -79,7 +83,7 @@
image.bitmap_unit = bitsPerPixel;
image.bitmap_bit_order = LSBFirst;
image.bitmap_pad = bitsPerPixel;
- image.depth = 24;
+ image.depth = fDepth;
image.bytes_per_line = pm.rowBytes() - pm.width() * pm.info().bytesPerPixel();
image.bits_per_pixel = bitsPerPixel;
if (!XInitImage(&image)) {