From 2de50de563df9d2315d74a63ce5ffbaf3c25f1ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michel=20D=C3=A4nzer?= Date: Wed, 19 Jul 2023 10:43:56 +0200 Subject: [PATCH] mi: Fix up alpha channel if needed in miPaintWindow See also the previous commit log. Fixes the issues with xterm & xcalc described in the GitLab issue below. Issue: https://gitlab.freedesktop.org/xorg/xserver/-/issues/1564 --- mi/miexpose.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/mi/miexpose.c b/mi/miexpose.c index 6b6938a75..6239365b5 100644 --- a/mi/miexpose.c +++ b/mi/miexpose.c @@ -405,6 +405,9 @@ miPaintWindow(WindowPtr pWin, RegionPtr prgn, int what) BoxPtr pbox; xRectangle *prect; int numRects, regionnumrects; +#ifdef COMPOSITE + WindowPtr orig_pWin = pWin; +#endif /* * Distance from screen to destination drawable, use this @@ -488,6 +491,27 @@ miPaintWindow(WindowPtr pWin, RegionPtr prgn, int what) gcval[1].val = fill.pixel | RootlessAlphaMask(pWin->drawable.bitsPerPixel); #else +#ifdef COMPOSITE + /* Make sure alpha will sample as 1.0 for opaque windows */ + if (drawable->depth == 32) { + int effective_depth = orig_pWin->drawable.depth; + + if (effective_depth == 32) { + orig_pWin = orig_pWin->parent; + while (orig_pWin && orig_pWin->parent) { + if (orig_pWin->drawable.depth == 24) { + effective_depth = 24; + break; + } + + orig_pWin = orig_pWin->parent; + } + } + + if (effective_depth == 24) + fill.pixel |= 0xff000000; + } +#endif gcval[1].val = fill.pixel; #endif gcval[2].val = FillSolid;