Feature to drag a file from Mac (client) to Windows (server):

- temporarily drop dragging file to desktop (specified by command line arg --filetransfer-des)
- on Mac side, fake an esc key while dragging off the screen does not seem to work
This commit is contained in:
jerry
2013-08-30 19:49:38 +00:00
parent af04f8b2ef
commit 43e2535335
18 changed files with 155 additions and 13 deletions

View File

@@ -1835,3 +1835,9 @@ CMSWindowsScreen::CHotKeyItem::operator<(const CHotKeyItem& x) const
return (m_keycode < x.m_keycode ||
(m_keycode == x.m_keycode && m_mask < x.m_mask));
}
void
CMSWindowsScreen::fakeDraggingFiles(CString str)
{
}

View File

@@ -115,6 +115,7 @@ public:
virtual void setOptions(const COptionsList& options);
virtual void setSequenceNumber(UInt32);
virtual bool isPrimary() const;
virtual void fakeDraggingFiles(CString str);
protected:
// IPlatformScreen overrides

View File

@@ -103,6 +103,8 @@ set(inc
../ipc
../net
../io
../server
../client
../synwinhk
../synwinxt
)
@@ -123,7 +125,7 @@ include_directories(${inc})
add_library(platform STATIC ${src})
if (UNIX)
target_link_libraries(platform io net ipc synergy ${libs})
target_link_libraries(platform io net ipc synergy server client ${libs})
endif()
if (APPLE)

View File

@@ -29,6 +29,7 @@ getDraggedFileURL()
NSArray* files = [pboard propertyListForType:NSFilenamesPboardType];
for (id file in files) {
[string appendString: (NSString*)file];
[string appendString: @"\0"];
}
return (CFStringRef)string;

View File

@@ -34,6 +34,9 @@
#include "XArch.h"
#include "COSXDragSimulator.h"
#include "COSXPasteboardPeeker.h"
#include "CClientApp.h"
#include "CServerApp.h"
#include "CClient.h"
#include <math.h>
@@ -98,6 +101,7 @@ 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)
{
@@ -593,6 +597,7 @@ COSXScreen::fakeMouseButton(ButtonID id, bool press)
}
m_fakeDraggingStarted = false;
m_draggingStarted = false;
}
}
@@ -638,6 +643,11 @@ COSXScreen::fakeMouseMove(SInt32 x, SInt32 y)
fakeKeyDown(kKeyControl_L, 8194, 29);
}
// index 0 means left mouse button
if (m_buttonState.test(0)) {
m_draggingStarted = true;
}
// synthesize event
CGPoint pos;
pos.x = x;
@@ -890,6 +900,24 @@ COSXScreen::leave()
{
hideCursor();
if (m_draggingStarted) {
if (!m_isPrimary) {
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);
m_draggingStarted = false;
}
}
if (m_isPrimary) {
// warp to center
//warpCursor(m_xCenter, m_yCenter);

View File

@@ -97,7 +97,6 @@ public:
virtual void setOptions(const COptionsList& options);
virtual void setSequenceNumber(UInt32);
virtual bool isPrimary() const;
virtual void fakeDraggingFiles(CString str);
const CString& getDropTarget() const { return m_dropTarget; }
@@ -345,6 +344,7 @@ private:
IEventQueue* m_events;
bool m_draggingStarted;
bool m_fakeDraggingStarted;
CThread* m_getDropTargetThread;
CString m_dropTarget;