Gtk+/X11:带或不带复合管理器的半透明窗口?

发布于 2024-10-16 15:53:38 字数 211 浏览 2 评论 0原文

我需要一些代码来使我的窗口(最好是其上的所有小部件)半透明。 我知道我可以使用 gtk_window_set_opacity(),但它仅在复合管理器运行时才有效,但如果不运行怎么办? 我在谷歌上搜索了很多,发现很多代码大多数甚至无法编译、无法工作或者只是概念证明。没有令人满意的解决方案。我不想搞乱 X11 Xlib 糟糕的 API(我只是没有时间学习它)。

哪里可以获得这样的库/代码片段?

I need some code for making my window (and preferably all widgets on it) semitransparent.
I know i can play around with gtk_window_set_opacity(), but it works only when composite manager is running, but what if not?
I've googled a lot, found lots of code that mostly doesn't even compile, doesn't work or just a proof of concept. No fulfilling solution. I don't want to mess with X11 Xlib awful API (I just don't have time to learn it).

Where to get such library/code snippet?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

箹锭⒈辈孓 2024-10-23 15:53:38

对此没有好的答案(这也是发明合成管理器的一个重要原因)。如果你已经能做到这一点,人们就不会发明整个合成管理器机制。

在旧的“透明终端”等中使用的唯一答案是基于对窗口下方的内容进行屏幕截图,然后在您自己的窗口中绘制屏幕截图。这是一个涉及 Xlib 的混乱,很难大部分正确,不可能完全正确,而且效率低下。不过,你也许可以做到。看看支持透明的终端的旧版本,我认为 VTE 曾经有这个代码,ZVT 小部件当然也有。例如,启蒙终端也是如此。

但真正要走的路是在没有 CM 的情况下,对用户不再透明。

There's no good answer to this (which is a good part of why compositing managers were invented). If you could already do this, people wouldn't have invented the whole compositing manager mechanism.

The only sort-of answer, used in old "transparent terminals" and the like, is based on making screenshots of the stuff underneath the window and then painting the screenshot in your own window. This is an Xlib-involving mess, hard to get mostly right, impossible to get completely correct, and inefficient. Still, you could do it perhaps. Look at old revisions of terminals supporting transparency, I think VTE used to have this code, ZVT widget certainly did. So did the Enlightenment terminal for example.

But really the way to go is to just fall back to no transparency for users without a CM.

红焚 2024-10-23 15:53:38

虽然现代 X11 服务器确实支持 RGBA 视觉效果,但这并不意味着它们会进行 Alpha 混合。 X11 运行的模型是,窗口是单个共享帧缓冲区上的掩码。 Z 排序可能会剪切窗口的某些部分,因此这些区域根本不会被绘制。

为了实现透明度,合成管理器必须将窗口重定向到离屏渲染,然后从那些离屏渲染的部分合成您在屏幕上看到的最终图像。 XDamage 扩展用于跟踪哪些窗口需要重新合成。

While modern X11 servers do support RGBA visuals this doesn't mean, they'll do alpha blending. X11 operates on the model, that a window is a mask on a single shared framebuffer. Z ordering may clip parts of a window so these areas are not drawn to at all.

To enable transparency a compositing manager must redirect the windows to off-screen rendering, then compose the final image you see on the screen from those off-screen rendered parts. The XDamage extension is used to keep track of which windows need re-compositing.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文