From b813814202d0c3c011df9f514b73afe7b1758b3c Mon Sep 17 00:00:00 2001
From: Mnikolenko ProductEngine <mnikolenko@productengine.com>
Date: Thu, 20 Jun 2019 15:41:27 +0300
Subject: [PATCH] SL-11432 FIXED [OSX] Avatar is spinning when pressing
 Alt+D+Command and then releasing D key

---
 indra/llwindow/llappdelegate-objc.h |  3 +++
 indra/llwindow/llopenglview-objc.mm |  9 ---------
 indra/newview/CMakeLists.txt        |  2 +-
 indra/newview/llappdelegate-objc.mm | 13 +++++++++++++
 4 files changed, 17 insertions(+), 10 deletions(-)

diff --git a/indra/llwindow/llappdelegate-objc.h b/indra/llwindow/llappdelegate-objc.h
index 6daf1ac55b9..0b38647b4a7 100644
--- a/indra/llwindow/llappdelegate-objc.h
+++ b/indra/llwindow/llappdelegate-objc.h
@@ -46,3 +46,6 @@
 - (void) languageUpdated;
 - (bool) romanScript;
 @end
+
+@interface LLApplication : NSApplication
+@end
diff --git a/indra/llwindow/llopenglview-objc.mm b/indra/llwindow/llopenglview-objc.mm
index 33eed7227af..1990499459d 100644
--- a/indra/llwindow/llopenglview-objc.mm
+++ b/indra/llwindow/llopenglview-objc.mm
@@ -509,15 +509,6 @@ attributedStringInfo getSegments(NSAttributedString *str)
     {
         [[self inputContext] handleEvent:theEvent];
     }
-    
-    // OS X intentionally does not send us key-up information on cmd-key combinations.
-    // This behaviour is not a bug, and only applies to cmd-combinations (no others).
-    // Since SL assumes we receive those, we fake it here.
-    if (mModifiers & NSCommandKeyMask && !mHasMarkedText)
-    {
-        eventData.mKeyEvent = NativeKeyEventData::KEYUP;
-        callKeyUp(&eventData, [theEvent keyCode], mModifiers);
-    }
 }
 
 - (void)flagsChanged:(NSEvent *)theEvent
diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt
index 46fd0f3fd15..b8789da66bc 100644
--- a/indra/newview/CMakeLists.txt
+++ b/indra/newview/CMakeLists.txt
@@ -2117,7 +2117,7 @@ if (DARWIN)
   set(MACOSX_BUNDLE_BUNDLE_VERSION "${VIEWER_SHORT_VERSION}${VIEWER_MACOSX_PHASE}${VIEWER_REVISION}")
   set(MACOSX_BUNDLE_COPYRIGHT "Copyright © Linden Research, Inc. 2018")
   set(MACOSX_BUNDLE_NSMAIN_NIB_FILE "SecondLife.nib")
-  set(MACOSX_BUNDLE_NSPRINCIPAL_CLASS "NSApplication")
+  set(MACOSX_BUNDLE_NSPRINCIPAL_CLASS "LLApplication")
 
   # https://blog.kitware.com/upcoming-in-cmake-2-8-12-osx-rpath-support/
   set(CMAKE_MACOSX_RPATH 1)
diff --git a/indra/newview/llappdelegate-objc.mm b/indra/newview/llappdelegate-objc.mm
index 1d555374278..47fde299c7e 100644
--- a/indra/newview/llappdelegate-objc.mm
+++ b/indra/newview/llappdelegate-objc.mm
@@ -342,3 +342,16 @@ struct AttachmentInfo
 #endif // LL_BUGSPLAT
 
 @end
+
+@implementation LLApplication
+
+- (void)sendEvent:(NSEvent *)event
+{
+    [super sendEvent:event];
+    if ([event type] == NSKeyUp && ([event modifierFlags] & NSCommandKeyMask))
+    {   
+        [[self keyWindow] sendEvent:event];
+    }
+}
+
+@end
-- 
GitLab