mirror of
https://github.com/debauchee/barrier.git
synced 2026-05-10 00:11:43 +08:00
merged 1.4 r1007:1008 into trunk
This commit is contained in:
@@ -64,24 +64,6 @@ CEvent::getFlags() const
|
||||
return m_flags;
|
||||
}
|
||||
|
||||
CEvent::Type
|
||||
CEvent::registerType(const char* name)
|
||||
{
|
||||
return EVENTQUEUE->registerType(name);
|
||||
}
|
||||
|
||||
CEvent::Type
|
||||
CEvent::registerTypeOnce(Type& type, const char* name)
|
||||
{
|
||||
return EVENTQUEUE->registerTypeOnce(type, name);
|
||||
}
|
||||
|
||||
const char*
|
||||
CEvent::getTypeName(Type type)
|
||||
{
|
||||
return EVENTQUEUE->getTypeName(type);
|
||||
}
|
||||
|
||||
void
|
||||
CEvent::deleteData(const CEvent& event)
|
||||
{
|
||||
|
||||
@@ -59,27 +59,6 @@ public:
|
||||
//! @name manipulators
|
||||
//@{
|
||||
|
||||
//! Creates a new event type
|
||||
/*!
|
||||
Returns a unique event type id.
|
||||
*/
|
||||
static Type registerType(const char* name);
|
||||
|
||||
//! Creates a new event type
|
||||
/*!
|
||||
If \p type contains \c kUnknown then it is set to a unique event
|
||||
type id otherwise it is left alone. The final value of \p type
|
||||
is returned.
|
||||
*/
|
||||
static Type registerTypeOnce(Type& type, const char* name);
|
||||
|
||||
//! Get name for event
|
||||
/*!
|
||||
Returns the name for the event \p type. This is primarily for
|
||||
debugging.
|
||||
*/
|
||||
static const char* getTypeName(Type type);
|
||||
|
||||
//! Release event data
|
||||
/*!
|
||||
Deletes event data for the given event (using free()).
|
||||
|
||||
@@ -187,21 +187,21 @@ CClient::getServerAddress() const
|
||||
CEvent::Type
|
||||
CClient::getConnectedEvent()
|
||||
{
|
||||
return CEvent::registerTypeOnce(s_connectedEvent,
|
||||
return EVENTQUEUE->registerTypeOnce(s_connectedEvent,
|
||||
"CClient::connected");
|
||||
}
|
||||
|
||||
CEvent::Type
|
||||
CClient::getConnectionFailedEvent()
|
||||
{
|
||||
return CEvent::registerTypeOnce(s_connectionFailedEvent,
|
||||
return EVENTQUEUE->registerTypeOnce(s_connectionFailedEvent,
|
||||
"CClient::failed");
|
||||
}
|
||||
|
||||
CEvent::Type
|
||||
CClient::getDisconnectedEvent()
|
||||
{
|
||||
return CEvent::registerTypeOnce(s_disconnectedEvent,
|
||||
return EVENTQUEUE->registerTypeOnce(s_disconnectedEvent,
|
||||
"CClient::disconnected");
|
||||
}
|
||||
|
||||
|
||||
@@ -33,6 +33,7 @@ if (WIN32)
|
||||
endif()
|
||||
|
||||
set(inc
|
||||
../arch
|
||||
../base
|
||||
../common
|
||||
)
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
*/
|
||||
|
||||
#include "IStream.h"
|
||||
#include "CEventQueue.h"
|
||||
|
||||
//
|
||||
// IStream
|
||||
@@ -30,34 +31,34 @@ CEvent::Type IStream::s_outputShutdownEvent = CEvent::kUnknown;
|
||||
CEvent::Type
|
||||
IStream::getInputReadyEvent()
|
||||
{
|
||||
return CEvent::registerTypeOnce(s_inputReadyEvent,
|
||||
return EVENTQUEUE->registerTypeOnce(s_inputReadyEvent,
|
||||
"IStream::inputReady");
|
||||
}
|
||||
|
||||
CEvent::Type
|
||||
IStream::getOutputFlushedEvent()
|
||||
{
|
||||
return CEvent::registerTypeOnce(s_outputFlushedEvent,
|
||||
return EVENTQUEUE->registerTypeOnce(s_outputFlushedEvent,
|
||||
"IStream::outputFlushed");
|
||||
}
|
||||
|
||||
CEvent::Type
|
||||
IStream::getOutputErrorEvent()
|
||||
{
|
||||
return CEvent::registerTypeOnce(s_outputErrorEvent,
|
||||
return EVENTQUEUE->registerTypeOnce(s_outputErrorEvent,
|
||||
"IStream::outputError");
|
||||
}
|
||||
|
||||
CEvent::Type
|
||||
IStream::getInputShutdownEvent()
|
||||
{
|
||||
return CEvent::registerTypeOnce(s_inputShutdownEvent,
|
||||
return EVENTQUEUE->registerTypeOnce(s_inputShutdownEvent,
|
||||
"IStream::inputShutdown");
|
||||
}
|
||||
|
||||
CEvent::Type
|
||||
IStream::getOutputShutdownEvent()
|
||||
{
|
||||
return CEvent::registerTypeOnce(s_outputShutdownEvent,
|
||||
return EVENTQUEUE->registerTypeOnce(s_outputShutdownEvent,
|
||||
"IStream::outputShutdown");
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
*/
|
||||
|
||||
#include "IDataSocket.h"
|
||||
#include "CEventQueue.h"
|
||||
|
||||
//
|
||||
// IDataSocket
|
||||
@@ -27,14 +28,14 @@ CEvent::Type IDataSocket::s_failedEvent = CEvent::kUnknown;
|
||||
CEvent::Type
|
||||
IDataSocket::getConnectedEvent()
|
||||
{
|
||||
return CEvent::registerTypeOnce(s_connectedEvent,
|
||||
return EVENTQUEUE->registerTypeOnce(s_connectedEvent,
|
||||
"IDataSocket::connected");
|
||||
}
|
||||
|
||||
CEvent::Type
|
||||
IDataSocket::getConnectionFailedEvent()
|
||||
{
|
||||
return CEvent::registerTypeOnce(s_failedEvent,
|
||||
return EVENTQUEUE->registerTypeOnce(s_failedEvent,
|
||||
"IDataSocket::failed");
|
||||
}
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
*/
|
||||
|
||||
#include "IListenSocket.h"
|
||||
#include "CEventQueue.h"
|
||||
|
||||
//
|
||||
// IListenSocket
|
||||
@@ -26,6 +27,6 @@ CEvent::Type IListenSocket::s_connectingEvent = CEvent::kUnknown;
|
||||
CEvent::Type
|
||||
IListenSocket::getConnectingEvent()
|
||||
{
|
||||
return CEvent::registerTypeOnce(s_connectingEvent,
|
||||
return EVENTQUEUE->registerTypeOnce(s_connectingEvent,
|
||||
"IListenSocket::connecting");
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
*/
|
||||
|
||||
#include "ISocket.h"
|
||||
#include "CEventQueue.h"
|
||||
|
||||
//
|
||||
// ISocket
|
||||
@@ -26,6 +27,6 @@ CEvent::Type ISocket::s_disconnectedEvent = CEvent::kUnknown;
|
||||
CEvent::Type
|
||||
ISocket::getDisconnectedEvent()
|
||||
{
|
||||
return CEvent::registerTypeOnce(s_disconnectedEvent,
|
||||
return EVENTQUEUE->registerTypeOnce(s_disconnectedEvent,
|
||||
"ISocket::disconnected");
|
||||
}
|
||||
|
||||
@@ -115,7 +115,7 @@ CClientListener::getNextClient()
|
||||
CEvent::Type
|
||||
CClientListener::getConnectedEvent()
|
||||
{
|
||||
return CEvent::registerTypeOnce(s_connectedEvent,
|
||||
return EVENTQUEUE->registerTypeOnce(s_connectedEvent,
|
||||
"CClientListener::connected");
|
||||
}
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
#include "CProtocolUtil.h"
|
||||
#include "IStream.h"
|
||||
#include "CLog.h"
|
||||
#include "CEventQueue.h"
|
||||
|
||||
//
|
||||
// CClientProxy
|
||||
@@ -59,21 +60,21 @@ CClientProxy::getStream() const
|
||||
CEvent::Type
|
||||
CClientProxy::getReadyEvent()
|
||||
{
|
||||
return CEvent::registerTypeOnce(s_readyEvent,
|
||||
return EVENTQUEUE->registerTypeOnce(s_readyEvent,
|
||||
"CClientProxy::ready");
|
||||
}
|
||||
|
||||
CEvent::Type
|
||||
CClientProxy::getDisconnectedEvent()
|
||||
{
|
||||
return CEvent::registerTypeOnce(s_disconnectedEvent,
|
||||
return EVENTQUEUE->registerTypeOnce(s_disconnectedEvent,
|
||||
"CClientProxy::disconnected");
|
||||
}
|
||||
|
||||
CEvent::Type
|
||||
CClientProxy::getClipboardChangedEvent()
|
||||
{
|
||||
return CEvent::registerTypeOnce(s_clipboardChangedEvent,
|
||||
return EVENTQUEUE->registerTypeOnce(s_clipboardChangedEvent,
|
||||
"CClientProxy::clipboardChanged");
|
||||
}
|
||||
|
||||
|
||||
@@ -79,14 +79,14 @@ CClientProxyUnknown::orphanClientProxy()
|
||||
CEvent::Type
|
||||
CClientProxyUnknown::getSuccessEvent()
|
||||
{
|
||||
return CEvent::registerTypeOnce(s_successEvent,
|
||||
return EVENTQUEUE->registerTypeOnce(s_successEvent,
|
||||
"CClientProxy::success");
|
||||
}
|
||||
|
||||
CEvent::Type
|
||||
CClientProxyUnknown::getFailureEvent()
|
||||
{
|
||||
return CEvent::registerTypeOnce(s_failureEvent,
|
||||
return EVENTQUEUE->registerTypeOnce(s_failureEvent,
|
||||
"CClientProxy::failure");
|
||||
}
|
||||
|
||||
|
||||
@@ -536,8 +536,8 @@ CInputFilter::CKeystrokeAction::format() const
|
||||
void
|
||||
CInputFilter::CKeystrokeAction::perform(const CEvent& event)
|
||||
{
|
||||
CEvent::Type type = m_press ? IPlatformScreen::getKeyDownEvent() :
|
||||
IPlatformScreen::getKeyUpEvent();
|
||||
CEvent::Type type = m_press ? IPlatformScreen::getKeyDownEvent(*EVENTQUEUE) :
|
||||
IPlatformScreen::getKeyUpEvent(*EVENTQUEUE);
|
||||
EVENTQUEUE->addEvent(CEvent(IPlatformScreen::getFakeInputBeginEvent(),
|
||||
event.getTarget(), NULL,
|
||||
CEvent::kDeliverImmediately));
|
||||
@@ -609,7 +609,7 @@ CInputFilter::CMouseButtonAction::perform(const CEvent& event)
|
||||
KeyID key = m_press ? kKeySetModifiers : kKeyClearModifiers;
|
||||
modifierInfo =
|
||||
IKeyState::CKeyInfo::alloc(key, m_buttonInfo->m_mask, 0, 1);
|
||||
EVENTQUEUE->addEvent(CEvent(IPlatformScreen::getKeyDownEvent(),
|
||||
EVENTQUEUE->addEvent(CEvent(IPlatformScreen::getKeyDownEvent(*EVENTQUEUE),
|
||||
event.getTarget(), modifierInfo,
|
||||
CEvent::kDeliverImmediately));
|
||||
}
|
||||
@@ -937,11 +937,11 @@ CInputFilter::setPrimaryClient(CPrimaryClient* client)
|
||||
rule->disable(m_primaryClient);
|
||||
}
|
||||
|
||||
EVENTQUEUE->removeHandler(IPlatformScreen::getKeyDownEvent(),
|
||||
EVENTQUEUE->removeHandler(IPlatformScreen::getKeyDownEvent(*EVENTQUEUE),
|
||||
m_primaryClient->getEventTarget());
|
||||
EVENTQUEUE->removeHandler(IPlatformScreen::getKeyUpEvent(),
|
||||
EVENTQUEUE->removeHandler(IPlatformScreen::getKeyUpEvent(*EVENTQUEUE),
|
||||
m_primaryClient->getEventTarget());
|
||||
EVENTQUEUE->removeHandler(IPlatformScreen::getKeyRepeatEvent(),
|
||||
EVENTQUEUE->removeHandler(IPlatformScreen::getKeyRepeatEvent(*EVENTQUEUE),
|
||||
m_primaryClient->getEventTarget());
|
||||
EVENTQUEUE->removeHandler(IPlatformScreen::getButtonDownEvent(),
|
||||
m_primaryClient->getEventTarget());
|
||||
@@ -958,15 +958,15 @@ CInputFilter::setPrimaryClient(CPrimaryClient* client)
|
||||
m_primaryClient = client;
|
||||
|
||||
if (m_primaryClient != NULL) {
|
||||
EVENTQUEUE->adoptHandler(IPlatformScreen::getKeyDownEvent(),
|
||||
EVENTQUEUE->adoptHandler(IPlatformScreen::getKeyDownEvent(*EVENTQUEUE),
|
||||
m_primaryClient->getEventTarget(),
|
||||
new TMethodEventJob<CInputFilter>(this,
|
||||
&CInputFilter::handleEvent));
|
||||
EVENTQUEUE->adoptHandler(IPlatformScreen::getKeyUpEvent(),
|
||||
EVENTQUEUE->adoptHandler(IPlatformScreen::getKeyUpEvent(*EVENTQUEUE),
|
||||
m_primaryClient->getEventTarget(),
|
||||
new TMethodEventJob<CInputFilter>(this,
|
||||
&CInputFilter::handleEvent));
|
||||
EVENTQUEUE->adoptHandler(IPlatformScreen::getKeyRepeatEvent(),
|
||||
EVENTQUEUE->adoptHandler(IPlatformScreen::getKeyRepeatEvent(*EVENTQUEUE),
|
||||
m_primaryClient->getEventTarget(),
|
||||
new TMethodEventJob<CInputFilter>(this,
|
||||
&CInputFilter::handleEvent));
|
||||
|
||||
@@ -95,15 +95,15 @@ CServer::CServer(const CConfig& config, CPrimaryClient* primaryClient) :
|
||||
EVENTQUEUE->adoptHandler(CEvent::kTimer, this,
|
||||
new TMethodEventJob<CServer>(this,
|
||||
&CServer::handleSwitchWaitTimeout));
|
||||
EVENTQUEUE->adoptHandler(IPlatformScreen::getKeyDownEvent(),
|
||||
EVENTQUEUE->adoptHandler(IPlatformScreen::getKeyDownEvent(*EVENTQUEUE),
|
||||
m_inputFilter,
|
||||
new TMethodEventJob<CServer>(this,
|
||||
&CServer::handleKeyDownEvent));
|
||||
EVENTQUEUE->adoptHandler(IPlatformScreen::getKeyUpEvent(),
|
||||
EVENTQUEUE->adoptHandler(IPlatformScreen::getKeyUpEvent(*EVENTQUEUE),
|
||||
m_inputFilter,
|
||||
new TMethodEventJob<CServer>(this,
|
||||
&CServer::handleKeyUpEvent));
|
||||
EVENTQUEUE->adoptHandler(IPlatformScreen::getKeyRepeatEvent(),
|
||||
EVENTQUEUE->adoptHandler(IPlatformScreen::getKeyRepeatEvent(* EVENTQUEUE),
|
||||
m_inputFilter,
|
||||
new TMethodEventJob<CServer>(this,
|
||||
&CServer::handleKeyRepeatEvent));
|
||||
@@ -182,11 +182,11 @@ CServer::CServer(const CConfig& config, CPrimaryClient* primaryClient) :
|
||||
CServer::~CServer()
|
||||
{
|
||||
// remove event handlers and timers
|
||||
EVENTQUEUE->removeHandler(IPlatformScreen::getKeyDownEvent(),
|
||||
EVENTQUEUE->removeHandler(IPlatformScreen::getKeyDownEvent(*EVENTQUEUE),
|
||||
m_inputFilter);
|
||||
EVENTQUEUE->removeHandler(IPlatformScreen::getKeyUpEvent(),
|
||||
EVENTQUEUE->removeHandler(IPlatformScreen::getKeyUpEvent(*EVENTQUEUE),
|
||||
m_inputFilter);
|
||||
EVENTQUEUE->removeHandler(IPlatformScreen::getKeyRepeatEvent(),
|
||||
EVENTQUEUE->removeHandler(IPlatformScreen::getKeyRepeatEvent(*EVENTQUEUE),
|
||||
m_inputFilter);
|
||||
EVENTQUEUE->removeHandler(IPlatformScreen::getButtonDownEvent(),
|
||||
m_inputFilter);
|
||||
@@ -345,49 +345,49 @@ CServer::getClients(std::vector<CString>& list) const
|
||||
CEvent::Type
|
||||
CServer::getErrorEvent()
|
||||
{
|
||||
return CEvent::registerTypeOnce(s_errorEvent,
|
||||
return EVENTQUEUE->registerTypeOnce(s_errorEvent,
|
||||
"CServer::error");
|
||||
}
|
||||
|
||||
CEvent::Type
|
||||
CServer::getConnectedEvent()
|
||||
{
|
||||
return CEvent::registerTypeOnce(s_connectedEvent,
|
||||
return EVENTQUEUE->registerTypeOnce(s_connectedEvent,
|
||||
"CServer::connected");
|
||||
}
|
||||
|
||||
CEvent::Type
|
||||
CServer::getDisconnectedEvent()
|
||||
{
|
||||
return CEvent::registerTypeOnce(s_disconnectedEvent,
|
||||
return EVENTQUEUE->registerTypeOnce(s_disconnectedEvent,
|
||||
"CServer::disconnected");
|
||||
}
|
||||
|
||||
CEvent::Type
|
||||
CServer::getSwitchToScreenEvent()
|
||||
{
|
||||
return CEvent::registerTypeOnce(s_switchToScreen,
|
||||
return EVENTQUEUE->registerTypeOnce(s_switchToScreen,
|
||||
"CServer::switchToScreen");
|
||||
}
|
||||
|
||||
CEvent::Type
|
||||
CServer::getSwitchInDirectionEvent()
|
||||
{
|
||||
return CEvent::registerTypeOnce(s_switchInDirection,
|
||||
return EVENTQUEUE->registerTypeOnce(s_switchInDirection,
|
||||
"CServer::switchInDirection");
|
||||
}
|
||||
|
||||
CEvent::Type
|
||||
CServer::getKeyboardBroadcastEvent()
|
||||
{
|
||||
return CEvent::registerTypeOnce(s_keyboardBroadcast,
|
||||
return EVENTQUEUE->registerTypeOnce(s_keyboardBroadcast,
|
||||
"CServer:keyboardBroadcast");
|
||||
}
|
||||
|
||||
CEvent::Type
|
||||
CServer::getLockCursorToScreenEvent()
|
||||
{
|
||||
return CEvent::registerTypeOnce(s_lockCursorToScreen,
|
||||
return EVENTQUEUE->registerTypeOnce(s_lockCursorToScreen,
|
||||
"CServer::lockCursorToScreen");
|
||||
}
|
||||
|
||||
|
||||
@@ -123,7 +123,7 @@ public:
|
||||
//@{
|
||||
|
||||
//! Swap with another \c CKeyMap
|
||||
void swap(CKeyMap&);
|
||||
virtual void swap(CKeyMap&);
|
||||
|
||||
//! Add a key entry
|
||||
/*!
|
||||
@@ -189,19 +189,19 @@ public:
|
||||
Records that modifier key \p key is half-duplex. This is called to
|
||||
set user configurable half-duplex settings.
|
||||
*/
|
||||
void addHalfDuplexModifier(KeyID key);
|
||||
virtual void addHalfDuplexModifier(KeyID key);
|
||||
|
||||
//! Finish adding entries
|
||||
/*!
|
||||
Called after adding entries, this does some internal housekeeping.
|
||||
*/
|
||||
void finish();
|
||||
virtual void finish();
|
||||
|
||||
//! Iterate over all added keys items
|
||||
/*!
|
||||
Calls \p cb for every key item.
|
||||
*/
|
||||
void foreachKey(ForeachKeyCallback cb, void* userData);
|
||||
virtual void foreachKey(ForeachKeyCallback cb, void* userData);
|
||||
|
||||
//@}
|
||||
//! @name accessors
|
||||
@@ -251,7 +251,7 @@ public:
|
||||
Returns \c true iff modifier key \p key or button \p button is
|
||||
half-duplex.
|
||||
*/
|
||||
bool isHalfDuplex(KeyID key, KeyButton button) const;
|
||||
virtual bool isHalfDuplex(KeyID key, KeyButton button) const;
|
||||
|
||||
//! Test if modifiers indicate a command
|
||||
/*!
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
*/
|
||||
|
||||
#include "CKeyState.h"
|
||||
#include "IEventQueue.h"
|
||||
#include "CLog.h"
|
||||
#include <cstring>
|
||||
#include <algorithm>
|
||||
@@ -383,7 +382,31 @@ static const KeyID s_numpadTable[] = {
|
||||
//
|
||||
|
||||
CKeyState::CKeyState() :
|
||||
m_mask(0)
|
||||
IKeyState(),
|
||||
m_mask(0),
|
||||
m_keyMapPtr(new CKeyMap()),
|
||||
m_keyMap(*m_keyMapPtr)
|
||||
{
|
||||
init();
|
||||
}
|
||||
|
||||
CKeyState::CKeyState(IEventQueue& eventQueue, CKeyMap& keyMap) :
|
||||
IKeyState(eventQueue),
|
||||
m_mask(0),
|
||||
m_keyMapPtr(0),
|
||||
m_keyMap(keyMap)
|
||||
{
|
||||
init();
|
||||
}
|
||||
|
||||
CKeyState::~CKeyState()
|
||||
{
|
||||
if (m_keyMapPtr)
|
||||
delete m_keyMapPtr;
|
||||
}
|
||||
|
||||
void
|
||||
CKeyState::init()
|
||||
{
|
||||
memset(&m_keys, 0, sizeof(m_keys));
|
||||
memset(&m_syntheticKeys, 0, sizeof(m_syntheticKeys));
|
||||
@@ -391,11 +414,6 @@ CKeyState::CKeyState() :
|
||||
memset(&m_serverKeys, 0, sizeof(m_serverKeys));
|
||||
}
|
||||
|
||||
CKeyState::~CKeyState()
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
void
|
||||
CKeyState::onKey(KeyButton button, bool down, KeyModifierMask newState)
|
||||
{
|
||||
@@ -431,23 +449,23 @@ CKeyState::sendKeyEvent(
|
||||
// ignore auto-repeat on half-duplex keys
|
||||
}
|
||||
else {
|
||||
EVENTQUEUE->addEvent(CEvent(getKeyDownEvent(), target,
|
||||
getEventQueue().addEvent(CEvent(getKeyDownEvent(), target,
|
||||
CKeyInfo::alloc(key, mask, button, 1)));
|
||||
EVENTQUEUE->addEvent(CEvent(getKeyUpEvent(), target,
|
||||
getEventQueue().addEvent(CEvent(getKeyUpEvent(), target,
|
||||
CKeyInfo::alloc(key, mask, button, 1)));
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (isAutoRepeat) {
|
||||
EVENTQUEUE->addEvent(CEvent(getKeyRepeatEvent(), target,
|
||||
getEventQueue().addEvent(CEvent(getKeyRepeatEvent(), target,
|
||||
CKeyInfo::alloc(key, mask, button, count)));
|
||||
}
|
||||
else if (press) {
|
||||
EVENTQUEUE->addEvent(CEvent(getKeyDownEvent(), target,
|
||||
getEventQueue().addEvent(CEvent(getKeyDownEvent(), target,
|
||||
CKeyInfo::alloc(key, mask, button, 1)));
|
||||
}
|
||||
else {
|
||||
EVENTQUEUE->addEvent(CEvent(getKeyUpEvent(), target,
|
||||
getEventQueue().addEvent(CEvent(getKeyUpEvent(), target,
|
||||
CKeyInfo::alloc(key, mask, button, 1)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@ platform specific methods.
|
||||
class CKeyState : public IKeyState {
|
||||
public:
|
||||
CKeyState();
|
||||
CKeyState(IEventQueue& eventQueue, CKeyMap& keyMap);
|
||||
virtual ~CKeyState();
|
||||
|
||||
//! @name manipulators
|
||||
@@ -137,6 +138,7 @@ protected:
|
||||
private:
|
||||
typedef CKeyMap::Keystrokes Keystrokes;
|
||||
typedef CKeyMap::ModifierToKeys ModifierToKeys;
|
||||
public:
|
||||
struct CAddActiveModifierContext {
|
||||
public:
|
||||
CAddActiveModifierContext(SInt32 group, KeyModifierMask mask,
|
||||
@@ -152,6 +154,7 @@ private:
|
||||
CAddActiveModifierContext(const CAddActiveModifierContext&);
|
||||
CAddActiveModifierContext& operator=(const CAddActiveModifierContext&);
|
||||
};
|
||||
private:
|
||||
|
||||
class ButtonToKeyLess {
|
||||
public:
|
||||
@@ -166,6 +169,9 @@ private:
|
||||
CKeyState(const CKeyState&);
|
||||
CKeyState& operator=(const CKeyState&);
|
||||
|
||||
// called by all ctors.
|
||||
void init();
|
||||
|
||||
// adds alias key sequences. these are sequences that are equivalent
|
||||
// to other sequences.
|
||||
void addAliasEntries();
|
||||
@@ -190,8 +196,11 @@ private:
|
||||
CKeyMap::KeyItem& keyItem, void* vcontext);
|
||||
|
||||
private:
|
||||
// must be declared before m_keyMap. used when this class owns the key map.
|
||||
CKeyMap* m_keyMapPtr;
|
||||
|
||||
// the keyboard map
|
||||
CKeyMap m_keyMap;
|
||||
CKeyMap& m_keyMap;
|
||||
|
||||
// current modifier state
|
||||
KeyModifierMask m_mask;
|
||||
|
||||
@@ -289,7 +289,7 @@ CServerApp::loadConfig(const CString& pathname)
|
||||
CEvent::Type
|
||||
CServerApp::getReloadConfigEvent()
|
||||
{
|
||||
return CEvent::registerTypeOnce(s_reloadConfigEvent, "reloadConfig");
|
||||
return EVENTQUEUE->registerTypeOnce(s_reloadConfigEvent, "reloadConfig");
|
||||
}
|
||||
|
||||
void
|
||||
@@ -303,13 +303,13 @@ CServerApp::forceReconnect(const CEvent&, void*)
|
||||
CEvent::Type
|
||||
CServerApp::getForceReconnectEvent()
|
||||
{
|
||||
return CEvent::registerTypeOnce(s_forceReconnectEvent, "forceReconnect");
|
||||
return EVENTQUEUE->registerTypeOnce(s_forceReconnectEvent, "forceReconnect");
|
||||
}
|
||||
|
||||
CEvent::Type
|
||||
CServerApp::getResetServerEvent()
|
||||
{
|
||||
return CEvent::registerTypeOnce(s_resetServerEvent, "resetServer");
|
||||
return EVENTQUEUE->registerTypeOnce(s_resetServerEvent, "resetServer");
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
*/
|
||||
|
||||
#include "IKeyState.h"
|
||||
#include "CEventQueue.h"
|
||||
#include <cstring>
|
||||
#include <cstdlib>
|
||||
|
||||
@@ -27,28 +28,37 @@ CEvent::Type IKeyState::s_keyDownEvent = CEvent::kUnknown;
|
||||
CEvent::Type IKeyState::s_keyUpEvent = CEvent::kUnknown;
|
||||
CEvent::Type IKeyState::s_keyRepeatEvent = CEvent::kUnknown;
|
||||
|
||||
CEvent::Type
|
||||
IKeyState::getKeyDownEvent()
|
||||
IKeyState::IKeyState() :
|
||||
m_eventQueue(*EVENTQUEUE)
|
||||
{
|
||||
return CEvent::registerTypeOnce(s_keyDownEvent,
|
||||
}
|
||||
|
||||
IKeyState::IKeyState(IEventQueue& eventQueue) :
|
||||
m_eventQueue(eventQueue)
|
||||
{
|
||||
}
|
||||
|
||||
CEvent::Type
|
||||
IKeyState::getKeyDownEvent(IEventQueue& eventQueue)
|
||||
{
|
||||
return eventQueue.registerTypeOnce(s_keyDownEvent,
|
||||
"IKeyState::keyDown");
|
||||
}
|
||||
|
||||
CEvent::Type
|
||||
IKeyState::getKeyUpEvent()
|
||||
IKeyState::getKeyUpEvent(IEventQueue& eventQueue)
|
||||
{
|
||||
return CEvent::registerTypeOnce(s_keyUpEvent,
|
||||
return eventQueue.registerTypeOnce(s_keyUpEvent,
|
||||
"IKeyState::keyUp");
|
||||
}
|
||||
|
||||
CEvent::Type
|
||||
IKeyState::getKeyRepeatEvent()
|
||||
IKeyState::getKeyRepeatEvent(IEventQueue& eventQueue)
|
||||
{
|
||||
return CEvent::registerTypeOnce(s_keyRepeatEvent,
|
||||
return eventQueue.registerTypeOnce(s_keyRepeatEvent,
|
||||
"IKeyState::keyRepeat");
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// IKeyState::CKeyInfo
|
||||
//
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include "CEvent.h"
|
||||
#include "CString.h"
|
||||
#include "stdset.h"
|
||||
#include "IEventQueue.h"
|
||||
|
||||
//! Key state interface
|
||||
/*!
|
||||
@@ -31,6 +32,9 @@ to synthesize key events.
|
||||
*/
|
||||
class IKeyState : public IInterface {
|
||||
public:
|
||||
IKeyState();
|
||||
IKeyState(IEventQueue& eventQueue);
|
||||
|
||||
enum {
|
||||
kNumButtons = 0x200
|
||||
};
|
||||
@@ -160,18 +164,33 @@ public:
|
||||
virtual void pollPressedKeys(KeyButtonSet& pressedKeys) const = 0;
|
||||
|
||||
//! Get key down event type. Event data is CKeyInfo*, count == 1.
|
||||
static CEvent::Type getKeyDownEvent();
|
||||
CEvent::Type getKeyDownEvent() { return getKeyDownEvent(m_eventQueue); }
|
||||
|
||||
//! Get key up event type. Event data is CKeyInfo*, count == 1.
|
||||
static CEvent::Type getKeyUpEvent();
|
||||
CEvent::Type getKeyUpEvent() { return getKeyUpEvent(m_eventQueue); }
|
||||
|
||||
//! Get key repeat event type. Event data is CKeyInfo*.
|
||||
static CEvent::Type getKeyRepeatEvent();
|
||||
CEvent::Type getKeyRepeatEvent() { return getKeyRepeatEvent(m_eventQueue); }
|
||||
|
||||
//! Get key down event type. Event data is CKeyInfo*, count == 1.
|
||||
static CEvent::Type getKeyDownEvent(IEventQueue& eventQueue);
|
||||
|
||||
//! Get key up event type. Event data is CKeyInfo*, count == 1.
|
||||
static CEvent::Type getKeyUpEvent(IEventQueue& eventQueue);
|
||||
|
||||
//! Get key repeat event type. Event data is CKeyInfo*.
|
||||
static CEvent::Type getKeyRepeatEvent(IEventQueue& eventQueue);
|
||||
|
||||
//@}
|
||||
|
||||
protected:
|
||||
IEventQueue& getEventQueue() const { return m_eventQueue; }
|
||||
|
||||
private:
|
||||
static CEvent::Type s_keyDownEvent;
|
||||
static CEvent::Type s_keyUpEvent;
|
||||
static CEvent::Type s_keyRepeatEvent;
|
||||
IEventQueue& m_eventQueue;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
*/
|
||||
|
||||
#include "IPrimaryScreen.h"
|
||||
#include "CEventQueue.h"
|
||||
#include <cstdlib>
|
||||
|
||||
//
|
||||
@@ -37,77 +38,77 @@ CEvent::Type IPrimaryScreen::s_fakeInputEnd = CEvent::kUnknown;
|
||||
CEvent::Type
|
||||
IPrimaryScreen::getButtonDownEvent()
|
||||
{
|
||||
return CEvent::registerTypeOnce(s_buttonDownEvent,
|
||||
return EVENTQUEUE->registerTypeOnce(s_buttonDownEvent,
|
||||
"IPrimaryScreen::buttonDown");
|
||||
}
|
||||
|
||||
CEvent::Type
|
||||
IPrimaryScreen::getButtonUpEvent()
|
||||
{
|
||||
return CEvent::registerTypeOnce(s_buttonUpEvent,
|
||||
return EVENTQUEUE->registerTypeOnce(s_buttonUpEvent,
|
||||
"IPrimaryScreen::buttonUp");
|
||||
}
|
||||
|
||||
CEvent::Type
|
||||
IPrimaryScreen::getMotionOnPrimaryEvent()
|
||||
{
|
||||
return CEvent::registerTypeOnce(s_motionPrimaryEvent,
|
||||
return EVENTQUEUE->registerTypeOnce(s_motionPrimaryEvent,
|
||||
"IPrimaryScreen::motionPrimary");
|
||||
}
|
||||
|
||||
CEvent::Type
|
||||
IPrimaryScreen::getMotionOnSecondaryEvent()
|
||||
{
|
||||
return CEvent::registerTypeOnce(s_motionSecondaryEvent,
|
||||
return EVENTQUEUE->registerTypeOnce(s_motionSecondaryEvent,
|
||||
"IPrimaryScreen::motionSecondary");
|
||||
}
|
||||
|
||||
CEvent::Type
|
||||
IPrimaryScreen::getWheelEvent()
|
||||
{
|
||||
return CEvent::registerTypeOnce(s_wheelEvent,
|
||||
return EVENTQUEUE->registerTypeOnce(s_wheelEvent,
|
||||
"IPrimaryScreen::wheel");
|
||||
}
|
||||
|
||||
CEvent::Type
|
||||
IPrimaryScreen::getScreensaverActivatedEvent()
|
||||
{
|
||||
return CEvent::registerTypeOnce(s_ssActivatedEvent,
|
||||
return EVENTQUEUE->registerTypeOnce(s_ssActivatedEvent,
|
||||
"IPrimaryScreen::screensaverActivated");
|
||||
}
|
||||
|
||||
CEvent::Type
|
||||
IPrimaryScreen::getScreensaverDeactivatedEvent()
|
||||
{
|
||||
return CEvent::registerTypeOnce(s_ssDeactivatedEvent,
|
||||
return EVENTQUEUE->registerTypeOnce(s_ssDeactivatedEvent,
|
||||
"IPrimaryScreen::screensaverDeactivated");
|
||||
}
|
||||
|
||||
CEvent::Type
|
||||
IPrimaryScreen::getHotKeyDownEvent()
|
||||
{
|
||||
return CEvent::registerTypeOnce(s_hotKeyDownEvent,
|
||||
return EVENTQUEUE->registerTypeOnce(s_hotKeyDownEvent,
|
||||
"IPrimaryScreen::hotKeyDown");
|
||||
}
|
||||
|
||||
CEvent::Type
|
||||
IPrimaryScreen::getHotKeyUpEvent()
|
||||
{
|
||||
return CEvent::registerTypeOnce(s_hotKeyUpEvent,
|
||||
return EVENTQUEUE->registerTypeOnce(s_hotKeyUpEvent,
|
||||
"IPrimaryScreen::hotKeyUp");
|
||||
}
|
||||
|
||||
CEvent::Type
|
||||
IPrimaryScreen::getFakeInputBeginEvent()
|
||||
{
|
||||
return CEvent::registerTypeOnce(s_fakeInputBegin,
|
||||
return EVENTQUEUE->registerTypeOnce(s_fakeInputBegin,
|
||||
"IPrimaryScreen::fakeInputBegin");
|
||||
}
|
||||
|
||||
CEvent::Type
|
||||
IPrimaryScreen::getFakeInputEndEvent()
|
||||
{
|
||||
return CEvent::registerTypeOnce(s_fakeInputEnd,
|
||||
return EVENTQUEUE->registerTypeOnce(s_fakeInputEnd,
|
||||
"IPrimaryScreen::fakeInputEnd");
|
||||
}
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
*/
|
||||
|
||||
#include "IScreen.h"
|
||||
#include "CEventQueue.h"
|
||||
|
||||
//
|
||||
// IScreen
|
||||
@@ -30,34 +31,34 @@ CEvent::Type IScreen::s_resumeEvent = CEvent::kUnknown;
|
||||
CEvent::Type
|
||||
IScreen::getErrorEvent()
|
||||
{
|
||||
return CEvent::registerTypeOnce(s_errorEvent,
|
||||
return EVENTQUEUE->registerTypeOnce(s_errorEvent,
|
||||
"IScreen::error");
|
||||
}
|
||||
|
||||
CEvent::Type
|
||||
IScreen::getShapeChangedEvent()
|
||||
{
|
||||
return CEvent::registerTypeOnce(s_shapeChangedEvent,
|
||||
return EVENTQUEUE->registerTypeOnce(s_shapeChangedEvent,
|
||||
"IScreen::shapeChanged");
|
||||
}
|
||||
|
||||
CEvent::Type
|
||||
IScreen::getClipboardGrabbedEvent()
|
||||
{
|
||||
return CEvent::registerTypeOnce(s_clipboardGrabbedEvent,
|
||||
return EVENTQUEUE->registerTypeOnce(s_clipboardGrabbedEvent,
|
||||
"IScreen::clipboardGrabbed");
|
||||
}
|
||||
|
||||
CEvent::Type
|
||||
IScreen::getSuspendEvent()
|
||||
{
|
||||
return CEvent::registerTypeOnce(s_suspendEvent,
|
||||
return EVENTQUEUE->registerTypeOnce(s_suspendEvent,
|
||||
"IScreen::suspend");
|
||||
}
|
||||
|
||||
CEvent::Type
|
||||
IScreen::getResumeEvent()
|
||||
{
|
||||
return CEvent::registerTypeOnce(s_resumeEvent,
|
||||
return EVENTQUEUE->registerTypeOnce(s_resumeEvent,
|
||||
"IScreen::resume");
|
||||
}
|
||||
|
||||
@@ -1,26 +1,26 @@
|
||||
# synergy -- mouse and keyboard sharing utility
|
||||
# Copyright (C) 2011 Chris Schoeneman, Nick Bolton, Sorin Sbarnea
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
include_directories(
|
||||
../../tools/gtest-1.6.0
|
||||
../../tools/gtest-1.6.0/include
|
||||
../../tools/gmock-1.6.0
|
||||
../../tools/gmock-1.6.0/include)
|
||||
|
||||
add_library(gtest STATIC ../../tools/gtest-1.6.0/src/gtest-all.cc)
|
||||
add_library(gmock STATIC ../../tools/gmock-1.6.0/src/gmock-all.cc)
|
||||
|
||||
add_subdirectory(integtests)
|
||||
add_subdirectory(unittests)
|
||||
# synergy -- mouse and keyboard sharing utility
|
||||
# Copyright (C) 2011 Chris Schoeneman, Nick Bolton, Sorin Sbarnea
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
include_directories(
|
||||
../../tools/gtest-1.6.0
|
||||
../../tools/gtest-1.6.0/include
|
||||
../../tools/gmock-1.6.0
|
||||
../../tools/gmock-1.6.0/include)
|
||||
|
||||
add_library(gtest STATIC ../../tools/gtest-1.6.0/src/gtest-all.cc)
|
||||
add_library(gmock STATIC ../../tools/gmock-1.6.0/src/gmock-all.cc)
|
||||
|
||||
add_subdirectory(integtests)
|
||||
add_subdirectory(unittests)
|
||||
|
||||
@@ -50,7 +50,7 @@ set(inc
|
||||
../../lib/net
|
||||
../../lib/platform
|
||||
../../lib/synergy
|
||||
../../../tools/gtest-1.6.0/include
|
||||
../../../tools/gtest-1.6.0/include
|
||||
../../../tools/gmock-1.6.0/include
|
||||
)
|
||||
|
||||
|
||||
@@ -50,33 +50,33 @@ public:
|
||||
|
||||
TEST_F(CMSWindowsClipboardTests, emptyUnowned_openCalled_returnsTrue)
|
||||
{
|
||||
CMSWindowsClipboard clipboard(NULL);
|
||||
clipboard.open(0);
|
||||
|
||||
bool actual = clipboard.emptyUnowned();
|
||||
|
||||
CMSWindowsClipboard clipboard(NULL);
|
||||
clipboard.open(0);
|
||||
|
||||
bool actual = clipboard.emptyUnowned();
|
||||
|
||||
EXPECT_EQ(true, actual);
|
||||
}
|
||||
|
||||
TEST_F(CMSWindowsClipboardTests, empty_openCalled_returnsTrue)
|
||||
{
|
||||
CMSWindowsClipboard clipboard(NULL);
|
||||
clipboard.open(0);
|
||||
|
||||
bool actual = clipboard.empty();
|
||||
|
||||
CMSWindowsClipboard clipboard(NULL);
|
||||
clipboard.open(0);
|
||||
|
||||
bool actual = clipboard.empty();
|
||||
|
||||
EXPECT_EQ(true, actual);
|
||||
}
|
||||
|
||||
TEST_F(CMSWindowsClipboardTests, empty_singleFormat_hasReturnsFalse)
|
||||
{
|
||||
CMSWindowsClipboard clipboard(NULL);
|
||||
clipboard.open(0);
|
||||
clipboard.add(CMSWindowsClipboard::kText, "synergy rocks!");
|
||||
|
||||
clipboard.empty();
|
||||
|
||||
bool actual = clipboard.has(CMSWindowsClipboard::kText);
|
||||
CMSWindowsClipboard clipboard(NULL);
|
||||
clipboard.open(0);
|
||||
clipboard.add(CMSWindowsClipboard::kText, "synergy rocks!");
|
||||
|
||||
clipboard.empty();
|
||||
|
||||
bool actual = clipboard.has(CMSWindowsClipboard::kText);
|
||||
EXPECT_EQ(false, actual);
|
||||
}
|
||||
|
||||
@@ -117,19 +117,19 @@ TEST_F(CMSWindowsClipboardTests, add_replaceValue_valueWasReplaced)
|
||||
|
||||
TEST_F(CMSWindowsClipboardTests, open_timeIsZero_returnsTrue)
|
||||
{
|
||||
CMSWindowsClipboard clipboard(NULL);
|
||||
|
||||
bool actual = clipboard.open(0);
|
||||
|
||||
CMSWindowsClipboard clipboard(NULL);
|
||||
|
||||
bool actual = clipboard.open(0);
|
||||
|
||||
EXPECT_EQ(true, actual);
|
||||
}
|
||||
|
||||
TEST_F(CMSWindowsClipboardTests, open_timeIsOne_returnsTrue)
|
||||
{
|
||||
CMSWindowsClipboard clipboard(NULL);
|
||||
|
||||
bool actual = clipboard.open(1);
|
||||
|
||||
CMSWindowsClipboard clipboard(NULL);
|
||||
|
||||
bool actual = clipboard.open(1);
|
||||
|
||||
EXPECT_EQ(true, actual);
|
||||
}
|
||||
|
||||
@@ -147,13 +147,13 @@ TEST_F(CMSWindowsClipboardTests, close_isOpen_noErrors)
|
||||
// * http://buildbot.synergy-foss.org:8000/builders/trunk-win32/builds/246/steps/shell_3/logs/stdio
|
||||
/*TEST_F(CMSWindowsClipboardTests, getTime_openWithNoEmpty_returnsOne)
|
||||
{
|
||||
CMSWindowsClipboard clipboard(NULL);
|
||||
clipboard.open(1);
|
||||
|
||||
CMSWindowsClipboard::Time actual = clipboard.getTime();
|
||||
|
||||
// this behavior is different to that of CClipboard which only
|
||||
// returns the value passed into open(t) after empty() is called.
|
||||
CMSWindowsClipboard clipboard(NULL);
|
||||
clipboard.open(1);
|
||||
|
||||
CMSWindowsClipboard::Time actual = clipboard.getTime();
|
||||
|
||||
// this behavior is different to that of CClipboard which only
|
||||
// returns the value passed into open(t) after empty() is called.
|
||||
EXPECT_EQ(1, actual);
|
||||
}*/
|
||||
|
||||
@@ -161,12 +161,12 @@ TEST_F(CMSWindowsClipboardTests, close_isOpen_noErrors)
|
||||
// http://buildbot.synergy-foss.org:8000/builders/trunk-win32/builds/266/steps/shell_3/logs/stdio
|
||||
/*TEST_F(CMSWindowsClipboardTests, getTime_openAndEmpty_returnsOne)
|
||||
{
|
||||
CMSWindowsClipboard clipboard(NULL);
|
||||
clipboard.open(1);
|
||||
clipboard.empty();
|
||||
|
||||
CMSWindowsClipboard::Time actual = clipboard.getTime();
|
||||
|
||||
CMSWindowsClipboard clipboard(NULL);
|
||||
clipboard.open(1);
|
||||
clipboard.empty();
|
||||
|
||||
CMSWindowsClipboard::Time actual = clipboard.getTime();
|
||||
|
||||
EXPECT_EQ(1, actual);
|
||||
}*/
|
||||
|
||||
|
||||
@@ -77,7 +77,7 @@ TEST_F(CXWindowsClipboardTests, empty_singleFormat_hasReturnsFalse)
|
||||
clipboard.empty();
|
||||
|
||||
bool actual = clipboard.has(CXWindowsClipboard::kText);
|
||||
EXPECT_EQ(false, actual);
|
||||
EXPECT_FALSE(actual);
|
||||
}
|
||||
|
||||
TEST_F(CXWindowsClipboardTests, add_newValue_valueWasStored)
|
||||
@@ -127,7 +127,7 @@ TEST_F(CXWindowsClipboardTests, has_withNoFormats_returnsFalse)
|
||||
|
||||
bool actual = clipboard.has(IClipboard::kText);
|
||||
|
||||
EXPECT_EQ(false, actual);
|
||||
EXPECT_FALSE(actual);
|
||||
}
|
||||
|
||||
TEST_F(CXWindowsClipboardTests, get_withNoFormats_returnsEmpty)
|
||||
|
||||
@@ -13,7 +13,14 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
set(h
|
||||
synergy/CKeyStateImpl.h
|
||||
synergy/CMockEventQueue.h
|
||||
synergy/CMockKeyMap.h
|
||||
)
|
||||
|
||||
set(src
|
||||
${h}
|
||||
Main.cpp
|
||||
synergy/CClipboardTests.cpp
|
||||
synergy/CKeyStateTests.cpp
|
||||
@@ -29,7 +36,7 @@ set(inc
|
||||
../../lib/net
|
||||
../../lib/platform
|
||||
../../lib/synergy
|
||||
../../../tools/gtest-1.6.0/include
|
||||
../../../tools/gtest-1.6.0/include
|
||||
../../../tools/gmock-1.6.0/include
|
||||
)
|
||||
|
||||
|
||||
@@ -20,24 +20,24 @@
|
||||
|
||||
TEST(CClipboardTests, empty_openCalled_returnsTrue)
|
||||
{
|
||||
CClipboard clipboard;
|
||||
clipboard.open(0);
|
||||
|
||||
bool actual = clipboard.empty();
|
||||
|
||||
CClipboard clipboard;
|
||||
clipboard.open(0);
|
||||
|
||||
bool actual = clipboard.empty();
|
||||
|
||||
EXPECT_EQ(true, actual);
|
||||
}
|
||||
|
||||
TEST(CClipboardTests, empty_singleFormat_hasReturnsFalse)
|
||||
{
|
||||
CClipboard clipboard;
|
||||
clipboard.open(0);
|
||||
clipboard.add(CClipboard::kText, "synergy rocks!");
|
||||
|
||||
clipboard.empty();
|
||||
|
||||
bool actual = clipboard.has(CClipboard::kText);
|
||||
EXPECT_EQ(false, actual);
|
||||
CClipboard clipboard;
|
||||
clipboard.open(0);
|
||||
clipboard.add(CClipboard::kText, "synergy rocks!");
|
||||
|
||||
clipboard.empty();
|
||||
|
||||
bool actual = clipboard.has(CClipboard::kText);
|
||||
EXPECT_FALSE(actual);
|
||||
}
|
||||
|
||||
TEST(CClipboardTests, add_newValue_valueWasStored)
|
||||
@@ -65,19 +65,19 @@ TEST(CClipboardTests, add_replaceValue_valueWasReplaced)
|
||||
|
||||
TEST(CClipboardTests, open_timeIsZero_returnsTrue)
|
||||
{
|
||||
CClipboard clipboard;
|
||||
|
||||
bool actual = clipboard.open(0);
|
||||
|
||||
CClipboard clipboard;
|
||||
|
||||
bool actual = clipboard.open(0);
|
||||
|
||||
EXPECT_EQ(true, actual);
|
||||
}
|
||||
|
||||
TEST(CClipboardTests, open_timeIsOne_returnsTrue)
|
||||
{
|
||||
CClipboard clipboard;
|
||||
|
||||
bool actual = clipboard.open(1);
|
||||
|
||||
CClipboard clipboard;
|
||||
|
||||
bool actual = clipboard.open(1);
|
||||
|
||||
EXPECT_EQ(true, actual);
|
||||
}
|
||||
|
||||
@@ -93,22 +93,22 @@ TEST(CClipboardTests, close_isOpen_noErrors)
|
||||
|
||||
TEST(CClipboardTests, getTime_openWithNoEmpty_returnsZero)
|
||||
{
|
||||
CClipboard clipboard;
|
||||
clipboard.open(1);
|
||||
|
||||
CClipboard::Time actual = clipboard.getTime();
|
||||
|
||||
CClipboard clipboard;
|
||||
clipboard.open(1);
|
||||
|
||||
CClipboard::Time actual = clipboard.getTime();
|
||||
|
||||
EXPECT_EQ(0, actual);
|
||||
}
|
||||
|
||||
TEST(CClipboardTests, getTime_openAndEmpty_returnsOne)
|
||||
{
|
||||
CClipboard clipboard;
|
||||
clipboard.open(1);
|
||||
clipboard.empty();
|
||||
|
||||
CClipboard::Time actual = clipboard.getTime();
|
||||
|
||||
CClipboard clipboard;
|
||||
clipboard.open(1);
|
||||
clipboard.empty();
|
||||
|
||||
CClipboard::Time actual = clipboard.getTime();
|
||||
|
||||
EXPECT_EQ(1, actual);
|
||||
}
|
||||
|
||||
@@ -130,7 +130,7 @@ TEST(CClipboardTests, has_withNoFormats_returnsFalse)
|
||||
|
||||
bool actual = clipboard.has(IClipboard::kText);
|
||||
|
||||
EXPECT_EQ(false, actual);
|
||||
EXPECT_FALSE(actual);
|
||||
}
|
||||
|
||||
TEST(CClipboardTests, get_withNoFormats_returnsEmpty)
|
||||
@@ -281,7 +281,7 @@ TEST(CClipboardTests, unmarshall_emptyData_hasTextIsFalse)
|
||||
|
||||
clipboard.open(0);
|
||||
bool actual = clipboard.has(IClipboard::kText);
|
||||
EXPECT_EQ(false, actual);
|
||||
EXPECT_FALSE(actual);
|
||||
}
|
||||
|
||||
TEST(CClipboardTests, unmarshall_withTextSize285_getTextIsValid)
|
||||
|
||||
60
src/test/unittests/synergy/CKeyStateImpl.h
Normal file
60
src/test/unittests/synergy/CKeyStateImpl.h
Normal file
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* synergy -- mouse and keyboard sharing utility
|
||||
* Copyright (C) 2011 Chris Schoeneman, Nick Bolton, Sorin Sbarnea
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef CKEYSTATEIMPL_H
|
||||
#define CKEYSTATEIMPL_H
|
||||
|
||||
#include "CKeyState.h"
|
||||
#include "gmock/gmock.h"
|
||||
|
||||
class CMockKeyMap;
|
||||
class CMockEventQueue;
|
||||
|
||||
// while the class name indicates that this is actually a mock, we use a
|
||||
// typedef later to rename it (so the name matches the compilation unit)
|
||||
// so the tests are less confusing.
|
||||
class CMockKeyState : public CKeyState
|
||||
{
|
||||
public:
|
||||
CMockKeyState() : CKeyState()
|
||||
{
|
||||
}
|
||||
|
||||
CMockKeyState(const CMockEventQueue& eventQueue, const CMockKeyMap& keyMap) :
|
||||
CKeyState((IEventQueue&)eventQueue, (CKeyMap&)keyMap)
|
||||
{
|
||||
}
|
||||
|
||||
MOCK_CONST_METHOD0(pollActiveGroup, SInt32());
|
||||
MOCK_CONST_METHOD0(pollActiveModifiers, KeyModifierMask());
|
||||
MOCK_METHOD0(fakeCtrlAltDel, bool());
|
||||
MOCK_METHOD1(getKeyMap, void(CKeyMap&));
|
||||
MOCK_METHOD1(fakeKey, void(const Keystroke&));
|
||||
MOCK_CONST_METHOD1(pollPressedKeys, void(KeyButtonSet&));
|
||||
};
|
||||
|
||||
// hide that we're actually testing a mock to make the unit tests less
|
||||
// confusing. use NiceMock so that we don't get warnings for unexpected
|
||||
// calls.
|
||||
typedef ::testing::NiceMock<CMockKeyState> CKeyStateImpl;
|
||||
|
||||
typedef UInt32 KeyID;
|
||||
|
||||
typedef void (*ForeachKeyCallback)(
|
||||
KeyID, SInt32 group, CKeyMap::KeyItem&, void* userData);
|
||||
|
||||
#endif
|
||||
@@ -16,66 +16,205 @@
|
||||
*/
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
#include "CKeyState.h"
|
||||
#include <gmock/gmock.h>
|
||||
#include "CKeyStateImpl.h"
|
||||
#include "CMockEventQueue.h"
|
||||
#include "CMockKeyMap.h"
|
||||
|
||||
using ::testing::_;
|
||||
using ::testing::NiceMock;
|
||||
using ::testing::Invoke;
|
||||
using ::testing::Return;
|
||||
using ::testing::SaveArg;
|
||||
|
||||
enum {
|
||||
kAKey = 30
|
||||
};
|
||||
|
||||
class CKeyStateImpl : public CKeyState
|
||||
TEST(CKeyStateTests, onKey_aKeyDown_keyStateOne)
|
||||
{
|
||||
protected:
|
||||
virtual SInt32 pollActiveGroup() const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
virtual KeyModifierMask pollActiveModifiers() const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
virtual bool fakeCtrlAltDel()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
virtual void getKeyMap(CKeyMap& keyMap)
|
||||
{
|
||||
}
|
||||
|
||||
virtual void fakeKey(const Keystroke& keystroke)
|
||||
{
|
||||
}
|
||||
|
||||
virtual void pollPressedKeys(KeyButtonSet& pressedKeys) const
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
TEST(CKeyStateTests, onKey_aKeyPressed_keyStateOne)
|
||||
{
|
||||
CKeyStateImpl keyState;
|
||||
CMockKeyMap keyMap;
|
||||
CMockEventQueue eventQueue;
|
||||
CKeyStateImpl keyState(eventQueue, keyMap);
|
||||
|
||||
keyState.onKey(kAKey, true, KeyModifierAlt);
|
||||
|
||||
EXPECT_EQ(1, keyState.getKeyState(kAKey));
|
||||
}
|
||||
|
||||
TEST(CKeyStateTests, onKey_validButtonUp_keyStateZero)
|
||||
TEST(CKeyStateTests, onKey_aKeyUp_keyStateZero)
|
||||
{
|
||||
CKeyStateImpl keyState;
|
||||
CMockKeyMap keyMap;
|
||||
CMockEventQueue eventQueue;
|
||||
CKeyStateImpl keyState(eventQueue, keyMap);
|
||||
|
||||
keyState.onKey(kAKey, false, KeyModifierAlt);
|
||||
|
||||
EXPECT_EQ(0, keyState.getKeyState(kAKey));
|
||||
}
|
||||
|
||||
TEST(CKeyStateTests, onKey_invalidKey_keyStateZero)
|
||||
{
|
||||
CMockKeyMap keyMap;
|
||||
CMockEventQueue eventQueue;
|
||||
CKeyStateImpl keyState(eventQueue, keyMap);
|
||||
|
||||
keyState.onKey(0, true, KeyModifierAlt);
|
||||
|
||||
EXPECT_EQ(0, keyState.getKeyState(0));
|
||||
}
|
||||
|
||||
TEST(CKeyStateTests, onKey_bogusButtonDown_keyStateZero)
|
||||
TEST(CKeyStateTests, sendKeyEvent_halfDuplexAndRepeat_addEventNotCalled)
|
||||
{
|
||||
CKeyStateImpl keyState;
|
||||
NiceMock<CMockKeyMap> keyMap;
|
||||
NiceMock<CMockEventQueue> eventQueue;
|
||||
CKeyStateImpl keyState(eventQueue, keyMap);
|
||||
ON_CALL(keyMap, isHalfDuplex(_, _)).WillByDefault(Return(true));
|
||||
|
||||
keyState.onKey(0, true, KeyModifierAlt);
|
||||
EXPECT_CALL(eventQueue, addEvent(_)).Times(0);
|
||||
|
||||
EXPECT_EQ(0, keyState.getKeyState(0));
|
||||
keyState.sendKeyEvent(NULL, false, true, kKeyCapsLock, 0, 0, 0);
|
||||
}
|
||||
|
||||
TEST(CKeyStateTests, sendKeyEvent_halfDuplex_addEventCalledTwice)
|
||||
{
|
||||
CMockKeyMap keyMap;
|
||||
NiceMock<CMockEventQueue> eventQueue;
|
||||
CKeyStateImpl keyState(eventQueue, keyMap);
|
||||
ON_CALL(keyMap, isHalfDuplex(_, _)).WillByDefault(Return(true));
|
||||
|
||||
EXPECT_CALL(eventQueue, addEvent(_)).Times(2);
|
||||
|
||||
keyState.sendKeyEvent(NULL, false, false, kKeyCapsLock, 0, 0, 0);
|
||||
}
|
||||
|
||||
TEST(CKeyStateTests, sendKeyEvent_keyRepeat_addEventCalledOnce)
|
||||
{
|
||||
CMockKeyMap keyMap;
|
||||
NiceMock<CMockEventQueue> eventQueue;
|
||||
CKeyStateImpl keyState(eventQueue, keyMap);
|
||||
|
||||
EXPECT_CALL(eventQueue, addEvent(_)).Times(1);
|
||||
|
||||
keyState.sendKeyEvent(NULL, false, true, kAKey, 0, 0, 0);
|
||||
}
|
||||
|
||||
TEST(CKeyStateTests, sendKeyEvent_keyDown_addEventCalledOnce)
|
||||
{
|
||||
CMockKeyMap keyMap;
|
||||
NiceMock<CMockEventQueue> eventQueue;
|
||||
CKeyStateImpl keyState(eventQueue, keyMap);
|
||||
|
||||
EXPECT_CALL(eventQueue, addEvent(_)).Times(1);
|
||||
|
||||
keyState.sendKeyEvent(NULL, true, false, kAKey, 0, 0, 0);
|
||||
}
|
||||
|
||||
TEST(CKeyStateTests, sendKeyEvent_keyUp_addEventCalledOnce)
|
||||
{
|
||||
CMockKeyMap keyMap;
|
||||
NiceMock<CMockEventQueue> eventQueue;
|
||||
CKeyStateImpl keyState(eventQueue, keyMap);
|
||||
|
||||
EXPECT_CALL(eventQueue, addEvent(_)).Times(1);
|
||||
|
||||
keyState.sendKeyEvent(NULL, false, false, kAKey, 0, 0, 0);
|
||||
}
|
||||
|
||||
TEST(CKeyStateTests, updateKeyMap_mockKeyMap_keyMapGotMock)
|
||||
{
|
||||
CMockKeyMap keyMap;
|
||||
CMockEventQueue eventQueue;
|
||||
CKeyStateImpl keyState(eventQueue, keyMap);
|
||||
|
||||
EXPECT_CALL(keyMap, swap(_));
|
||||
EXPECT_CALL(keyMap, finish());
|
||||
|
||||
keyState.updateKeyMap();
|
||||
}
|
||||
|
||||
void
|
||||
stubPollPressedKeys(IKeyState::KeyButtonSet& pressedKeys)
|
||||
{
|
||||
pressedKeys.insert(kAKey);
|
||||
}
|
||||
|
||||
TEST(CKeyStateTests, updateKeyState_pollInsertsSingleKey_keyIsDown)
|
||||
{
|
||||
NiceMock<CMockKeyMap> keyMap;
|
||||
CMockEventQueue eventQueue;
|
||||
CKeyStateImpl keyState(eventQueue, keyMap);
|
||||
ON_CALL(keyState, pollPressedKeys(_)).WillByDefault(Invoke(stubPollPressedKeys));
|
||||
|
||||
keyState.updateKeyState();
|
||||
|
||||
bool actual = keyState.isKeyDown(kAKey);
|
||||
ASSERT_TRUE(actual);
|
||||
}
|
||||
|
||||
TEST(CKeyStateTests, updateKeyState_pollDoesNothing_keyNotSet)
|
||||
{
|
||||
NiceMock<CMockKeyMap> keyMap;
|
||||
CMockEventQueue eventQueue;
|
||||
CKeyStateImpl keyState(eventQueue, keyMap);
|
||||
|
||||
keyState.updateKeyState();
|
||||
|
||||
bool actual = keyState.isKeyDown(kAKey);
|
||||
ASSERT_FALSE(actual);
|
||||
}
|
||||
|
||||
TEST(CKeyStateTests, updateKeyState_activeModifiers_maskSet)
|
||||
{
|
||||
NiceMock<CMockKeyMap> keyMap;
|
||||
CMockEventQueue eventQueue;
|
||||
CKeyStateImpl keyState(eventQueue, keyMap);
|
||||
ON_CALL(keyState, pollActiveModifiers()).WillByDefault(Return(KeyModifierAlt));
|
||||
|
||||
keyState.updateKeyState();
|
||||
|
||||
KeyModifierMask actual = keyState.getActiveModifiers();
|
||||
ASSERT_EQ(KeyModifierAlt, actual);
|
||||
}
|
||||
|
||||
TEST(CKeyStateTests, updateKeyState_activeModifiers_maskNotSet)
|
||||
{
|
||||
NiceMock<CMockKeyMap> keyMap;
|
||||
CMockEventQueue eventQueue;
|
||||
CKeyStateImpl keyState(eventQueue, keyMap);
|
||||
|
||||
keyState.updateKeyState();
|
||||
|
||||
KeyModifierMask actual = keyState.getActiveModifiers();
|
||||
ASSERT_EQ(0, actual);
|
||||
}
|
||||
|
||||
void
|
||||
assertMaskIsOne(ForeachKeyCallback cb, void* userData)
|
||||
{
|
||||
ASSERT_EQ(1, ((CKeyState::CAddActiveModifierContext*)userData)->m_mask);
|
||||
}
|
||||
|
||||
TEST(CKeyStateTests, updateKeyState_activeModifiers_keyMapGotModifers)
|
||||
{
|
||||
CMockKeyMap keyMap;
|
||||
CMockEventQueue eventQueue;
|
||||
CKeyStateImpl keyState(eventQueue, keyMap);
|
||||
EXPECT_CALL(keyMap, foreachKey(_, _));
|
||||
|
||||
ON_CALL(keyState, pollActiveModifiers()).WillByDefault(Return(1));
|
||||
ON_CALL(keyMap, foreachKey(_, _)).WillByDefault(Invoke(assertMaskIsOne));
|
||||
|
||||
keyState.updateKeyState();
|
||||
}
|
||||
|
||||
TEST(CKeyStateTests, setHalfDuplexMask_capsLock_halfDuplexCapsLockAdded)
|
||||
{
|
||||
CMockKeyMap keyMap;
|
||||
CMockEventQueue eventQueue;
|
||||
CKeyStateImpl keyState(eventQueue, keyMap);
|
||||
|
||||
EXPECT_CALL(keyMap, addHalfDuplexModifier(kKeyCapsLock));
|
||||
|
||||
keyState.setHalfDuplexMask(KeyModifierCapsLock);
|
||||
}
|
||||
|
||||
44
src/test/unittests/synergy/CMockEventQueue.h
Normal file
44
src/test/unittests/synergy/CMockEventQueue.h
Normal file
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* synergy -- mouse and keyboard sharing utility
|
||||
* Copyright (C) 2011 Chris Schoeneman, Nick Bolton, Sorin Sbarnea
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef CMOCKEVENTQUEUE_H
|
||||
#define CMOCKEVENTQUEUE_H
|
||||
|
||||
#include <gmock/gmock.h>
|
||||
#include "IEventQueue.h"
|
||||
|
||||
class CMockEventQueue : public IEventQueue
|
||||
{
|
||||
public:
|
||||
MOCK_METHOD2(newOneShotTimer, CEventQueueTimer*(double, void*));
|
||||
MOCK_METHOD2(newTimer, CEventQueueTimer*(double, void*));
|
||||
MOCK_METHOD2(getEvent, bool(CEvent&, double));
|
||||
MOCK_METHOD1(adoptBuffer, void(IEventQueueBuffer*));
|
||||
MOCK_METHOD2(registerTypeOnce, CEvent::Type(CEvent::Type&, const char*));
|
||||
MOCK_METHOD1(removeHandlers, void(void*));
|
||||
MOCK_METHOD1(registerType, CEvent::Type(const char*));
|
||||
MOCK_CONST_METHOD0(isEmpty, bool());
|
||||
MOCK_METHOD3(adoptHandler, void(CEvent::Type, void*, IEventJob*));
|
||||
MOCK_METHOD1(getTypeName, const char*(CEvent::Type));
|
||||
MOCK_METHOD1(addEvent, void(const CEvent&));
|
||||
MOCK_METHOD2(removeHandler, void(CEvent::Type, void*));
|
||||
MOCK_METHOD1(dispatchEvent, bool(const CEvent&));
|
||||
MOCK_CONST_METHOD2(getHandler, IEventJob*(CEvent::Type, void*));
|
||||
MOCK_METHOD1(deleteTimer, void(CEventQueueTimer*));
|
||||
};
|
||||
|
||||
#endif
|
||||
34
src/test/unittests/synergy/CMockKeyMap.h
Normal file
34
src/test/unittests/synergy/CMockKeyMap.h
Normal file
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* synergy -- mouse and keyboard sharing utility
|
||||
* Copyright (C) 2011 Chris Schoeneman, Nick Bolton, Sorin Sbarnea
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef CMOCKKEYMAP_H
|
||||
#define CMOCKKEYMAP_H
|
||||
|
||||
#include <gmock/gmock.h>
|
||||
#include "CKeyMap.h"
|
||||
|
||||
class CMockKeyMap : public CKeyMap
|
||||
{
|
||||
public:
|
||||
MOCK_METHOD1(swap, void(CKeyMap&));
|
||||
MOCK_METHOD0(finish, void());
|
||||
MOCK_METHOD2(foreachKey, void(ForeachKeyCallback, void*));
|
||||
MOCK_METHOD1(addHalfDuplexModifier, void(KeyID));
|
||||
MOCK_CONST_METHOD2(isHalfDuplex, bool(KeyID, KeyButton));
|
||||
};
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user