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

- changed the size of the window for dragging on Mac to 3 by 3 pixels.
- on server side, use a new thread to write file to the drop directory.
This commit is contained in:
jerry
2013-09-24 16:29:51 +00:00
parent e145fef76f
commit 4816a30db3
12 changed files with 126 additions and 55 deletions

View File

@@ -38,6 +38,8 @@
#include "CArchMiscWindows.h"
#include "CApp.h"
#include "CArgsBase.h"
#include "CClientApp.h"
#include "CClient.h"
#include <string.h>
#include <pbt.h>
#include <Shlobj.h>
@@ -126,8 +128,9 @@ CMSWindowsScreen::CMSWindowsScreen(
try {
if (m_isPrimary && !m_noHooks) {
m_hookLibrary = openHookLibrary("synwinhk");
m_shellLibrary = openShellLibrary("synwinxt");
}
m_shellLibrary = openShellLibrary("synwinxt");
m_screensaver = new CMSWindowsScreenSaver();
m_desks = new CMSWindowsDesks(
m_isPrimary, m_noHooks,
@@ -359,6 +362,26 @@ CMSWindowsScreen::leave()
forceShowCursor();
if (m_draggingStarted) {
CString& draggingDir = getDraggingFileDir();
LOG((CLOG_DEBUG "get dragging file dir: %s", draggingDir.c_str()));
size_t size = draggingDir.size();
if (!m_isPrimary) {
// TODO: fake these keys properly
fakeKeyDown(kKeyEscape, 8192, 1);
fakeKeyUp(1);
fakeMouseButton(kButtonLeft, false);
CClientApp& app = CClientApp::instance();
CClient* client = app.getClientPtr();
UInt32 fileCount = 1;
LOG((CLOG_DEBUG "send dragging info to server: %s", draggingDir.c_str()));
client->draggingInfoSending(fileCount, draggingDir, size);
LOG((CLOG_DEBUG "send dragging file to server"));
client->sendFileToServer(draggingDir.c_str());
}
m_draggingStarted = false;
}
@@ -708,12 +731,26 @@ void
CMSWindowsScreen::fakeMouseButton(ButtonID id, bool press)
{
m_desks->fakeMouseButton(id, press);
if (id == kButtonLeft) {
if (press) {
m_buttons[kButtonLeft] = true;
}
else {
m_buttons[kButtonLeft] = false;
m_fakeDraggingStarted = false;
m_draggingStarted = false;
}
}
}
void
CMSWindowsScreen::fakeMouseMove(SInt32 x, SInt32 y)
{
m_desks->fakeMouseMove(x, y);
if (m_buttons[kButtonLeft]) {
m_draggingStarted = true;
}
}
void

View File

@@ -123,6 +123,7 @@ endif()
include_directories(${inc})
add_library(platform STATIC ${src})
target_link_libraries(platform client ${libs})
if (UNIX)
target_link_libraries(platform io net ipc synergy server client ${libs})

View File

@@ -37,7 +37,7 @@ runCocoaApp()
g_app = app;
NSWindow* window = [[NSWindow alloc]
initWithContentRect: NSMakeRect(0, 0, 100, 4)
initWithContentRect: NSMakeRect(0, 0, 3, 3)
styleMask: NSBorderlessWindowMask
backing: NSBackingStoreBuffered
defer: NO];
@@ -45,7 +45,7 @@ runCocoaApp()
[window setAlphaValue:0.1];
[window makeKeyAndOrderFront:nil];
COSXDragView* dragView = [[COSXDragView alloc] initWithFrame:NSMakeRect(0, 0, 100, 4)];
COSXDragView* dragView = [[COSXDragView alloc] initWithFrame:NSMakeRect(0, 0, 3, 3)];
g_dragWindow = window;
g_dragView = dragView;
@@ -74,24 +74,10 @@ fakeDragging(const char* str, int length, int cursorX, int cursorY)
int newPosX = 0;
int newPosY = 0;
if (cursorX == 0) {
newPosX = cursorX - 99;
}
else if (cursorX == screen.size.width - 1) {
newPosX = cursorX - 1;
}
newPosY = screen.size.height - cursorY - 2;
newPosX = cursorX - 1;
newPosY = screen.size.height - cursorY - 1;
if (cursorY == 0) {
newPosY = screen.size.height - 1;
newPosX = cursorX - 50;
}
else if (cursorY == screen.size.height - 1) {
newPosY = 1;
newPosX = cursorX - 50;
}
NSRect rect = NSMakeRect(newPosX, newPosY, 100, 4);
NSRect rect = NSMakeRect(newPosX, newPosY, 3, 3);
NSLog ( @"newPosX: %d", newPosX);
NSLog ( @"newPosY: %d", newPosY);

View File

@@ -102,7 +102,6 @@ COSXScreen::COSXScreen(IEventQueue* events, bool isPrimary, bool autoShowHideCur
m_eventTapRLSR(nullptr),
m_eventTapPort(nullptr),
m_pmRootPort(0),
m_fakeDraggingStarted(false),
m_getDropTargetThread(NULL)
{
try {
@@ -601,7 +600,6 @@ COSXScreen::fakeMouseButton(ButtonID id, bool press)
this, &COSXScreen::getDropTargetThread));
}
m_fakeDraggingStarted = false;
m_draggingStarted = false;
}
}
@@ -637,6 +635,7 @@ COSXScreen::getDropTargetThread(void*)
#else
LOG((CLOG_WARN "drag drop not supported"));
#endif
m_fakeDraggingStarted = false;
}
void
@@ -743,15 +742,6 @@ COSXScreen::showCursor()
}
m_cursorHidden = false;
if (m_fakeDraggingStarted) {
#if defined(MAC_OS_X_VERSION_10_7)
// TODO: use real file extension
fakeDragging("txt", 3, m_xCursor, m_yCursor);
#else
LOG((CLOG_WARN "drag drop not supported"));
#endif
}
}
void
@@ -1234,6 +1224,11 @@ COSXScreen::onMouseButton(bool pressed, UInt16 macButton)
LOG((CLOG_DEBUG2 "dragging file directory is cleared"));
}
else {
if (m_fakeDraggingStarted) {
m_getDropTargetThread = new CThread(new TMethodJob<COSXScreen>(
this, &COSXScreen::getDropTargetThread));
}
m_draggingStarted = false;
}
}
@@ -2093,6 +2088,12 @@ void
COSXScreen::fakeDraggingFiles(CString str)
{
m_fakeDraggingStarted = true;
#if defined(MAC_OS_X_VERSION_10_7)
// TODO: use real file extension
fakeDragging("txt", 3, m_xCursor, m_yCursor);
#else
LOG((CLOG_WARN "drag drop not supported"));
#endif
}
CString&

View File

@@ -345,7 +345,6 @@ private:
IEventQueue* m_events;
bool m_fakeDraggingStarted;
CThread* m_getDropTargetThread;
CString m_dropTarget;
};