2001-10-06 18:13:28 +04:00
|
|
|
#include "CClient.h"
|
|
|
|
#include "CInputPacketStream.h"
|
|
|
|
#include "COutputPacketStream.h"
|
|
|
|
#include "CProtocolUtil.h"
|
2001-11-25 21:32:41 +03:00
|
|
|
#include "CClipboard.h"
|
2001-10-08 23:24:46 +04:00
|
|
|
#include "ISecondaryScreen.h"
|
|
|
|
#include "ProtocolTypes.h"
|
2001-11-25 21:32:41 +03:00
|
|
|
#include "CLock.h"
|
2001-10-14 22:29:43 +04:00
|
|
|
#include "CThread.h"
|
2001-10-06 18:13:28 +04:00
|
|
|
#include "CTimerThread.h"
|
2001-10-08 23:24:46 +04:00
|
|
|
#include "XSynergy.h"
|
2001-10-14 22:29:43 +04:00
|
|
|
#include "TMethodJob.h"
|
2001-10-14 18:37:41 +04:00
|
|
|
#include "CLog.h"
|
2001-11-19 03:33:36 +03:00
|
|
|
#include <assert.h>
|
2001-10-08 23:24:46 +04:00
|
|
|
#include <memory>
|
2001-10-06 18:13:28 +04:00
|
|
|
|
2001-11-19 03:33:36 +03:00
|
|
|
// hack to work around operator=() bug in STL in g++ prior to v3
|
|
|
|
#if defined(__GNUC__) && (__GNUC__ < 3)
|
|
|
|
#define assign(_dst, _src, _type) _dst.reset(_src)
|
|
|
|
#else
|
|
|
|
#define assign(_dst, _src, _type) _dst = std::auto_ptr<_type >(_src)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2001-10-06 18:13:28 +04:00
|
|
|
//
|
|
|
|
// CClient
|
|
|
|
//
|
|
|
|
|
|
|
|
CClient::CClient(const CString& clientName) :
|
2001-10-08 23:24:46 +04:00
|
|
|
m_name(clientName),
|
|
|
|
m_input(NULL),
|
|
|
|
m_output(NULL),
|
|
|
|
m_screen(NULL)
|
2001-10-06 18:13:28 +04:00
|
|
|
{
|
2001-10-14 22:29:43 +04:00
|
|
|
// do nothing
|
2001-10-06 18:13:28 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
CClient::~CClient()
|
|
|
|
{
|
2001-10-14 22:29:43 +04:00
|
|
|
// do nothing
|
|
|
|
}
|
|
|
|
|
|
|
|
void CClient::run(const CNetworkAddress& serverAddress)
|
|
|
|
{
|
2001-11-19 03:33:36 +03:00
|
|
|
CThread* thread;
|
|
|
|
try {
|
|
|
|
log((CLOG_NOTE "starting client"));
|
|
|
|
|
|
|
|
// connect to secondary screen
|
|
|
|
openSecondaryScreen();
|
|
|
|
|
|
|
|
// start server interactions
|
|
|
|
m_serverAddress = &serverAddress;
|
|
|
|
thread = new CThread(new TMethodJob<CClient>(this, &CClient::runSession));
|
|
|
|
|
|
|
|
// handle events
|
|
|
|
log((CLOG_DEBUG "starting event handling"));
|
|
|
|
m_screen->run();
|
|
|
|
|
|
|
|
// clean up
|
|
|
|
log((CLOG_DEBUG "stopping client"));
|
|
|
|
thread->cancel();
|
|
|
|
thread->wait();
|
|
|
|
delete thread;
|
|
|
|
closeSecondaryScreen();
|
|
|
|
}
|
|
|
|
catch (XBase& e) {
|
2001-11-25 21:32:41 +03:00
|
|
|
log((CLOG_ERR "client error: %s", e.what()));
|
2001-11-19 03:33:36 +03:00
|
|
|
|
|
|
|
// clean up
|
|
|
|
thread->cancel();
|
|
|
|
thread->wait();
|
|
|
|
delete thread;
|
|
|
|
closeSecondaryScreen();
|
|
|
|
}
|
|
|
|
catch (...) {
|
|
|
|
log((CLOG_DEBUG "unknown client error"));
|
|
|
|
|
|
|
|
// clean up
|
|
|
|
thread->cancel();
|
|
|
|
thread->wait();
|
|
|
|
delete thread;
|
|
|
|
closeSecondaryScreen();
|
|
|
|
throw;
|
|
|
|
}
|
2001-10-06 18:13:28 +04:00
|
|
|
}
|
|
|
|
|
2001-11-25 21:32:41 +03:00
|
|
|
void CClient::onClipboardChanged()
|
|
|
|
{
|
|
|
|
log((CLOG_DEBUG "sending clipboard changed"));
|
|
|
|
CLock lock(&m_mutex);
|
|
|
|
if (m_output != NULL) {
|
|
|
|
// m_output can be NULL if the screen calls this method
|
|
|
|
// before we've gotten around to connecting to the server.
|
|
|
|
CProtocolUtil::writef(m_output, kMsgCClipboard);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-11-19 03:33:36 +03:00
|
|
|
#include "CTCPSocket.h" // FIXME
|
2001-10-14 22:29:43 +04:00
|
|
|
void CClient::runSession(void*)
|
2001-10-06 18:13:28 +04:00
|
|
|
{
|
2001-10-14 18:37:41 +04:00
|
|
|
log((CLOG_DEBUG "starting client \"%s\"", m_name.c_str()));
|
|
|
|
|
2001-10-06 18:13:28 +04:00
|
|
|
std::auto_ptr<ISocket> socket;
|
|
|
|
std::auto_ptr<IInputStream> input;
|
|
|
|
std::auto_ptr<IOutputStream> output;
|
|
|
|
try {
|
|
|
|
// allow connect this much time to succeed
|
|
|
|
CTimerThread timer(30.0); // FIXME -- timeout in member
|
|
|
|
|
|
|
|
// create socket and attempt to connect to server
|
2001-10-14 18:37:41 +04:00
|
|
|
log((CLOG_DEBUG "connecting to server"));
|
2001-11-19 03:33:36 +03:00
|
|
|
assign(socket, new CTCPSocket(), ISocket); // FIXME -- use factory
|
2001-10-14 22:29:43 +04:00
|
|
|
socket->connect(*m_serverAddress);
|
2001-10-14 18:37:41 +04:00
|
|
|
log((CLOG_INFO "connected to server"));
|
2001-10-06 18:13:28 +04:00
|
|
|
|
|
|
|
// get the input and output streams
|
|
|
|
IInputStream* srcInput = socket->getInputStream();
|
|
|
|
IOutputStream* srcOutput = socket->getOutputStream();
|
|
|
|
|
|
|
|
// attach the encryption layer
|
2001-10-21 04:21:21 +04:00
|
|
|
bool own = false;
|
2001-10-06 18:13:28 +04:00
|
|
|
/* FIXME -- implement ISecurityFactory
|
|
|
|
if (m_securityFactory != NULL) {
|
2001-10-21 04:21:21 +04:00
|
|
|
input.reset(m_securityFactory->createInputFilter(srcInput, own));
|
|
|
|
output.reset(m_securityFactory->createOutputFilter(srcOutput, own));
|
2001-10-06 18:13:28 +04:00
|
|
|
srcInput = input.get();
|
|
|
|
srcOutput = output.get();
|
2001-10-21 04:21:21 +04:00
|
|
|
own = true;
|
2001-10-06 18:13:28 +04:00
|
|
|
}
|
|
|
|
*/
|
|
|
|
|
|
|
|
// attach the packetizing filters
|
2001-11-19 03:33:36 +03:00
|
|
|
assign(input, new CInputPacketStream(srcInput, own), IInputStream);
|
|
|
|
assign(output, new COutputPacketStream(srcOutput, own), IOutputStream);
|
2001-10-06 18:13:28 +04:00
|
|
|
|
|
|
|
// wait for hello from server
|
2001-10-14 18:37:41 +04:00
|
|
|
log((CLOG_DEBUG "wait for hello"));
|
2001-10-06 18:13:28 +04:00
|
|
|
SInt32 major, minor;
|
|
|
|
CProtocolUtil::readf(input.get(), "Synergy%2i%2i", &major, &minor);
|
|
|
|
|
|
|
|
// check versions
|
2001-10-14 18:37:41 +04:00
|
|
|
log((CLOG_DEBUG "got hello version %d.%d", major, minor));
|
2001-10-06 18:13:28 +04:00
|
|
|
if (major < kMajorVersion ||
|
|
|
|
(major == kMajorVersion && minor < kMinorVersion)) {
|
|
|
|
throw XIncompatibleClient(major, minor);
|
|
|
|
}
|
|
|
|
|
|
|
|
// say hello back
|
2001-10-14 18:37:41 +04:00
|
|
|
log((CLOG_DEBUG "say hello version %d.%d", kMajorVersion, kMinorVersion));
|
2001-10-06 18:13:28 +04:00
|
|
|
CProtocolUtil::writef(output.get(), "Synergy%2i%2i%s",
|
2001-11-25 21:32:41 +03:00
|
|
|
kMajorVersion, kMinorVersion, &m_name);
|
2001-10-06 18:13:28 +04:00
|
|
|
|
|
|
|
// record streams in a more useful place
|
2001-11-25 21:32:41 +03:00
|
|
|
CLock lock(&m_mutex);
|
2001-10-06 18:13:28 +04:00
|
|
|
m_input = input.get();
|
|
|
|
m_output = output.get();
|
|
|
|
}
|
|
|
|
catch (XIncompatibleClient& e) {
|
2001-10-14 18:37:41 +04:00
|
|
|
log((CLOG_ERR "server has incompatible version %d.%d", e.getMajor(), e.getMinor()));
|
2001-11-19 03:33:36 +03:00
|
|
|
m_screen->stop();
|
2001-10-06 18:13:28 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
catch (XThread&) {
|
2001-10-14 18:37:41 +04:00
|
|
|
log((CLOG_ERR "connection timed out"));
|
2001-11-19 03:33:36 +03:00
|
|
|
m_screen->stop();
|
2001-10-06 18:13:28 +04:00
|
|
|
throw;
|
|
|
|
}
|
|
|
|
catch (XBase& e) {
|
2001-10-14 18:37:41 +04:00
|
|
|
log((CLOG_ERR "connection failed: %s", e.what()));
|
2001-11-19 03:33:36 +03:00
|
|
|
m_screen->stop();
|
2001-10-08 23:24:46 +04:00
|
|
|
return;
|
|
|
|
}
|
2001-10-06 18:13:28 +04:00
|
|
|
|
|
|
|
try {
|
2001-10-08 23:24:46 +04:00
|
|
|
// handle messages from server
|
2001-10-06 18:13:28 +04:00
|
|
|
for (;;) {
|
|
|
|
// wait for reply
|
2001-10-14 18:37:41 +04:00
|
|
|
log((CLOG_DEBUG "waiting for message"));
|
2001-10-06 18:13:28 +04:00
|
|
|
UInt8 code[4];
|
|
|
|
UInt32 n = input->read(code, 4);
|
|
|
|
|
|
|
|
// verify we got an entire code
|
|
|
|
if (n == 0) {
|
2001-10-14 18:37:41 +04:00
|
|
|
log((CLOG_NOTE "server disconnected"));
|
2001-10-06 18:13:28 +04:00
|
|
|
// server hungup
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (n != 4) {
|
|
|
|
// client sent an incomplete message
|
2001-10-14 18:37:41 +04:00
|
|
|
log((CLOG_ERR "incomplete message from server"));
|
2001-10-06 18:13:28 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
// parse message
|
2001-10-14 18:37:41 +04:00
|
|
|
log((CLOG_DEBUG "msg from server: %c%c%c%c", code[0], code[1], code[2], code[3]));
|
2001-10-06 18:13:28 +04:00
|
|
|
if (memcmp(code, kMsgDMouseMove, 4) == 0) {
|
2001-10-08 23:24:46 +04:00
|
|
|
onMouseMove();
|
2001-10-06 18:13:28 +04:00
|
|
|
}
|
|
|
|
else if (memcmp(code, kMsgDMouseWheel, 4) == 0) {
|
2001-10-08 23:24:46 +04:00
|
|
|
onMouseWheel();
|
2001-10-06 18:13:28 +04:00
|
|
|
}
|
|
|
|
else if (memcmp(code, kMsgDKeyDown, 4) == 0) {
|
2001-10-08 23:24:46 +04:00
|
|
|
onKeyDown();
|
2001-10-06 18:13:28 +04:00
|
|
|
}
|
|
|
|
else if (memcmp(code, kMsgDKeyUp, 4) == 0) {
|
2001-10-08 23:24:46 +04:00
|
|
|
onKeyUp();
|
2001-10-06 18:13:28 +04:00
|
|
|
}
|
|
|
|
else if (memcmp(code, kMsgDMouseDown, 4) == 0) {
|
2001-10-08 23:24:46 +04:00
|
|
|
onMouseDown();
|
2001-10-06 18:13:28 +04:00
|
|
|
}
|
|
|
|
else if (memcmp(code, kMsgDMouseUp, 4) == 0) {
|
2001-10-08 23:24:46 +04:00
|
|
|
onMouseUp();
|
2001-10-06 18:13:28 +04:00
|
|
|
}
|
|
|
|
else if (memcmp(code, kMsgDKeyRepeat, 4) == 0) {
|
2001-10-08 23:24:46 +04:00
|
|
|
onKeyRepeat();
|
2001-10-06 18:13:28 +04:00
|
|
|
}
|
|
|
|
else if (memcmp(code, kMsgCEnter, 4) == 0) {
|
2001-10-08 23:24:46 +04:00
|
|
|
onEnter();
|
2001-10-06 18:13:28 +04:00
|
|
|
}
|
|
|
|
else if (memcmp(code, kMsgCLeave, 4) == 0) {
|
2001-10-08 23:24:46 +04:00
|
|
|
onLeave();
|
2001-10-06 18:13:28 +04:00
|
|
|
}
|
|
|
|
else if (memcmp(code, kMsgCClipboard, 4) == 0) {
|
2001-10-08 23:24:46 +04:00
|
|
|
onGrabClipboard();
|
2001-10-06 18:13:28 +04:00
|
|
|
}
|
|
|
|
else if (memcmp(code, kMsgCScreenSaver, 4) == 0) {
|
2001-10-08 23:24:46 +04:00
|
|
|
onScreenSaver();
|
2001-10-06 18:13:28 +04:00
|
|
|
}
|
|
|
|
else if (memcmp(code, kMsgQInfo, 4) == 0) {
|
2001-10-08 23:24:46 +04:00
|
|
|
onQueryInfo();
|
2001-10-06 18:13:28 +04:00
|
|
|
}
|
|
|
|
else if (memcmp(code, kMsgQClipboard, 4) == 0) {
|
2001-10-08 23:24:46 +04:00
|
|
|
onQueryClipboard();
|
2001-10-06 18:13:28 +04:00
|
|
|
}
|
|
|
|
else if (memcmp(code, kMsgDClipboard, 4) == 0) {
|
2001-10-08 23:24:46 +04:00
|
|
|
onSetClipboard();
|
2001-10-06 18:13:28 +04:00
|
|
|
}
|
|
|
|
else if (memcmp(code, kMsgCClose, 4) == 0) {
|
|
|
|
// server wants us to hangup
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// unknown message
|
2001-10-14 18:37:41 +04:00
|
|
|
log((CLOG_ERR "unknown message from server"));
|
2001-10-06 18:13:28 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (XBase& e) {
|
2001-10-14 18:37:41 +04:00
|
|
|
log((CLOG_ERR "error: %s", e.what()));
|
2001-11-19 03:33:36 +03:00
|
|
|
m_screen->stop();
|
2001-10-06 18:13:28 +04:00
|
|
|
return;
|
|
|
|
}
|
2001-10-08 23:24:46 +04:00
|
|
|
|
|
|
|
// done with socket
|
2001-10-14 18:37:41 +04:00
|
|
|
log((CLOG_DEBUG "disconnecting from server"));
|
2001-10-08 23:24:46 +04:00
|
|
|
socket->close();
|
2001-11-19 03:33:36 +03:00
|
|
|
|
|
|
|
// exit event loop
|
|
|
|
m_screen->stop();
|
|
|
|
}
|
|
|
|
|
|
|
|
// FIXME -- use factory to create screen
|
|
|
|
#if defined(CONFIG_PLATFORM_WIN32)
|
|
|
|
#include "CMSWindowsSecondaryScreen.h"
|
|
|
|
#elif defined(CONFIG_PLATFORM_UNIX)
|
|
|
|
#include "CXWindowsSecondaryScreen.h"
|
|
|
|
#endif
|
|
|
|
void CClient::openSecondaryScreen()
|
|
|
|
{
|
|
|
|
assert(m_screen == NULL);
|
|
|
|
|
|
|
|
// open screen
|
|
|
|
log((CLOG_DEBUG "creating secondary screen"));
|
|
|
|
#if defined(CONFIG_PLATFORM_WIN32)
|
|
|
|
m_screen = new CMSWindowsSecondaryScreen;
|
|
|
|
#elif defined(CONFIG_PLATFORM_UNIX)
|
|
|
|
m_screen = new CXWindowsSecondaryScreen;
|
|
|
|
#endif
|
|
|
|
log((CLOG_DEBUG "opening secondary screen"));
|
|
|
|
m_screen->open(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CClient::closeSecondaryScreen()
|
|
|
|
{
|
|
|
|
assert(m_screen != NULL);
|
|
|
|
|
|
|
|
// close the secondary screen
|
|
|
|
try {
|
|
|
|
log((CLOG_DEBUG "closing secondary screen"));
|
|
|
|
m_screen->close();
|
|
|
|
}
|
|
|
|
catch (...) {
|
|
|
|
// ignore
|
|
|
|
}
|
|
|
|
|
|
|
|
// clean up
|
|
|
|
log((CLOG_DEBUG "destroying secondary screen"));
|
|
|
|
delete m_screen;
|
|
|
|
m_screen = NULL;
|
2001-10-06 18:13:28 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void CClient::onEnter()
|
|
|
|
{
|
|
|
|
SInt32 x, y;
|
2001-11-25 21:32:41 +03:00
|
|
|
{
|
|
|
|
CLock lock(&m_mutex);
|
|
|
|
CProtocolUtil::readf(m_input, kMsgCEnter + 4, &x, &y);
|
|
|
|
}
|
2001-10-06 18:13:28 +04:00
|
|
|
m_screen->enter(x, y);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CClient::onLeave()
|
|
|
|
{
|
|
|
|
m_screen->leave();
|
|
|
|
}
|
|
|
|
|
|
|
|
void CClient::onGrabClipboard()
|
|
|
|
{
|
2001-11-25 21:32:41 +03:00
|
|
|
m_screen->grabClipboard();
|
2001-10-06 18:13:28 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void CClient::onScreenSaver()
|
|
|
|
{
|
|
|
|
SInt32 on;
|
2001-11-25 21:32:41 +03:00
|
|
|
{
|
|
|
|
CLock lock(&m_mutex);
|
|
|
|
CProtocolUtil::readf(m_input, kMsgCScreenSaver + 4, &on);
|
|
|
|
}
|
2001-10-06 18:13:28 +04:00
|
|
|
// FIXME
|
|
|
|
}
|
|
|
|
|
|
|
|
void CClient::onQueryInfo()
|
|
|
|
{
|
|
|
|
SInt32 w, h;
|
2001-10-08 23:24:46 +04:00
|
|
|
m_screen->getSize(&w, &h);
|
2001-10-06 18:13:28 +04:00
|
|
|
SInt32 zoneSize = m_screen->getJumpZoneSize();
|
2001-11-25 21:32:41 +03:00
|
|
|
|
2001-10-14 18:37:41 +04:00
|
|
|
log((CLOG_DEBUG "sending info size=%d,%d zone=%d", w, h, zoneSize));
|
2001-11-25 21:32:41 +03:00
|
|
|
CLock lock(&m_mutex);
|
2001-10-06 18:13:28 +04:00
|
|
|
CProtocolUtil::writef(m_output, kMsgDInfo, w, h, zoneSize);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CClient::onQueryClipboard()
|
|
|
|
{
|
2001-11-25 21:32:41 +03:00
|
|
|
// parse message
|
|
|
|
UInt32 seqNum;
|
|
|
|
CClipboard clipboard;
|
|
|
|
{
|
|
|
|
CLock lock(&m_mutex);
|
|
|
|
CProtocolUtil::readf(m_input, kMsgQClipboard + 4, &seqNum);
|
|
|
|
}
|
|
|
|
log((CLOG_DEBUG "received query clipboard seqnum=%d", seqNum));
|
|
|
|
|
|
|
|
// get screen's clipboard data
|
|
|
|
m_screen->getClipboard(&clipboard);
|
|
|
|
|
|
|
|
// marshall the data
|
|
|
|
CString data = clipboard.marshall();
|
|
|
|
|
|
|
|
// send it
|
|
|
|
log((CLOG_DEBUG "sending clipboard seqnum=%d, size=%d", seqNum, data.size()));
|
|
|
|
{
|
|
|
|
CLock lock(&m_mutex);
|
|
|
|
CProtocolUtil::writef(m_output, kMsgDClipboard, seqNum, &data);
|
|
|
|
}
|
2001-10-06 18:13:28 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void CClient::onSetClipboard()
|
|
|
|
{
|
2001-11-25 21:32:41 +03:00
|
|
|
CString data;
|
|
|
|
{
|
|
|
|
// parse message
|
|
|
|
UInt32 seqNum;
|
|
|
|
CLock lock(&m_mutex);
|
|
|
|
CProtocolUtil::readf(m_input, kMsgDClipboard + 4, &seqNum, &data);
|
|
|
|
}
|
|
|
|
log((CLOG_DEBUG "received clipboard size=%d", data.size()));
|
|
|
|
|
|
|
|
// unmarshall
|
|
|
|
CClipboard clipboard;
|
|
|
|
clipboard.unmarshall(data);
|
|
|
|
|
|
|
|
// set screen's clipboard
|
|
|
|
m_screen->setClipboard(&clipboard);
|
2001-10-06 18:13:28 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void CClient::onKeyDown()
|
|
|
|
{
|
|
|
|
SInt32 id, mask;
|
2001-11-25 21:32:41 +03:00
|
|
|
{
|
|
|
|
CLock lock(&m_mutex);
|
|
|
|
CProtocolUtil::readf(m_input, kMsgDKeyDown + 4, &id, &mask);
|
|
|
|
}
|
2001-10-26 01:40:29 +04:00
|
|
|
m_screen->keyDown(static_cast<KeyID>(id),
|
2001-10-08 23:24:46 +04:00
|
|
|
static_cast<KeyModifierMask>(mask));
|
2001-10-06 18:13:28 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void CClient::onKeyRepeat()
|
|
|
|
{
|
|
|
|
SInt32 id, mask, count;
|
2001-11-25 21:32:41 +03:00
|
|
|
{
|
|
|
|
CLock lock(&m_mutex);
|
|
|
|
CProtocolUtil::readf(m_input, kMsgDKeyRepeat + 4, &id, &mask, &count);
|
|
|
|
}
|
2001-10-26 01:40:29 +04:00
|
|
|
m_screen->keyRepeat(static_cast<KeyID>(id),
|
2001-10-08 23:24:46 +04:00
|
|
|
static_cast<KeyModifierMask>(mask),
|
2001-10-06 18:13:28 +04:00
|
|
|
count);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CClient::onKeyUp()
|
|
|
|
{
|
|
|
|
SInt32 id, mask;
|
2001-11-25 21:32:41 +03:00
|
|
|
{
|
|
|
|
CLock lock(&m_mutex);
|
|
|
|
CProtocolUtil::readf(m_input, kMsgDKeyUp + 4, &id, &mask);
|
|
|
|
}
|
2001-10-26 01:40:29 +04:00
|
|
|
m_screen->keyUp(static_cast<KeyID>(id),
|
2001-10-08 23:24:46 +04:00
|
|
|
static_cast<KeyModifierMask>(mask));
|
2001-10-06 18:13:28 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void CClient::onMouseDown()
|
|
|
|
{
|
|
|
|
SInt32 id;
|
2001-11-25 21:32:41 +03:00
|
|
|
{
|
|
|
|
CLock lock(&m_mutex);
|
|
|
|
CProtocolUtil::readf(m_input, kMsgDMouseDown + 4, &id);
|
|
|
|
}
|
2001-10-26 01:40:29 +04:00
|
|
|
m_screen->mouseDown(static_cast<ButtonID>(id));
|
2001-10-06 18:13:28 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void CClient::onMouseUp()
|
|
|
|
{
|
|
|
|
SInt32 id;
|
2001-11-25 21:32:41 +03:00
|
|
|
{
|
|
|
|
CLock lock(&m_mutex);
|
|
|
|
CProtocolUtil::readf(m_input, kMsgDMouseUp + 4, &id);
|
|
|
|
}
|
2001-10-26 01:40:29 +04:00
|
|
|
m_screen->mouseUp(static_cast<ButtonID>(id));
|
2001-10-06 18:13:28 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void CClient::onMouseMove()
|
|
|
|
{
|
|
|
|
SInt32 x, y;
|
2001-11-25 21:32:41 +03:00
|
|
|
{
|
|
|
|
CLock lock(&m_mutex);
|
|
|
|
CProtocolUtil::readf(m_input, kMsgDMouseMove + 4, &x, &y);
|
|
|
|
}
|
2001-10-26 01:40:29 +04:00
|
|
|
m_screen->mouseMove(x, y);
|
2001-10-06 18:13:28 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void CClient::onMouseWheel()
|
|
|
|
{
|
|
|
|
SInt32 delta;
|
2001-11-25 21:32:41 +03:00
|
|
|
{
|
|
|
|
CLock lock(&m_mutex);
|
|
|
|
CProtocolUtil::readf(m_input, kMsgDMouseWheel + 4, &delta);
|
|
|
|
}
|
2001-10-26 01:40:29 +04:00
|
|
|
m_screen->mouseWheel(delta);
|
2001-10-06 18:13:28 +04:00
|
|
|
}
|