You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

在透明XCB窗口绘图出现伪影,如何解决该技术问题?

XCB透明窗口绘图伪影问题

Illustratory image

我尝试创建由合成器提供透明度信息的XCB透明窗口。已成功创建透明窗口并使用Cairo进行绘图,但遇到了附图所示的问题:第二个窗口出现了来自第一个窗口的绘图伪影,不清楚具体解决方法。

以下是我使用的Lua代码(实际C代码的简化版本):

local init_x = 80
local init_y = 280
local init_width = 300
local init_height = 200

local win_id = swin.create(init_x, init_y, init_width, init_height)
local pix_id = spixmap.create(init_width, init_height)

local surf = scairo.create_from_pixmap(pix_id, init_width, init_height)
local lsurf = lgi.cairo.Surface(surf, true)
local cr = lgi.cairo.Context(lsurf)

-- the source operator should use data from the compositor
cr:set_operator(lgi.cairo.Operator.SOURCE)
-- paint the window transparent. 
cr:paint_with_alpha(0.0)

cr:rectangle(0, 0, 40, 40)
cr:set_source_rgb(0.8, 0.1, 0.8)
cr:fill()

swin.map(win_id)
spixmap.draw_portion_to_window(pix_id, win_id, 0, 0, init_width, init_height)

我认为代码逻辑并无问题,若需更多细节可告知,我会补充内容。


内容的提问来源于stack exchange,提问作者DesertCarMechanic

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.07 11:17:13