Skip to content

支持透明 framebuffer,让无边框窗口可以实现圆角 #90

Closed

Description

@Linductor-alkaid

支持透明 framebuffer,让无边框窗口可以实现圆角

EUI-NEO v0.6.0-dev(ff1e757),bundled GLFW X11 后端。Ubuntu 24.04,GNOME 46 Wayland 会话(XWayland),Mutter 46.2。

用户需求

.decorated(false) 的应用自绘窗口 chrome 时需要圆角窗口。当前做不到:窗口表面永远不透明,因为

  • core::window::WindowCreateRequest 没有透明选项,GLFW 后端从不设置 GLFW_TRANSPARENT_FRAMEBUFFER;
  • DslAppConfig.clearColor 的 alpha 写进的是不透明表面,合成器看不到任何透明像素。

渲染侧其实已经准备好了:圆角矩形自带抗锯齿,Runtime::render 尊重 clearColor 的 alpha,GL 混合状态能正确累积 alpha(glBlendFuncSeparate(SRC_ALPHA, ONE_MINUS_SRC_ALPHA, ONE, ONE_MINUS_SRC_ALPHA)),在 (0,0,0,0) 清屏背景上恰好产出合成器期望的 premultiplied 内容。唯一缺的是窗口层:framebuffer 需要以带 alpha 的表面创建。

Bundled GLFW 在 X11、Wayland、Windows、Cocoa 上都支持透明 framebuffer(X11 需要合成器在跑,主流桌面都满足)。SDL2 没有等价 flag(SDL3 才加入),该后端只能如实报告"不支持"。

建议方案

  1. core::window::WindowCreateRequest.transparent = false,GLFW 后端映射为 glfwWindowHint(GLFW_TRANSPARENT_FRAMEBUFFER, ...);SDL2 后端暂忽略。
  2. 增加 bool framebufferTransparent(Handle window),让应用能确认平台真的授予了透明(GLFW 可以报告;X11 没有合成器时会是 false)。
  3. DslAppConfig.transparent(bool),经 app::windowTransparent() 接入 glfw_app_main / sdl2_app_main 的主窗口请求。
  4. Vulkan:从 capabilities.supportedCompositeAlpha 里选择 swapchain compositeAlpha,不再硬编码 VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR —— 窗口透明时优先 POST_MULTIPLIED(与 premultiplied framebuffer 匹配),否则保持 OPAQUE。
  5. 应用随后清屏为 (0,0,0,0) 并自绘圆角根表面,四角像素保持透明。

Windows 说明:GLFW 在 Win32 上实现 GLFW_TRANSPARENT_FRAMEBUFFER;Windows 11 的 DWM 本身会给顶级窗口圆角,所以该选项当前主要惠及 Linux/macOS —— 按平台写入文档,不选择就不改变任何行为。

验收标准

  • GLFW + OpenGL 在 GNOME/XWayland:无边框窗口呈现抗锯齿圆角根表面,四角透出桌面内容。
  • Vulkan 选择了受支持的 composite-alpha 模式,圆角渲染一致。
  • SDL2 后端保持可构建,行为与现在完全一致(透明报告为未授予)。
  • 未启用 .transparent() 的默认应用逐像素等价于当前行为。

Activity

  1. changed the title [-]Transparent framebuffer support so undecorated windows can have rounded corners[/-] [+]支持透明 framebuffer,让无边框窗口可以实现圆角[/+] on Oct 8, 2026
  2. sudoevolve commented on Oct 10, 2026

    @sudoevolve
    Owner

    Implemented in #98: transparent framebuffer requests and actual-grant reporting are now supported.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions