fixed drag drop from Mac server to Windows client
This commit is contained in:
parent
39734374b1
commit
4e09b06cb0
|
@ -822,5 +822,5 @@ CClient::sendFileThread(void* filename)
|
|||
void
|
||||
CClient::draggingInfoSending(UInt32 fileCount, CString& fileList, size_t size)
|
||||
{
|
||||
m_server->draggingInfoSending(fileCount, fileList, size);
|
||||
m_server->draggingInfoSending(fileCount, fileList.c_str(), size);
|
||||
}
|
||||
|
|
|
@ -947,7 +947,8 @@ CServerProxy::fileChunkSending(UInt8 mark, char* data, size_t dataSize)
|
|||
}
|
||||
|
||||
void
|
||||
CServerProxy::draggingInfoSending(UInt32 fileCount, CString fileList, size_t size)
|
||||
CServerProxy::draggingInfoSending(UInt32 fileCount, const char* data, size_t dataSize)
|
||||
{
|
||||
CProtocolUtil::writef(m_stream, kMsgDDragInfo, fileCount, &fileList);
|
||||
CString info(data, dataSize);
|
||||
CProtocolUtil::writef(m_stream, kMsgDDragInfo, fileCount, &info);
|
||||
}
|
||||
|
|
|
@ -59,7 +59,7 @@ public:
|
|||
void fileChunkSending(UInt8 mark, char* data, size_t dataSize);
|
||||
|
||||
// sending dragging information to server
|
||||
void draggingInfoSending(UInt32 fileCount, CString fileList, size_t size);
|
||||
void draggingInfoSending(UInt32 fileCount, const char* data, size_t dataSize);
|
||||
|
||||
#ifdef TEST_ENV
|
||||
void handleDataForTest() { handleData(CEvent(), NULL); }
|
||||
|
|
|
@ -358,6 +358,11 @@ CMSWindowsScreen::leave()
|
|||
m_isOnScreen = false;
|
||||
forceShowCursor();
|
||||
|
||||
if (m_draggingStarted) {
|
||||
fakeMouseButton(kButtonLeft, false);
|
||||
m_draggingStarted = false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
void runCocoaApp();
|
||||
void stopCocoaLoop();
|
||||
void fakeDragging(const char* str, int length, int cursorX, int cursorY);
|
||||
CFStringRef getCocoaDropTarget();
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
|
||||
NSWindow* g_dragWindow = NULL;
|
||||
COSXDragView* g_dragView = NULL;
|
||||
NSApplication* g_app = NULL;
|
||||
|
||||
void
|
||||
runCocoaApp()
|
||||
|
@ -33,7 +34,8 @@ runCocoaApp()
|
|||
|
||||
|
||||
NSApplication* app = [[NSApplication alloc] init];
|
||||
|
||||
g_app = app;
|
||||
|
||||
NSWindow* window = [[NSWindow alloc]
|
||||
initWithContentRect: NSMakeRect(0, 0, 100, 4)
|
||||
styleMask: NSBorderlessWindowMask
|
||||
|
@ -56,6 +58,12 @@ runCocoaApp()
|
|||
[pool release];
|
||||
}
|
||||
|
||||
void
|
||||
stopCocoaLoop()
|
||||
{
|
||||
[g_app stop: g_dragWindow];
|
||||
}
|
||||
|
||||
void
|
||||
fakeDragging(const char* str, int length, int cursorX, int cursorY)
|
||||
{
|
||||
|
|
|
@ -37,6 +37,7 @@
|
|||
#include "CClientApp.h"
|
||||
#include "CServerApp.h"
|
||||
#include "CClient.h"
|
||||
#include "CServer.h"
|
||||
|
||||
#include <math.h>
|
||||
|
||||
|
@ -101,7 +102,6 @@ COSXScreen::COSXScreen(IEventQueue* events, bool isPrimary, bool autoShowHideCur
|
|||
m_eventTapRLSR(nullptr),
|
||||
m_eventTapPort(nullptr),
|
||||
m_pmRootPort(0),
|
||||
m_draggingStarted(false),
|
||||
m_fakeDraggingStarted(false),
|
||||
m_getDropTargetThread(NULL)
|
||||
{
|
||||
|
@ -318,6 +318,10 @@ COSXScreen::getJumpZoneSize() const
|
|||
bool
|
||||
COSXScreen::isAnyMouseButtonDown(UInt32& buttonID) const
|
||||
{
|
||||
if (m_buttonState.test(0)) {
|
||||
buttonID = kButtonLeft;
|
||||
}
|
||||
|
||||
return (GetCurrentButtonState() != 0);
|
||||
}
|
||||
|
||||
|
@ -908,24 +912,36 @@ COSXScreen::leave()
|
|||
{
|
||||
hideCursor();
|
||||
|
||||
if (m_draggingStarted && !m_isPrimary) {
|
||||
// fake ctrl key up
|
||||
fakeKeyUp(29);
|
||||
// fake esc key down and up
|
||||
fakeKeyDown(kKeyEscape, 8192, 1);
|
||||
fakeKeyUp(1);
|
||||
if (m_draggingStarted) {
|
||||
CFStringRef dragInfo = getDraggedFileURL();
|
||||
char* dragInfoCStr = CFStringRefToUTF8String(dragInfo);
|
||||
LOG((CLOG_DEBUG "drag info: %s", dragInfoCStr));
|
||||
CFRelease(dragInfo);
|
||||
CString fileList(dragInfoCStr);
|
||||
size_t size = fileList.size();
|
||||
CClientApp& app = CClientApp::instance();
|
||||
CClient* client = app.getClientPtr();
|
||||
UInt32 fileCount = 1;
|
||||
client->draggingInfoSending(fileCount, fileList, size);
|
||||
LOG((CLOG_DEBUG "send dragging file to server"));
|
||||
client->sendFileToServer(dragInfoCStr);
|
||||
|
||||
// fake esc key down and up
|
||||
fakeKeyDown(kKeyEscape, 8192, 1);
|
||||
fakeKeyUp(1);
|
||||
|
||||
fakeMouseButton(kButtonLeft, false);
|
||||
|
||||
if (m_isPrimary) {
|
||||
CServerApp& app = CServerApp::instance();
|
||||
CServer* server = app.getServerPtr();
|
||||
LOG((CLOG_DEBUG "send dragging file to client"));
|
||||
server->sendFileToClient(dragInfoCStr);
|
||||
}
|
||||
else {
|
||||
// fake ctrl key up
|
||||
fakeKeyUp(29);
|
||||
CClientApp& app = CClientApp::instance();
|
||||
CClient* client = app.getClientPtr();
|
||||
UInt32 fileCount = 1;
|
||||
client->draggingInfoSending(fileCount, fileList, size);
|
||||
LOG((CLOG_DEBUG "send dragging file to server"));
|
||||
client->sendFileToServer(dragInfoCStr);
|
||||
}
|
||||
m_draggingStarted = false;
|
||||
}
|
||||
|
||||
|
@ -1149,6 +1165,9 @@ COSXScreen::onMouseMove(SInt32 mx, SInt32 my)
|
|||
// motion on primary screen
|
||||
sendEvent(m_events->forIPrimaryScreen().motionOnPrimary(),
|
||||
CMotionInfo::alloc(m_xCursor, m_yCursor));
|
||||
if (m_buttonState.test(0)) {
|
||||
m_draggingStarted = true;
|
||||
}
|
||||
}
|
||||
else {
|
||||
// motion on secondary screen. warp mouse back to
|
||||
|
@ -1212,6 +1231,18 @@ COSXScreen::onMouseButton(bool pressed, UInt16 macButton)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (macButton == kButtonLeft) {
|
||||
MouseButtonState state = pressed ? kMouseButtonDown : kMouseButtonUp;
|
||||
m_buttonState.set(kButtonLeft - 1, state);
|
||||
if (pressed) {
|
||||
m_draggingFileDir.clear();
|
||||
LOG((CLOG_DEBUG2 "dragging file directory is cleared"));
|
||||
}
|
||||
else {
|
||||
m_draggingStarted = false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -1951,13 +1982,7 @@ COSXScreen::handleCGInputEvent(CGEventTapProxy proxy,
|
|||
case kCGEventOtherMouseUp:
|
||||
screen->onMouseButton(false, CGEventGetIntegerValueField(event, kCGMouseEventButtonNumber) + 1);
|
||||
break;
|
||||
case kCGEventLeftMouseDragged: {
|
||||
CFStringRef dragInfo = getDraggedFileURL();
|
||||
char* info = CFStringRefToUTF8String(dragInfo);
|
||||
LOG((CLOG_DEBUG "drag info: %s", info));
|
||||
CFRelease(dragInfo);
|
||||
break;
|
||||
}
|
||||
case kCGEventLeftMouseDragged:
|
||||
case kCGEventRightMouseDragged:
|
||||
case kCGEventOtherMouseDragged:
|
||||
case kCGEventMouseMoved:
|
||||
|
@ -2075,3 +2100,17 @@ COSXScreen::fakeDraggingFiles(CString str)
|
|||
{
|
||||
m_fakeDraggingStarted = true;
|
||||
}
|
||||
|
||||
CString&
|
||||
COSXScreen::getDraggingFileDir()
|
||||
{
|
||||
if (m_draggingStarted) {
|
||||
CFStringRef dragInfo = getDraggedFileURL();
|
||||
char* info = CFStringRefToUTF8String(dragInfo);
|
||||
LOG((CLOG_DEBUG "drag info: %s", info));
|
||||
CFRelease(dragInfo);
|
||||
CString fileList(info);
|
||||
m_draggingFileDir = fileList;
|
||||
}
|
||||
return m_draggingFileDir;
|
||||
}
|
||||
|
|
|
@ -98,6 +98,7 @@ public:
|
|||
virtual void setSequenceNumber(UInt32);
|
||||
virtual bool isPrimary() const;
|
||||
virtual void fakeDraggingFiles(CString str);
|
||||
virtual CString& getDraggingFileDir();
|
||||
|
||||
const CString& getDropTarget() const { return m_dropTarget; }
|
||||
|
||||
|
@ -344,7 +345,6 @@ private:
|
|||
|
||||
IEventQueue* m_events;
|
||||
|
||||
bool m_draggingStarted;
|
||||
bool m_fakeDraggingStarted;
|
||||
CThread* m_getDropTargetThread;
|
||||
CString m_dropTarget;
|
||||
|
|
|
@ -1752,7 +1752,7 @@ CServer::onMouseMovePrimary(SInt32 x, SInt32 y)
|
|||
LOG((CLOG_DEBUG3 "dragging file list: %s", fileList));
|
||||
LOG((CLOG_DEBUG3 "dragging file list string size: %i", size));
|
||||
newScreen->draggingInfoSending(fileCount, fileList, size);
|
||||
m_screen->setDraggingStarted(false);
|
||||
//m_screen->setDraggingStarted(false);
|
||||
}
|
||||
|
||||
// switch screen
|
||||
|
@ -2307,3 +2307,9 @@ CServer::dragInfoReceived(UInt32 fileNum, CString content)
|
|||
LOG((CLOG_DEBUG2 "dragging file %i name: %s", i + 1, m_dragFileList.at(i).c_str()));
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
CServer::draggingInfoSending(UInt32 fileCount, CString& fileList, size_t size)
|
||||
{
|
||||
m_active->draggingInfoSending(fileCount, fileList.c_str(), size);
|
||||
}
|
||||
|
|
|
@ -158,6 +158,9 @@ public:
|
|||
//! Received dragging information from client
|
||||
void dragInfoReceived(UInt32 fileNum, CString content);
|
||||
|
||||
//! Send dragging file information to client
|
||||
void draggingInfoSending(UInt32 fileCount, CString& fileList, size_t size);
|
||||
|
||||
//@}
|
||||
//! @name accessors
|
||||
//@{
|
||||
|
|
|
@ -45,6 +45,10 @@
|
|||
#include <ApplicationServices/ApplicationServices.h>
|
||||
#endif
|
||||
|
||||
#if defined(__APPLE__)
|
||||
#include "COSXDragSimulator.h"
|
||||
#endif
|
||||
|
||||
CApp* CApp::s_instance = nullptr;
|
||||
|
||||
CApp::CApp(IEventQueue* events, CreateTaskBarReceiverFunc createTaskBarReceiver, CArgsBase* args) :
|
||||
|
@ -393,4 +397,10 @@ CApp::runEventsLoop(void*)
|
|||
{
|
||||
m_events->cacheCurrentEventQueueRef();
|
||||
m_events->loop();
|
||||
|
||||
#if defined(MAC_OS_X_VERSION_10_7)
|
||||
|
||||
stopCocoaLoop();
|
||||
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -376,7 +376,7 @@ CScreen::isLockedToScreen() const
|
|||
LOG((CLOG_DEBUG "locked by mouse buttonID: %d", buttonID));
|
||||
if (buttonID == kButtonLeft) {
|
||||
// TODO: fake esc key down and up
|
||||
m_screen->fakeMouseButton(buttonID, false);
|
||||
//m_screen->fakeMouseButton(buttonID, false);
|
||||
}
|
||||
|
||||
return (buttonID == kButtonLeft) ? false : true;
|
||||
|
|
Loading…
Reference in New Issue