diff --git a/UI/data/locale/en-US.ini b/UI/data/locale/en-US.ini
index 2f3c31935..48b540fbc 100644
--- a/UI/data/locale/en-US.ini
+++ b/UI/data/locale/en-US.ini
@@ -751,6 +751,7 @@ Basic.Settings.Advanced.Network="Network"
Basic.Settings.Advanced.Network.BindToIP="Bind to IP"
Basic.Settings.Advanced.Network.EnableNewSocketLoop="Enable new networking code"
Basic.Settings.Advanced.Network.EnableLowLatencyMode="Low latency mode"
+Basic.Settings.Advanced.Hotkeys.DisableHotkeysInFocus="Disable hotkeys when main window is in focus"
# advanced audio properties
Basic.AdvAudio="Advanced Audio Properties"
diff --git a/UI/forms/OBSBasicSettings.ui b/UI/forms/OBSBasicSettings.ui
index adb8a1f5a..df0cc5bba 100644
--- a/UI/forms/OBSBasicSettings.ui
+++ b/UI/forms/OBSBasicSettings.ui
@@ -144,7 +144,7 @@
0
- 0
+ -44
801
741
@@ -733,8 +733,8 @@
0
0
- 818
- 697
+ 601
+ 640
@@ -3372,8 +3372,8 @@
0
0
- 800
- 69
+ 63
+ 16
@@ -3768,8 +3768,8 @@
0
0
- 818
- 697
+ 98
+ 28
@@ -3816,7 +3816,7 @@
0
0
803
- 761
+ 793
@@ -3844,6 +3844,12 @@
QFormLayout::AllNonFixedFieldsGrow
+
+ Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter
+
+
+ 2
+
-
@@ -3857,6 +3863,19 @@
-
+ -
+
+
+ Qt::Horizontal
+
+
+
+ 170
+ 0
+
+
+
+
@@ -3872,6 +3891,9 @@
Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter
+
+ 2
+
-
@@ -4044,6 +4066,19 @@
+ -
+
+
+ Qt::Horizontal
+
+
+
+ 170
+ 20
+
+
+
+
@@ -4056,6 +4091,12 @@
QFormLayout::AllNonFixedFieldsGrow
+
+ Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter
+
+
+ 2
+
-
@@ -4076,6 +4117,19 @@
+ -
+
+
+ Qt::Horizontal
+
+
+
+ 170
+ 20
+
+
+
+
@@ -4091,6 +4145,9 @@
Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter
+
+ 2
+
-
@@ -4153,6 +4210,19 @@
+ -
+
+
+ Qt::Horizontal
+
+
+
+ 170
+ 20
+
+
+
+
@@ -4165,6 +4235,9 @@
QFormLayout::AllNonFixedFieldsGrow
+
+ Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter
+
2
@@ -4254,6 +4327,19 @@
+ -
+
+
+ Qt::Horizontal
+
+
+
+ 170
+ 20
+
+
+
+
@@ -4266,6 +4352,12 @@
QFormLayout::AllNonFixedFieldsGrow
+
+ Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter
+
+
+ 2
+
-
@@ -4335,6 +4427,19 @@
+ -
+
+
+ Qt::Horizontal
+
+
+
+ 170
+ 20
+
+
+
+
@@ -4347,9 +4452,12 @@
QFormLayout::AllNonFixedFieldsGrow
- -
-
-
+
+ Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter
+
+
+ 2
+
-
@@ -4360,6 +4468,9 @@
+ -
+
+
-
@@ -4377,6 +4488,51 @@
+ -
+
+
+ Qt::Horizontal
+
+
+
+ 170
+ 20
+
+
+
+
+
+
+
+ -
+
+
+ Basic.Settings.Hotkeys
+
+
+
+ 2
+
+
-
+
+
+ Basic.Settings.Advanced.Hotkeys.DisableHotkeysInFocus
+
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+
+ 170
+ 20
+
+
+
+
diff --git a/UI/obs-app.cpp b/UI/obs-app.cpp
index 0185e6b62..752337fe5 100644
--- a/UI/obs-app.cpp
+++ b/UI/obs-app.cpp
@@ -916,6 +916,9 @@ void OBSApp::AppInit()
EnableOSXVSync(false);
#endif
+ enableHotkeysInFocus = !config_get_bool(globalConfig, "General",
+ "DisableHotkeysInFocus");
+
move_basic_to_profiles();
move_basic_to_scene_collections();
@@ -942,6 +945,18 @@ static bool StartupOBS(const char *locale, profiler_name_store_t *store)
return obs_startup(locale, path, store);
}
+inline void OBSApp::ResetHotkeyState(bool inFocus)
+{
+ obs_hotkey_enable_background_press(
+ inFocus || enableHotkeysInFocus);
+}
+
+void OBSApp::EnableInFocusHotkeys(bool enable)
+{
+ enableHotkeysInFocus = enable;
+ ResetHotkeyState(applicationState() != Qt::ApplicationActive);
+}
+
bool OBSApp::OBSInit()
{
ProfileScope("OBSApp::OBSInit");
@@ -973,13 +988,12 @@ bool OBSApp::OBSInit()
mainWindow->OBSInit();
connect(this, &QGuiApplication::applicationStateChanged,
- [](Qt::ApplicationState state)
+ [this](Qt::ApplicationState state)
{
- obs_hotkey_enable_background_press(
+ ResetHotkeyState(
state != Qt::ApplicationActive);
});
- obs_hotkey_enable_background_press(
- applicationState() != Qt::ApplicationActive);
+ ResetHotkeyState(applicationState() != Qt::ApplicationActive);
return true;
} else {
return false;
diff --git a/UI/obs-app.hpp b/UI/obs-app.hpp
index 87d6a1c63..c32896129 100644
--- a/UI/obs-app.hpp
+++ b/UI/obs-app.hpp
@@ -73,6 +73,9 @@ private:
os_inhibit_t *sleepInhibitor = nullptr;
int sleepInhibitRefs = 0;
+ bool enableHotkeysInFocus = true;
+
+
std::deque translatorHooks;
bool InitGlobalConfig();
@@ -80,6 +83,8 @@ private:
bool InitLocale();
bool InitTheme();
+ inline void ResetHotkeyState(bool inFocus);
+
public:
OBSApp(int &argc, char **argv, profiler_name_store_t *store);
~OBSApp();
@@ -87,6 +92,8 @@ public:
void AppInit();
bool OBSInit();
+ void EnableInFocusHotkeys(bool enable);
+
inline QMainWindow *GetMainWindow() const {return mainWindow.data();}
inline config_t *GlobalConfig() const {return globalConfig;}
diff --git a/UI/window-basic-settings.cpp b/UI/window-basic-settings.cpp
index 7d06e70e6..4e54fbdd6 100644
--- a/UI/window-basic-settings.cpp
+++ b/UI/window-basic-settings.cpp
@@ -442,6 +442,7 @@ OBSBasicSettings::OBSBasicSettings(QWidget *parent)
HookWidget(ui->bindToIP, COMBO_CHANGED, ADV_CHANGED);
HookWidget(ui->enableNewSocketLoop, CHECK_CHANGED, ADV_CHANGED);
HookWidget(ui->enableLowLatencyMode, CHECK_CHANGED, ADV_CHANGED);
+ HookWidget(ui->disableFocusHotkeys, CHECK_CHANGED, ADV_CHANGED);
#if !defined(_WIN32) && !defined(__APPLE__)
delete ui->enableAutoUpdates;
@@ -702,11 +703,17 @@ OBSBasicSettings::OBSBasicSettings(QWidget *parent)
SimpleRecordingQualityChanged();
UpdateAutomaticReplayBufferCheckboxes();
+
+ App()->EnableInFocusHotkeys(false);
}
OBSBasicSettings::~OBSBasicSettings()
{
+ bool disableHotkeysInFocus = config_get_bool(App()->GlobalConfig(),
+ "General", "DisableHotkeysInFocus");
+
main->EnableOutputs(true);
+ App()->EnableInFocusHotkeys(!disableHotkeysInFocus);
}
void OBSBasicSettings::SaveCombo(QComboBox *widget, const char *section,
@@ -2280,6 +2287,10 @@ void OBSBasicSettings::LoadAdvancedSettings()
ui->enableLowLatencyMode->setChecked(enableLowLatencyMode);
#endif
+ bool disableFocusHotkeys = config_get_bool(App()->GlobalConfig(),
+ "General", "DisableHotkeysInFocus");
+ ui->disableFocusHotkeys->setChecked(disableFocusHotkeys);
+
loading = false;
}
@@ -2789,6 +2800,10 @@ void OBSBasicSettings::SaveAdvancedSettings()
SaveCheckBox(ui->enableLowLatencyMode, "Output", "LowLatencyEnable");
#endif
+ bool disableFocusHotkeys = ui->disableFocusHotkeys->isChecked();
+ config_set_bool(App()->GlobalConfig(), "General",
+ "DisableHotkeysInFocus", disableFocusHotkeys);
+
#ifdef __APPLE__
if (WidgetChanged(ui->disableOSXVSync)) {
bool disable = ui->disableOSXVSync->isChecked();