mirror of
https://github.com/obsproject/obs-studio.git
synced 2026-03-02 21:38:21 -05:00
UI: Add option to hide OBS windows on Windows
This uses the SetWindowDisplayAffinity API to hide windows from capture applications (including OBS). This is not perfect - internal windows such as context menus, combo box dropdowns, etc will still be displayed. Even with these limitations, it should help people with single monitors capture content with less interference from the OBS window. This implementation is for Windows only but the code is generic enough that adding other platforms should be straightforward.
This commit is contained in:
@@ -9947,3 +9947,29 @@ void OBSBasic::UpdatePreviewSafeAreas()
|
||||
drawSafeAreas = config_get_bool(App()->GlobalConfig(), "BasicWindow",
|
||||
"ShowSafeAreas");
|
||||
}
|
||||
|
||||
void OBSBasic::SetDisplayAffinity(QWindow *window)
|
||||
{
|
||||
if (!SetDisplayAffinitySupported())
|
||||
return;
|
||||
|
||||
bool hideFromCapture = config_get_bool(App()->GlobalConfig(),
|
||||
"BasicWindow",
|
||||
"HideOBSWindowsFromCapture");
|
||||
|
||||
// Don't hide projectors, those are designed to be visible / captured
|
||||
if (window->property("isOBSProjectorWindow") == true)
|
||||
return;
|
||||
|
||||
#ifdef _WIN32
|
||||
HWND hwnd = (HWND)window->winId();
|
||||
|
||||
if (hideFromCapture)
|
||||
SetWindowDisplayAffinity(hwnd, WDA_EXCLUDEFROMCAPTURE);
|
||||
else
|
||||
SetWindowDisplayAffinity(hwnd, WDA_NONE);
|
||||
#else
|
||||
// TODO: Implement for other platforms if possible. Don't forget to
|
||||
// implement SetDisplayAffinitySupported too!
|
||||
#endif
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user