summaryrefslogtreecommitdiff
path: root/indra/llwindow
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llwindow')
-rw-r--r--indra/llwindow/llopenglview-objc.mm124
-rwxr-xr-xindra/llwindow/llwindowcallbacks.cpp4
-rwxr-xr-xindra/llwindow/llwindowcallbacks.h1
-rwxr-xr-xindra/llwindow/llwindowmacosx-objc.h16
-rwxr-xr-xindra/llwindow/llwindowmacosx-objc.mm5
-rwxr-xr-xindra/llwindow/llwindowmacosx.cpp23
6 files changed, 105 insertions, 68 deletions
diff --git a/indra/llwindow/llopenglview-objc.mm b/indra/llwindow/llopenglview-objc.mm
index 406bc9cf47..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
@@ -341,6 +350,9 @@ attributedStringInfo getSegments(NSAttributedString *str)
callRightMouseUp(mMousePos, [theEvent modifierFlags]);
mSimulatedRightClick = false;
} else {
+ NSPoint mPoint = [theEvent locationInWindow];
+ mMousePos[0] = mPoint.x;
+ mMousePos[1] = mPoint.y;
callLeftMouseUp(mMousePos, [theEvent modifierFlags]);
}
}
@@ -388,7 +400,7 @@ attributedStringInfo getSegments(NSAttributedString *str)
NSPoint mPoint = [theEvent locationInWindow];
mMousePos[0] = mPoint.x;
mMousePos[1] = mPoint.y;
- callMouseMoved(mMousePos, 0);
+ callMouseDragged(mMousePos, 0);
}
- (void) otherMouseDown:(NSEvent *)theEvent
@@ -423,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];
@@ -472,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/llwindowcallbacks.cpp b/indra/llwindow/llwindowcallbacks.cpp
index eadff8a6b4..d2afb3f91b 100755
--- a/indra/llwindow/llwindowcallbacks.cpp
+++ b/indra/llwindow/llwindowcallbacks.cpp
@@ -112,6 +112,10 @@ void LLWindowCallbacks::handleMouseMove(LLWindow *window, const LLCoordGL pos, M
{
}
+void LLWindowCallbacks::handleMouseDragged(LLWindow *window, const LLCoordGL pos, MASK mask)
+{
+}
+
void LLWindowCallbacks::handleScrollWheel(LLWindow *window, S32 clicks)
{
}
diff --git a/indra/llwindow/llwindowcallbacks.h b/indra/llwindow/llwindowcallbacks.h
index 7da5959700..6a7137e593 100755
--- a/indra/llwindow/llwindowcallbacks.h
+++ b/indra/llwindow/llwindowcallbacks.h
@@ -52,6 +52,7 @@ public:
virtual BOOL handleActivate(LLWindow *window, BOOL activated);
virtual BOOL handleActivateApp(LLWindow *window, BOOL activating);
virtual void handleMouseMove(LLWindow *window, LLCoordGL pos, MASK mask);
+ virtual void handleMouseDragged(LLWindow *window, LLCoordGL pos, MASK mask);
virtual void handleScrollWheel(LLWindow *window, S32 clicks);
virtual void handleResize(LLWindow *window, S32 width, S32 height);
virtual void handleFocus(LLWindow *window);
diff --git a/indra/llwindow/llwindowmacosx-objc.h b/indra/llwindow/llwindowmacosx-objc.h
index dc184b91fb..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;
@@ -92,6 +92,7 @@ void setCrossCursor();
void setNotAllowedCursor();
void hideNSCursor();
void showNSCursor();
+bool isCGCursorVisible();
void hideNSCursorTillMove(bool hide);
void requestUserAttention();
long showAlert(std::string title, std::string text, int type);
@@ -133,6 +134,7 @@ void callLeftMouseUp(float *pos, unsigned int mask);
void callDoubleClick(float *pos, unsigned int mask);
void callResize(unsigned int width, unsigned int height);
void callMouseMoved(float *pos, unsigned int mask);
+void callMouseDragged(float *pos, unsigned int mask);
void callScrollMoved(float delta);
void callMouseExit();
void callWindowFocus();
diff --git a/indra/llwindow/llwindowmacosx-objc.mm b/indra/llwindow/llwindowmacosx-objc.mm
index 1a21bf8430..43ce9a2255 100755
--- a/indra/llwindow/llwindowmacosx-objc.mm
+++ b/indra/llwindow/llwindowmacosx-objc.mm
@@ -163,6 +163,11 @@ void showNSCursor()
[NSCursor unhide];
}
+bool isCGCursorVisible()
+{
+ return CGCursorIsVisible();
+}
+
void hideNSCursorTillMove(bool hide)
{
[NSCursor setHiddenUntilMouseMoves:hide];
diff --git a/indra/llwindow/llwindowmacosx.cpp b/indra/llwindow/llwindowmacosx.cpp
index 0d41884462..754306b5d2 100755
--- a/indra/llwindow/llwindowmacosx.cpp
+++ b/indra/llwindow/llwindowmacosx.cpp
@@ -343,6 +343,18 @@ void callMouseMoved(float *pos, MASK mask)
//gWindowImplementation->getCallbacks()->handleScrollWheel(gWindowImplementation, 0);
}
+void callMouseDragged(float *pos, MASK mask)
+{
+ LLCoordGL outCoords;
+ outCoords.mX = ll_round(pos[0]);
+ outCoords.mY = ll_round(pos[1]);
+ float deltas[2];
+ gWindowImplementation->getMouseDeltas(deltas);
+ outCoords.mX += deltas[0];
+ outCoords.mY += deltas[1];
+ gWindowImplementation->getCallbacks()->handleMouseDragged(gWindowImplementation, outCoords, gKeyboard->currentMask(TRUE));
+}
+
void callScrollMoved(float delta)
{
gWindowImplementation->getCallbacks()->handleScrollWheel(gWindowImplementation, delta);
@@ -1445,8 +1457,15 @@ void LLWindowMacOSX::updateCursor()
mNextCursor = UI_CURSOR_WORKING;
}
- if(mCurrentCursor == mNextCursor)
- return;
+ if(mCurrentCursor == mNextCursor)
+ {
+ if(mCursorHidden && mHideCursorPermanent && isCGCursorVisible())
+ {
+ hideNSCursor();
+ adjustCursorDecouple();
+ }
+ return;
+ }
// RN: replace multi-drag cursors with single versions
if (mNextCursor == UI_CURSOR_ARROWDRAGMULTI)