2002-07-09 21:22:31 +00:00
|
|
|
#include "CPrimaryClient.h"
|
2002-07-30 18:31:00 +00:00
|
|
|
#include "IPrimaryScreenFactory.h"
|
2002-07-09 21:22:31 +00:00
|
|
|
#include "IServer.h"
|
2002-07-31 12:39:34 +00:00
|
|
|
#include "XScreen.h"
|
2002-07-29 16:06:52 +00:00
|
|
|
#include "XSynergy.h"
|
2002-07-13 22:00:38 +00:00
|
|
|
#include "CPrimaryScreen.h"
|
2002-07-09 21:22:31 +00:00
|
|
|
#include "CClipboard.h"
|
|
|
|
#include "CLog.h"
|
|
|
|
|
|
|
|
//
|
|
|
|
// CPrimaryClient
|
|
|
|
//
|
|
|
|
|
2002-07-30 18:31:00 +00:00
|
|
|
CPrimaryClient::CPrimaryClient(IPrimaryScreenFactory* screenFactory,
|
|
|
|
IServer* server,
|
|
|
|
IPrimaryScreenReceiver* receiver,
|
|
|
|
const CString& name) :
|
2002-07-09 21:22:31 +00:00
|
|
|
m_server(server),
|
|
|
|
m_name(name),
|
|
|
|
m_seqNum(0)
|
|
|
|
{
|
|
|
|
assert(m_server != NULL);
|
|
|
|
|
|
|
|
// create screen
|
|
|
|
log((CLOG_DEBUG1 "creating primary screen"));
|
2002-07-31 12:39:34 +00:00
|
|
|
if (screenFactory != NULL) {
|
|
|
|
m_screen = screenFactory->create(this, receiver);
|
|
|
|
}
|
|
|
|
if (m_screen == NULL) {
|
|
|
|
throw XScreenOpenFailure();
|
|
|
|
}
|
2002-07-09 21:22:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
CPrimaryClient::~CPrimaryClient()
|
|
|
|
{
|
2002-07-24 13:01:18 +00:00
|
|
|
log((CLOG_DEBUG1 "destroying primary screen"));
|
2002-07-09 21:22:31 +00:00
|
|
|
delete m_screen;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2002-07-30 15:17:44 +00:00
|
|
|
CPrimaryClient::exitMainLoop()
|
2002-07-09 21:22:31 +00:00
|
|
|
{
|
2002-07-30 15:17:44 +00:00
|
|
|
m_screen->exitMainLoop();
|
2002-07-09 21:22:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2002-07-11 13:13:37 +00:00
|
|
|
CPrimaryClient::reconfigure(UInt32 activeSides)
|
2002-07-09 21:22:31 +00:00
|
|
|
{
|
2002-07-11 13:13:37 +00:00
|
|
|
m_screen->reconfigure(activeSides);
|
2002-07-09 21:22:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CPrimaryClient::getClipboard(ClipboardID id, CString& data) const
|
|
|
|
{
|
|
|
|
CClipboard clipboard;
|
|
|
|
m_screen->getClipboard(id, &clipboard);
|
|
|
|
data = clipboard.marshall();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
CPrimaryClient::isLockedToScreen() const
|
|
|
|
{
|
|
|
|
return m_screen->isLockedToScreen();
|
|
|
|
}
|
|
|
|
|
|
|
|
KeyModifierMask
|
|
|
|
CPrimaryClient::getToggleMask() const
|
|
|
|
{
|
|
|
|
return m_screen->getToggleMask();
|
|
|
|
}
|
|
|
|
|
2002-07-16 16:52:26 +00:00
|
|
|
void
|
|
|
|
CPrimaryClient::onError()
|
|
|
|
{
|
|
|
|
// forward to server
|
|
|
|
m_server->onError();
|
|
|
|
}
|
|
|
|
|
2002-07-09 21:22:31 +00:00
|
|
|
void
|
2002-07-10 21:22:28 +00:00
|
|
|
CPrimaryClient::onInfoChanged(const CClientInfo& info)
|
2002-07-09 21:22:31 +00:00
|
|
|
{
|
2002-07-10 14:15:17 +00:00
|
|
|
m_info = info;
|
2002-07-29 16:06:52 +00:00
|
|
|
try {
|
|
|
|
m_server->onInfoChanged(getName(), m_info);
|
|
|
|
}
|
|
|
|
catch (XBadClient&) {
|
|
|
|
// ignore
|
|
|
|
}
|
2002-07-09 21:22:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2002-07-10 21:22:28 +00:00
|
|
|
CPrimaryClient::onGrabClipboard(ClipboardID id)
|
2002-07-09 21:22:31 +00:00
|
|
|
{
|
2002-07-29 16:06:52 +00:00
|
|
|
try {
|
|
|
|
return m_server->onGrabClipboard(getName(), id, m_seqNum);
|
|
|
|
}
|
|
|
|
catch (XBadClient&) {
|
|
|
|
return false;
|
|
|
|
}
|
2002-07-09 21:22:31 +00:00
|
|
|
}
|
|
|
|
|
2002-07-10 14:15:17 +00:00
|
|
|
void
|
2002-07-10 21:22:28 +00:00
|
|
|
CPrimaryClient::onClipboardChanged(ClipboardID id, const CString& data)
|
2002-07-09 21:22:31 +00:00
|
|
|
{
|
|
|
|
m_server->onClipboardChanged(id, m_seqNum, data);
|
|
|
|
}
|
|
|
|
|
2002-07-31 12:39:34 +00:00
|
|
|
void
|
2002-07-09 21:22:31 +00:00
|
|
|
CPrimaryClient::open()
|
|
|
|
{
|
2002-07-16 16:52:26 +00:00
|
|
|
// all clipboards are clean
|
2002-07-09 21:22:31 +00:00
|
|
|
for (UInt32 i = 0; i < kClipboardEnd; ++i) {
|
|
|
|
m_clipboardDirty[i] = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// now open the screen
|
|
|
|
m_screen->open();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2002-07-30 15:17:44 +00:00
|
|
|
CPrimaryClient::mainLoop()
|
2002-07-09 21:22:31 +00:00
|
|
|
{
|
2002-07-30 15:17:44 +00:00
|
|
|
m_screen->mainLoop();
|
2002-07-09 21:22:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CPrimaryClient::close()
|
|
|
|
{
|
|
|
|
m_screen->close();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CPrimaryClient::enter(SInt32 xAbs, SInt32 yAbs,
|
|
|
|
UInt32 seqNum, KeyModifierMask, bool screensaver)
|
|
|
|
{
|
|
|
|
// note -- we must not call any server methods except onError().
|
|
|
|
m_seqNum = seqNum;
|
|
|
|
m_screen->enter(xAbs, yAbs, screensaver);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
CPrimaryClient::leave()
|
|
|
|
{
|
|
|
|
// note -- we must not call any server methods except onError().
|
|
|
|
return m_screen->leave();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CPrimaryClient::setClipboard(ClipboardID id, const CString& data)
|
|
|
|
{
|
|
|
|
// note -- we must not call any server methods except onError().
|
|
|
|
|
|
|
|
// ignore if this clipboard is already clean
|
|
|
|
if (m_clipboardDirty[id]) {
|
|
|
|
// this clipboard is now clean
|
|
|
|
m_clipboardDirty[id] = false;
|
|
|
|
|
|
|
|
// unmarshall data
|
|
|
|
CClipboard clipboard;
|
|
|
|
clipboard.unmarshall(data, 0);
|
|
|
|
|
|
|
|
// set clipboard
|
|
|
|
m_screen->setClipboard(id, &clipboard);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CPrimaryClient::grabClipboard(ClipboardID id)
|
|
|
|
{
|
|
|
|
// grab clipboard
|
|
|
|
m_screen->grabClipboard(id);
|
|
|
|
|
|
|
|
// clipboard is dirty (because someone else owns it now)
|
|
|
|
m_clipboardDirty[id] = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CPrimaryClient::setClipboardDirty(ClipboardID id, bool dirty)
|
|
|
|
{
|
|
|
|
m_clipboardDirty[id] = dirty;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CPrimaryClient::keyDown(KeyID, KeyModifierMask)
|
|
|
|
{
|
|
|
|
// ignore
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CPrimaryClient::keyRepeat(KeyID, KeyModifierMask, SInt32)
|
|
|
|
{
|
|
|
|
// ignore
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CPrimaryClient::keyUp(KeyID, KeyModifierMask)
|
|
|
|
{
|
|
|
|
// ignore
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CPrimaryClient::mouseDown(ButtonID)
|
|
|
|
{
|
|
|
|
// ignore
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CPrimaryClient::mouseUp(ButtonID)
|
|
|
|
{
|
|
|
|
// ignore
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CPrimaryClient::mouseMove(SInt32 x, SInt32 y)
|
|
|
|
{
|
|
|
|
m_screen->warpCursor(x, y);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CPrimaryClient::mouseWheel(SInt32)
|
|
|
|
{
|
|
|
|
// ignore
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2002-07-13 22:00:38 +00:00
|
|
|
CPrimaryClient::screensaver(bool)
|
2002-07-09 21:22:31 +00:00
|
|
|
{
|
|
|
|
// ignore
|
|
|
|
}
|
|
|
|
|
|
|
|
CString
|
|
|
|
CPrimaryClient::getName() const
|
|
|
|
{
|
|
|
|
return m_name;
|
|
|
|
}
|
|
|
|
|
2002-07-13 22:00:38 +00:00
|
|
|
SInt32
|
|
|
|
CPrimaryClient::getJumpZoneSize() const
|
|
|
|
{
|
|
|
|
return m_info.m_zoneSize;
|
|
|
|
}
|
|
|
|
|
2002-07-09 21:22:31 +00:00
|
|
|
void
|
|
|
|
CPrimaryClient::getShape(SInt32& x, SInt32& y, SInt32& w, SInt32& h) const
|
|
|
|
{
|
2002-07-10 14:15:17 +00:00
|
|
|
x = m_info.m_x;
|
|
|
|
y = m_info.m_y;
|
|
|
|
w = m_info.m_w;
|
|
|
|
h = m_info.m_h;
|
2002-07-09 21:22:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2002-07-13 22:00:38 +00:00
|
|
|
CPrimaryClient::getCursorPos(SInt32&, SInt32&) const
|
2002-07-10 20:18:32 +00:00
|
|
|
{
|
|
|
|
assert(0 && "shouldn't be called");
|
|
|
|
}
|
|
|
|
|
2002-07-13 22:00:38 +00:00
|
|
|
void
|
|
|
|
CPrimaryClient::getCursorCenter(SInt32& x, SInt32& y) const
|
2002-07-09 21:22:31 +00:00
|
|
|
{
|
2002-07-13 22:00:38 +00:00
|
|
|
x = m_info.m_mx;
|
|
|
|
y = m_info.m_my;
|
2002-07-09 21:22:31 +00:00
|
|
|
}
|