From 03e396af4be429eac20b7f08ab33f0ada1210ced Mon Sep 17 00:00:00 2001 From: Cinder Date: Wed, 4 Jun 2014 07:20:08 -0600 Subject: [PATCH] Transplant cmd key fix to Mac64 branch --HG-- branch : Mac64 --- indra/llwindow/llappdelegate-objc.h | 5 +++++ indra/llwindow/llopenglview-objc.mm | 11 ++--------- indra/newview/CMakeLists.txt | 2 +- indra/newview/llappdelegate-objc.mm | 15 +++++++++++++++ 4 files changed, 23 insertions(+), 10 deletions(-) diff --git a/indra/llwindow/llappdelegate-objc.h b/indra/llwindow/llappdelegate-objc.h index faa5d3abb7..6fe2ae7319 100644 --- a/indra/llwindow/llappdelegate-objc.h +++ b/indra/llwindow/llappdelegate-objc.h @@ -27,6 +27,11 @@ #import #import "llopenglview-objc.h" +// [Cinder] Override NSApplication to give us access to sendEvent +@interface LLNSApplication : NSApplication +@end +// [/Cinder] + @interface LLAppDelegate : NSObject { LLNSWindow *window; NSWindow *inputWindow; diff --git a/indra/llwindow/llopenglview-objc.mm b/indra/llwindow/llopenglview-objc.mm index 7d258ac9a3..179c25b694 100644 --- a/indra/llwindow/llopenglview-objc.mm +++ b/indra/llwindow/llopenglview-objc.mm @@ -392,18 +392,11 @@ attributedStringInfo getSegments(NSAttributedString *str) [[theEvent charactersIgnoringModifiers] characterAtIndex:0] != NSRightArrowFunctionKey) { [(LLAppDelegate*)[NSApp delegate] showInputWindow:true withEvent:theEvent]; - } else + } + else { [[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) - { - callKeyUp([theEvent keyCode], mModifiers); - } } - (void)flagsChanged:(NSEvent *)theEvent { diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index 234f173d7d..49086ae482 100755 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -2350,7 +2350,7 @@ if (DARWIN) set(MACOSX_BUNDLE_BUNDLE_VERSION "${VIEWER_SHORT_VERSION}${VIEWER_MACOSX_PHASE}${VIEWER_REVISION}") set(MACOSX_BUNDLE_COPYRIGHT "Copyright 2010-2014 The Phoenix Firestorm Project, Inc.") set(MACOSX_BUNDLE_NSMAIN_NIB_FILE "Firestorm.nib") - set(MACOSX_BUNDLE_NSPRINCIPAL_CLASS "NSApplication") + set(MACOSX_BUNDLE_NSPRINCIPAL_CLASS "LLNSApplication") set_target_properties( ${VIEWER_BINARY_NAME} diff --git a/indra/newview/llappdelegate-objc.mm b/indra/newview/llappdelegate-objc.mm index 3dd9f42318..ec2dcaa399 100644 --- a/indra/newview/llappdelegate-objc.mm +++ b/indra/newview/llappdelegate-objc.mm @@ -28,6 +28,21 @@ #include "llwindowmacosx-objc.h" #include // Used for Text Input Services ("Safe" API - it's supported) +// [Cinder] We need to override sendEvent in NSApplication and force those +// Apple bastards to send us Command keyUp events! +@implementation LLNSApplication + +- (void)sendEvent:(NSEvent *)event { + // Fuck you, conventions! + if ([event type] == NSKeyUp && ([event modifierFlags] & NSCommandKeyMask)) + [[self keyWindow] sendEvent:event]; + else + [super sendEvent:event]; +} + +@end +// [Cinder] + @implementation LLAppDelegate @synthesize window;