Change API to no longer include slurl argument (its a platform-agnostic policy), add some code (not working yet) to implement DND on the mac
parent
aae1917d2e
commit
c272582ab7
|
|
@ -163,9 +163,9 @@ void LLWindowCallbacks::handleDataCopy(LLWindow *window, S32 data_type, void *da
|
|||
{
|
||||
}
|
||||
|
||||
BOOL LLWindowCallbacks::handleDragNDrop(LLWindow *window, LLCoordGL pos, MASK mask, BOOL drop, std::string data, BOOL is_slurl )
|
||||
LLWindowCallbacks::DragNDropResult LLWindowCallbacks::handleDragNDrop(LLWindow *window, LLCoordGL pos, MASK mask, BOOL drop, std::string data )
|
||||
{
|
||||
return FALSE;
|
||||
return LLWindowCallbacks::DND_NONE;
|
||||
}
|
||||
|
||||
BOOL LLWindowCallbacks::handleTimerEvent(LLWindow *window)
|
||||
|
|
|
|||
|
|
@ -68,10 +68,17 @@ public:
|
|||
virtual void handleWindowBlock(LLWindow *window); // window is taking over CPU for a while
|
||||
virtual void handleWindowUnblock(LLWindow *window); // window coming back after taking over CPU for a while
|
||||
virtual void handleDataCopy(LLWindow *window, S32 data_type, void *data);
|
||||
virtual BOOL handleDragNDrop(LLWindow *window, LLCoordGL pos, MASK mask, BOOL drop, std::string data, BOOL is_slurl);
|
||||
virtual BOOL handleTimerEvent(LLWindow *window);
|
||||
virtual BOOL handleDeviceChange(LLWindow *window);
|
||||
|
||||
|
||||
enum DragNDropResult {
|
||||
DND_NONE = 0, // No drop allowed
|
||||
DND_MOVE, // Drop accepted would result in a "move" operation
|
||||
DND_COPY, // Drop accepted would result in a "copy" operation
|
||||
DND_LINK // Drop accepted would result in a "link" operation
|
||||
};
|
||||
virtual DragNDropResult handleDragNDrop(LLWindow *window, LLCoordGL pos, MASK mask, BOOL drop, std::string data);
|
||||
|
||||
virtual void handlePingWatchdog(LLWindow *window, const char * msg);
|
||||
virtual void handlePauseWatchdog(LLWindow *window);
|
||||
virtual void handleResumeWatchdog(LLWindow *window);
|
||||
|
|
|
|||
|
|
@ -499,8 +499,9 @@ BOOL LLWindowMacOSX::createContext(int x, int y, int width, int height, int bits
|
|||
|
||||
// Set up window event handlers (some window-related events ONLY go to window handlers.)
|
||||
InstallStandardEventHandler(GetWindowEventTarget(mWindow));
|
||||
InstallWindowEventHandler (mWindow, mEventHandlerUPP, GetEventTypeCount (WindowHandlerEventList), WindowHandlerEventList, (void*)this, &mWindowHandlerRef); // add event handler
|
||||
|
||||
InstallWindowEventHandler(mWindow, mEventHandlerUPP, GetEventTypeCount (WindowHandlerEventList), WindowHandlerEventList, (void*)this, &mWindowHandlerRef); // add event handler
|
||||
InstallTrackingHandler( dragTrackingHandler, mWindow, (void*)this );
|
||||
InstallReceiveHandler( dragReceiveHandler, mWindow, (void*)this );
|
||||
}
|
||||
|
||||
{
|
||||
|
|
@ -2172,11 +2173,8 @@ OSStatus LLWindowMacOSX::eventHandler (EventHandlerCallRef myHandler, EventRef e
|
|||
}
|
||||
else
|
||||
{
|
||||
MASK mask = 0;
|
||||
if(modifiers & shiftKey) { mask |= MASK_SHIFT; }
|
||||
if(modifiers & (cmdKey | controlKey)) { mask |= MASK_CONTROL; }
|
||||
if(modifiers & optionKey) { mask |= MASK_ALT; }
|
||||
|
||||
MASK mask = LLWindowMacOSX::modifiersToMask(modifiers);
|
||||
|
||||
llassert( actualType == typeUnicodeText );
|
||||
|
||||
// The result is a UTF16 buffer. Pass the characters in turn to handleUnicodeChar.
|
||||
|
|
@ -3377,3 +3375,87 @@ std::vector<std::string> LLWindowMacOSX::getDynamicFallbackFontList()
|
|||
return std::vector<std::string>();
|
||||
}
|
||||
|
||||
// static
|
||||
MASK LLWindowMacOSX::modifiersToMask(SInt16 modifiers)
|
||||
{
|
||||
MASK mask = 0;
|
||||
if(modifiers & shiftKey) { mask |= MASK_SHIFT; }
|
||||
if(modifiers & (cmdKey | controlKey)) { mask |= MASK_CONTROL; }
|
||||
if(modifiers & optionKey) { mask |= MASK_ALT; }
|
||||
return mask;
|
||||
}
|
||||
|
||||
OSErr LLWindowMacOSX::dragTrackingHandler(DragTrackingMessage message, WindowRef theWindow,
|
||||
void * handlerRefCon, DragRef theDrag)
|
||||
{
|
||||
LLWindowMacOSX *self = (LLWindowMacOSX*)handlerRefCon;
|
||||
return self->handleDragNDrop(theDrag, false);
|
||||
}
|
||||
|
||||
OSErr LLWindowMacOSX::dragReceiveHandler(WindowRef theWindow, void * handlerRefCon,
|
||||
DragRef theDrag)
|
||||
{
|
||||
LLWindowMacOSX *self = (LLWindowMacOSX*)handlerRefCon;
|
||||
return self->handleDragNDrop(theDrag, true);
|
||||
|
||||
}
|
||||
|
||||
OSErr LLWindowMacOSX::handleDragNDrop(DragRef theDrag, bool drop)
|
||||
{
|
||||
OSErr result = noErr;
|
||||
|
||||
UInt16 num_items = 0;
|
||||
::CountDragItems(theDrag, &num_items);
|
||||
if (1 == num_items)
|
||||
{
|
||||
SInt16 modifiers, mouseDownModifiers, mouseUpModifiers;
|
||||
::GetDragModifiers(theDrag, &modifiers, &mouseDownModifiers, &mouseUpModifiers);
|
||||
MASK mask = LLWindowMacOSX::modifiersToMask(modifiers);
|
||||
|
||||
Point mouse_point;
|
||||
// This will return the mouse point in global screen coords
|
||||
::GetDragMouse(theDrag, &mouse_point, NULL);
|
||||
LLCoordScreen screen_coords(mouse_point.v, mouse_point.h);
|
||||
LLCoordGL gl_pos;
|
||||
convertCoords(screen_coords, &gl_pos);
|
||||
|
||||
DragItemRef theItemRef;
|
||||
::GetDragItemReferenceNumber(theDrag, 0, &theItemRef);
|
||||
|
||||
UInt16 numFlavors = 0;
|
||||
::CountDragItemFlavors(theDrag, theItemRef, &numFlavors);
|
||||
|
||||
FlavorType theType = kScrapFlavorTypeUnicode;
|
||||
std::string url;
|
||||
for (UInt16 i=0; i<numFlavors; i++)
|
||||
{
|
||||
::GetFlavorType(theDrag, theItemRef, i, &theType);
|
||||
|
||||
printf("Drag Flavor: '%lu'", theType);
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
Size size = 1024;
|
||||
::GetFlavorDataSize(theDrag, theItemRef, theType, &size);
|
||||
|
||||
::GetFlavorData(theDrag, theItemRef, theType, mDragData, &size, 0);
|
||||
url = mDragData;
|
||||
|
||||
printf("Drag Flavor: '%lu' - Drag data : %s", theType, url.c_str());
|
||||
fflush(stdout);
|
||||
|
||||
LLWindowCallbacks::DragNDropResult res =
|
||||
mCallbacks->handleDragNDrop(this, gl_pos, mask, drop, url);
|
||||
|
||||
if (LLWindowCallbacks::DND_NONE == res)
|
||||
{
|
||||
result = dragNotAcceptedErr;
|
||||
}
|
||||
}
|
||||
else {
|
||||
result = dragNotAcceptedErr;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -160,8 +160,12 @@ protected:
|
|||
void adjustCursorDecouple(bool warpingMouse = false);
|
||||
void fixWindowSize(void);
|
||||
void stopDockTileBounce();
|
||||
|
||||
|
||||
static MASK modifiersToMask(SInt16 modifiers);
|
||||
static OSErr dragTrackingHandler(DragTrackingMessage message, WindowRef theWindow,
|
||||
void * handlerRefCon, DragRef theDrag);
|
||||
static OSErr dragReceiveHandler(WindowRef theWindow, void * handlerRefCon, DragRef theDrag);
|
||||
OSErr handleDragNDrop(DragRef theDrag, bool drop);
|
||||
|
||||
//
|
||||
// Platform specific variables
|
||||
//
|
||||
|
|
@ -198,13 +202,16 @@ protected:
|
|||
NMRec mBounceRec;
|
||||
LLTimer mBounceTimer;
|
||||
|
||||
// Imput method management through Text Service Manager.
|
||||
// Input method management through Text Service Manager.
|
||||
TSMDocumentID mTSMDocument;
|
||||
BOOL mLanguageTextInputAllowed;
|
||||
ScriptCode mTSMScriptCode;
|
||||
LangCode mTSMLangCode;
|
||||
LLPreeditor* mPreeditor;
|
||||
|
||||
// Storage for drag data
|
||||
char mDragData[1024];
|
||||
|
||||
static BOOL sUseMultGL;
|
||||
|
||||
friend class LLWindowManager;
|
||||
|
|
|
|||
|
|
@ -822,16 +822,16 @@ BOOL LLViewerWindow::handleMiddleMouseDown(LLWindow *window, LLCoordGL pos, MAS
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL LLViewerWindow::handleDragNDrop( LLWindow *window, LLCoordGL pos, MASK mask, BOOL drop, std::string data, BOOL slurl )
|
||||
LLWindowCallbacks::DragNDropResult LLViewerWindow::handleDragNDrop( LLWindow *window, LLCoordGL pos, MASK mask, BOOL drop, std::string data)
|
||||
{
|
||||
BOOL result = FALSE;
|
||||
LLWindowCallbacks::DragNDropResult result = LLWindowCallbacks::DND_NONE;
|
||||
if (gSavedSettings.getBOOL("PrimMediaDragNDrop"))
|
||||
{
|
||||
// special case SLURLs
|
||||
if ( slurl )
|
||||
if ( std::string::npos != data.find("slurl.com") )
|
||||
{
|
||||
LLURLDispatcher::dispatch( data, NULL, true );
|
||||
return TRUE;
|
||||
return LLWindowCallbacks::DND_MOVE;
|
||||
};
|
||||
|
||||
LLPickInfo pick_info = pickImmediate( pos.mX, pos.mY, TRUE /*BOOL pick_transparent*/ );
|
||||
|
|
@ -863,24 +863,30 @@ BOOL LLViewerWindow::handleDragNDrop( LLWindow *window, LLCoordGL pos, MASK mas
|
|||
// XXX This shouldn't be necessary, should it ?!?
|
||||
obj->getMediaImpl(object_face)->navigateReload();
|
||||
obj->sendMediaDataUpdate();
|
||||
|
||||
result = LLWindowCallbacks::DND_COPY;
|
||||
}
|
||||
else {
|
||||
// just navigate to the URL
|
||||
obj->getMediaImpl(object_face)->navigateTo(url);
|
||||
|
||||
result = LLWindowCallbacks::DND_LINK;
|
||||
}
|
||||
LLSelectMgr::getInstance()->unhighlightObjectOnly(mDragHoveredObject);
|
||||
mDragHoveredObject = NULL;
|
||||
|
||||
}
|
||||
else {
|
||||
mDragHoveredObject = obj;
|
||||
// Highlight the dragged object
|
||||
LLSelectMgr::getInstance()->highlightObjectOnly(mDragHoveredObject);
|
||||
|
||||
result = (! te->hasMedia()) ? LLWindowCallbacks::DND_COPY : LLWindowCallbacks::DND_LINK;
|
||||
}
|
||||
result = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
if (!result && !mDragHoveredObject.isNull())
|
||||
if (result == LLWindowCallbacks::DND_NONE && !mDragHoveredObject.isNull())
|
||||
{
|
||||
LLSelectMgr::getInstance()->unhighlightObjectOnly(mDragHoveredObject);
|
||||
mDragHoveredObject = NULL;
|
||||
|
|
@ -3312,8 +3318,8 @@ LLPickInfo LLViewerWindow::pickImmediate(S32 x, S32 y_from_bot, BOOL pick_trans
|
|||
}
|
||||
else
|
||||
{
|
||||
llwarns << "List of last picks is empty" << llendl;
|
||||
llwarns << "Using stub pick" << llendl;
|
||||
lldebugs << "List of last picks is empty" << llendl;
|
||||
lldebugs << "Using stub pick" << llendl;
|
||||
mLastPick = LLPickInfo();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -170,7 +170,7 @@ public:
|
|||
/*virtual*/ BOOL handleRightMouseUp(LLWindow *window, LLCoordGL pos, MASK mask);
|
||||
/*virtual*/ BOOL handleMiddleMouseDown(LLWindow *window, LLCoordGL pos, MASK mask);
|
||||
/*virtual*/ BOOL handleMiddleMouseUp(LLWindow *window, LLCoordGL pos, MASK mask);
|
||||
/*virtual*/ BOOL handleDragNDrop(LLWindow *window, LLCoordGL pos, MASK mask, BOOL drop, std::string data, BOOL slurl);
|
||||
/*virtual*/ LLWindowCallbacks::DragNDropResult handleDragNDrop(LLWindow *window, LLCoordGL pos, MASK mask, BOOL drop, std::string data);
|
||||
void handleMouseMove(LLWindow *window, LLCoordGL pos, MASK mask);
|
||||
/*virtual*/ void handleMouseLeave(LLWindow *window);
|
||||
/*virtual*/ void handleResize(LLWindow *window, S32 x, S32 y);
|
||||
|
|
|
|||
Loading…
Reference in New Issue