chore: 合并 master

This commit is contained in:
刘旭 2021-11-09 13:05:21 +08:00
commit d6bfb04f04
6 changed files with 40 additions and 19 deletions

View file

@ -38,6 +38,8 @@ bool GraphicsCaptureFrameSource::Initialize() {
const RECT& srcClient = App::GetInstance().GetSrcClientRect();
// 在源窗口存在 DPI 缩放时有时会有一像素的偏移(取决于窗口在屏幕上的位置)
// 可能是 DwmGetWindowAttribute 的 bug
_frameInWnd = {
UINT(srcClient.left - srcRect.left),
UINT(srcClient.top - srcRect.top),
@ -101,6 +103,7 @@ bool GraphicsCaptureFrameSource::Initialize() {
// 开始捕获
_captureSession = _captureFramePool.CreateCaptureSession(captureItem);
// 隐藏光标
if (winrt::ApiInformation::IsPropertyPresent(
L"Windows.Graphics.Capture.GraphicsCaptureSession",
L"IsCursorCaptureEnabled"
@ -111,6 +114,24 @@ bool GraphicsCaptureFrameSource::Initialize() {
SPDLOG_LOGGER_INFO(logger, "当前系统无 IsCursorCaptureEnabled API");
}
// 不显示黄色边框
if (winrt::ApiInformation::IsPropertyPresent(
L"Windows.Graphics.Capture.GraphicsCaptureSession",
L"IsBorderRequired"
)) {
// 从 win11 开始提供
// 先请求权限
auto status = winrt::GraphicsCaptureAccess::RequestAccessAsync(winrt::GraphicsCaptureAccessKind::Borderless).get();
if (status == decltype(status)::Allowed) {
_captureSession.IsBorderRequired(false);
} else {
SPDLOG_LOGGER_INFO(logger, "IsCursorCaptureEnabled 失败");
}
} else {
SPDLOG_LOGGER_INFO(logger, "当前系统无 IsBorderRequired API");
}
_captureSession.StartCapture();
} catch (const winrt::hresult_error& e) {
SPDLOG_LOGGER_ERROR(logger, fmt::format("初始化 WinRT 失败:{}", StrUtils::UTF16ToUTF8(e.message())));