Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

优化窗口边框的裁剪 #864

Merged
merged 9 commits into from
Mar 28, 2024
Merged

优化窗口边框的裁剪 #864

merged 9 commits into from
Mar 28, 2024

Conversation

Blinue
Copy link
Owner

@Blinue Blinue commented Mar 28, 2024

  1. 优化了对最大化窗口的支持
    • 修复 Win11 中最大化窗口的不正确裁剪,这是因为 Win11 中 DwmGetWindowAttribute 返回值发生了变化,且 Graphics Capture 捕获区域也和 Win10 不同。由于缺少文档,我测试了很多类型的窗口来做适配,因此现在的实现高度依赖 OS 的实现细节,可能会在未来失效。
    • 修复 Desktop Duplication 无法捕获最大化的窗口的问题。
    • 修复最大化窗口被认为跨越了多个屏幕的问题。
  2. 自动裁剪上边框。这里要考虑太多因素,因为 Win32 窗口实现可谓花样百出。
    1. 如果窗口已最大化,则认为它没有上边框。
    2. 如果窗口禁用了非客户区绘制,则认为它没有上边框。这可以使用 DwmGetWindowAttribute 查询。
    3. 如果窗口使用系统原生边框,则认为它有上边框(仅限捕获标题栏时)。
    4. 如果窗口将客户区扩展到整个窗口,则 DWM 也不会绘制边框。这类窗口的例子包括 https://github.com/melak47/BorderlessWindow 、steam、很多国产应用,基本上没有系统原生边框的窗口都使用这个技术。
    5. 如果窗口自定义了标题栏,而保留了左右下三个方向的原生边框,则认为它上边框。在 Win11 中,DWM 会绘制原生上边框;在 Win10 中,这类窗口很可能会自行绘制上边框(如 Chrome、UWP 等)或者使用 DwmExtendFrameIntoClientArea 保留系统原生上边框(如 Magpie 主窗口、Windows Terminal 等)。
  3. 启用捕获标题栏时也裁剪窗口边框,包括上边框。

@Blinue Blinue added the enhancement New feature or request label Mar 28, 2024
@Blinue Blinue changed the title 优化对窗口边框的裁剪 优化窗口边框的裁剪 Mar 28, 2024
@Blinue Blinue merged commit b167cd1 into render-system Mar 28, 2024
4 checks passed
@Blinue Blinue deleted the maximized branch March 28, 2024 12:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant