Restored lost files and changes in version 1.3.1 to depot.

This commit is contained in:
crs
2007-06-17 11:19:18 +00:00
parent 73acb7860d
commit 52ae656411
199 changed files with 27622 additions and 13726 deletions

View File

@@ -0,0 +1,52 @@
/*
* synergy -- mouse and keyboard sharing utility
* Copyright (C) 2006 Chris Schoeneman
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file COPYING that should have accompanied this file.
*
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#include "CBaseClientProxy.h"
//
// CBaseClientProxy
//
CBaseClientProxy::CBaseClientProxy(const CString& name) :
m_name(name),
m_x(0),
m_y(0)
{
// do nothing
}
CBaseClientProxy::~CBaseClientProxy()
{
// do nothing
}
void
CBaseClientProxy::setJumpCursorPos(SInt32 x, SInt32 y)
{
m_x = x;
m_y = y;
}
void
CBaseClientProxy::getJumpCursorPos(SInt32& x, SInt32& y) const
{
x = m_x;
y = m_y;
}
CString
CBaseClientProxy::getName() const
{
return m_name;
}

View File

@@ -0,0 +1,85 @@
/*
* synergy -- mouse and keyboard sharing utility
* Copyright (C) 2002 Chris Schoeneman
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file COPYING that should have accompanied this file.
*
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#ifndef CBASECLIENTPROXY_H
#define CBASECLIENTPROXY_H
#include "IClient.h"
#include "CString.h"
//! Generic proxy for client or primary
class CBaseClientProxy : public IClient {
public:
/*!
\c name is the name of the client.
*/
CBaseClientProxy(const CString& name);
~CBaseClientProxy();
//! @name manipulators
//@{
//! Save cursor position
/*!
Save the position of the cursor when jumping from client.
*/
void setJumpCursorPos(SInt32 x, SInt32 y);
//@}
//! @name accessors
//@{
//! Get cursor position
/*!
Get the position of the cursor when last jumping from client.
*/
void getJumpCursorPos(SInt32& x, SInt32& y) const;
//@}
// IScreen
virtual void* getEventTarget() const = 0;
virtual bool getClipboard(ClipboardID id, IClipboard*) const = 0;
virtual void getShape(SInt32& x, SInt32& y,
SInt32& width, SInt32& height) const = 0;
virtual void getCursorPos(SInt32& x, SInt32& y) const = 0;
// IClient overrides
virtual void enter(SInt32 xAbs, SInt32 yAbs,
UInt32 seqNum, KeyModifierMask mask,
bool forScreensaver) = 0;
virtual bool leave() = 0;
virtual void setClipboard(ClipboardID, const IClipboard*) = 0;
virtual void grabClipboard(ClipboardID) = 0;
virtual void setClipboardDirty(ClipboardID, bool) = 0;
virtual void keyDown(KeyID, KeyModifierMask, KeyButton) = 0;
virtual void keyRepeat(KeyID, KeyModifierMask,
SInt32 count, KeyButton) = 0;
virtual void keyUp(KeyID, KeyModifierMask, KeyButton) = 0;
virtual void mouseDown(ButtonID) = 0;
virtual void mouseUp(ButtonID) = 0;
virtual void mouseMove(SInt32 xAbs, SInt32 yAbs) = 0;
virtual void mouseRelativeMove(SInt32 xRel, SInt32 yRel) = 0;
virtual void mouseWheel(SInt32 xDelta, SInt32 yDelta) = 0;
virtual void screensaver(bool activate) = 0;
virtual void resetOptions() = 0;
virtual void setOptions(const COptionsList& options) = 0;
virtual CString getName() const;
private:
CString m_name;
SInt32 m_x, m_y;
};
#endif

View File

@@ -26,7 +26,7 @@ CEvent::Type CClientProxy::s_disconnectedEvent = CEvent::kUnknown;
CEvent::Type CClientProxy::s_clipboardChangedEvent= CEvent::kUnknown;
CClientProxy::CClientProxy(const CString& name, IStream* stream) :
m_name(name),
CBaseClientProxy(name),
m_stream(stream)
{
// do nothing
@@ -53,12 +53,6 @@ CClientProxy::getStream() const
return m_stream;
}
CString
CClientProxy::getName() const
{
return m_name;
}
CEvent::Type
CClientProxy::getReadyEvent()
{

View File

@@ -15,14 +15,14 @@
#ifndef CCLIENTPROXY_H
#define CCLIENTPROXY_H
#include "IClient.h"
#include "CBaseClientProxy.h"
#include "CEvent.h"
#include "CString.h"
class IStream;
//! Generic proxy for client
class CClientProxy : public IClient {
class CClientProxy : public CBaseClientProxy {
public:
/*!
\c name is the name of the client.
@@ -97,14 +97,12 @@ public:
virtual void mouseUp(ButtonID) = 0;
virtual void mouseMove(SInt32 xAbs, SInt32 yAbs) = 0;
virtual void mouseRelativeMove(SInt32 xRel, SInt32 yRel) = 0;
virtual void mouseWheel(SInt32 delta) = 0;
virtual void mouseWheel(SInt32 xDelta, SInt32 yDelta) = 0;
virtual void screensaver(bool activate) = 0;
virtual void resetOptions() = 0;
virtual void setOptions(const COptionsList& options) = 0;
virtual CString getName() const;
private:
CString m_name;
IStream* m_stream;
static CEvent::Type s_readyEvent;

View File

@@ -27,7 +27,6 @@
CClientProxy1_0::CClientProxy1_0(const CString& name, IStream* stream) :
CClientProxy(name, stream),
m_heartbeatAlarm(kHeartRate * kHeartBeatsUntilDeath),
m_heartbeatTimer(NULL),
m_parser(&CClientProxy1_0::parseHandshakeMessage)
{
@@ -52,6 +51,8 @@ CClientProxy1_0::CClientProxy1_0(const CString& name, IStream* stream) :
new TMethodEventJob<CClientProxy1_0>(this,
&CClientProxy1_0::handleFlatline, NULL));
setHeartbeatRate(kHeartRate, kHeartRate * kHeartBeatsUntilDeath);
LOG((CLOG_DEBUG1 "querying client \"%s\" info", getName().c_str()));
CProtocolUtil::writef(getStream(), kMsgQInfo);
}
@@ -104,6 +105,26 @@ CClientProxy1_0::removeHeartbeatTimer()
}
}
void
CClientProxy1_0::resetHeartbeatTimer()
{
// reset the alarm
removeHeartbeatTimer();
addHeartbeatTimer();
}
void
CClientProxy1_0::resetHeartbeatRate()
{
setHeartbeatRate(kHeartRate, kHeartRate * kHeartBeatsUntilDeath);
}
void
CClientProxy1_0::setHeartbeatRate(double, double alarm)
{
m_heartbeatAlarm = alarm;
}
void
CClientProxy1_0::handleData(const CEvent&, void*)
{
@@ -121,7 +142,7 @@ CClientProxy1_0::handleData(const CEvent&, void*)
// parse message
LOG((CLOG_DEBUG2 "msg from \"%s\": %c%c%c%c", getName().c_str(), code[0], code[1], code[2], code[3]));
if (!(this->*m_parser)(code)) {
LOG((CLOG_ERR "invalid message from client \"%s\"", getName().c_str()));
LOG((CLOG_ERR "invalid message from client \"%s\": %c%c%c%c", getName().c_str(), code[0], code[1], code[2], code[3]));
disconnect();
return;
}
@@ -131,8 +152,7 @@ CClientProxy1_0::handleData(const CEvent&, void*)
}
// restart heartbeat timer
removeHeartbeatTimer();
addHeartbeatTimer();
resetHeartbeatTimer();
}
bool
@@ -148,6 +168,7 @@ CClientProxy1_0::parseHandshakeMessage(const UInt8* code)
m_parser = &CClientProxy1_0::parseMessage;
if (recvInfo()) {
EVENTQUEUE->addEvent(CEvent(getReadyEvent(), getEventTarget()));
addHeartbeatTimer();
return true;
}
}
@@ -325,10 +346,11 @@ CClientProxy1_0::mouseRelativeMove(SInt32, SInt32)
}
void
CClientProxy1_0::mouseWheel(SInt32 delta)
CClientProxy1_0::mouseWheel(SInt32, SInt32 yDelta)
{
LOG((CLOG_DEBUG2 "send mouse wheel to \"%s\" %+d", getName().c_str(), delta));
CProtocolUtil::writef(getStream(), kMsgDMouseWheel, delta);
// clients prior to 1.3 only support the y axis
LOG((CLOG_DEBUG2 "send mouse wheel to \"%s\" %+d", getName().c_str(), yDelta));
CProtocolUtil::writef(getStream(), kMsgDMouseWheel1_0, yDelta);
}
void
@@ -345,7 +367,7 @@ CClientProxy1_0::resetOptions()
CProtocolUtil::writef(getStream(), kMsgCResetOptions);
// reset heart rate and death
m_heartbeatAlarm = kHeartRate * kHeartBeatsUntilDeath;
resetHeartbeatRate();
removeHeartbeatTimer();
addHeartbeatTimer();
}
@@ -363,7 +385,7 @@ CClientProxy1_0::setOptions(const COptionsList& options)
if (rate <= 0.0) {
rate = -1.0;
}
m_heartbeatAlarm = rate * kHeartBeatsUntilDeath;
setHeartbeatRate(rate, rate * kHeartBeatsUntilDeath);
removeHeartbeatTimer();
addHeartbeatTimer();
}

View File

@@ -50,7 +50,7 @@ public:
virtual void mouseUp(ButtonID);
virtual void mouseMove(SInt32 xAbs, SInt32 yAbs);
virtual void mouseRelativeMove(SInt32 xRel, SInt32 yRel);
virtual void mouseWheel(SInt32 delta);
virtual void mouseWheel(SInt32 xDelta, SInt32 yDelta);
virtual void screensaver(bool activate);
virtual void resetOptions();
virtual void setOptions(const COptionsList& options);
@@ -59,11 +59,15 @@ protected:
virtual bool parseHandshakeMessage(const UInt8* code);
virtual bool parseMessage(const UInt8* code);
virtual void resetHeartbeatRate();
virtual void setHeartbeatRate(double rate, double alarm);
virtual void resetHeartbeatTimer();
virtual void addHeartbeatTimer();
virtual void removeHeartbeatTimer();
private:
void disconnect();
void removeHandlers();
void addHeartbeatTimer();
void removeHeartbeatTimer();
void handleData(const CEvent&, void*);
void handleDisconnect(const CEvent&, void*);

View File

@@ -0,0 +1,114 @@
/*
* synergy -- mouse and keyboard sharing utility
* Copyright (C) 2006 Chris Schoeneman
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file COPYING that should have accompanied this file.
*
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#include "CClientProxy1_3.h"
#include "CProtocolUtil.h"
#include "CLog.h"
#include "IEventQueue.h"
#include "TMethodEventJob.h"
//
// CClientProxy1_3
//
CClientProxy1_3::CClientProxy1_3(const CString& name, IStream* stream) :
CClientProxy1_2(name, stream),
m_keepAliveRate(kKeepAliveRate),
m_keepAliveTimer(NULL)
{
setHeartbeatRate(kKeepAliveRate, kKeepAliveRate * kKeepAlivesUntilDeath);
}
CClientProxy1_3::~CClientProxy1_3()
{
// cannot do this in superclass or our override wouldn't get called
removeHeartbeatTimer();
}
void
CClientProxy1_3::mouseWheel(SInt32 xDelta, SInt32 yDelta)
{
LOG((CLOG_DEBUG2 "send mouse wheel to \"%s\" %+d,%+d", getName().c_str(), xDelta, yDelta));
CProtocolUtil::writef(getStream(), kMsgDMouseWheel, xDelta, yDelta);
}
bool
CClientProxy1_3::parseMessage(const UInt8* code)
{
// process message
if (memcmp(code, kMsgCKeepAlive, 4) == 0) {
// reset alarm
resetHeartbeatTimer();
return true;
}
else {
return CClientProxy1_2::parseMessage(code);
}
}
void
CClientProxy1_3::resetHeartbeatRate()
{
setHeartbeatRate(kKeepAliveRate, kKeepAliveRate * kKeepAlivesUntilDeath);
}
void
CClientProxy1_3::setHeartbeatRate(double rate, double)
{
m_keepAliveRate = rate;
CClientProxy1_2::setHeartbeatRate(rate, rate * kKeepAlivesUntilDeath);
}
void
CClientProxy1_3::resetHeartbeatTimer()
{
// reset the alarm but not the keep alive timer
CClientProxy1_2::removeHeartbeatTimer();
CClientProxy1_2::addHeartbeatTimer();
}
void
CClientProxy1_3::addHeartbeatTimer()
{
// create and install a timer to periodically send keep alives
if (m_keepAliveRate > 0.0) {
m_keepAliveTimer = EVENTQUEUE->newTimer(m_keepAliveRate, NULL);
EVENTQUEUE->adoptHandler(CEvent::kTimer, m_keepAliveTimer,
new TMethodEventJob<CClientProxy1_3>(this,
&CClientProxy1_3::handleKeepAlive, NULL));
}
// superclass does the alarm
CClientProxy1_2::addHeartbeatTimer();
}
void
CClientProxy1_3::removeHeartbeatTimer()
{
// remove the timer that sends keep alives periodically
if (m_keepAliveTimer != NULL) {
EVENTQUEUE->removeHandler(CEvent::kTimer, m_keepAliveTimer);
EVENTQUEUE->deleteTimer(m_keepAliveTimer);
m_keepAliveTimer = NULL;
}
// superclass does the alarm
CClientProxy1_2::removeHeartbeatTimer();
}
void
CClientProxy1_3::handleKeepAlive(const CEvent&, void*)
{
CProtocolUtil::writef(getStream(), kMsgCKeepAlive);
}

View File

@@ -0,0 +1,47 @@
/*
* synergy -- mouse and keyboard sharing utility
* Copyright (C) 2006 Chris Schoeneman
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file COPYING that should have accompanied this file.
*
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#ifndef CCLIENTPROXY1_3_H
#define CCLIENTPROXY1_3_H
#include "CClientProxy1_2.h"
//! Proxy for client implementing protocol version 1.3
class CClientProxy1_3 : public CClientProxy1_2 {
public:
CClientProxy1_3(const CString& name, IStream* adoptedStream);
~CClientProxy1_3();
// IClient overrides
virtual void mouseWheel(SInt32 xDelta, SInt32 yDelta);
protected:
// CClientProxy overrides
virtual bool parseMessage(const UInt8* code);
virtual void resetHeartbeatRate();
virtual void setHeartbeatRate(double rate, double alarm);
virtual void resetHeartbeatTimer();
virtual void addHeartbeatTimer();
virtual void removeHeartbeatTimer();
private:
void handleKeepAlive(const CEvent&, void*);
private:
double m_keepAliveRate;
CEventQueueTimer* m_keepAliveTimer;
};
#endif

View File

@@ -16,6 +16,7 @@
#include "CClientProxy1_0.h"
#include "CClientProxy1_1.h"
#include "CClientProxy1_2.h"
#include "CClientProxy1_3.h"
#include "ProtocolTypes.h"
#include "CProtocolUtil.h"
#include "XSynergy.h"
@@ -219,6 +220,10 @@ CClientProxyUnknown::handleData(const CEvent&, void*)
case 2:
m_proxy = new CClientProxy1_2(name, m_stream);
break;
case 3:
m_proxy = new CClientProxy1_3(name, m_stream);
break;
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -19,12 +19,15 @@
#include "ProtocolTypes.h"
#include "CNetworkAddress.h"
#include "CStringUtil.h"
#include "CInputFilter.h"
#include "XBase.h"
#include "stdmap.h"
#include "stdset.h"
#include "IPlatformScreen.h"
#include <iosfwd>
class CConfig;
class CConfigReadContext;
namespace std {
template <>
@@ -50,17 +53,93 @@ namespace and must be unique.
class CConfig {
public:
typedef std::map<OptionID, OptionValue> CScreenOptions;
typedef std::pair<float, float> CInterval;
class CCellEdge {
public:
CCellEdge(EDirection side, float position);
CCellEdge(EDirection side, const CInterval&);
CCellEdge(const CString& name, EDirection side, const CInterval&);
~CCellEdge();
CInterval getInterval() const;
void setName(const CString& newName);
CString getName() const;
EDirection getSide() const;
bool overlaps(const CCellEdge&) const;
bool isInside(float x) const;
// transform position to [0,1]
float transform(float x) const;
// transform [0,1] to position
float inverseTransform(float x) const;
// compares side and start of interval
bool operator<(const CCellEdge&) const;
// compares side and interval
bool operator==(const CCellEdge&) const;
bool operator!=(const CCellEdge&) const;
private:
void init(const CString& name, EDirection side,
const CInterval&);
private:
CString m_name;
EDirection m_side;
CInterval m_interval;
};
private:
class CCell {
class CName {
public:
CName(CConfig*, const CString& name);
bool operator==(const CString& name) const;
private:
CConfig* m_config;
CString m_name;
};
class CCell {
private:
typedef std::map<CCellEdge, CCellEdge> CEdgeLinks;
public:
typedef CEdgeLinks::const_iterator const_iterator;
bool add(const CCellEdge& src, const CCellEdge& dst);
void remove(EDirection side);
void remove(EDirection side, float position);
void remove(const CName& destinationName);
void rename(const CName& oldName, const CString& newName);
bool hasEdge(const CCellEdge&) const;
bool overlaps(const CCellEdge&) const;
bool getLink(EDirection side, float position,
const CCellEdge*& src, const CCellEdge*& dst) const;
bool operator==(const CCell&) const;
bool operator!=(const CCell&) const;
const_iterator begin() const;
const_iterator end() const;
private:
CEdgeLinks m_neighbors;
public:
CString m_neighbor[kLastDirection - kFirstDirection + 1];
CScreenOptions m_options;
};
typedef std::map<CString, CCell, CStringUtil::CaselessCmp> CCellMap;
typedef std::map<CString, CString, CStringUtil::CaselessCmp> CNameMap;
public:
typedef CCell::const_iterator link_const_iterator;
typedef CCellMap::const_iterator internal_const_iterator;
typedef CNameMap::const_iterator all_const_iterator;
class const_iterator : std::iterator_traits<CConfig> {
@@ -141,6 +220,13 @@ public:
*/
bool removeAlias(const CString& alias);
//! Remove aliases
/*!
Removes all aliases for a canonical screen name. It returns false
if the canonical name is unknown, otherwise returns true.
*/
bool removeAliases(const CString& canonical);
//! Remove all aliases
/*!
This removes all aliases but not the screens.
@@ -149,25 +235,43 @@ public:
//! Connect screens
/*!
Establishes a one-way connection between opposite edges of two
screens. The user will be able to jump from the \c srcSide of
screen \c srcName to the opposite side of screen \c dstName
when both screens are connected to the server and the user
isn't locked to a screen. Returns false if \c srcName is
unknown.
Establishes a one-way connection between portions of opposite edges
of two screens. Each portion is described by an interval defined
by two numbers, the start and end of the interval half-open on the
end. The numbers range from 0 to 1, inclusive, for the left/top
to the right/bottom. The user will be able to jump from the
\c srcStart to \c srcSend interval of \c srcSide of screen
\c srcName to the opposite side of screen \c dstName in the interval
\c dstStart and \c dstEnd when both screens are connected to the
server and the user isn't locked to a screen. Returns false if
\c srcName is unknown. \c srcStart must be less than or equal to
\c srcEnd and \c dstStart must be less then or equal to \c dstEnd
and all of \c srcStart, \c srcEnd, \c dstStart, or \c dstEnd must
be inside the range [0,1].
*/
bool connect(const CString& srcName,
EDirection srcSide,
const CString& dstName);
float srcStart, float srcEnd,
const CString& dstName,
float dstStart, float dstEnd);
//! Disconnect screens
/*!
Removes a connection created by connect(). Returns false if
\c srcName is unknown.
Removes all connections created by connect() on side \c srcSide.
Returns false if \c srcName is unknown.
*/
bool disconnect(const CString& srcName,
EDirection srcSide);
//! Disconnect screens
/*!
Removes the connections created by connect() on side \c srcSide
covering position \c position. Returns false if \c srcName is
unknown.
*/
bool disconnect(const CString& srcName,
EDirection srcSide, float position);
//! Set server address
/*!
Set the synergy listen addresses. There is no default address so
@@ -199,6 +303,13 @@ public:
*/
bool removeOptions(const CString& name);
//! Get the hot key input filter
/*!
Returns the hot key input filter. Clients can modify hotkeys using
that object.
*/
CInputFilter* getInputFilter();
//@}
//! @name accessors
//@{
@@ -241,10 +352,33 @@ public:
//! Get neighbor
/*!
Returns the canonical screen name of the neighbor in the given
direction (set through connect()). Returns the empty string
if there is no neighbor in that direction.
direction (set through connect()) at position \c position. Returns
the empty string if there is no neighbor in that direction, otherwise
saves the position on the neighbor in \c positionOut if it's not
\c NULL.
*/
CString getNeighbor(const CString&, EDirection) const;
CString getNeighbor(const CString&, EDirection,
float position, float* positionOut) const;
//! Check for neighbor
/*!
Returns \c true if the screen has a neighbor anywhere along the edge
given by the direction.
*/
bool hasNeighbor(const CString&, EDirection) const;
//! Check for neighbor
/*!
Returns \c true if the screen has a neighbor in the given range along
the edge given by the direction.
*/
bool hasNeighbor(const CString&, EDirection,
float start, float end) const;
//! Get beginning neighbor iterator
link_const_iterator beginNeighbor(const CString&) const;
//! Get ending neighbor iterator
link_const_iterator endNeighbor(const CString&) const;
//! Get the server address
const CNetworkAddress& getSynergyAddress() const;
@@ -257,11 +391,25 @@ public:
*/
const CScreenOptions* getOptions(const CString& name) const;
//! Check for lock to screen action
/*!
Returns \c true if this configuration has a lock to screen action.
This is for backwards compatible support of ScrollLock locking.
*/
bool hasLockToScreenAction() const;
//! Compare configurations
bool operator==(const CConfig&) const;
//! Compare configurations
bool operator!=(const CConfig&) const;
//! Read configuration
/*!
Reads a configuration from a context. Throws XConfigRead on error
and context is unchanged.
*/
void read(CConfigReadContext& context);
//! Read configuration
/*!
Reads a configuration from a stream. Throws XConfigRead on error.
@@ -280,26 +428,90 @@ public:
*/
static const char* dirName(EDirection);
//! Get interval as string
/*!
Returns an interval as a parseable string.
*/
static CString formatInterval(const CInterval&);
//@}
private:
static bool readLine(std::istream&, CString&);
static OptionValue parseBoolean(const CString&);
static OptionValue parseInt(const CString&);
static OptionValue parseModifierKey(const CString&);
void readSection(CConfigReadContext&);
void readSectionOptions(CConfigReadContext&);
void readSectionScreens(CConfigReadContext&);
void readSectionLinks(CConfigReadContext&);
void readSectionAliases(CConfigReadContext&);
CInputFilter::CCondition*
parseCondition(CConfigReadContext&,
const CString& condition,
const std::vector<CString>& args);
void parseAction(CConfigReadContext&,
const CString& action,
const std::vector<CString>& args,
CInputFilter::CRule&, bool activate);
void parseScreens(CConfigReadContext&, const CString&,
std::set<CString>& screens) const;
static const char* getOptionName(OptionID);
static CString getOptionValue(OptionID, OptionValue);
void readSection(std::istream&);
void readSectionOptions(std::istream&);
void readSectionScreens(std::istream&);
void readSectionLinks(std::istream&);
void readSectionAliases(std::istream&);
private:
CCellMap m_map;
CNameMap m_nameToCanonicalName;
CNetworkAddress m_synergyAddress;
CScreenOptions m_globalOptions;
CInputFilter m_inputFilter;
bool m_hasLockToScreenAction;
};
//! Configuration read context
/*!
Maintains a context when reading a configuration from a stream.
*/
class CConfigReadContext {
public:
typedef std::vector<CString> ArgList;
CConfigReadContext(std::istream&, SInt32 firstLine = 1);
~CConfigReadContext();
bool readLine(CString&);
UInt32 getLineNumber() const;
operator void*() const;
bool operator!() const;
OptionValue parseBoolean(const CString&) const;
OptionValue parseInt(const CString&) const;
OptionValue parseModifierKey(const CString&) const;
OptionValue parseCorner(const CString&) const;
OptionValue parseCorners(const CString&) const;
CConfig::CInterval
parseInterval(const ArgList& args) const;
void parseNameWithArgs(
const CString& type, const CString& line,
const CString& delim, CString::size_type& index,
CString& name, ArgList& args) const;
IPlatformScreen::CKeyInfo*
parseKeystroke(const CString& keystroke) const;
IPlatformScreen::CKeyInfo*
parseKeystroke(const CString& keystroke,
const std::set<CString>& screens) const;
IPlatformScreen::CButtonInfo*
parseMouse(const CString& mouse) const;
KeyModifierMask parseModifier(const CString& modifiers) const;
private:
// not implemented
CConfigReadContext& operator=(const CConfigReadContext&);
static CString concatArgs(const ArgList& args);
private:
std::istream& m_stream;
SInt32 m_line;
};
//! Configuration stream read exception
@@ -308,7 +520,9 @@ Thrown when a configuration stream cannot be parsed.
*/
class XConfigRead : public XBase {
public:
XConfigRead(const CString&);
XConfigRead(const CConfigReadContext& context, const CString&);
XConfigRead(const CConfigReadContext& context,
const char* errorFmt, const CString& arg);
~XConfigRead();
protected:

999
lib/server/CInputFilter.cpp Normal file
View File

@@ -0,0 +1,999 @@
/*
* synergy -- mouse and keyboard sharing utility
* Copyright (C) 2005 Chris Schoeneman
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file COPYING that should have accompanied this file.
*
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#include "CInputFilter.h"
#include "CServer.h"
#include "CPrimaryClient.h"
#include "CKeyMap.h"
#include "CEventQueue.h"
#include "CLog.h"
#include "TMethodEventJob.h"
#include <stdlib.h>
#include <string.h>
// -----------------------------------------------------------------------------
// Input Filter Condition Classes
// -----------------------------------------------------------------------------
CInputFilter::CCondition::CCondition()
{
// do nothing
}
CInputFilter::CCondition::~CCondition()
{
// do nothing
}
void
CInputFilter::CCondition::enablePrimary(CPrimaryClient*)
{
// do nothing
}
void
CInputFilter::CCondition::disablePrimary(CPrimaryClient*)
{
// do nothing
}
CInputFilter::CKeystrokeCondition::CKeystrokeCondition(
IPlatformScreen::CKeyInfo* info) :
m_id(0),
m_key(info->m_key),
m_mask(info->m_mask)
{
free(info);
}
CInputFilter::CKeystrokeCondition::CKeystrokeCondition(
KeyID key, KeyModifierMask mask) :
m_id(0),
m_key(key),
m_mask(mask)
{
// do nothing
}
CInputFilter::CKeystrokeCondition::~CKeystrokeCondition()
{
// do nothing
}
KeyID
CInputFilter::CKeystrokeCondition::getKey() const
{
return m_key;
}
KeyModifierMask
CInputFilter::CKeystrokeCondition::getMask() const
{
return m_mask;
}
CInputFilter::CCondition*
CInputFilter::CKeystrokeCondition::clone() const
{
return new CKeystrokeCondition(m_key, m_mask);
}
CString
CInputFilter::CKeystrokeCondition::format() const
{
return CStringUtil::print("keystroke(%s)",
CKeyMap::formatKey(m_key, m_mask).c_str());
}
CInputFilter::EFilterStatus
CInputFilter::CKeystrokeCondition::match(const CEvent& event)
{
EFilterStatus status;
// check for hotkey events
CEvent::Type type = event.getType();
if (type == IPrimaryScreen::getHotKeyDownEvent()) {
status = kActivate;
}
else if (type == IPrimaryScreen::getHotKeyUpEvent()) {
status = kDeactivate;
}
else {
return kNoMatch;
}
// check if it's our hotkey
IPrimaryScreen::CHotKeyInfo* kinfo =
reinterpret_cast<IPlatformScreen::CHotKeyInfo*>(event.getData());
if (kinfo->m_id != m_id) {
return kNoMatch;
}
return status;
}
void
CInputFilter::CKeystrokeCondition::enablePrimary(CPrimaryClient* primary)
{
m_id = primary->registerHotKey(m_key, m_mask);
}
void
CInputFilter::CKeystrokeCondition::disablePrimary(CPrimaryClient* primary)
{
primary->unregisterHotKey(m_id);
m_id = 0;
}
CInputFilter::CMouseButtonCondition::CMouseButtonCondition(
IPlatformScreen::CButtonInfo* info) :
m_button(info->m_button),
m_mask(info->m_mask)
{
free(info);
}
CInputFilter::CMouseButtonCondition::CMouseButtonCondition(
ButtonID button, KeyModifierMask mask) :
m_button(button),
m_mask(mask)
{
// do nothing
}
CInputFilter::CMouseButtonCondition::~CMouseButtonCondition()
{
// do nothing
}
ButtonID
CInputFilter::CMouseButtonCondition::getButton() const
{
return m_button;
}
KeyModifierMask
CInputFilter::CMouseButtonCondition::getMask() const
{
return m_mask;
}
CInputFilter::CCondition*
CInputFilter::CMouseButtonCondition::clone() const
{
return new CMouseButtonCondition(m_button, m_mask);
}
CString
CInputFilter::CMouseButtonCondition::format() const
{
CString key = CKeyMap::formatKey(kKeyNone, m_mask);
if (!key.empty()) {
key += "+";
}
return CStringUtil::print("mousebutton(%s%d)", key.c_str(), m_button);
}
CInputFilter::EFilterStatus
CInputFilter::CMouseButtonCondition::match(const CEvent& event)
{
static const KeyModifierMask s_ignoreMask =
KeyModifierAltGr | KeyModifierCapsLock |
KeyModifierNumLock | KeyModifierScrollLock;
EFilterStatus status;
// check for hotkey events
CEvent::Type type = event.getType();
if (type == IPrimaryScreen::getButtonDownEvent()) {
status = kActivate;
}
else if (type == IPrimaryScreen::getButtonUpEvent()) {
status = kDeactivate;
}
else {
return kNoMatch;
}
// check if it's the right button and modifiers. ignore modifiers
// that cannot be combined with a mouse button.
IPlatformScreen::CButtonInfo* minfo =
reinterpret_cast<IPlatformScreen::CButtonInfo*>(event.getData());
if (minfo->m_button != m_button ||
(minfo->m_mask & ~s_ignoreMask) != m_mask) {
return kNoMatch;
}
return status;
}
CInputFilter::CScreenConnectedCondition::CScreenConnectedCondition(
const CString& screen) :
m_screen(screen)
{
// do nothing
}
CInputFilter::CScreenConnectedCondition::~CScreenConnectedCondition()
{
// do nothing
}
CInputFilter::CCondition*
CInputFilter::CScreenConnectedCondition::clone() const
{
return new CScreenConnectedCondition(m_screen);
}
CString
CInputFilter::CScreenConnectedCondition::format() const
{
return CStringUtil::print("connect(%s)", m_screen.c_str());
}
CInputFilter::EFilterStatus
CInputFilter::CScreenConnectedCondition::match(const CEvent& event)
{
if (event.getType() == CServer::getConnectedEvent()) {
CServer::CScreenConnectedInfo* info =
reinterpret_cast<CServer::CScreenConnectedInfo*>(event.getData());
if (m_screen == info->m_screen || m_screen.empty()) {
return kActivate;
}
}
return kNoMatch;
}
// -----------------------------------------------------------------------------
// Input Filter Action Classes
// -----------------------------------------------------------------------------
CInputFilter::CAction::CAction()
{
// do nothing
}
CInputFilter::CAction::~CAction()
{
// do nothing
}
CInputFilter::CLockCursorToScreenAction::CLockCursorToScreenAction(Mode mode):
m_mode(mode)
{
// do nothing
}
CInputFilter::CLockCursorToScreenAction::Mode
CInputFilter::CLockCursorToScreenAction::getMode() const
{
return m_mode;
}
CInputFilter::CAction*
CInputFilter::CLockCursorToScreenAction::clone() const
{
return new CLockCursorToScreenAction(*this);
}
CString
CInputFilter::CLockCursorToScreenAction::format() const
{
static const char* s_mode[] = { "off", "on", "toggle" };
return CStringUtil::print("lockCursorToScreen(%s)", s_mode[m_mode]);
}
void
CInputFilter::CLockCursorToScreenAction::perform(const CEvent& event)
{
static const CServer::CLockCursorToScreenInfo::State s_state[] = {
CServer::CLockCursorToScreenInfo::kOff,
CServer::CLockCursorToScreenInfo::kOn,
CServer::CLockCursorToScreenInfo::kToggle
};
// send event
CServer::CLockCursorToScreenInfo* info =
CServer::CLockCursorToScreenInfo::alloc(s_state[m_mode]);
EVENTQUEUE->addEvent(CEvent(CServer::getLockCursorToScreenEvent(),
event.getTarget(), info,
CEvent::kDeliverImmediately));
}
CInputFilter::CSwitchToScreenAction::CSwitchToScreenAction(
const CString& screen) :
m_screen(screen)
{
// do nothing
}
CString
CInputFilter::CSwitchToScreenAction::getScreen() const
{
return m_screen;
}
CInputFilter::CAction*
CInputFilter::CSwitchToScreenAction::clone() const
{
return new CSwitchToScreenAction(*this);
}
CString
CInputFilter::CSwitchToScreenAction::format() const
{
return CStringUtil::print("switchToScreen(%s)", m_screen.c_str());
}
void
CInputFilter::CSwitchToScreenAction::perform(const CEvent& event)
{
// pick screen name. if m_screen is empty then use the screen from
// event if it has one.
CString screen = m_screen;
if (screen.empty() && event.getType() == CServer::getConnectedEvent()) {
CServer::CScreenConnectedInfo* info =
reinterpret_cast<CServer::CScreenConnectedInfo*>(event.getData());
screen = info->m_screen;
}
// send event
CServer::CSwitchToScreenInfo* info =
CServer::CSwitchToScreenInfo::alloc(screen);
EVENTQUEUE->addEvent(CEvent(CServer::getSwitchToScreenEvent(),
event.getTarget(), info,
CEvent::kDeliverImmediately));
}
CInputFilter::CSwitchInDirectionAction::CSwitchInDirectionAction(
EDirection direction) :
m_direction(direction)
{
// do nothing
}
EDirection
CInputFilter::CSwitchInDirectionAction::getDirection() const
{
return m_direction;
}
CInputFilter::CAction*
CInputFilter::CSwitchInDirectionAction::clone() const
{
return new CSwitchInDirectionAction(*this);
}
CString
CInputFilter::CSwitchInDirectionAction::format() const
{
static const char* s_names[] = {
"",
"left",
"right",
"up",
"down"
};
return CStringUtil::print("switchInDirection(%s)", s_names[m_direction]);
}
void
CInputFilter::CSwitchInDirectionAction::perform(const CEvent& event)
{
CServer::CSwitchInDirectionInfo* info =
CServer::CSwitchInDirectionInfo::alloc(m_direction);
EVENTQUEUE->addEvent(CEvent(CServer::getSwitchInDirectionEvent(),
event.getTarget(), info,
CEvent::kDeliverImmediately));
}
CInputFilter::CKeystrokeAction::CKeystrokeAction(
IPlatformScreen::CKeyInfo* info, bool press) :
m_keyInfo(info),
m_press(press)
{
// do nothing
}
CInputFilter::CKeystrokeAction::~CKeystrokeAction()
{
free(m_keyInfo);
}
void
CInputFilter::CKeystrokeAction::adoptInfo(IPlatformScreen::CKeyInfo* info)
{
free(m_keyInfo);
m_keyInfo = info;
}
const IPlatformScreen::CKeyInfo*
CInputFilter::CKeystrokeAction::getInfo() const
{
return m_keyInfo;
}
bool
CInputFilter::CKeystrokeAction::isOnPress() const
{
return m_press;
}
CInputFilter::CAction*
CInputFilter::CKeystrokeAction::clone() const
{
IKeyState::CKeyInfo* info = IKeyState::CKeyInfo::alloc(*m_keyInfo);
return new CKeystrokeAction(info, m_press);
}
CString
CInputFilter::CKeystrokeAction::format() const
{
const char* type = formatName();
if (m_keyInfo->m_screens[0] == '\0') {
return CStringUtil::print("%s(%s)", type,
CKeyMap::formatKey(m_keyInfo->m_key,
m_keyInfo->m_mask).c_str());
}
else if (m_keyInfo->m_screens[0] == '*') {
return CStringUtil::print("%s(%s,*)", type,
CKeyMap::formatKey(m_keyInfo->m_key,
m_keyInfo->m_mask).c_str());
}
else {
return CStringUtil::print("%s(%s,%.*s)", type,
CKeyMap::formatKey(m_keyInfo->m_key,
m_keyInfo->m_mask).c_str(),
strlen(m_keyInfo->m_screens + 1) - 1,
m_keyInfo->m_screens + 1);
}
}
void
CInputFilter::CKeystrokeAction::perform(const CEvent& event)
{
CEvent::Type type = m_press ? IPlatformScreen::getKeyDownEvent() :
IPlatformScreen::getKeyUpEvent();
EVENTQUEUE->addEvent(CEvent(IPlatformScreen::getFakeInputBeginEvent(),
event.getTarget(), NULL,
CEvent::kDeliverImmediately));
EVENTQUEUE->addEvent(CEvent(type, event.getTarget(), m_keyInfo,
CEvent::kDeliverImmediately |
CEvent::kDontFreeData));
EVENTQUEUE->addEvent(CEvent(IPlatformScreen::getFakeInputEndEvent(),
event.getTarget(), NULL,
CEvent::kDeliverImmediately));
}
const char*
CInputFilter::CKeystrokeAction::formatName() const
{
return (m_press ? "keyDown" : "keyUp");
}
CInputFilter::CMouseButtonAction::CMouseButtonAction(
IPlatformScreen::CButtonInfo* info, bool press) :
m_buttonInfo(info),
m_press(press)
{
// do nothing
}
CInputFilter::CMouseButtonAction::~CMouseButtonAction()
{
free(m_buttonInfo);
}
const IPlatformScreen::CButtonInfo*
CInputFilter::CMouseButtonAction::getInfo() const
{
return m_buttonInfo;
}
bool
CInputFilter::CMouseButtonAction::isOnPress() const
{
return m_press;
}
CInputFilter::CAction*
CInputFilter::CMouseButtonAction::clone() const
{
IPlatformScreen::CButtonInfo* info =
IPrimaryScreen::CButtonInfo::alloc(*m_buttonInfo);
return new CMouseButtonAction(info, m_press);
}
CString
CInputFilter::CMouseButtonAction::format() const
{
const char* type = formatName();
CString key = CKeyMap::formatKey(kKeyNone, m_buttonInfo->m_mask);
return CStringUtil::print("%s(%s%s%d)", type,
key.c_str(), key.empty() ? "" : "+",
m_buttonInfo->m_button);
}
void
CInputFilter::CMouseButtonAction::perform(const CEvent& event)
{
// send modifiers
IPlatformScreen::CKeyInfo* modifierInfo = NULL;
if (m_buttonInfo->m_mask != 0) {
KeyID key = m_press ? kKeySetModifiers : kKeyClearModifiers;
modifierInfo =
IKeyState::CKeyInfo::alloc(key, m_buttonInfo->m_mask, 0, 1);
EVENTQUEUE->addEvent(CEvent(IPlatformScreen::getKeyDownEvent(),
event.getTarget(), modifierInfo,
CEvent::kDeliverImmediately));
}
// send button
CEvent::Type type = m_press ? IPlatformScreen::getButtonDownEvent() :
IPlatformScreen::getButtonUpEvent();
EVENTQUEUE->addEvent(CEvent(type, event.getTarget(), m_buttonInfo,
CEvent::kDeliverImmediately |
CEvent::kDontFreeData));
}
const char*
CInputFilter::CMouseButtonAction::formatName() const
{
return (m_press ? "mouseDown" : "mouseUp");
}
//
// CInputFilter::CRule
//
CInputFilter::CRule::CRule() :
m_condition(NULL)
{
// do nothing
}
CInputFilter::CRule::CRule(CCondition* adoptedCondition) :
m_condition(adoptedCondition)
{
// do nothing
}
CInputFilter::CRule::CRule(const CRule& rule) :
m_condition(NULL)
{
copy(rule);
}
CInputFilter::CRule::~CRule()
{
clear();
}
CInputFilter::CRule&
CInputFilter::CRule::operator=(const CRule& rule)
{
if (&rule != this) {
copy(rule);
}
return *this;
}
void
CInputFilter::CRule::clear()
{
delete m_condition;
for (CActionList::iterator i = m_activateActions.begin();
i != m_activateActions.end(); ++i) {
delete *i;
}
for (CActionList::iterator i = m_deactivateActions.begin();
i != m_deactivateActions.end(); ++i) {
delete *i;
}
m_condition = NULL;
m_activateActions.clear();
m_deactivateActions.clear();
}
void
CInputFilter::CRule::copy(const CRule& rule)
{
clear();
if (rule.m_condition != NULL) {
m_condition = rule.m_condition->clone();
}
for (CActionList::const_iterator i = rule.m_activateActions.begin();
i != rule.m_activateActions.end(); ++i) {
m_activateActions.push_back((*i)->clone());
}
for (CActionList::const_iterator i = rule.m_deactivateActions.begin();
i != rule.m_deactivateActions.end(); ++i) {
m_deactivateActions.push_back((*i)->clone());
}
}
void
CInputFilter::CRule::setCondition(CCondition* adopted)
{
delete m_condition;
m_condition = adopted;
}
void
CInputFilter::CRule::adoptAction(CAction* action, bool onActivation)
{
if (action != NULL) {
if (onActivation) {
m_activateActions.push_back(action);
}
else {
m_deactivateActions.push_back(action);
}
}
}
void
CInputFilter::CRule::removeAction(bool onActivation, UInt32 index)
{
if (onActivation) {
delete m_activateActions[index];
m_activateActions.erase(m_activateActions.begin() + index);
}
else {
delete m_deactivateActions[index];
m_deactivateActions.erase(m_deactivateActions.begin() + index);
}
}
void
CInputFilter::CRule::replaceAction(CAction* adopted,
bool onActivation, UInt32 index)
{
if (adopted == NULL) {
removeAction(onActivation, index);
}
else if (onActivation) {
delete m_activateActions[index];
m_activateActions[index] = adopted;
}
else {
delete m_deactivateActions[index];
m_deactivateActions[index] = adopted;
}
}
void
CInputFilter::CRule::enable(CPrimaryClient* primaryClient)
{
if (m_condition != NULL) {
m_condition->enablePrimary(primaryClient);
}
}
void
CInputFilter::CRule::disable(CPrimaryClient* primaryClient)
{
if (m_condition != NULL) {
m_condition->disablePrimary(primaryClient);
}
}
bool
CInputFilter::CRule::handleEvent(const CEvent& event)
{
// NULL condition never matches
if (m_condition == NULL) {
return false;
}
// match
const CActionList* actions;
switch (m_condition->match(event)) {
default:
// not handled
return false;
case kActivate:
actions = &m_activateActions;
LOG((CLOG_DEBUG1 "activate actions"));
break;
case kDeactivate:
actions = &m_deactivateActions;
LOG((CLOG_DEBUG1 "deactivate actions"));
break;
}
// perform actions
for (CActionList::const_iterator i = actions->begin();
i != actions->end(); ++i) {
LOG((CLOG_DEBUG1 "hotkey: %s", (*i)->format().c_str()));
(*i)->perform(event);
}
return true;
}
CString
CInputFilter::CRule::format() const
{
CString s;
if (m_condition != NULL) {
// condition
s += m_condition->format();
s += " = ";
// activate actions
CActionList::const_iterator i = m_activateActions.begin();
if (i != m_activateActions.end()) {
s += (*i)->format();
while (++i != m_activateActions.end()) {
s += ", ";
s += (*i)->format();
}
}
// deactivate actions
if (!m_deactivateActions.empty()) {
s += "; ";
i = m_deactivateActions.begin();
if (i != m_deactivateActions.end()) {
s += (*i)->format();
while (++i != m_deactivateActions.end()) {
s += ", ";
s += (*i)->format();
}
}
}
}
return s;
}
const CInputFilter::CCondition*
CInputFilter::CRule::getCondition() const
{
return m_condition;
}
UInt32
CInputFilter::CRule::getNumActions(bool onActivation) const
{
if (onActivation) {
return static_cast<UInt32>(m_activateActions.size());
}
else {
return static_cast<UInt32>(m_deactivateActions.size());
}
}
const CInputFilter::CAction&
CInputFilter::CRule::getAction(bool onActivation, UInt32 index) const
{
if (onActivation) {
return *m_activateActions[index];
}
else {
return *m_deactivateActions[index];
}
}
// -----------------------------------------------------------------------------
// Input Filter Class
// -----------------------------------------------------------------------------
CInputFilter::CInputFilter() :
m_primaryClient(NULL)
{
// do nothing
}
CInputFilter::CInputFilter(const CInputFilter& x) :
m_ruleList(x.m_ruleList),
m_primaryClient(NULL)
{
setPrimaryClient(x.m_primaryClient);
}
CInputFilter::~CInputFilter()
{
setPrimaryClient(NULL);
}
CInputFilter&
CInputFilter::operator=(const CInputFilter& x)
{
if (&x != this) {
CPrimaryClient* oldClient = m_primaryClient;
setPrimaryClient(NULL);
m_ruleList = x.m_ruleList;
setPrimaryClient(oldClient);
}
return *this;
}
void
CInputFilter::addFilterRule(const CRule& rule)
{
m_ruleList.push_back(rule);
if (m_primaryClient != NULL) {
m_ruleList.back().enable(m_primaryClient);
}
}
void
CInputFilter::removeFilterRule(UInt32 index)
{
if (m_primaryClient != NULL) {
m_ruleList[index].disable(m_primaryClient);
}
m_ruleList.erase(m_ruleList.begin() + index);
}
CInputFilter::CRule&
CInputFilter::getRule(UInt32 index)
{
return m_ruleList[index];
}
void
CInputFilter::setPrimaryClient(CPrimaryClient* client)
{
if (m_primaryClient == client) {
return;
}
if (m_primaryClient != NULL) {
for (CRuleList::iterator rule = m_ruleList.begin();
rule != m_ruleList.end(); ++rule) {
rule->disable(m_primaryClient);
}
EVENTQUEUE->removeHandler(IPlatformScreen::getKeyDownEvent(),
m_primaryClient->getEventTarget());
EVENTQUEUE->removeHandler(IPlatformScreen::getKeyUpEvent(),
m_primaryClient->getEventTarget());
EVENTQUEUE->removeHandler(IPlatformScreen::getKeyRepeatEvent(),
m_primaryClient->getEventTarget());
EVENTQUEUE->removeHandler(IPlatformScreen::getButtonDownEvent(),
m_primaryClient->getEventTarget());
EVENTQUEUE->removeHandler(IPlatformScreen::getButtonUpEvent(),
m_primaryClient->getEventTarget());
EVENTQUEUE->removeHandler(IPlatformScreen::getHotKeyDownEvent(),
m_primaryClient->getEventTarget());
EVENTQUEUE->removeHandler(IPlatformScreen::getHotKeyUpEvent(),
m_primaryClient->getEventTarget());
EVENTQUEUE->removeHandler(CServer::getConnectedEvent(),
m_primaryClient->getEventTarget());
}
m_primaryClient = client;
if (m_primaryClient != NULL) {
EVENTQUEUE->adoptHandler(IPlatformScreen::getKeyDownEvent(),
m_primaryClient->getEventTarget(),
new TMethodEventJob<CInputFilter>(this,
&CInputFilter::handleEvent));
EVENTQUEUE->adoptHandler(IPlatformScreen::getKeyUpEvent(),
m_primaryClient->getEventTarget(),
new TMethodEventJob<CInputFilter>(this,
&CInputFilter::handleEvent));
EVENTQUEUE->adoptHandler(IPlatformScreen::getKeyRepeatEvent(),
m_primaryClient->getEventTarget(),
new TMethodEventJob<CInputFilter>(this,
&CInputFilter::handleEvent));
EVENTQUEUE->adoptHandler(IPlatformScreen::getButtonDownEvent(),
m_primaryClient->getEventTarget(),
new TMethodEventJob<CInputFilter>(this,
&CInputFilter::handleEvent));
EVENTQUEUE->adoptHandler(IPlatformScreen::getButtonUpEvent(),
m_primaryClient->getEventTarget(),
new TMethodEventJob<CInputFilter>(this,
&CInputFilter::handleEvent));
EVENTQUEUE->adoptHandler(IPlatformScreen::getHotKeyDownEvent(),
m_primaryClient->getEventTarget(),
new TMethodEventJob<CInputFilter>(this,
&CInputFilter::handleEvent));
EVENTQUEUE->adoptHandler(IPlatformScreen::getHotKeyUpEvent(),
m_primaryClient->getEventTarget(),
new TMethodEventJob<CInputFilter>(this,
&CInputFilter::handleEvent));
EVENTQUEUE->adoptHandler(CServer::getConnectedEvent(),
m_primaryClient->getEventTarget(),
new TMethodEventJob<CInputFilter>(this,
&CInputFilter::handleEvent));
for (CRuleList::iterator rule = m_ruleList.begin();
rule != m_ruleList.end(); ++rule) {
rule->enable(m_primaryClient);
}
}
}
CString
CInputFilter::format(const CString& linePrefix) const
{
CString s;
for (CRuleList::const_iterator i = m_ruleList.begin();
i != m_ruleList.end(); ++i) {
s += linePrefix;
s += i->format();
s += "\n";
}
return s;
}
UInt32
CInputFilter::getNumRules() const
{
return static_cast<UInt32>(m_ruleList.size());
}
bool
CInputFilter::operator==(const CInputFilter& x) const
{
// if there are different numbers of rules then we can't be equal
if (m_ruleList.size() != x.m_ruleList.size()) {
return false;
}
// compare rule lists. the easiest way to do that is to format each
// rule into a string, sort the strings, then compare the results.
std::vector<CString> aList, bList;
for (CRuleList::const_iterator i = m_ruleList.begin();
i != m_ruleList.end(); ++i) {
aList.push_back(i->format());
}
for (CRuleList::const_iterator i = x.m_ruleList.begin();
i != x.m_ruleList.end(); ++i) {
bList.push_back(i->format());
}
std::partial_sort(aList.begin(), aList.end(), aList.end());
std::partial_sort(bList.begin(), bList.end(), bList.end());
return (aList == bList);
}
bool
CInputFilter::operator!=(const CInputFilter& x) const
{
return !operator==(x);
}
void
CInputFilter::handleEvent(const CEvent& event, void*)
{
// copy event and adjust target
CEvent myEvent(event.getType(), this, event.getData(),
event.getFlags() | CEvent::kDontFreeData |
CEvent::kDeliverImmediately);
// let each rule try to match the event until one does
for (CRuleList::iterator rule = m_ruleList.begin();
rule != m_ruleList.end(); ++rule) {
if (rule->handleEvent(myEvent)) {
// handled
return;
}
}
// not handled so pass through
EVENTQUEUE->addEvent(myEvent);
}

322
lib/server/CInputFilter.h Normal file
View File

@@ -0,0 +1,322 @@
/*
* synergy -- mouse and keyboard sharing utility
* Copyright (C) 2005 Chris Schoeneman
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file COPYING that should have accompanied this file.
*
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#ifndef CINPUTFILTER_H
#define CINPUTFILTER_H
#include "KeyTypes.h"
#include "MouseTypes.h"
#include "ProtocolTypes.h"
#include "IPlatformScreen.h"
#include "CString.h"
#include "stdmap.h"
class CPrimaryClient;
class CEvent;
class CInputFilter {
public:
// -------------------------------------------------------------------------
// Input Filter Condition Classes
// -------------------------------------------------------------------------
enum EFilterStatus {
kNoMatch,
kActivate,
kDeactivate
};
class CCondition {
public:
CCondition();
virtual ~CCondition();
virtual CCondition* clone() const = 0;
virtual CString format() const = 0;
virtual EFilterStatus match(const CEvent&) = 0;
virtual void enablePrimary(CPrimaryClient*);
virtual void disablePrimary(CPrimaryClient*);
};
// CKeystrokeCondition
class CKeystrokeCondition : public CCondition {
public:
CKeystrokeCondition(IPlatformScreen::CKeyInfo*);
CKeystrokeCondition(KeyID key, KeyModifierMask mask);
virtual ~CKeystrokeCondition();
KeyID getKey() const;
KeyModifierMask getMask() const;
// CCondition overrides
virtual CCondition* clone() const;
virtual CString format() const;
virtual EFilterStatus match(const CEvent&);
virtual void enablePrimary(CPrimaryClient*);
virtual void disablePrimary(CPrimaryClient*);
private:
UInt32 m_id;
KeyID m_key;
KeyModifierMask m_mask;
};
// CMouseButtonCondition
class CMouseButtonCondition : public CCondition {
public:
CMouseButtonCondition(IPlatformScreen::CButtonInfo*);
CMouseButtonCondition(ButtonID, KeyModifierMask mask);
virtual ~CMouseButtonCondition();
ButtonID getButton() const;
KeyModifierMask getMask() const;
// CCondition overrides
virtual CCondition* clone() const;
virtual CString format() const;
virtual EFilterStatus match(const CEvent&);
private:
ButtonID m_button;
KeyModifierMask m_mask;
};
// CScreenConnectedCondition
class CScreenConnectedCondition : public CCondition {
public:
CScreenConnectedCondition(const CString& screen);
virtual ~CScreenConnectedCondition();
// CCondition overrides
virtual CCondition* clone() const;
virtual CString format() const;
virtual EFilterStatus match(const CEvent&);
private:
CString m_screen;
};
// -------------------------------------------------------------------------
// Input Filter Action Classes
// -------------------------------------------------------------------------
class CAction {
public:
CAction();
virtual ~CAction();
virtual CAction* clone() const = 0;
virtual CString format() const = 0;
virtual void perform(const CEvent&) = 0;
};
// CLockCursorToScreenAction
class CLockCursorToScreenAction : public CAction {
public:
enum Mode { kOff, kOn, kToggle };
CLockCursorToScreenAction(Mode = kToggle);
Mode getMode() const;
// CAction overrides
virtual CAction* clone() const;
virtual CString format() const;
virtual void perform(const CEvent&);
private:
Mode m_mode;
};
// CSwitchToScreenAction
class CSwitchToScreenAction : public CAction {
public:
CSwitchToScreenAction(const CString& screen);
CString getScreen() const;
// CAction overrides
virtual CAction* clone() const;
virtual CString format() const;
virtual void perform(const CEvent&);
private:
CString m_screen;
};
// CSwitchInDirectionAction
class CSwitchInDirectionAction : public CAction {
public:
CSwitchInDirectionAction(EDirection);
EDirection getDirection() const;
// CAction overrides
virtual CAction* clone() const;
virtual CString format() const;
virtual void perform(const CEvent&);
private:
EDirection m_direction;
};
// CKeystrokeAction
class CKeystrokeAction : public CAction {
public:
CKeystrokeAction(IPlatformScreen::CKeyInfo* adoptedInfo, bool press);
~CKeystrokeAction();
void adoptInfo(IPlatformScreen::CKeyInfo*);
const IPlatformScreen::CKeyInfo*
getInfo() const;
bool isOnPress() const;
// CAction overrides
virtual CAction* clone() const;
virtual CString format() const;
virtual void perform(const CEvent&);
protected:
virtual const char* formatName() const;
private:
IPlatformScreen::CKeyInfo* m_keyInfo;
bool m_press;
};
// CMouseButtonAction -- modifier combinations not implemented yet
class CMouseButtonAction : public CAction {
public:
CMouseButtonAction(IPlatformScreen::CButtonInfo* adoptedInfo,
bool press);
~CMouseButtonAction();
const IPlatformScreen::CButtonInfo*
getInfo() const;
bool isOnPress() const;
// CAction overrides
virtual CAction* clone() const;
virtual CString format() const;
virtual void perform(const CEvent&);
protected:
virtual const char* formatName() const;
private:
IPlatformScreen::CButtonInfo* m_buttonInfo;
bool m_press;
};
class CRule {
public:
CRule();
CRule(CCondition* adopted);
CRule(const CRule&);
~CRule();
CRule& operator=(const CRule&);
// replace the condition
void setCondition(CCondition* adopted);
// add an action to the rule
void adoptAction(CAction*, bool onActivation);
// remove an action from the rule
void removeAction(bool onActivation, UInt32 index);
// replace an action in the rule
void replaceAction(CAction* adopted,
bool onActivation, UInt32 index);
// enable/disable
void enable(CPrimaryClient*);
void disable(CPrimaryClient*);
// event handling
bool handleEvent(const CEvent&);
// convert rule to a string
CString format() const;
// get the rule's condition
const CCondition*
getCondition() const;
// get number of actions
UInt32 getNumActions(bool onActivation) const;
// get action by index
const CAction& getAction(bool onActivation, UInt32 index) const;
private:
void clear();
void copy(const CRule&);
private:
typedef std::vector<CAction*> CActionList;
CCondition* m_condition;
CActionList m_activateActions;
CActionList m_deactivateActions;
};
// -------------------------------------------------------------------------
// Input Filter Class
// -------------------------------------------------------------------------
typedef std::vector<CRule> CRuleList;
CInputFilter();
CInputFilter(const CInputFilter&);
virtual ~CInputFilter();
CInputFilter& operator=(const CInputFilter&);
// add rule, adopting the condition and the actions
void addFilterRule(const CRule& rule);
// remove a rule
void removeFilterRule(UInt32 index);
// get rule by index
CRule& getRule(UInt32 index);
// enable event filtering using the given primary client. disable
// if client is NULL.
void setPrimaryClient(CPrimaryClient* client);
// convert rules to a string
CString format(const CString& linePrefix) const;
// get number of rules
UInt32 getNumRules() const;
//! Compare filters
bool operator==(const CInputFilter&) const;
//! Compare filters
bool operator!=(const CInputFilter&) const;
private:
// event handling
void handleEvent(const CEvent&, void*);
private:
CRuleList m_ruleList;
CPrimaryClient* m_primaryClient;
};
#endif

View File

@@ -22,8 +22,9 @@
//
CPrimaryClient::CPrimaryClient(const CString& name, CScreen* screen) :
m_name(name),
m_screen(screen)
CBaseClientProxy(name),
m_screen(screen),
m_fakeInputCount(0)
{
// all clipboards are clean
for (UInt32 i = 0; i < kClipboardEnd; ++i) {
@@ -42,6 +43,34 @@ CPrimaryClient::reconfigure(UInt32 activeSides)
m_screen->reconfigure(activeSides);
}
UInt32
CPrimaryClient::registerHotKey(KeyID key, KeyModifierMask mask)
{
return m_screen->registerHotKey(key, mask);
}
void
CPrimaryClient::unregisterHotKey(UInt32 id)
{
m_screen->unregisterHotKey(id);
}
void
CPrimaryClient::fakeInputBegin()
{
if (++m_fakeInputCount == 1) {
m_screen->fakeInputBegin();
}
}
void
CPrimaryClient::fakeInputEnd()
{
if (--m_fakeInputCount == 0) {
m_screen->fakeInputEnd();
}
}
SInt32
CPrimaryClient::getJumpZoneSize() const
{
@@ -57,7 +86,7 @@ CPrimaryClient::getCursorCenter(SInt32& x, SInt32& y) const
KeyModifierMask
CPrimaryClient::getToggleMask() const
{
return m_screen->getActiveModifiers();
return m_screen->pollActiveModifiers();
}
bool
@@ -150,9 +179,15 @@ CPrimaryClient::setClipboardDirty(ClipboardID id, bool dirty)
}
void
CPrimaryClient::keyDown(KeyID, KeyModifierMask, KeyButton)
CPrimaryClient::keyDown(KeyID key, KeyModifierMask mask, KeyButton button)
{
// ignore
if (m_fakeInputCount > 0) {
// XXX -- don't forward keystrokes to primary screen for now
(void)key;
(void)mask;
(void)button;
// m_screen->keyDown(key, mask, button);
}
}
void
@@ -162,9 +197,15 @@ CPrimaryClient::keyRepeat(KeyID, KeyModifierMask, SInt32, KeyButton)
}
void
CPrimaryClient::keyUp(KeyID, KeyModifierMask, KeyButton)
CPrimaryClient::keyUp(KeyID key, KeyModifierMask mask, KeyButton button)
{
// ignore
if (m_fakeInputCount > 0) {
// XXX -- don't forward keystrokes to primary screen for now
(void)key;
(void)mask;
(void)button;
// m_screen->keyUp(key, mask, button);
}
}
void
@@ -192,7 +233,7 @@ CPrimaryClient::mouseRelativeMove(SInt32, SInt32)
}
void
CPrimaryClient::mouseWheel(SInt32)
CPrimaryClient::mouseWheel(SInt32, SInt32)
{
// ignore
}
@@ -214,9 +255,3 @@ CPrimaryClient::setOptions(const COptionsList& options)
{
m_screen->setOptions(options);
}
CString
CPrimaryClient::getName() const
{
return m_name;
}

View File

@@ -15,7 +15,7 @@
#ifndef CPRIMARYCLIENT_H
#define CPRIMARYCLIENT_H
#include "IClient.h"
#include "CBaseClientProxy.h"
#include "ProtocolTypes.h"
class CScreen;
@@ -26,7 +26,7 @@ The primary screen does not have a client associated with it. This
class provides a pseudo-client to allow the primary screen to be
treated as if it was a client.
*/
class CPrimaryClient : public IClient {
class CPrimaryClient : public CBaseClientProxy {
public:
/*!
\c name is the name of the server and \p screen is primary screen.
@@ -43,6 +43,34 @@ public:
*/
void reconfigure(UInt32 activeSides);
//! Register a system hotkey
/*!
Registers a system-wide hotkey for key \p key with modifiers \p mask.
Returns an id used to unregister the hotkey.
*/
UInt32 registerHotKey(KeyID key, KeyModifierMask mask);
//! Unregister a system hotkey
/*!
Unregisters a previously registered hot key.
*/
void unregisterHotKey(UInt32 id);
//! Prepare to synthesize input on primary screen
/*!
Prepares the primary screen to receive synthesized input. We do not
want to receive this synthesized input as user input so this method
ensures that we ignore it. Calls to \c fakeInputBegin() and
\c fakeInputEnd() may be nested; only the outermost have an effect.
*/
void fakeInputBegin();
//! Done synthesizing input on primary screen
/*!
Undoes whatever \c fakeInputBegin() did.
*/
void fakeInputEnd();
//@}
//! @name accessors
//@{
@@ -61,7 +89,7 @@ public:
the edges of the screen, typically the center.
*/
void getCursorCenter(SInt32& x, SInt32& y) const;
//! Get toggle key state
/*!
Returns the primary screen's current toggle modifier key state.
@@ -103,16 +131,15 @@ public:
virtual void mouseUp(ButtonID);
virtual void mouseMove(SInt32 xAbs, SInt32 yAbs);
virtual void mouseRelativeMove(SInt32 xRel, SInt32 yRel);
virtual void mouseWheel(SInt32 delta);
virtual void mouseWheel(SInt32 xDelta, SInt32 yDelta);
virtual void screensaver(bool activate);
virtual void resetOptions();
virtual void setOptions(const COptionsList& options);
virtual CString getName() const;
private:
CString m_name;
CScreen* m_screen;
bool m_clipboardDirty[kClipboardEnd];
SInt32 m_fakeInputCount;
};
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -26,9 +26,10 @@
#include "stdset.h"
#include "stdvector.h"
class CBaseClientProxy;
class CEventQueueTimer;
class CPrimaryClient;
class IClient;
class CInputFilter;
//! Synergy server
/*!
@@ -36,6 +37,46 @@ This class implements the top-level server algorithms for synergy.
*/
class CServer {
public:
//! Lock cursor to screen data
class CLockCursorToScreenInfo {
public:
enum State { kOff, kOn, kToggle };
static CLockCursorToScreenInfo* alloc(State state = kToggle);
public:
State m_state;
};
//! Switch to screen data
class CSwitchToScreenInfo {
public:
static CSwitchToScreenInfo* alloc(const CString& screen);
public:
// this is a C-string; this type is a variable size structure
char m_screen[1];
};
//! Switch in direction data
class CSwitchInDirectionInfo {
public:
static CSwitchInDirectionInfo* alloc(EDirection direction);
public:
EDirection m_direction;
};
//! Screen connected data
class CScreenConnectedInfo {
public:
static CScreenConnectedInfo* alloc(const CString& screen);
public:
// this is a C-string; this type is a variable size structure
char m_screen[1];
};
/*!
Start the server with the configuration \p config and the primary
client (local screen) \p primaryClient. The client retains
@@ -60,7 +101,7 @@ public:
Adds \p client to the server. The client is adopted and will be
destroyed when the client disconnects or is disconnected.
*/
void adoptClient(IClient* client);
void adoptClient(CBaseClientProxy* client);
//! Disconnect clients
/*!
@@ -94,6 +135,14 @@ public:
*/
static CEvent::Type getErrorEvent();
//! Get connected event type
/*!
Returns the connected event type. This is sent when a client screen
has connected. The event data is a \c CScreenConnectedInfo* that
indicates the connected screen.
*/
static CEvent::Type getConnectedEvent();
//! Get disconnected event type
/*!
Returns the disconnected event type. This is sent when all the
@@ -101,18 +150,35 @@ public:
*/
static CEvent::Type getDisconnectedEvent();
//@}
protected:
//! Handle special keys
//! Get switch to screen event type
/*!
Handles keys with special meaning.
Returns the switch to screen event type. The server responds to this
by switching screens. The event data is a \c CSwitchToScreenInfo*
that indicates the target screen.
*/
bool onCommandKey(KeyID, KeyModifierMask, bool down);
static CEvent::Type getSwitchToScreenEvent();
//! Get switch in direction event type
/*!
Returns the switch in direction event type. The server responds to this
by switching screens. The event data is a \c CSwitchInDirectionInfo*
that indicates the target direction.
*/
static CEvent::Type getSwitchInDirectionEvent();
//! Get lock cursor event type
/*!
Returns the lock cursor event type. The server responds to this
by locking the cursor to the active screen or unlocking it. The
event data is a \c CLockCursorToScreenInfo*.
*/
static CEvent::Type getLockCursorToScreenEvent();
//@}
private:
// get canonical name of client
CString getName(const IClient*) const;
CString getName(const CBaseClientProxy*) const;
// get the sides of the primary screen that have neighbors
UInt32 getActivePrimarySides() const;
@@ -127,28 +193,52 @@ private:
bool isLockedToScreen() const;
// returns the jump zone of the client
SInt32 getJumpZoneSize(IClient*) const;
SInt32 getJumpZoneSize(CBaseClientProxy*) const;
// change the active screen
void switchScreen(IClient*,
void switchScreen(CBaseClientProxy*,
SInt32 x, SInt32 y, bool forScreenSaver);
// lookup neighboring screen
IClient* getNeighbor(IClient*, EDirection) const;
// jump to screen
void jumpToScreen(CBaseClientProxy*);
// convert pixel position to fraction, using x or y depending on the
// direction.
float mapToFraction(CBaseClientProxy*, EDirection,
SInt32 x, SInt32 y) const;
// convert fraction to pixel position, writing only x or y depending
// on the direction.
void mapToPixel(CBaseClientProxy*, EDirection, float f,
SInt32& x, SInt32& y) const;
// returns true if the client has a neighbor anywhere along the edge
// indicated by the direction.
bool hasAnyNeighbor(CBaseClientProxy*, EDirection) const;
// lookup neighboring screen, mapping the coordinate independent of
// the direction to the neighbor's coordinate space.
CBaseClientProxy* getNeighbor(CBaseClientProxy*, EDirection,
SInt32& x, SInt32& y) const;
// lookup neighboring screen. given a position relative to the
// source screen, find the screen we should move onto and where.
// if the position is sufficiently far from the source then we
// cross multiple screens. if there is no suitable screen then
// return NULL and x,y are not modified.
IClient* getNeighbor(IClient*, EDirection,
CBaseClientProxy* mapToNeighbor(CBaseClientProxy*, EDirection,
SInt32& x, SInt32& y) const;
// adjusts x and y or neither to avoid ending up in a jump zone
// after entering the client in the given direction.
void avoidJumpZone(CBaseClientProxy*, EDirection,
SInt32& x, SInt32& y) const;
// test if a switch is permitted. this includes testing user
// options like switch delay and tracking any state required to
// implement them. returns true iff a switch is permitted.
bool isSwitchOkay(IClient* dst, EDirection,
SInt32 x, SInt32 y);
bool isSwitchOkay(CBaseClientProxy* dst, EDirection,
SInt32 x, SInt32 y, SInt32 xActive, SInt32 yActive);
// update switch state due to a mouse move at \p x, \p y that
// doesn't switch screens.
@@ -181,11 +271,16 @@ private:
// returns true iff the delay switch timer is started
bool isSwitchWaitStarted() const;
// returns the corner (EScreenSwitchCornerMasks) where x,y is on the
// given client. corners have the given size.
UInt32 getCorner(CBaseClientProxy*,
SInt32 x, SInt32 y, SInt32 size) const;
// stop relative mouse moves
void stopRelativeMoves();
// send screen options to \c client
void sendOptions(IClient* client) const;
void sendOptions(CBaseClientProxy* client) const;
// process options from configuration
void processOptions();
@@ -207,28 +302,35 @@ private:
void handleSwitchWaitTimeout(const CEvent&, void*);
void handleClientDisconnected(const CEvent&, void*);
void handleClientCloseTimeout(const CEvent&, void*);
void handleSwitchToScreenEvent(const CEvent&, void*);
void handleSwitchInDirectionEvent(const CEvent&, void*);
void handleLockCursorToScreenEvent(const CEvent&, void*);
void handleFakeInputBeginEvent(const CEvent&, void*);
void handleFakeInputEndEvent(const CEvent&, void*);
// event processing
void onClipboardChanged(IClient* sender,
void onClipboardChanged(CBaseClientProxy* sender,
ClipboardID id, UInt32 seqNum);
void onScreensaver(bool activated);
void onKeyDown(KeyID, KeyModifierMask, KeyButton);
void onKeyUp(KeyID, KeyModifierMask, KeyButton);
void onKeyDown(KeyID, KeyModifierMask, KeyButton,
const char* screens);
void onKeyUp(KeyID, KeyModifierMask, KeyButton,
const char* screens);
void onKeyRepeat(KeyID, KeyModifierMask, SInt32, KeyButton);
void onMouseDown(ButtonID);
void onMouseUp(ButtonID);
bool onMouseMovePrimary(SInt32 x, SInt32 y);
void onMouseMoveSecondary(SInt32 dx, SInt32 dy);
void onMouseWheel(SInt32 delta);
void onMouseWheel(SInt32 xDelta, SInt32 yDelta);
// add client to list and attach event handlers for client
bool addClient(IClient*);
bool addClient(CBaseClientProxy*);
// remove client from list and detach event handlers for client
bool removeClient(IClient*);
bool removeClient(CBaseClientProxy*);
// close a client
void closeClient(IClient*, const char* msg);
void closeClient(CBaseClientProxy*, const char* msg);
// close clients not in \p config
void closeClients(const CConfig& config);
@@ -238,11 +340,11 @@ private:
void closeAllClients();
// remove clients from internal state
void removeActiveClient(IClient*);
void removeOldClient(IClient*);
void removeActiveClient(CBaseClientProxy*);
void removeOldClient(CBaseClientProxy*);
// force the cursor off of \p client
void forceLeaveClient(IClient* client);
void forceLeaveClient(CBaseClientProxy* client);
private:
class CClipboardInfo {
@@ -260,17 +362,17 @@ private:
CPrimaryClient* m_primaryClient;
// all clients (including the primary client) indexed by name
typedef std::map<CString, IClient*> CClientList;
typedef std::set<IClient*> CClientSet;
typedef std::map<CString, CBaseClientProxy*> CClientList;
typedef std::set<CBaseClientProxy*> CClientSet;
CClientList m_clients;
CClientSet m_clientSet;
// all old connections that we're waiting to hangup
typedef std::map<IClient*, CEventQueueTimer*> COldClients;
typedef std::map<CBaseClientProxy*, CEventQueueTimer*> COldClients;
COldClients m_oldClients;
// the client with focus
IClient* m_active;
CBaseClientProxy* m_active;
// the sequence number of enter messages
UInt32 m_seqNum;
@@ -289,17 +391,20 @@ private:
// current configuration
CConfig m_config;
// input filter (from m_config);
CInputFilter* m_inputFilter;
// clipboard cache
CClipboardInfo m_clipboards[kClipboardEnd];
// state saved when screen saver activates
IClient* m_activeSaver;
CBaseClientProxy* m_activeSaver;
SInt32 m_xSaver, m_ySaver;
// common state for screen switch tests. all tests are always
// trying to reach the same screen in the same direction.
EDirection m_switchDir;
IClient* m_switchScreen;
CBaseClientProxy* m_switchScreen;
// state for delayed screen switching
double m_switchWaitDelay;
@@ -316,8 +421,15 @@ private:
// relative mouse move option
bool m_relativeMoves;
// screen locking (former scroll lock)
bool m_lockedToScreen;
static CEvent::Type s_errorEvent;
static CEvent::Type s_connectedEvent;
static CEvent::Type s_disconnectedEvent;
static CEvent::Type s_switchToScreen;
static CEvent::Type s_switchInDirection;
static CEvent::Type s_lockCursorToScreen;
};
#endif

View File

@@ -23,22 +23,28 @@ MAINTAINERCLEANFILES = \
noinst_LIBRARIES = libserver.a
libserver_a_SOURCES = \
CBaseClientProxy.cpp \
CClientListener.cpp \
CClientProxy.cpp \
CClientProxy1_0.cpp \
CClientProxy1_1.cpp \
CClientProxy1_2.cpp \
CClientProxy1_3.cpp \
CClientProxyUnknown.cpp \
CConfig.cpp \
CInputFilter.cpp \
CPrimaryClient.cpp \
CServer.cpp \
CBaseClientProxy.h \
CClientListener.h \
CClientProxy.h \
CClientProxy1_0.h \
CClientProxy1_1.h \
CClientProxy1_2.h \
CClientProxy1_3.h \
CClientProxyUnknown.h \
CConfig.h \
CInputFilter.h \
CPrimaryClient.h \
CServer.h \
$(NULL)

View File

@@ -41,7 +41,7 @@ RSC=rc.exe
# PROP Intermediate_Dir "..\..\gen\build"
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c
# ADD CPP /nologo /MT /W4 /GX /O2 /I "..\common" /I "..\arch" /I "..\base" /I "..\mt" /I "..\io" /I "..\net" /I "..\synergy" /I "..\platform" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /Fd"..\..\gen\build\server.pdb" /FD /c
# ADD CPP /nologo /MT /W4 /GR /GX /O2 /I "..\common" /I "..\arch" /I "..\base" /I "..\mt" /I "..\io" /I "..\net" /I "..\synergy" /I "..\platform" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /Fd"..\..\gen\build\server.pdb" /FD /c
# SUBTRACT CPP /YX
# ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /d "NDEBUG"
@@ -65,7 +65,7 @@ LIB32=link.exe -lib
# PROP Intermediate_Dir "..\..\gen\debug"
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
# ADD CPP /nologo /MTd /W4 /Gm /GX /ZI /Od /I "..\common" /I "..\arch" /I "..\base" /I "..\mt" /I "..\io" /I "..\net" /I "..\synergy" /I "..\platform" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /Fd"..\..\gen\debug\server.pdb" /FD /GZ /c
# ADD CPP /nologo /MTd /W4 /Gm /GR /GX /ZI /Od /I "..\common" /I "..\arch" /I "..\base" /I "..\mt" /I "..\io" /I "..\net" /I "..\synergy" /I "..\platform" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /Fd"..\..\gen\debug\server.pdb" /FD /GZ /c
# SUBTRACT CPP /YX
# ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /d "_DEBUG"
@@ -87,6 +87,10 @@ LIB32=link.exe -lib
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Source File
SOURCE=.\CBaseClientProxy.cpp
# End Source File
# Begin Source File
SOURCE=.\CClientListener.cpp
# End Source File
# Begin Source File
@@ -107,6 +111,10 @@ SOURCE=.\CClientProxy1_2.cpp
# End Source File
# Begin Source File
SOURCE=.\CClientProxy1_3.cpp
# End Source File
# Begin Source File
SOURCE=.\CClientProxyUnknown.cpp
# End Source File
# Begin Source File
@@ -115,6 +123,10 @@ SOURCE=.\CConfig.cpp
# End Source File
# Begin Source File
SOURCE=.\CInputFilter.cpp
# End Source File
# Begin Source File
SOURCE=.\CPrimaryClient.cpp
# End Source File
# Begin Source File
@@ -127,6 +139,10 @@ SOURCE=.\CServer.cpp
# PROP Default_Filter "h;hpp;hxx;hm;inl"
# Begin Source File
SOURCE=.\CBaseClientProxy.h
# End Source File
# Begin Source File
SOURCE=.\CClientListener.h
# End Source File
# Begin Source File
@@ -147,6 +163,10 @@ SOURCE=.\CClientProxy1_2.h
# End Source File
# Begin Source File
SOURCE=.\CClientProxy1_3.h
# End Source File
# Begin Source File
SOURCE=.\CClientProxyUnknown.h
# End Source File
# Begin Source File
@@ -155,6 +175,10 @@ SOURCE=.\CConfig.h
# End Source File
# Begin Source File
SOURCE=.\CInputFilter.h
# End Source File
# Begin Source File
SOURCE=.\CPrimaryClient.h
# End Source File
# Begin Source File