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:
parent
e9cbe52d96
commit
076cd5d5d4
12 changed files with 162 additions and 0 deletions
|
|
@ -383,6 +383,7 @@ OBSBasicSettings::OBSBasicSettings(QWidget *parent)
|
|||
HookWidget(ui->theme, COMBO_CHANGED, GENERAL_CHANGED);
|
||||
HookWidget(ui->enableAutoUpdates, CHECK_CHANGED, GENERAL_CHANGED);
|
||||
HookWidget(ui->openStatsOnStartup, CHECK_CHANGED, GENERAL_CHANGED);
|
||||
HookWidget(ui->hideOBSFromCapture, CHECK_CHANGED, GENERAL_CHANGED);
|
||||
HookWidget(ui->warnBeforeStreamStart,CHECK_CHANGED, GENERAL_CHANGED);
|
||||
HookWidget(ui->warnBeforeStreamStop, CHECK_CHANGED, GENERAL_CHANGED);
|
||||
HookWidget(ui->warnBeforeRecordStop, CHECK_CHANGED, GENERAL_CHANGED);
|
||||
|
|
@ -589,6 +590,7 @@ OBSBasicSettings::OBSBasicSettings(QWidget *parent)
|
|||
#ifdef _WIN32
|
||||
uint32_t winVer = GetWindowsVersion();
|
||||
if (winVer > 0 && winVer < 0x602) {
|
||||
// Older than Windows 8
|
||||
toggleAero = new QCheckBox(
|
||||
QTStr("Basic.Settings.Video.DisableAero"), this);
|
||||
QFormLayout *videoLayout = reinterpret_cast<QFormLayout *>(
|
||||
|
|
@ -600,6 +602,11 @@ OBSBasicSettings::OBSBasicSettings(QWidget *parent)
|
|||
&OBSBasicSettings::ToggleDisableAero);
|
||||
}
|
||||
|
||||
if (!SetDisplayAffinitySupported()) {
|
||||
delete ui->hideOBSFromCapture;
|
||||
ui->hideOBSFromCapture = nullptr;
|
||||
}
|
||||
|
||||
#define PROCESS_PRIORITY(val) \
|
||||
{ \
|
||||
"Basic.Settings.Advanced.General.ProcessPriority."##val, val \
|
||||
|
|
@ -627,6 +634,7 @@ OBSBasicSettings::OBSBasicSettings(QWidget *parent)
|
|||
delete ui->processPriority;
|
||||
delete ui->enableNewSocketLoop;
|
||||
delete ui->enableLowLatencyMode;
|
||||
delete ui->hideOBSFromCapture;
|
||||
#ifdef __linux__
|
||||
delete ui->browserHWAccel;
|
||||
delete ui->sourcesGroup;
|
||||
|
|
@ -642,6 +650,7 @@ OBSBasicSettings::OBSBasicSettings(QWidget *parent)
|
|||
ui->processPriority = nullptr;
|
||||
ui->enableNewSocketLoop = nullptr;
|
||||
ui->enableLowLatencyMode = nullptr;
|
||||
ui->hideOBSFromCapture = nullptr;
|
||||
#ifdef __linux__
|
||||
ui->browserHWAccel = nullptr;
|
||||
ui->sourcesGroup = nullptr;
|
||||
|
|
@ -1226,6 +1235,15 @@ void OBSBasicSettings::LoadGeneralSettings()
|
|||
"OpenStatsOnStartup");
|
||||
ui->openStatsOnStartup->setChecked(openStatsOnStartup);
|
||||
|
||||
#if defined(_WIN32)
|
||||
if (ui->hideOBSFromCapture) {
|
||||
bool hideWindowFromCapture =
|
||||
config_get_bool(GetGlobalConfig(), "BasicWindow",
|
||||
"HideOBSWindowsFromCapture");
|
||||
ui->hideOBSFromCapture->setChecked(hideWindowFromCapture);
|
||||
}
|
||||
#endif
|
||||
|
||||
bool recordWhenStreaming = config_get_bool(
|
||||
GetGlobalConfig(), "BasicWindow", "RecordWhenStreaming");
|
||||
ui->recordWhenStreaming->setChecked(recordWhenStreaming);
|
||||
|
|
@ -2974,6 +2992,20 @@ void OBSBasicSettings::SaveGeneralSettings()
|
|||
config_set_bool(GetGlobalConfig(), "General",
|
||||
"EnableAutoUpdates",
|
||||
ui->enableAutoUpdates->isChecked());
|
||||
#endif
|
||||
#ifdef _WIN32
|
||||
if (WidgetChanged(ui->hideOBSFromCapture)) {
|
||||
bool hide_window = ui->hideOBSFromCapture->isChecked();
|
||||
config_set_bool(GetGlobalConfig(), "BasicWindow",
|
||||
"HideOBSWindowsFromCapture", hide_window);
|
||||
|
||||
QWindowList windows = QGuiApplication::allWindows();
|
||||
for (auto window : windows) {
|
||||
if (window->isVisible()) {
|
||||
main->SetDisplayAffinity(window);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
if (WidgetChanged(ui->openStatsOnStartup))
|
||||
config_set_bool(main->Config(), "General", "OpenStatsOnStartup",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue