libobs-winrt: Disable WGC border on insider SDK
Functionality is coming in a future Windows update to disable the yellow border when using WGC. Add code now to opt in. Will require SDK upgrade later for OBS build. winrt::apartment_type::multi_threaded is necessary to dodge assert for calling get() on RequestAccessAsync result. Don't think I will ever fully understand COM apartments.master
parent
71d5451670
commit
2e82a6c7e8
|
@ -240,6 +240,24 @@ static void winrt_capture_device_loss_release(void *data)
|
||||||
capture->item = nullptr;
|
capture->item = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef NTDDI_WIN10_FE
|
||||||
|
static bool winrt_capture_border_toggle_supported()
|
||||||
|
try {
|
||||||
|
return winrt::Windows::Foundation::Metadata::ApiInformation::
|
||||||
|
IsPropertyPresent(
|
||||||
|
L"Windows.Graphics.Capture.GraphicsCaptureSession",
|
||||||
|
L"IsBorderRequired");
|
||||||
|
} catch (const winrt::hresult_error &err) {
|
||||||
|
blog(LOG_ERROR, "winrt_capture_border_toggle_supported (0x%08X): %ls",
|
||||||
|
err.to_abi(), err.message().c_str());
|
||||||
|
return false;
|
||||||
|
} catch (...) {
|
||||||
|
blog(LOG_ERROR, "winrt_capture_border_toggle_supported (0x%08X)",
|
||||||
|
winrt::to_hresult());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static void winrt_capture_device_loss_rebuild(void *device_void, void *data)
|
static void winrt_capture_device_loss_rebuild(void *device_void, void *data)
|
||||||
{
|
{
|
||||||
winrt_capture *capture = static_cast<winrt_capture *>(data);
|
winrt_capture *capture = static_cast<winrt_capture *>(data);
|
||||||
|
@ -286,6 +304,17 @@ static void winrt_capture_device_loss_rebuild(void *device_void, void *data)
|
||||||
const winrt::Windows::Graphics::Capture::GraphicsCaptureSession session =
|
const winrt::Windows::Graphics::Capture::GraphicsCaptureSession session =
|
||||||
frame_pool.CreateCaptureSession(item);
|
frame_pool.CreateCaptureSession(item);
|
||||||
|
|
||||||
|
#ifdef NTDDI_WIN10_FE
|
||||||
|
if (winrt_capture_border_toggle_supported()) {
|
||||||
|
winrt::Windows::Graphics::Capture::GraphicsCaptureAccess::
|
||||||
|
RequestAccessAsync(
|
||||||
|
winrt::Windows::Graphics::Capture::
|
||||||
|
GraphicsCaptureAccessKind::Borderless)
|
||||||
|
.get();
|
||||||
|
session.IsBorderRequired(false);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (winrt_capture_cursor_toggle_supported())
|
if (winrt_capture_cursor_toggle_supported())
|
||||||
session.IsCursorCaptureEnabled(capture->capture_cursor &&
|
session.IsCursorCaptureEnabled(capture->capture_cursor &&
|
||||||
capture->cursor_visible);
|
capture->cursor_visible);
|
||||||
|
@ -369,6 +398,17 @@ try {
|
||||||
const winrt::Windows::Graphics::Capture::GraphicsCaptureSession session =
|
const winrt::Windows::Graphics::Capture::GraphicsCaptureSession session =
|
||||||
frame_pool.CreateCaptureSession(item);
|
frame_pool.CreateCaptureSession(item);
|
||||||
|
|
||||||
|
#ifdef NTDDI_WIN10_FE
|
||||||
|
if (winrt_capture_border_toggle_supported()) {
|
||||||
|
winrt::Windows::Graphics::Capture::GraphicsCaptureAccess::
|
||||||
|
RequestAccessAsync(
|
||||||
|
winrt::Windows::Graphics::Capture::
|
||||||
|
GraphicsCaptureAccessKind::Borderless)
|
||||||
|
.get();
|
||||||
|
session.IsBorderRequired(false);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/* disable cursor capture if possible since ours performs better */
|
/* disable cursor capture if possible since ours performs better */
|
||||||
const BOOL cursor_toggle_supported =
|
const BOOL cursor_toggle_supported =
|
||||||
winrt_capture_cursor_toggle_supported();
|
winrt_capture_cursor_toggle_supported();
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
extern "C" EXPORT void winrt_initialize()
|
extern "C" EXPORT void winrt_initialize()
|
||||||
{
|
{
|
||||||
winrt::init_apartment(winrt::apartment_type::single_threaded);
|
winrt::init_apartment(winrt::apartment_type::multi_threaded);
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" EXPORT void winrt_uninitialize()
|
extern "C" EXPORT void winrt_uninitialize()
|
||||||
|
|
Loading…
Reference in New Issue