removed IPrimaryReceiver in favor of IServer, which required a few

minor changes to support IPrimaryReciever's functionality.  this
does mean that the IPrimaryScreen class will be calling some
methods with dummy arguments.  those are documented in
CPrimaryClient.
This commit is contained in:
crs 2002-07-10 14:15:17 +00:00
parent 64232c7854
commit f90076938b
12 changed files with 126 additions and 178 deletions

View File

@ -2,7 +2,6 @@
#include "CServer.h" #include "CServer.h"
#include "CClipboard.h" #include "CClipboard.h"
#include "CProtocolUtil.h" #include "CProtocolUtil.h"
#include "ProtocolTypes.h"
#include "XSynergy.h" #include "XSynergy.h"
#include "IInputStream.h" #include "IInputStream.h"
#include "IOutputStream.h" #include "IOutputStream.h"
@ -245,25 +244,25 @@ void
CClientProxy1_0::getShape(SInt32& x, SInt32& y, SInt32& w, SInt32& h) const CClientProxy1_0::getShape(SInt32& x, SInt32& y, SInt32& w, SInt32& h) const
{ {
CLock lock(&m_mutex); CLock lock(&m_mutex);
x = m_x; x = m_info.m_x;
y = m_y; y = m_info.m_y;
w = m_w; w = m_info.m_w;
h = m_h; h = m_info.m_h;
} }
void void
CClientProxy1_0::getCenter(SInt32& x, SInt32& y) const CClientProxy1_0::getCenter(SInt32& x, SInt32& y) const
{ {
CLock lock(&m_mutex); CLock lock(&m_mutex);
x = m_cx; x = m_info.m_mx;
y = m_cy; y = m_info.m_my;
} }
SInt32 SInt32
CClientProxy1_0::getJumpZoneSize() const CClientProxy1_0::getJumpZoneSize() const
{ {
CLock lock(&m_mutex); CLock lock(&m_mutex);
return m_zoneSize; return m_info.m_zoneSize;
} }
void void
@ -273,23 +272,32 @@ CClientProxy1_0::recvInfo(bool notify)
CLock lock(&m_mutex); CLock lock(&m_mutex);
// parse the message // parse the message
SInt16 x, y, w, h, zoneSize, mx, my;
CProtocolUtil::readf(getInputStream(), kMsgDInfo + 4, CProtocolUtil::readf(getInputStream(), kMsgDInfo + 4,
&m_x, &m_y, &m_w, &m_h, &x, &y, &w, &h, &zoneSize, &mx, &my);
&m_zoneSize, &m_cx, &m_cy); log((CLOG_DEBUG "received client \"%s\" info shape=%d,%d %dx%d, zone=%d, pos=%d,%d", getName().c_str(), x, y, w, h, zoneSize, mx, my));
log((CLOG_DEBUG "received client \"%s\" info shape=%d,%d %dx%d, zone=%d, pos=%d,%d", getName().c_str(), m_x, m_y, m_w, m_h, m_zoneSize, m_cx, m_cy));
// validate // validate
if (m_w <= 0 || m_h <= 0 || m_zoneSize < 0) { if (w <= 0 || h <= 0 || zoneSize < 0) {
throw XBadClient(); throw XBadClient();
} }
if (m_cx < m_x || m_cy < m_y || m_cx >= m_x + m_w || m_cy >= m_y + m_h) { if (mx < x || my < y || mx >= x + w || my >= y + h) {
throw XBadClient(); throw XBadClient();
} }
// save
m_info.m_x = x;
m_info.m_y = y;
m_info.m_w = w;
m_info.m_h = h;
m_info.m_zoneSize = zoneSize;
m_info.m_mx = mx;
m_info.m_my = my;
} }
// tell server of change // tell server of change
if (notify) { if (notify) {
getServer()->onInfoChanged(getName()); getServer()->onInfoChanged(getName(), m_info);
} }
// acknowledge receipt // acknowledge receipt
@ -333,5 +341,5 @@ CClientProxy1_0::recvGrabClipboard()
// send update. this calls us back to reset our clipboard dirty flag // send update. this calls us back to reset our clipboard dirty flag
// so don't hold a lock during the call. // so don't hold a lock during the call.
getServer()->onGrabClipboard(id, seqNum, getName()); getServer()->onGrabClipboard(getName(), id, seqNum);
} }

View File

@ -2,6 +2,7 @@
#define CCLIENTPROXY1_0_H #define CCLIENTPROXY1_0_H
#include "CClientProxy.h" #include "CClientProxy.h"
#include "ProtocolTypes.h"
#include "CMutex.h" #include "CMutex.h"
class CClientProxy1_0 : public CClientProxy { class CClientProxy1_0 : public CClientProxy {
@ -42,10 +43,7 @@ private:
private: private:
CMutex m_mutex; CMutex m_mutex;
SInt16 m_x, m_y; CClientInfo m_info;
SInt16 m_w, m_h;
SInt16 m_zoneSize;
SInt16 m_cx, m_cy;
bool m_clipboardDirty[kClipboardEnd]; bool m_clipboardDirty[kClipboardEnd];
}; };

View File

@ -75,27 +75,22 @@ CPrimaryClient::onError()
} }
void void
CPrimaryClient::onInfoChanged(SInt32 x, SInt32 y, SInt32 w, SInt32 h, CPrimaryClient::onInfoChanged(const CString&, const CClientInfo& info)
SInt32 zoneSize, SInt32 cx, SInt32 cy)
{ {
m_x = x; m_info = info;
m_y = y; m_server->onInfoChanged(getName(), m_info);
m_w = w;
m_h = h;
m_zoneSize = zoneSize;
m_cx = cx;
m_cy = cy;
m_server->onInfoChanged(getName());
} }
bool bool
CPrimaryClient::onGrabClipboard(ClipboardID id) CPrimaryClient::onGrabClipboard(const CString&, ClipboardID id, UInt32)
{ {
m_clipboardOwner[id] = m_server->onGrabClipboard(id, m_seqNum, getName()); bool result = m_server->onGrabClipboard(getName(), id, m_seqNum);
m_clipboardOwner[id] = result;
return result;
} }
bool void
CPrimaryClient::onClipboardChanged(ClipboardID id, const CString& data) CPrimaryClient::onClipboardChanged(ClipboardID id, UInt32, const CString& data)
{ {
m_server->onClipboardChanged(id, m_seqNum, data); m_server->onClipboardChanged(id, m_seqNum, data);
} }
@ -288,21 +283,21 @@ CPrimaryClient::getName() const
void void
CPrimaryClient::getShape(SInt32& x, SInt32& y, SInt32& w, SInt32& h) const CPrimaryClient::getShape(SInt32& x, SInt32& y, SInt32& w, SInt32& h) const
{ {
x = m_x; x = m_info.m_x;
y = m_y; y = m_info.m_y;
w = m_w; w = m_info.m_w;
h = m_h; h = m_info.m_h;
} }
void void
CPrimaryClient::getCenter(SInt32& x, SInt32& y) const CPrimaryClient::getCenter(SInt32& x, SInt32& y) const
{ {
x = m_cx; x = m_info.m_mx;
y = m_cy; y = m_info.m_my;
} }
SInt32 SInt32
CPrimaryClient::getJumpZoneSize() const CPrimaryClient::getJumpZoneSize() const
{ {
return m_zoneSize; return m_info.m_zoneSize;
} }

View File

@ -1,14 +1,15 @@
#ifndef CPRIMARYCLIENT_H #ifndef CPRIMARYCLIENT_H
#define CPRIMARYCLIENT_H #define CPRIMARYCLIENT_H
#include "IPrimaryReceiver.h" #include "IServer.h"
#include "IClient.h" #include "IClient.h"
#include "ProtocolTypes.h"
class IClipboard; class IClipboard;
class IPrimaryScreen; class IPrimaryScreen;
class IServer; class IServer;
class CPrimaryClient : public IPrimaryReceiver, public IClient { class CPrimaryClient : public IServer, public IClient {
public: public:
CPrimaryClient(IServer*, const CString& name); CPrimaryClient(IServer*, const CString& name);
~CPrimaryClient(); ~CPrimaryClient();
@ -32,14 +33,14 @@ public:
// returns the state of the toggle keys on the primary screen // returns the state of the toggle keys on the primary screen
KeyModifierMask getToggleMask() const; KeyModifierMask getToggleMask() const;
// IPrimaryReceiver overrides // IServer overrides
// onInfoChanged() ignores the client name.
// onGrabClipboard() ignores the client name and sequence number.
// onClipboardChanged() ignores the sequence number.
virtual void onError(); virtual void onError();
virtual void onInfoChanged(SInt32 xScreen, SInt32 yScreen, virtual void onInfoChanged(const CString&, const CClientInfo&);
SInt32 wScreen, SInt32 hScreen, virtual bool onGrabClipboard(const CString&, ClipboardID, UInt32);
SInt32 zoneSize, virtual void onClipboardChanged(ClipboardID, UInt32, const CString&);
SInt32 xMouse, SInt32 yMouse);
virtual bool onGrabClipboard(ClipboardID);
virtual bool onClipboardChanged(ClipboardID, const CString& data);
virtual void onKeyDown(KeyID, KeyModifierMask); virtual void onKeyDown(KeyID, KeyModifierMask);
virtual void onKeyUp(KeyID, KeyModifierMask); virtual void onKeyUp(KeyID, KeyModifierMask);
virtual void onKeyRepeat(KeyID, KeyModifierMask, SInt32 count); virtual void onKeyRepeat(KeyID, KeyModifierMask, SInt32 count);
@ -80,11 +81,8 @@ private:
IPrimaryScreen* m_screen; IPrimaryScreen* m_screen;
CString m_name; CString m_name;
UInt32 m_seqNum; UInt32 m_seqNum;
SInt16 m_x, m_y; CClientInfo m_info;
SInt16 m_w, m_h; bool m_clipboardOwner[kClipboardEnd]; // FIXME -- unneeded?
SInt16 m_zoneSize;
SInt16 m_cx, m_cy;
bool m_clipboardOwner[kClipboardEnd];
bool m_clipboardDirty[kClipboardEnd]; bool m_clipboardDirty[kClipboardEnd];
}; };

View File

@ -8,7 +8,7 @@
#include "ProtocolTypes.h" #include "ProtocolTypes.h"
#include "XScreen.h" #include "XScreen.h"
#include "XSynergy.h" #include "XSynergy.h"
#include "CNetworkAddress.h" // XXX #include "CNetworkAddress.h"
#include "IDataSocket.h" #include "IDataSocket.h"
#include "IListenSocket.h" #include "IListenSocket.h"
#include "ISocketFactory.h" #include "ISocketFactory.h"
@ -235,7 +235,7 @@ CServer::onError()
} }
void void
CServer::onInfoChanged(const CString& name) CServer::onInfoChanged(const CString& name, const CClientInfo& info)
{ {
CLock lock(&m_mutex); CLock lock(&m_mutex);
@ -249,17 +249,10 @@ CServer::onInfoChanged(const CString& name)
// update the remote mouse coordinates // update the remote mouse coordinates
if (client == m_active) { if (client == m_active) {
client->getCenter(m_x, m_y); m_x = info.m_mx;
m_y = info.m_my;
} }
log((CLOG_INFO "screen \"%s\" shape=%d,%d %dx%d zone=%d pos=%d,%d", name.c_str(), info.m_x, info.m_y, info.m_w, info.m_h, info.m_zoneSize, info.m_mx, info.m_my));
#ifndef NDEBUG
{
SInt32 x, y, w, h, mx, my;
client->getShape(x, y, w, h);
client->getCenter(mx, my);
log((CLOG_INFO "screen \"%s\" shape=%d,%d %dx%d zone=%d pos=%d,%d", name.c_str(), x, y, w, h, client->getJumpZoneSize(), m_x, m_y));
}
#endif
// handle resolution change to primary screen // handle resolution change to primary screen
if (client == m_primaryClient) { if (client == m_primaryClient) {
@ -272,27 +265,10 @@ CServer::onInfoChanged(const CString& name)
} }
} }
void bool
CServer::onGrabClipboard(ClipboardID id) CServer::onGrabClipboard(const CString& name, ClipboardID id, UInt32 seqNum)
{ {
CLock lock(&m_mutex); CLock lock(&m_mutex);
assert(m_primaryClient != NULL);
grabClipboardNoLock(id, 0, m_primaryClient->getName());
}
bool
CServer::onGrabClipboard(ClipboardID id, UInt32 seqNum, const CString& client)
{
CLock lock(&m_mutex);
return grabClipboardNoLock(id, seqNum, client);
}
bool
CServer::grabClipboardNoLock(ClipboardID id,
UInt32 seqNum, const CString& name)
{
// note -- must be locked on entry
CClipboardInfo& clipboard = m_clipboards[id];
// screen must be connected // screen must be connected
CClientList::iterator grabber = m_clients.find(name); CClientList::iterator grabber = m_clients.find(name);
@ -302,6 +278,7 @@ CServer::grabClipboardNoLock(ClipboardID id,
// ignore grab if sequence number is old. always allow primary // ignore grab if sequence number is old. always allow primary
// screen to grab. // screen to grab.
CClipboardInfo& clipboard = m_clipboards[id];
if (name != m_primaryClient->getName() && if (name != m_primaryClient->getName() &&
seqNum < clipboard.m_clipboardSeqNum) { seqNum < clipboard.m_clipboardSeqNum) {
log((CLOG_INFO "ignored screen \"%s\" grab of clipboard %d", name.c_str(), id)); log((CLOG_INFO "ignored screen \"%s\" grab of clipboard %d", name.c_str(), id));
@ -337,8 +314,7 @@ CServer::grabClipboardNoLock(ClipboardID id,
} }
void void
CServer::onClipboardChanged(ClipboardID id, CServer::onClipboardChanged(ClipboardID id, UInt32 seqNum, const CString& data)
UInt32 seqNum, const CString& data)
{ {
CLock lock(&m_mutex); CLock lock(&m_mutex);
onClipboardChangedNoLock(id, seqNum, data); onClipboardChangedNoLock(id, seqNum, data);
@ -760,7 +736,8 @@ CServer::switchScreen(IClient* dst, SInt32 x, SInt32 y, bool screenSaver)
if (clipboard.m_clipboardOwner == m_primaryClient->getName()) { if (clipboard.m_clipboardOwner == m_primaryClient->getName()) {
CString clipboardData; CString clipboardData;
m_primaryClient->getClipboard(id, clipboardData); m_primaryClient->getClipboard(id, clipboardData);
onClipboardChangedNoLock(id, m_seqNum, clipboardData); onClipboardChangedNoLock(id,
clipboard.m_clipboardSeqNum, clipboardData);
} }
} }
} }

View File

@ -4,10 +4,6 @@
#include "IServer.h" #include "IServer.h"
#include "CConfig.h" #include "CConfig.h"
#include "CClipboard.h" #include "CClipboard.h"
#include "ClipboardTypes.h"
#include "KeyTypes.h"
#include "MouseTypes.h"
#include "CNetworkAddress.h"
#include "CCondVar.h" #include "CCondVar.h"
#include "CMutex.h" #include "CMutex.h"
#include "CThread.h" #include "CThread.h"
@ -59,11 +55,9 @@ public:
// IServer overrides // IServer overrides
virtual void onError(); virtual void onError();
virtual void onInfoChanged(const CString& clientName); virtual void onInfoChanged(const CString&, const CClientInfo&);
virtual bool onGrabClipboard(ClipboardID, virtual bool onGrabClipboard(const CString&, ClipboardID, UInt32);
UInt32 seqNum, const CString& clientName); virtual void onClipboardChanged(ClipboardID, UInt32, const CString&);
virtual void onClipboardChanged(ClipboardID,
UInt32 seqNum, const CString& data);
virtual void onKeyDown(KeyID, KeyModifierMask); virtual void onKeyDown(KeyID, KeyModifierMask);
virtual void onKeyUp(KeyID, KeyModifierMask); virtual void onKeyUp(KeyID, KeyModifierMask);
virtual void onKeyRepeat(KeyID, KeyModifierMask, SInt32 count); virtual void onKeyRepeat(KeyID, KeyModifierMask, SInt32 count);
@ -72,7 +66,6 @@ public:
virtual bool onMouseMovePrimary(SInt32 x, SInt32 y); virtual bool onMouseMovePrimary(SInt32 x, SInt32 y);
virtual void onMouseMoveSecondary(SInt32 dx, SInt32 dy); virtual void onMouseMoveSecondary(SInt32 dx, SInt32 dy);
virtual void onMouseWheel(SInt32 delta); virtual void onMouseWheel(SInt32 delta);
virtual void onGrabClipboard(ClipboardID);
virtual void onScreenSaver(bool activated); virtual void onScreenSaver(bool activated);
protected: protected:
@ -85,10 +78,6 @@ private:
bool onMouseMovePrimaryNoLock(SInt32 x, SInt32 y); bool onMouseMovePrimaryNoLock(SInt32 x, SInt32 y);
void onMouseMoveSecondaryNoLock(SInt32 dx, SInt32 dy); void onMouseMoveSecondaryNoLock(SInt32 dx, SInt32 dy);
// grab the clipboard
bool grabClipboardNoLock(ClipboardID,
UInt32 seqNum, const CString& clientName);
// set the clipboard // set the clipboard
void onClipboardChangedNoLock(ClipboardID, void onClipboardChangedNoLock(ClipboardID,
UInt32 seqNum, const CString& data); UInt32 seqNum, const CString& data);

View File

@ -1,9 +1,10 @@
#include "CXWindowsPrimaryScreen.h" #include "CXWindowsPrimaryScreen.h"
#include "IPrimaryReceiver.h"
#include "CXWindowsClipboard.h" #include "CXWindowsClipboard.h"
#include "CXWindowsScreenSaver.h" #include "CXWindowsScreenSaver.h"
#include "CXWindowsUtil.h" #include "CXWindowsUtil.h"
#include "CClipboard.h" #include "CClipboard.h"
#include "IServer.h"
#include "ProtocolTypes.h"
#include "CThread.h" #include "CThread.h"
#include "CLog.h" #include "CLog.h"
#include "CStopwatch.h" #include "CStopwatch.h"
@ -20,8 +21,8 @@
// CXWindowsPrimaryScreen // CXWindowsPrimaryScreen
// //
CXWindowsPrimaryScreen::CXWindowsPrimaryScreen(IPrimaryReceiver* receiver) : CXWindowsPrimaryScreen::CXWindowsPrimaryScreen(IServer* server) :
m_receiver(receiver), m_server(server),
m_active(false), m_active(false),
m_window(None) m_window(None)
{ {
@ -66,7 +67,7 @@ CXWindowsPrimaryScreen::run()
if (xevent.xclient.message_type == m_atomScreenSaver || if (xevent.xclient.message_type == m_atomScreenSaver ||
xevent.xclient.format == 32) { xevent.xclient.format == 32) {
// screen saver activation/deactivation event // screen saver activation/deactivation event
m_receiver->onScreenSaver(xevent.xclient.data.l[0] != 0); m_server->onScreenSaver(xevent.xclient.data.l[0] != 0);
} }
break; break;
@ -76,12 +77,12 @@ CXWindowsPrimaryScreen::run()
const KeyModifierMask mask = mapModifier(xevent.xkey.state); const KeyModifierMask mask = mapModifier(xevent.xkey.state);
const KeyID key = mapKey(&xevent.xkey); const KeyID key = mapKey(&xevent.xkey);
if (key != kKeyNone) { if (key != kKeyNone) {
m_receiver->onKeyDown(key, mask); m_server->onKeyDown(key, mask);
if (key == XK_Caps_Lock && m_capsLockHalfDuplex) { if (key == XK_Caps_Lock && m_capsLockHalfDuplex) {
m_receiver->onKeyUp(key, mask | KeyModifierCapsLock); m_server->onKeyUp(key, mask | KeyModifierCapsLock);
} }
else if (key == XK_Num_Lock && m_numLockHalfDuplex) { else if (key == XK_Num_Lock && m_numLockHalfDuplex) {
m_receiver->onKeyUp(key, mask | KeyModifierNumLock); m_server->onKeyUp(key, mask | KeyModifierNumLock);
} }
} }
} }
@ -111,12 +112,12 @@ CXWindowsPrimaryScreen::run()
// no press event follows so it's a plain release // no press event follows so it's a plain release
log((CLOG_DEBUG1 "event: KeyRelease code=%d, state=0x%04x", xevent.xkey.keycode, xevent.xkey.state)); log((CLOG_DEBUG1 "event: KeyRelease code=%d, state=0x%04x", xevent.xkey.keycode, xevent.xkey.state));
if (key == XK_Caps_Lock && m_capsLockHalfDuplex) { if (key == XK_Caps_Lock && m_capsLockHalfDuplex) {
m_receiver->onKeyDown(key, mask); m_server->onKeyDown(key, mask);
} }
else if (key == XK_Num_Lock && m_numLockHalfDuplex) { else if (key == XK_Num_Lock && m_numLockHalfDuplex) {
m_receiver->onKeyDown(key, mask); m_server->onKeyDown(key, mask);
} }
m_receiver->onKeyUp(key, mask); m_server->onKeyUp(key, mask);
} }
else { else {
// found a press event following so it's a repeat. // found a press event following so it's a repeat.
@ -124,7 +125,7 @@ CXWindowsPrimaryScreen::run()
// repeats but we'll just send a repeat of 1. // repeats but we'll just send a repeat of 1.
// note that we discard the press event. // note that we discard the press event.
log((CLOG_DEBUG1 "event: repeat code=%d, state=0x%04x", xevent.xkey.keycode, xevent.xkey.state)); log((CLOG_DEBUG1 "event: repeat code=%d, state=0x%04x", xevent.xkey.keycode, xevent.xkey.state));
m_receiver->onKeyRepeat(key, mask, 1); m_server->onKeyRepeat(key, mask, 1);
} }
} }
} }
@ -135,7 +136,7 @@ CXWindowsPrimaryScreen::run()
log((CLOG_DEBUG1 "event: ButtonPress button=%d", xevent.xbutton.button)); log((CLOG_DEBUG1 "event: ButtonPress button=%d", xevent.xbutton.button));
const ButtonID button = mapButton(xevent.xbutton.button); const ButtonID button = mapButton(xevent.xbutton.button);
if (button != kButtonNone) { if (button != kButtonNone) {
m_receiver->onMouseDown(button); m_server->onMouseDown(button);
} }
} }
break; break;
@ -145,15 +146,15 @@ CXWindowsPrimaryScreen::run()
log((CLOG_DEBUG1 "event: ButtonRelease button=%d", xevent.xbutton.button)); log((CLOG_DEBUG1 "event: ButtonRelease button=%d", xevent.xbutton.button));
const ButtonID button = mapButton(xevent.xbutton.button); const ButtonID button = mapButton(xevent.xbutton.button);
if (button != kButtonNone) { if (button != kButtonNone) {
m_receiver->onMouseUp(button); m_server->onMouseUp(button);
} }
else if (xevent.xbutton.button == 4) { else if (xevent.xbutton.button == 4) {
// wheel forward (away from user) // wheel forward (away from user)
m_receiver->onMouseWheel(120); m_server->onMouseWheel(120);
} }
else if (xevent.xbutton.button == 5) { else if (xevent.xbutton.button == 5) {
// wheel backward (toward user) // wheel backward (toward user)
m_receiver->onMouseWheel(-120); m_server->onMouseWheel(-120);
} }
} }
break; break;
@ -184,7 +185,7 @@ CXWindowsPrimaryScreen::run()
} }
else if (!m_active) { else if (!m_active) {
// motion on primary screen // motion on primary screen
m_receiver->onMouseMovePrimary(m_x, m_y); m_server->onMouseMovePrimary(m_x, m_y);
} }
else { else {
// motion on secondary screen. warp mouse back to // motion on secondary screen. warp mouse back to
@ -215,7 +216,7 @@ CXWindowsPrimaryScreen::run()
// warping to the primary screen's enter position, // warping to the primary screen's enter position,
// effectively overriding it. // effectively overriding it.
if (x != 0 || y != 0) { if (x != 0 || y != 0) {
m_receiver->onMouseMoveSecondary(x, y); m_server->onMouseMoveSecondary(x, y);
} }
} }
} }
@ -269,8 +270,8 @@ CXWindowsPrimaryScreen::open()
} }
// save mouse position // save mouse position
m_x = x; m_x = mx;
m_y = y; m_y = my;
} }
// save position of center of screen // save position of center of screen
@ -278,7 +279,15 @@ CXWindowsPrimaryScreen::open()
m_yCenter = y + (h >> 1); m_yCenter = y + (h >> 1);
// send screen info // send screen info
m_receiver->onInfoChanged(x, y, w, h, 1, m_x, m_y); CClientInfo info;
info.m_x = x;
info.m_y = y;
info.m_w = w;
info.m_h = h;
info.m_zoneSize = 1;
info.m_mx = m_x;
info.m_my = m_y;
m_server->onInfoChanged("", info);
} }
void void
@ -586,14 +595,14 @@ void
CXWindowsPrimaryScreen::onUnexpectedClose() CXWindowsPrimaryScreen::onUnexpectedClose()
{ {
// tell server to shutdown // tell server to shutdown
m_receiver->onError(); m_server->onError();
} }
void void
CXWindowsPrimaryScreen::onLostClipboard(ClipboardID id) CXWindowsPrimaryScreen::onLostClipboard(ClipboardID id)
{ {
// tell server that the clipboard was grabbed locally // tell server that the clipboard was grabbed locally
m_receiver->onGrabClipboard(id); m_server->onGrabClipboard("", id, 0);
} }
void void

View File

@ -5,11 +5,11 @@
#include "IPrimaryScreen.h" #include "IPrimaryScreen.h"
#include "MouseTypes.h" #include "MouseTypes.h"
class IPrimaryReceiver; class IServer;
class CXWindowsPrimaryScreen : public CXWindowsScreen, public IPrimaryScreen { class CXWindowsPrimaryScreen : public CXWindowsScreen, public IPrimaryScreen {
public: public:
CXWindowsPrimaryScreen(IPrimaryReceiver*); CXWindowsPrimaryScreen(IServer*);
virtual ~CXWindowsPrimaryScreen(); virtual ~CXWindowsPrimaryScreen();
// IPrimaryScreen overrides // IPrimaryScreen overrides
@ -60,7 +60,7 @@ private:
static Bool findKeyEvent(Display*, XEvent* xevent, XPointer arg); static Bool findKeyEvent(Display*, XEvent* xevent, XPointer arg);
private: private:
IPrimaryReceiver* m_receiver; IServer* m_server;
bool m_active; bool m_active;
Window m_window; Window m_window;

View File

@ -1,46 +0,0 @@
#ifndef IPRIMARYRECEIVER_H
#define IPRIMARYRECEIVER_H
#include "IInterface.h"
#include "ClipboardTypes.h"
#include "KeyTypes.h"
#include "MouseTypes.h"
#include "CString.h"
class IPrimaryReceiver : public IInterface {
public:
// manipulators
// notify of serious error. this implies that the primary screen
// cannot continue to function.
virtual void onError() = 0;
// notify of info change
virtual void onInfoChanged(SInt32 xScreen, SInt32 yScreen,
SInt32 wScreen, SInt32 hScreen,
SInt32 zoneSize,
SInt32 xMouse, SInt32 yMouse) = 0;
// notify of clipboard grab. returns true if the grab was honored,
// false otherwise.
virtual bool onGrabClipboard(ClipboardID) = 0;
// notify of new clipboard data. returns true if the clipboard data
// was accepted, false if the change was rejected.
virtual bool onClipboardChanged(ClipboardID,
const CString& data) = 0;
// call to notify of events. onMouseMovePrimary() returns
// true iff the mouse enters a jump zone and jumps.
virtual void onKeyDown(KeyID, KeyModifierMask) = 0;
virtual void onKeyUp(KeyID, KeyModifierMask) = 0;
virtual void onKeyRepeat(KeyID, KeyModifierMask, SInt32 count) = 0;
virtual void onMouseDown(ButtonID) = 0;
virtual void onMouseUp(ButtonID) = 0;
virtual bool onMouseMovePrimary(SInt32 x, SInt32 y) = 0;
virtual void onMouseMoveSecondary(SInt32 dx, SInt32 dy) = 0;
virtual void onMouseWheel(SInt32 delta) = 0;
virtual void onScreenSaver(bool activated) = 0;
};
#endif

View File

@ -19,7 +19,6 @@ synergyd_SOURCES = \
CPrimaryClient.h \ CPrimaryClient.h \
CServer.h \ CServer.h \
CXWindowsPrimaryScreen.h \ CXWindowsPrimaryScreen.h \
IPrimaryReceiver.h \
IPrimaryScreen.h \ IPrimaryScreen.h \
$(NULL) $(NULL)
synergyd_LDADD = \ synergyd_LDADD = \

View File

@ -7,6 +7,8 @@
#include "MouseTypes.h" #include "MouseTypes.h"
#include "CString.h" #include "CString.h"
class CClientInfo;
class IServer : public IInterface { class IServer : public IInterface {
public: public:
// manipulators // manipulators
@ -15,13 +17,14 @@ public:
// shutdown. // shutdown.
virtual void onError() = 0; virtual void onError() = 0;
// notify of client info change (maybe IClient should be named IScreen) // notify of client info change
virtual void onInfoChanged(const CString& clientName) = 0; virtual void onInfoChanged(const CString& clientName,
const CClientInfo&) = 0;
// notify of clipboard grab. returns true if the grab was honored, // notify of clipboard grab. returns true if the grab was honored,
// false otherwise. // false otherwise.
virtual bool onGrabClipboard(ClipboardID, virtual bool onGrabClipboard(const CString& clientName,
UInt32 seqNum, const CString& clientName) = 0; ClipboardID, UInt32 seqNum) = 0;
// notify of new clipboard data // notify of new clipboard data
virtual void onClipboardChanged(ClipboardID, virtual void onClipboardChanged(ClipboardID,

View File

@ -159,5 +159,23 @@ static const char kMsgEUnknown[] = "EUNK";
// primary should disconnect after sending this message. // primary should disconnect after sending this message.
static const char kMsgEBad[] = "EBAD"; static const char kMsgEBad[] = "EBAD";
//
// structures
//
class CClientInfo {
public:
// the coordinates of the screen
SInt32 m_x, m_y;
SInt32 m_w, m_h;
// the size of the jump zone
SInt32 m_zoneSize;
// mouse position
SInt32 m_mx, m_my;
};
#endif #endif