浏览代码

UI: Fix hotkeys working even when disabled in focus

Fixes a bug where the hotkey inject would trigger hotkeys despite
hotkeys being disabled when in focus.
jp9000 6 年之前
父节点
当前提交
9ca1e85f7d
共有 2 个文件被更改,包括 11 次插入0 次删除
  1. 6 0
      UI/obs-app.cpp
  2. 5 0
      UI/obs-app.hpp

+ 6 - 0
UI/obs-app.cpp

@@ -93,6 +93,9 @@ QObject *CreateShortcutFilter()
 {
 	return new OBSEventFilter([](QObject *obj, QEvent *event) {
 		auto mouse_event = [](QMouseEvent &event) {
+			if (!App()->HotkeysEnabledInFocus())
+				return true;
+
 			obs_key_combination_t hotkey = {0, OBS_KEY_NONE};
 			bool pressed = event.type() == QEvent::MouseButtonPress;
 
@@ -147,6 +150,9 @@ QObject *CreateShortcutFilter()
 		};
 
 		auto key_event = [&](QKeyEvent *event) {
+			if (!App()->HotkeysEnabledInFocus())
+				return true;
+
 			QDialog *dialog = qobject_cast<QDialog *>(obj);
 
 			obs_key_combination_t hotkey = {0, OBS_KEY_NONE};

+ 5 - 0
UI/obs-app.hpp

@@ -107,6 +107,11 @@ public:
 
 	void EnableInFocusHotkeys(bool enable);
 
+	inline bool HotkeysEnabledInFocus() const
+	{
+		return enableHotkeysInFocus;
+	}
+
 	inline QMainWindow *GetMainWindow() const { return mainWindow.data(); }
 
 	inline config_t *GlobalConfig() const { return globalConfig; }