summaryrefslogtreecommitdiff
path: root/indra
diff options
context:
space:
mode:
authorAndreyL ProductEngine <alihatskiy@productengine.com>2016-04-21 22:48:32 +0300
committerAndreyL ProductEngine <alihatskiy@productengine.com>2016-04-21 22:48:32 +0300
commit56f736b65473d67b0a0d817e3c4d0b266a82f856 (patch)
treea49e44691443b75119e14563676262c32af71e7c /indra
parent7de3a6e81971cb239ec4691e37e6718ecabd00d8 (diff)
parenta07897bf9c8377a0557c9baed2f0debff949bc16 (diff)
Merged in cinderblocks/storm-2127
Diffstat (limited to 'indra')
-rw-r--r--indra/llwindow/llopenglview-objc.mm119
-rwxr-xr-xindra/llwindow/llwindowmacosx-objc.h14
2 files changed, 68 insertions, 65 deletions
diff --git a/indra/llwindow/llopenglview-objc.mm b/indra/llwindow/llopenglview-objc.mm
index ca502e0659..22f3339cf1 100644
--- a/indra/llwindow/llopenglview-objc.mm
+++ b/indra/llwindow/llopenglview-objc.mm
@@ -25,13 +25,69 @@
*/
#import "llopenglview-objc.h"
-#include "llwindowmacosx-objc.h"
+#import "llwindowmacosx-objc.h"
#import "llappdelegate-objc.h"
+#pragma mark local functions
+NativeKeyEventData extractKeyDataFromKeyEvent(NSEvent* theEvent)
+{
+ NativeKeyEventData eventData;
+ eventData.mKeyEvent = NativeKeyEventData::KEYUNKNOWN;
+ eventData.mEventType = [theEvent type];
+ eventData.mEventModifiers = [theEvent modifierFlags];
+ eventData.mEventKeyCode = [theEvent keyCode];
+ NSString *strEventChars = [theEvent characters];
+ eventData.mEventChars = (strEventChars.length) ? [strEventChars characterAtIndex:0] : 0;
+ NSString *strEventUChars = [theEvent charactersIgnoringModifiers];
+ eventData.mEventUnmodChars = (strEventUChars.length) ? [strEventUChars characterAtIndex:0] : 0;
+ eventData.mEventRepeat = [theEvent isARepeat];
+ return eventData;
+}
+
+NativeKeyEventData extractKeyDataFromModifierEvent(NSEvent* theEvent)
+{
+ NativeKeyEventData eventData;
+ eventData.mKeyEvent = NativeKeyEventData::KEYUNKNOWN;
+ eventData.mEventType = [theEvent type];
+ eventData.mEventModifiers = [theEvent modifierFlags];
+ eventData.mEventKeyCode = [theEvent keyCode];
+ return eventData;
+}
+attributedStringInfo getSegments(NSAttributedString *str)
+{
+ attributedStringInfo segments;
+ segment_lengths seg_lengths;
+ segment_standouts seg_standouts;
+ NSRange effectiveRange;
+ NSRange limitRange = NSMakeRange(0, [str length]);
+
+ while (limitRange.length > 0) {
+ NSNumber *attr = [str attribute:NSUnderlineStyleAttributeName atIndex:limitRange.location longestEffectiveRange:&effectiveRange inRange:limitRange];
+ limitRange = NSMakeRange(NSMaxRange(effectiveRange), NSMaxRange(limitRange) - NSMaxRange(effectiveRange));
+
+ if (effectiveRange.length <= 0)
+ {
+ effectiveRange.length = 1;
+ }
+
+ if ([attr integerValue] == 2)
+ {
+ seg_lengths.push_back(effectiveRange.length);
+ seg_standouts.push_back(true);
+ } else
+ {
+ seg_lengths.push_back(effectiveRange.length);
+ seg_standouts.push_back(false);
+ }
+ }
+ segments.seg_lengths = seg_lengths;
+ segments.seg_standouts = seg_standouts;
+ return segments;
+}
-//---------------------------
+#pragma mark class implementations
@implementation NSScreen (PointConversion)
@@ -63,53 +119,6 @@
@end
-void extractKeyDataFromEvent (NSEvent *theEvent, NativeKeyEventData * eventData)
-{
- eventData->mKeyEvent = NativeKeyEventData::KEYUNKNOWN;
- eventData->mEventType = [theEvent type];
- eventData->mEventModifiers = [theEvent modifierFlags];
- eventData->mEventKeyCode = [theEvent keyCode];
- NSString *strEventChars = [theEvent characters];
- eventData->mEventChars = (strEventChars.length) ? [strEventChars characterAtIndex:0] : 0;
- NSString *strEventUChars = [theEvent charactersIgnoringModifiers];
- eventData->mEventUnmodChars = (strEventUChars.length) ? [strEventUChars characterAtIndex:0] : 0;
- eventData->mEventRepeat = [theEvent isARepeat];
-
-}
-
-
-attributedStringInfo getSegments(NSAttributedString *str)
-{
- attributedStringInfo segments;
- segment_lengths seg_lengths;
- segment_standouts seg_standouts;
- NSRange effectiveRange;
- NSRange limitRange = NSMakeRange(0, [str length]);
-
- while (limitRange.length > 0) {
- NSNumber *attr = [str attribute:NSUnderlineStyleAttributeName atIndex:limitRange.location longestEffectiveRange:&effectiveRange inRange:limitRange];
- limitRange = NSMakeRange(NSMaxRange(effectiveRange), NSMaxRange(limitRange) - NSMaxRange(effectiveRange));
-
- if (effectiveRange.length <= 0)
- {
- effectiveRange.length = 1;
- }
-
- if ([attr integerValue] == 2)
- {
- seg_lengths.push_back(effectiveRange.length);
- seg_standouts.push_back(true);
- } else
- {
- seg_lengths.push_back(effectiveRange.length);
- seg_standouts.push_back(false);
- }
- }
- segments.seg_lengths = seg_lengths;
- segments.seg_standouts = seg_standouts;
- return segments;
-}
-
@implementation LLOpenGLView
// Force a high quality update after live resizing
@@ -426,18 +435,14 @@ attributedStringInfo getSegments(NSAttributedString *str)
- (void) keyUp:(NSEvent *)theEvent
{
- NativeKeyEventData eventData;
-
- extractKeyDataFromEvent( theEvent, &eventData );
+ NativeKeyEventData eventData = extractKeyDataFromKeyEvent(theEvent);
eventData.mKeyEvent = NativeKeyEventData::KEYUP;
callKeyUp(&eventData, [theEvent keyCode], [theEvent modifierFlags]);
}
- (void) keyDown:(NSEvent *)theEvent
{
- NativeKeyEventData eventData;
-
- extractKeyDataFromEvent( theEvent, &eventData );
+ NativeKeyEventData eventData = extractKeyDataFromKeyEvent(theEvent);
eventData.mKeyEvent = NativeKeyEventData::KEYDOWN;
uint keycode = [theEvent keyCode];
@@ -475,9 +480,7 @@ attributedStringInfo getSegments(NSAttributedString *str)
- (void)flagsChanged:(NSEvent *)theEvent
{
- NativeKeyEventData eventData;
-
- extractKeyDataFromEvent( theEvent, &eventData );
+ NativeKeyEventData eventData = extractKeyDataFromModifierEvent(theEvent);
mModifiers = [theEvent modifierFlags];
callModifier([theEvent modifierFlags]);
diff --git a/indra/llwindow/llwindowmacosx-objc.h b/indra/llwindow/llwindowmacosx-objc.h
index 507d1239be..c22f3382fb 100755
--- a/indra/llwindow/llwindowmacosx-objc.h
+++ b/indra/llwindow/llwindowmacosx-objc.h
@@ -55,13 +55,13 @@ struct NativeKeyEventData {
KEYCHAR
};
- EventType mKeyEvent;
- uint32_t mEventType;
- uint32_t mEventModifiers;
- uint32_t mEventKeyCode;
- uint32_t mEventChars;
- uint32_t mEventUnmodChars;
- bool mEventRepeat;
+ EventType mKeyEvent = KEYUNKNOWN;
+ uint32_t mEventType = 0;
+ uint32_t mEventModifiers = 0;
+ uint32_t mEventKeyCode = 0;
+ uint32_t mEventChars = 0;
+ uint32_t mEventUnmodChars = 0;
+ bool mEventRepeat = false;
};
typedef const NativeKeyEventData * NSKeyEventRef;