diff options
author | Joseph Eagar <joeedh@gmail.com> | 2009-11-29 03:53:23 +0300 |
---|---|---|
committer | Joseph Eagar <joeedh@gmail.com> | 2009-11-29 03:53:23 +0300 |
commit | abd16aac5af56a37a3435b94039d77b74223abab (patch) | |
tree | 47ba926d0e8e2c3a903a5d2f1b8290d274cb381c /intern/ghost | |
parent | 3d0db91f820a509bc6c93718499ffe8ff49515d3 (diff) | |
parent | d459c9c9abd2ad0819e5c096f6e3e5a93a02a219 (diff) |
ok, apparently didn't commit this either. apparently includes a merge with trunk/2.5 at r24811 I thought I'd committed but did not, yeek.
Diffstat (limited to 'intern/ghost')
-rw-r--r-- | intern/ghost/GHOST_C-api.h | 2 | ||||
-rw-r--r-- | intern/ghost/GHOST_ISystem.h | 15 | ||||
-rw-r--r-- | intern/ghost/GHOST_IWindow.h | 11 | ||||
-rw-r--r-- | intern/ghost/intern/GHOST_C-api.cpp | 6 | ||||
-rw-r--r-- | intern/ghost/intern/GHOST_DisplayManagerCocoa.mm | 4 | ||||
-rw-r--r-- | intern/ghost/intern/GHOST_EventDragnDrop.h | 35 | ||||
-rw-r--r-- | intern/ghost/intern/GHOST_EventPrinter.cpp | 71 | ||||
-rw-r--r-- | intern/ghost/intern/GHOST_System.cpp | 11 | ||||
-rw-r--r-- | intern/ghost/intern/GHOST_System.h | 18 | ||||
-rw-r--r-- | intern/ghost/intern/GHOST_SystemCocoa.h | 3 | ||||
-rw-r--r-- | intern/ghost/intern/GHOST_SystemCocoa.mm | 76 | ||||
-rw-r--r-- | intern/ghost/intern/GHOST_Window.cpp | 10 | ||||
-rw-r--r-- | intern/ghost/intern/GHOST_Window.h | 14 | ||||
-rw-r--r-- | intern/ghost/intern/GHOST_WindowCocoa.mm | 9 | ||||
-rw-r--r-- | intern/ghost/make/msvc_9_0/ghost.vcproj | 4 |
15 files changed, 198 insertions, 91 deletions
diff --git a/intern/ghost/GHOST_C-api.h b/intern/ghost/GHOST_C-api.h index 5e434c0eaa0..d4788ae9e86 100644 --- a/intern/ghost/GHOST_C-api.h +++ b/intern/ghost/GHOST_C-api.h @@ -414,7 +414,7 @@ extern GHOST_TSuccess GHOST_GetButtonState(GHOST_SystemHandle systemhandle, /** * Tells if the ongoing drag'n'drop object can be accepted upon mouse drop */ -extern void GHOST_setAcceptDragOperation(GHOST_SystemHandle systemhandle, GHOST_TInt8 canAccept); +extern void GHOST_setAcceptDragOperation(GHOST_WindowHandle windowhandle, GHOST_TInt8 canAccept); /** diff --git a/intern/ghost/GHOST_ISystem.h b/intern/ghost/GHOST_ISystem.h index e56a0dae879..305caa70ae4 100644 --- a/intern/ghost/GHOST_ISystem.h +++ b/intern/ghost/GHOST_ISystem.h @@ -369,21 +369,6 @@ public: virtual void putClipboard(GHOST_TInt8 *buffer, bool selection) const = 0; - /*************************************************************************************** - ** Drag'n'drop operations - ***************************************************************************************/ - - /** - * Tells if the ongoing drag'n'drop object can be accepted upon mouse drop - */ - virtual void setAcceptDragOperation(bool canAccept) = 0; - - /** - * Returns acceptance of the dropped object - * Usually called by the "object dropped" event handling function - */ - virtual bool canAcceptDragOperation() const = 0; - protected: /** * Initialize the system. diff --git a/intern/ghost/GHOST_IWindow.h b/intern/ghost/GHOST_IWindow.h index 512fad877cb..5d1e0a67e7e 100644 --- a/intern/ghost/GHOST_IWindow.h +++ b/intern/ghost/GHOST_IWindow.h @@ -149,6 +149,17 @@ public: virtual void clientToScreen(GHOST_TInt32 inX, GHOST_TInt32 inY, GHOST_TInt32& outX, GHOST_TInt32& outY) const = 0; /** + * Tells if the ongoing drag'n'drop object can be accepted upon mouse drop + */ + virtual void setAcceptDragOperation(bool canAccept) = 0; + + /** + * Returns acceptance of the dropped object + * Usually called by the "object dropped" event handling function + */ + virtual bool canAcceptDragOperation() const = 0; + + /** * Returns the state of the window (normal, minimized, maximized). * @return The state of the window. */ diff --git a/intern/ghost/intern/GHOST_C-api.cpp b/intern/ghost/intern/GHOST_C-api.cpp index 76b3d7caf7e..556176809f4 100644 --- a/intern/ghost/intern/GHOST_C-api.cpp +++ b/intern/ghost/intern/GHOST_C-api.cpp @@ -404,11 +404,11 @@ GHOST_TSuccess GHOST_GetButtonState(GHOST_SystemHandle systemhandle, } -void GHOST_setAcceptDragOperation(GHOST_SystemHandle systemhandle, GHOST_TInt8 canAccept) +void GHOST_setAcceptDragOperation(GHOST_WindowHandle windowhandle, GHOST_TInt8 canAccept) { - GHOST_ISystem* system = (GHOST_ISystem*) systemhandle; + GHOST_IWindow* window = (GHOST_IWindow*) windowhandle; - system->setAcceptDragOperation(canAccept); + window->setAcceptDragOperation(canAccept); } diff --git a/intern/ghost/intern/GHOST_DisplayManagerCocoa.mm b/intern/ghost/intern/GHOST_DisplayManagerCocoa.mm index 5be49851bcb..cd2362ab538 100644 --- a/intern/ghost/intern/GHOST_DisplayManagerCocoa.mm +++ b/intern/ghost/intern/GHOST_DisplayManagerCocoa.mm @@ -155,11 +155,11 @@ GHOST_TSuccess GHOST_DisplayManagerCocoa::setCurrentDisplaySetting(GHOST_TUns8 d NULL);*/
#ifdef GHOST_DEBUG
- printf("GHOST_DisplayManagerCocoa::setCurrentDisplaySetting(): switching to:\n");
+/* printf("GHOST_DisplayManagerCocoa::setCurrentDisplaySetting(): switching to:\n"); printf(" setting.xPixels=%d\n", getValue(displayModeValues, kCGDisplayWidth));
printf(" setting.yPixels=%d\n", getValue(displayModeValues, kCGDisplayHeight));
printf(" setting.bpp=%d\n", getValue(displayModeValues, kCGDisplayBitsPerPixel));
- printf(" setting.frequency=%d\n", getValue(displayModeValues, kCGDisplayRefreshRate));
+ printf(" setting.frequency=%d\n", getValue(displayModeValues, kCGDisplayRefreshRate)); */ #endif // GHOST_DEBUG
//CGDisplayErr err = ::CGDisplaySwitchToMode(m_displayIDs[display], displayModeValues);
diff --git a/intern/ghost/intern/GHOST_EventDragnDrop.h b/intern/ghost/intern/GHOST_EventDragnDrop.h index f1810b0eb0a..85c18efb118 100644 --- a/intern/ghost/intern/GHOST_EventDragnDrop.h +++ b/intern/ghost/intern/GHOST_EventDragnDrop.h @@ -50,8 +50,7 @@ * <li> Outside of the normal sequence, dropped data can be sent (GHOST_kEventDraggingDropOnIcon). This can happen when the user drops an object * on the application icon. (Also used in OSX to pass the filename of the document the user doubled-clicked in the finder) * - * <br><br>Note that the event handler is responsible for freeing the received data. - * <br>And the mouse positions are given in Blender coordinates (y=0 at bottom) + * <br><br>Note that the mouse positions are given in Blender coordinates (y=0 at bottom) * * <br>Currently supported object types : * <li>UTF-8 string @@ -81,6 +80,38 @@ public: m_dragnDropEventData.data = data; m_data = &m_dragnDropEventData; } + + ~GHOST_EventDragnDrop() + { + //Free the dropped object data + if (m_dragnDropEventData.data == NULL) + return; + + switch (m_dragnDropEventData.dataType) { + case GHOST_kDragnDropTypeBitmap: + //Not currently implemented + break; + case GHOST_kDragnDropTypeFilenames: + { + GHOST_TStringArray *strArray = (GHOST_TStringArray*)m_dragnDropEventData.data; + int i; + + for (i=0;i<strArray->count;i++) + free(strArray->strings[i]); + + free(strArray); + } + break; + case GHOST_kDragnDropTypeString: + free(m_dragnDropEventData.data); + break; + + default: + break; + } + } + + protected: /** The x,y-coordinates of the cursor position. */ diff --git a/intern/ghost/intern/GHOST_EventPrinter.cpp b/intern/ghost/intern/GHOST_EventPrinter.cpp index b4f5cc96083..c6b3416669e 100644 --- a/intern/ghost/intern/GHOST_EventPrinter.cpp +++ b/intern/ghost/intern/GHOST_EventPrinter.cpp @@ -33,6 +33,7 @@ #include "GHOST_EventPrinter.h" #include <iostream> #include "GHOST_EventKey.h" +#include "GHOST_EventDragnDrop.h" #include "GHOST_Debug.h" #ifdef HAVE_CONFIG_H @@ -97,7 +98,77 @@ bool GHOST_EventPrinter::processEvent(GHOST_IEvent* event) std::cout << "GHOST_kEventKeyDown, key: " << str.Ptr(); } break; + + case GHOST_kEventDraggingEntered: + { + GHOST_TEventDragnDropData* dragnDropData = (GHOST_TEventDragnDropData*)((GHOST_IEvent*)event)->getData(); + std::cout << "GHOST_kEventDraggingEntered, dragged object type : " << dragnDropData->dataType; + std::cout << " mouse at x=" << dragnDropData->x << " y=" << dragnDropData->y; + } + break; + + case GHOST_kEventDraggingUpdated: + { + GHOST_TEventDragnDropData* dragnDropData = (GHOST_TEventDragnDropData*)((GHOST_IEvent*)event)->getData(); + std::cout << "GHOST_kEventDraggingUpdated, dragged object type : " << dragnDropData->dataType; + std::cout << " mouse at x=" << dragnDropData->x << " y=" << dragnDropData->y; + } + break; + case GHOST_kEventDraggingExited: + { + GHOST_TEventDragnDropData* dragnDropData = (GHOST_TEventDragnDropData*)((GHOST_IEvent*)event)->getData(); + std::cout << "GHOST_kEventDraggingExited, dragged object type : " << dragnDropData->dataType; + } + break; + + case GHOST_kEventDraggingDropDone: + { + GHOST_TEventDragnDropData* dragnDropData = (GHOST_TEventDragnDropData*)((GHOST_IEvent*)event)->getData(); + std::cout << "GHOST_kEventDraggingDropDone, dragged object type : " << dragnDropData->dataType; + std::cout << " mouse at x=" << dragnDropData->x << " y=" << dragnDropData->y; + switch (dragnDropData->dataType) { + case GHOST_kDragnDropTypeString: + std::cout << " string received = " << (char*)dragnDropData->data; + break; + case GHOST_kDragnDropTypeFilenames: + { + GHOST_TStringArray *strArray = (GHOST_TStringArray*)dragnDropData->data; + int i; + std::cout << "\nReceived " << strArray->count << " filenames"; + for (i=0;i<strArray->count;i++) + std::cout << " Filename #" << i << ": " << strArray->strings[i]; + } + break; + default: + break; + } + } + break; + + case GHOST_kEventDraggingDropOnIcon: + { + GHOST_TEventDragnDropData* dragnDropData = (GHOST_TEventDragnDropData*)((GHOST_IEvent*)event)->getData(); + std::cout << "GHOST_kEventDraggingDropOnIcon, dragged object type : " << dragnDropData->dataType; + switch (dragnDropData->dataType) { + case GHOST_kDragnDropTypeString: + std::cout << " string received = " << (char*)dragnDropData->data; + break; + case GHOST_kDragnDropTypeFilenames: + { + GHOST_TStringArray *strArray = (GHOST_TStringArray*)dragnDropData->data; + int i; + std::cout << "\nReceived " << strArray->count << " filenames"; + for (i=0;i<strArray->count;i++) + std::cout << " Filename #" << i << ": " << strArray->strings[i]; + } + break; + default: + break; + } + } + break; + case GHOST_kEventQuit: std::cout << "GHOST_kEventQuit"; break; diff --git a/intern/ghost/intern/GHOST_System.cpp b/intern/ghost/intern/GHOST_System.cpp index cccee12d696..79d8389ffc6 100644 --- a/intern/ghost/intern/GHOST_System.cpp +++ b/intern/ghost/intern/GHOST_System.cpp @@ -54,7 +54,6 @@ GHOST_System::GHOST_System() : m_displayManager(0), m_timerManager(0), m_windowManager(0), m_eventManager(0), m_ndofManager(0) { - m_canAcceptDragOperation = false; } @@ -276,16 +275,6 @@ GHOST_TSuccess GHOST_System::getButtonState(GHOST_TButtonMask mask, bool& isDown return success; } -void GHOST_System::setAcceptDragOperation(bool canAccept) -{ - m_canAcceptDragOperation = canAccept; -} - -bool GHOST_System::canAcceptDragOperation() const -{ - return m_canAcceptDragOperation; -} - GHOST_TSuccess GHOST_System::init() { m_timerManager = new GHOST_TimerManager (); diff --git a/intern/ghost/intern/GHOST_System.h b/intern/ghost/intern/GHOST_System.h index 542553e830e..e381b673957 100644 --- a/intern/ghost/intern/GHOST_System.h +++ b/intern/ghost/intern/GHOST_System.h @@ -233,21 +233,6 @@ public: virtual GHOST_TSuccess getButtonState(GHOST_TButtonMask mask, bool& isDown) const; /*************************************************************************************** - ** Drag'n'drop operations - ***************************************************************************************/ - - /** - * Tells if the ongoing drag'n'drop object can be accepted upon mouse drop - */ - virtual void setAcceptDragOperation(bool canAccept); - - /** - * Returns acceptance of the dropped object - * Usually called by the "object dropped" event handling function - */ - virtual bool canAcceptDragOperation() const; - - /*************************************************************************************** ** Other (internal) functionality. ***************************************************************************************/ @@ -348,9 +333,6 @@ protected: /** The N-degree of freedom device manager */ GHOST_NDOFManager* m_ndofManager; - /** The acceptance of the "drop candidate" of the current drag'n'drop operation */ - bool m_canAcceptDragOperation; - /** Prints all the events. */ #ifdef GHOST_DEBUG GHOST_EventPrinter* m_eventPrinter; diff --git a/intern/ghost/intern/GHOST_SystemCocoa.h b/intern/ghost/intern/GHOST_SystemCocoa.h index ebf4fee29e4..97fae12a31f 100644 --- a/intern/ghost/intern/GHOST_SystemCocoa.h +++ b/intern/ghost/intern/GHOST_SystemCocoa.h @@ -246,6 +246,9 @@ protected: /** Start time at initialization. */ GHOST_TUns64 m_start_time; + /** Event has been processed directly by Cocoa and has sent a ghost event to be dispatched */ + bool m_outsideLoopEventProcessed; + /** Mouse buttons state */ GHOST_TUns32 m_pressedMouseButtons; diff --git a/intern/ghost/intern/GHOST_SystemCocoa.mm b/intern/ghost/intern/GHOST_SystemCocoa.mm index ccd7157c6e3..d8c46741ed0 100644 --- a/intern/ghost/intern/GHOST_SystemCocoa.mm +++ b/intern/ghost/intern/GHOST_SystemCocoa.mm @@ -449,12 +449,12 @@ GHOST_SystemCocoa::GHOST_SystemCocoa() m_pressedMouseButtons =0;
m_cursorDelta_x=0; m_cursorDelta_y=0; + m_outsideLoopEventProcessed = false; m_displayManager = new GHOST_DisplayManagerCocoa ();
GHOST_ASSERT(m_displayManager, "GHOST_SystemCocoa::GHOST_SystemCocoa(): m_displayManager==0\n");
m_displayManager->initialize();
//NSEvent timeStamp is given in system uptime, state start date is boot time
- //FIXME : replace by Cocoa equivalent
int mib[2];
struct timeval boottime;
size_t len;
@@ -560,17 +560,13 @@ GHOST_TSuccess GHOST_SystemCocoa::init() GHOST_TUns64 GHOST_SystemCocoa::getMilliSeconds() const
{
//Cocoa equivalent exists in 10.6 ([[NSProcessInfo processInfo] systemUptime])
- int mib[2];
- struct timeval boottime;
- size_t len;
+ struct timeval currentTime; - mib[0] = CTL_KERN;
- mib[1] = KERN_BOOTTIME;
- len = sizeof(struct timeval);
+ gettimeofday(¤tTime, NULL); - sysctl(mib, 2, &boottime, &len, NULL, 0);
-
- return ((boottime.tv_sec*1000)+(boottime.tv_usec/1000));
+ //Return timestamp of system uptime + + return ((currentTime.tv_sec*1000)+(currentTime.tv_usec/1000)-m_start_time); }
@@ -744,6 +740,8 @@ bool GHOST_SystemCocoa::processEvents(bool waitForEvent) bool anyProcessed = false;
NSEvent *event;
+ m_outsideLoopEventProcessed = false; + // SetMouseCoalescingEnabled(false, NULL);
//TODO : implement timer ??
@@ -842,7 +840,7 @@ bool GHOST_SystemCocoa::processEvents(bool waitForEvent) - return anyProcessed;
+ return anyProcessed || m_outsideLoopEventProcessed; }
//Note: called from NSWindow delegate
@@ -879,6 +877,8 @@ GHOST_TSuccess GHOST_SystemCocoa::handleWindowEvent(GHOST_TEventType eventType, return GHOST_kFailure;
break;
}
+ + m_outsideLoopEventProcessed = true; return GHOST_kSuccess;
}
@@ -892,10 +892,9 @@ GHOST_TSuccess GHOST_SystemCocoa::handleDraggingEvent(GHOST_TEventType eventType switch(eventType) { case GHOST_kEventDraggingEntered: - setAcceptDragOperation(FALSE); //Drag operation needs to be accepted explicitely by the event manager case GHOST_kEventDraggingUpdated: case GHOST_kEventDraggingExited: - pushEvent(new GHOST_EventDragnDrop(getMilliSeconds(),GHOST_kEventDraggingEntered,draggedObjectType,window,mouseX,mouseY,NULL)); + pushEvent(new GHOST_EventDragnDrop(getMilliSeconds(),eventType,draggedObjectType,window,mouseX,mouseY,NULL)); break; case GHOST_kEventDraggingDropDone: @@ -914,6 +913,7 @@ GHOST_TSuccess GHOST_SystemCocoa::handleDraggingEvent(GHOST_TEventType eventType switch (draggedObjectType) { case GHOST_kDragnDropTypeBitmap: //TODO: implement bitmap conversion to a blender friendly format + return GHOST_kFailure; break; case GHOST_kDragnDropTypeFilenames: droppedArray = (NSArray*)data; @@ -930,7 +930,7 @@ GHOST_TSuccess GHOST_SystemCocoa::handleDraggingEvent(GHOST_TEventType eventType { droppedStr = [droppedArray objectAtIndex:i]; - pastedTextSize = [droppedStr lengthOfBytesUsingEncoding:NSUTF8StringEncoding]; + pastedTextSize = [droppedStr lengthOfBytesUsingEncoding:NSISOLatin1StringEncoding]; temp_buff = (GHOST_TUns8*) malloc(pastedTextSize+1); if (!temp_buff) { @@ -938,7 +938,7 @@ GHOST_TSuccess GHOST_SystemCocoa::handleDraggingEvent(GHOST_TEventType eventType break; } - strncpy((char*)temp_buff, [droppedStr UTF8String], pastedTextSize); + strncpy((char*)temp_buff, [droppedStr cStringUsingEncoding:NSISOLatin1StringEncoding], pastedTextSize); temp_buff[pastedTextSize] = '\0'; strArray->strings[i] = temp_buff; @@ -949,7 +949,7 @@ GHOST_TSuccess GHOST_SystemCocoa::handleDraggingEvent(GHOST_TEventType eventType case GHOST_kDragnDropTypeString: droppedStr = (NSString*)data; - pastedTextSize = [droppedStr lengthOfBytesUsingEncoding:NSUTF8StringEncoding]; + pastedTextSize = [droppedStr lengthOfBytesUsingEncoding:NSISOLatin1StringEncoding]; temp_buff = (GHOST_TUns8*) malloc(pastedTextSize+1); @@ -957,7 +957,7 @@ GHOST_TSuccess GHOST_SystemCocoa::handleDraggingEvent(GHOST_TEventType eventType return GHOST_kFailure; } - strncpy((char*)temp_buff, [droppedStr UTF8String], pastedTextSize); + strncpy((char*)temp_buff, [droppedStr cStringUsingEncoding:NSISOLatin1StringEncoding], pastedTextSize); temp_buff[pastedTextSize] = '\0'; @@ -968,12 +968,13 @@ GHOST_TSuccess GHOST_SystemCocoa::handleDraggingEvent(GHOST_TEventType eventType return GHOST_kFailure; break; } - pushEvent(new GHOST_EventDragnDrop(getMilliSeconds(),GHOST_kEventDraggingEntered,draggedObjectType,window,mouseX,mouseY,eventData)); + pushEvent(new GHOST_EventDragnDrop(getMilliSeconds(),eventType,draggedObjectType,window,mouseX,mouseY,eventData)); } break; default: return GHOST_kFailure; } + m_outsideLoopEventProcessed = true; return GHOST_kSuccess; } @@ -1006,6 +1007,7 @@ GHOST_TUns8 GHOST_SystemCocoa::handleQuitRequest() }
else {
pushEvent( new GHOST_Event(getMilliSeconds(), GHOST_kEventQuit, NULL) );
+ m_outsideLoopEventProcessed = true; return GHOST_kExitNow;
}
@@ -1078,7 +1080,7 @@ GHOST_TSuccess GHOST_SystemCocoa::handleMouseEvent(void *eventPtr) case NSLeftMouseDown:
case NSRightMouseDown:
case NSOtherMouseDown:
- pushEvent(new GHOST_EventButton([event timestamp], GHOST_kEventButtonDown, window, convertButton([event buttonNumber])));
+ pushEvent(new GHOST_EventButton([event timestamp]*1000, GHOST_kEventButtonDown, window, convertButton([event buttonNumber]))); //Handle tablet events combined with mouse events
switch ([event subtype]) {
case NX_SUBTYPE_TABLET_POINT:
@@ -1096,7 +1098,7 @@ GHOST_TSuccess GHOST_SystemCocoa::handleMouseEvent(void *eventPtr) case NSLeftMouseUp:
case NSRightMouseUp:
case NSOtherMouseUp:
- pushEvent(new GHOST_EventButton([event timestamp], GHOST_kEventButtonUp, window, convertButton([event buttonNumber])));
+ pushEvent(new GHOST_EventButton([event timestamp]*1000, GHOST_kEventButtonUp, window, convertButton([event buttonNumber]))); //Handle tablet events combined with mouse events
switch ([event subtype]) {
case NX_SUBTYPE_TABLET_POINT:
@@ -1140,7 +1142,7 @@ GHOST_TSuccess GHOST_SystemCocoa::handleMouseEvent(void *eventPtr) y_accum += -[event deltaY]; //Strange Apple implementation (inverted coordinates for the deltaY) ... window->setCursorGrabAccum(x_accum, y_accum); - pushEvent(new GHOST_EventCursor([event timestamp], GHOST_kEventCursorMove, window, x_warp+x_accum, y_warp+y_accum)); + pushEvent(new GHOST_EventCursor([event timestamp]*1000, GHOST_kEventCursorMove, window, x_warp+x_accum, y_warp+y_accum)); } break; case GHOST_kGrabWrap: //Wrap cursor at area/window boundaries @@ -1184,14 +1186,14 @@ GHOST_TSuccess GHOST_SystemCocoa::handleMouseEvent(void *eventPtr) //Post event window->getCursorGrabInitPos(x_cur, y_cur); - pushEvent(new GHOST_EventCursor([event timestamp], GHOST_kEventCursorMove, window, x_cur + x_accum, y_cur + y_accum)); + pushEvent(new GHOST_EventCursor([event timestamp]*1000, GHOST_kEventCursorMove, window, x_cur + x_accum, y_cur + y_accum)); } break; default: { //Normal cursor operation: send mouse position in window NSPoint mousePos = [event locationInWindow]; - pushEvent(new GHOST_EventCursor([event timestamp], GHOST_kEventCursorMove, window, mousePos.x, mousePos.y)); + pushEvent(new GHOST_EventCursor([event timestamp]*1000, GHOST_kEventCursorMove, window, mousePos.x, mousePos.y)); m_cursorDelta_x=0; m_cursorDelta_y=0; //Mouse motion occured between two cursor warps, so we can reset the delta counter } @@ -1207,7 +1209,7 @@ GHOST_TSuccess GHOST_SystemCocoa::handleMouseEvent(void *eventPtr) if (deltaF == 0.0) break; //discard trackpad delta=0 events
delta = deltaF > 0.0 ? 1 : -1;
- pushEvent(new GHOST_EventWheel([event timestamp], window, delta));
+ pushEvent(new GHOST_EventWheel([event timestamp]*1000, window, delta)); }
break;
@@ -1266,26 +1268,26 @@ GHOST_TSuccess GHOST_SystemCocoa::handleKeyEvent(void *eventPtr) break; //Cmd-Q is directly handled by Cocoa
if ([event type] == NSKeyDown) {
- pushEvent( new GHOST_EventKey([event timestamp], GHOST_kEventKeyDown, window, keyCode, ascii) );
+ pushEvent( new GHOST_EventKey([event timestamp]*1000, GHOST_kEventKeyDown, window, keyCode, ascii) ); //printf("\nKey pressed keyCode=%u ascii=%i %c",keyCode,ascii,ascii);
} else {
- pushEvent( new GHOST_EventKey([event timestamp], GHOST_kEventKeyUp, window, keyCode, ascii) );
+ pushEvent( new GHOST_EventKey([event timestamp]*1000, GHOST_kEventKeyUp, window, keyCode, ascii) ); }
break;
case NSFlagsChanged:
modifiers = [event modifierFlags];
if ((modifiers & NSShiftKeyMask) != (m_modifierMask & NSShiftKeyMask)) {
- pushEvent( new GHOST_EventKey([event timestamp], (modifiers & NSShiftKeyMask)?GHOST_kEventKeyDown:GHOST_kEventKeyUp, window, GHOST_kKeyLeftShift) );
+ pushEvent( new GHOST_EventKey([event timestamp]*1000, (modifiers & NSShiftKeyMask)?GHOST_kEventKeyDown:GHOST_kEventKeyUp, window, GHOST_kKeyLeftShift) ); }
if ((modifiers & NSControlKeyMask) != (m_modifierMask & NSControlKeyMask)) {
- pushEvent( new GHOST_EventKey([event timestamp], (modifiers & NSControlKeyMask)?GHOST_kEventKeyDown:GHOST_kEventKeyUp, window, GHOST_kKeyLeftControl) );
+ pushEvent( new GHOST_EventKey([event timestamp]*1000, (modifiers & NSControlKeyMask)?GHOST_kEventKeyDown:GHOST_kEventKeyUp, window, GHOST_kKeyLeftControl) ); }
if ((modifiers & NSAlternateKeyMask) != (m_modifierMask & NSAlternateKeyMask)) {
- pushEvent( new GHOST_EventKey([event timestamp], (modifiers & NSAlternateKeyMask)?GHOST_kEventKeyDown:GHOST_kEventKeyUp, window, GHOST_kKeyLeftAlt) );
+ pushEvent( new GHOST_EventKey([event timestamp]*1000, (modifiers & NSAlternateKeyMask)?GHOST_kEventKeyDown:GHOST_kEventKeyUp, window, GHOST_kKeyLeftAlt) ); }
if ((modifiers & NSCommandKeyMask) != (m_modifierMask & NSCommandKeyMask)) {
- pushEvent( new GHOST_EventKey([event timestamp], (modifiers & NSCommandKeyMask)?GHOST_kEventKeyDown:GHOST_kEventKeyUp, window, GHOST_kKeyCommand) );
+ pushEvent( new GHOST_EventKey([event timestamp]*1000, (modifiers & NSCommandKeyMask)?GHOST_kEventKeyDown:GHOST_kEventKeyUp, window, GHOST_kKeyCommand) ); }
m_modifierMask = modifiers;
@@ -1318,7 +1320,7 @@ GHOST_TUns8* GHOST_SystemCocoa::getClipboard(bool selection) const }
NSArray *supportedTypes =
- [NSArray arrayWithObjects: @"public.utf8-plain-text", nil];
+ [NSArray arrayWithObjects: NSStringPboardType, nil]; NSString *bestType = [[NSPasteboard generalPasteboard]
availableTypeFromArray:supportedTypes];
@@ -1328,14 +1330,14 @@ GHOST_TUns8* GHOST_SystemCocoa::getClipboard(bool selection) const return NULL;
}
- NSString * textPasted = [pasteBoard stringForType:@"public.utf8-plain-text"];
+ NSString * textPasted = [pasteBoard stringForType:NSStringPboardType]; if (textPasted == nil) {
[pool drain];
return NULL;
}
- pastedTextSize = [textPasted lengthOfBytesUsingEncoding:NSUTF8StringEncoding];
+ pastedTextSize = [textPasted lengthOfBytesUsingEncoding:NSISOLatin1StringEncoding]; temp_buff = (GHOST_TUns8*) malloc(pastedTextSize+1);
@@ -1344,7 +1346,7 @@ GHOST_TUns8* GHOST_SystemCocoa::getClipboard(bool selection) const return NULL;
}
- strncpy((char*)temp_buff, [textPasted UTF8String], pastedTextSize);
+ strncpy((char*)temp_buff, [textPasted cStringUsingEncoding:NSISOLatin1StringEncoding], pastedTextSize); temp_buff[pastedTextSize] = '\0';
@@ -1372,13 +1374,13 @@ void GHOST_SystemCocoa::putClipboard(GHOST_TInt8 *buffer, bool selection) const return;
}
- NSArray *supportedTypes = [NSArray arrayWithObject:@"public.utf8-plain-text"];
+ NSArray *supportedTypes = [NSArray arrayWithObject:NSStringPboardType]; [pasteBoard declareTypes:supportedTypes owner:nil];
- textToCopy = [NSString stringWithUTF8String:buffer];
+ textToCopy = [NSString stringWithCString:buffer encoding:NSISOLatin1StringEncoding]; - [pasteBoard setString:textToCopy forType:@"public.utf8-plain-text"];
+ [pasteBoard setString:textToCopy forType:NSStringPboardType]; [pool drain];
}
diff --git a/intern/ghost/intern/GHOST_Window.cpp b/intern/ghost/intern/GHOST_Window.cpp index 33484284d7c..e89e0274276 100644 --- a/intern/ghost/intern/GHOST_Window.cpp +++ b/intern/ghost/intern/GHOST_Window.cpp @@ -53,6 +53,7 @@ GHOST_Window::GHOST_Window( m_stereoVisual(stereoVisual) { m_isUnsavedChanges = false; + m_canAcceptDragOperation = false; m_cursorGrabAccumPos[0] = 0; m_cursorGrabAccumPos[1] = 0; @@ -154,6 +155,15 @@ GHOST_TSuccess GHOST_Window::setCustomCursorShape(GHOST_TUns8 *bitmap, GHOST_TUn } } +void GHOST_Window::setAcceptDragOperation(bool canAccept) +{ + m_canAcceptDragOperation = canAccept; +} + +bool GHOST_Window::canAcceptDragOperation() const +{ + return m_canAcceptDragOperation; +} GHOST_TSuccess GHOST_Window::setModifiedState(bool isUnsavedChanges) { diff --git a/intern/ghost/intern/GHOST_Window.h b/intern/ghost/intern/GHOST_Window.h index 86447a8623c..1b5681dc41c 100644 --- a/intern/ghost/intern/GHOST_Window.h +++ b/intern/ghost/intern/GHOST_Window.h @@ -184,6 +184,17 @@ public: virtual GHOST_TSuccess getCursorGrabBounds(GHOST_Rect& bounds); /** + * Tells if the ongoing drag'n'drop object can be accepted upon mouse drop + */ + virtual void setAcceptDragOperation(bool canAccept); + + /** + * Returns acceptance of the dropped object + * Usually called by the "object dropped" event handling function + */ + virtual bool canAcceptDragOperation() const; + + /** * Sets the window "modified" status, indicating unsaved changes * @param isUnsavedChanges Unsaved changes or not * @return Indication of success. @@ -294,6 +305,9 @@ protected: /** The current shape of the cursor */ GHOST_TStandardCursor m_cursorShape; + /** The acceptance of the "drop candidate" of the current drag'n'drop operation */ + bool m_canAcceptDragOperation; + /** Modified state : are there unsaved changes */ bool m_isUnsavedChanges; diff --git a/intern/ghost/intern/GHOST_WindowCocoa.mm b/intern/ghost/intern/GHOST_WindowCocoa.mm index dffb9b7772f..909ba803a9d 100644 --- a/intern/ghost/intern/GHOST_WindowCocoa.mm +++ b/intern/ghost/intern/GHOST_WindowCocoa.mm @@ -153,10 +153,15 @@ extern "C" { else if ([[draggingPBoard types] containsObject:NSStringPboardType]) m_draggedObjectType = GHOST_kDragnDropTypeString; else return NSDragOperationNone; + associatedWindow->setAcceptDragOperation(FALSE); //Drag operation needs to be accepted explicitly by the event manager systemCocoa->handleDraggingEvent(GHOST_kEventDraggingEntered, m_draggedObjectType, associatedWindow, mouseLocation.x, mouseLocation.y, nil); return NSDragOperationCopy; } +- (BOOL)wantsPeriodicDraggingUpdates +{ + return NO; //No need to overflow blender event queue. Events shall be sent only on changes +} - (NSDragOperation)draggingUpdated:(id < NSDraggingInfo >)sender { @@ -174,7 +179,7 @@ extern "C" { - (BOOL)prepareForDragOperation:(id < NSDraggingInfo >)sender { - if (systemCocoa->canAcceptDragOperation()) + if (associatedWindow->canAcceptDragOperation()) return YES; else return NO; @@ -194,7 +199,7 @@ extern "C" { data = [draggingPBoard propertyListForType:NSFilenamesPboardType]; break; case GHOST_kDragnDropTypeString: - data = [draggingPBoard stringForType:@"public.utf8-plain-text"]; + data = [draggingPBoard stringForType:NSStringPboardType]; break; default: return NO; diff --git a/intern/ghost/make/msvc_9_0/ghost.vcproj b/intern/ghost/make/msvc_9_0/ghost.vcproj index 6b3a49cfc9c..9569fba5a0e 100644 --- a/intern/ghost/make/msvc_9_0/ghost.vcproj +++ b/intern/ghost/make/msvc_9_0/ghost.vcproj @@ -365,6 +365,10 @@ >
</File>
<File
+ RelativePath="..\..\intern\GHOST_EventDragnDrop.h"
+ >
+ </File>
+ <File
RelativePath="..\..\intern\GHOST_EventKey.h"
>
</File>
|