From b06d655727c15530c1f65ccea83ab911f42e04ff Mon Sep 17 00:00:00 2001 From: Rick Pasetto Date: Mon, 11 Jan 2010 18:44:00 -0800 Subject: Add cursor-change override while dragging on the mac This changes the setCursor() call in LLWindowMacOSX to be ignored if we're currently dragging via the OS http://codereview.lindenlab.com/273045 --- indra/llwindow/llwindowmacosx.cpp | 38 ++++++++++++++++++++++++++++++++++++-- indra/llwindow/llwindowmacosx.h | 2 ++ 2 files changed, 38 insertions(+), 2 deletions(-) (limited to 'indra') diff --git a/indra/llwindow/llwindowmacosx.cpp b/indra/llwindow/llwindowmacosx.cpp index dc5a98756a..783d1f39ca 100644 --- a/indra/llwindow/llwindowmacosx.cpp +++ b/indra/llwindow/llwindowmacosx.cpp @@ -278,6 +278,8 @@ LLWindowMacOSX::LLWindowMacOSX(LLWindowCallbacks* callbacks, mMoveEventCampartorUPP = NewEventComparatorUPP(staticMoveEventComparator); mGlobalHandlerRef = NULL; mWindowHandlerRef = NULL; + + mDragOverrideCursor = -1; // We're not clipping yet SetRect( &mOldMouseClip, 0, 0, 0, 0 ); @@ -2795,6 +2797,8 @@ void LLWindowMacOSX::setCursor(ECursorType cursor) { OSStatus result = noErr; + if (mDragOverrideCursor != -1) return; + if (cursor == UI_CURSOR_ARROW && mBusyCount > 0) { @@ -3499,10 +3503,40 @@ OSErr LLWindowMacOSX::handleDragNDrop(DragRef drag, LLWindowCallbacks::DragNDrop LLWindowCallbacks::DragNDropResult res = mCallbacks->handleDragNDrop(this, gl_pos, mask, action, url); - if (LLWindowCallbacks::DND_NONE != res) + switch (res) { + case LLWindowCallbacks::DND_NONE: // No drop allowed + if (action == LLWindowCallbacks::DNDA_TRACK) + { + mDragOverrideCursor = kThemeNotAllowedCursor; + } + else { + mDragOverrideCursor = -1; + } + break; + case LLWindowCallbacks::DND_MOVE: // Drop accepted would result in a "move" operation + mDragOverrideCursor = kThemePointingHandCursor; + result = noErr; + break; + case LLWindowCallbacks::DND_COPY: // Drop accepted would result in a "copy" operation + mDragOverrideCursor = kThemeCopyArrowCursor; + result = noErr; + break; + case LLWindowCallbacks::DND_LINK: // Drop accepted would result in a "link" operation: + mDragOverrideCursor = kThemeAliasArrowCursor; + result = noErr; + break; + default: + mDragOverrideCursor = -1; + break; + } + if (mDragOverrideCursor == -1) { - result = noErr; + SetThemeCursor(kThemeArrowCursor); + } + else { + SetThemeCursor(mDragOverrideCursor); } + } } } diff --git a/indra/llwindow/llwindowmacosx.h b/indra/llwindow/llwindowmacosx.h index 09b8891db0..377f10b6d4 100644 --- a/indra/llwindow/llwindowmacosx.h +++ b/indra/llwindow/llwindowmacosx.h @@ -201,6 +201,8 @@ protected: U32 mFSAASamples; BOOL mForceRebuild; + S32 mDragOverrideCursor; + F32 mBounceTime; NMRec mBounceRec; LLTimer mBounceTimer; -- cgit v1.2.3 From df69302cd2f00dd44b5b34aeb3ba896ce7548556 Mon Sep 17 00:00:00 2001 From: Rick Pasetto Date: Tue, 12 Jan 2010 11:31:07 -0800 Subject: Add restoring of previous cursor to mac impl http://codereview.lindenlab.com/273045 --- indra/llwindow/llwindowmacosx.cpp | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'indra') diff --git a/indra/llwindow/llwindowmacosx.cpp b/indra/llwindow/llwindowmacosx.cpp index 783d1f39ca..9ccd4c7f97 100644 --- a/indra/llwindow/llwindowmacosx.cpp +++ b/indra/llwindow/llwindowmacosx.cpp @@ -2797,8 +2797,14 @@ void LLWindowMacOSX::setCursor(ECursorType cursor) { OSStatus result = noErr; - if (mDragOverrideCursor != -1) return; - + if (mDragOverrideCursor != -1) + { + // A drag is in progress...remember the requested cursor and we'll + // restore it when it is done + mCurrentCursor = cursor; + return; + } + if (cursor == UI_CURSOR_ARROW && mBusyCount > 0) { @@ -3529,11 +3535,19 @@ OSErr LLWindowMacOSX::handleDragNDrop(DragRef drag, LLWindowCallbacks::DragNDrop mDragOverrideCursor = -1; break; } + // This overrides the cursor being set by setCursor. + // This is a bit of a hack workaround because lots of areas + // within the viewer just blindly set the cursor. if (mDragOverrideCursor == -1) { - SetThemeCursor(kThemeArrowCursor); + // Restore the cursor + ECursorType temp_cursor = mCurrentCursor; + // get around the "setting the same cursor" code in setCursor() + mCurrentCursor = UI_CURSOR_COUNT; + setCursor(temp_cursor); } else { + // Override the cursor SetThemeCursor(mDragOverrideCursor); } -- cgit v1.2.3