From 28e07331acf45edb380c094179cef6ea5adeb010 Mon Sep 17 00:00:00 2001
From: Andrey Kleshchev <andreykproductengine@lindenlab.com>
Date: Fri, 17 Sep 2021 23:15:14 +0300
Subject: SL-15594 Ignore voice keys when keybinding is waiting for a key

---
 indra/newview/llsetkeybinddialog.h |  2 ++
 indra/newview/llviewerinput.cpp    | 21 +++++++++++++++++++++
 2 files changed, 23 insertions(+)

diff --git a/indra/newview/llsetkeybinddialog.h b/indra/newview/llsetkeybinddialog.h
index a34b952233..24dfa1dbfd 100644
--- a/indra/newview/llsetkeybinddialog.h
+++ b/indra/newview/llsetkeybinddialog.h
@@ -76,6 +76,8 @@ public:
     static void onDefault(void* user_data);
     static void onClickTimeout(void* user_data, MASK mask);
 
+    static bool isRecording() { return sRecordKeys; }
+
     class Updater;
 
 private:
diff --git a/indra/newview/llviewerinput.cpp b/indra/newview/llviewerinput.cpp
index 6629a2ffac..94ec534732 100644
--- a/indra/newview/llviewerinput.cpp
+++ b/indra/newview/llviewerinput.cpp
@@ -38,6 +38,7 @@
 #include "llkeybind.h" // LLKeyData
 #include "llmorphview.h"
 #include "llmoveview.h"
+#include "llsetkeybinddialog.h"
 #include "lltoolfocus.h"
 #include "lltoolpie.h"
 #include "llviewercontrol.h"
@@ -1052,18 +1053,38 @@ BOOL LLViewerInput::handleKeyUp(KEY translated_key, MASK translated_mask)
 
 bool LLViewerInput::handleGlobalBindsKeyDown(KEY key, MASK mask)
 {
+    if (LLSetKeyBindDialog::isRecording())
+    {
+        // handleGlobalBindsKeyDown happens before view handling, so can't
+        // be interupted by LLSetKeyBindDialog, check manually
+        return false;
+    }
     S32 mode = getMode();
     return scanKey(mGlobalKeyBindings[mode], mGlobalKeyBindings[mode].size(), key, mask, TRUE, FALSE, FALSE, FALSE);
 }
 
 bool LLViewerInput::handleGlobalBindsKeyUp(KEY key, MASK mask)
 {
+    if (LLSetKeyBindDialog::isRecording())
+    {
+        // handleGlobalBindsKeyUp happens before view handling, so can't
+        // be interupted by LLSetKeyBindDialog, check manually
+        return false;
+    }
+
     S32 mode = getMode();
     return scanKey(mGlobalKeyBindings[mode], mGlobalKeyBindings[mode].size(), key, mask, FALSE, TRUE, FALSE, FALSE);
 }
 
 bool LLViewerInput::handleGlobalBindsMouse(EMouseClickType clicktype, MASK mask, bool down)
 {
+    if (LLSetKeyBindDialog::isRecording())
+    {
+        // handleGlobalBindsMouse happens before view handling, so can't
+        // be interupted by LLSetKeyBindDialog, check manually
+        return false;
+    }
+
     bool res = false;
     S32 mode = getMode();
     if (down)
-- 
cgit v1.2.3