more refactoring.

This commit is contained in:
crs 2002-07-10 21:22:28 +00:00
parent 710e1bdd47
commit 3468f3d503
16 changed files with 176 additions and 276 deletions

View File

@ -28,7 +28,6 @@ CClient::CClient(const CString& clientName) :
m_server(NULL),
m_camp(false),
m_active(false),
m_seqNum(0),
m_rejected(true)
{
// do nothing
@ -66,18 +65,29 @@ CClient::wasRejected() const
}
void
CClient::onClipboardChanged(ClipboardID id)
CClient::onInfoChanged(const CClientInfo& info)
{
log((CLOG_DEBUG "resolution changed"));
CLock lock(&m_mutex);
if (m_server != NULL) {
m_server->onInfoChanged(info);
}
}
bool
CClient::onGrabClipboard(ClipboardID id)
{
CLock lock(&m_mutex);
if (m_server == NULL) {
// m_server can be NULL if the screen calls this method
// before we've gotten around to connecting to the server.
// we simply ignore the clipboard change in that case.
return;
return false;
}
// grab ownership
m_server->onGrabClipboard(m_name, id, m_seqNum);
m_server->onGrabClipboard(id);
// we now own the clipboard and it has not been sent to the server
m_ownClipboard[id] = true;
@ -88,21 +98,14 @@ CClient::onClipboardChanged(ClipboardID id)
if (!m_active) {
sendClipboard(id);
}
return true;
}
void
CClient::onResolutionChanged()
CClient::onClipboardChanged(ClipboardID, const CString&)
{
log((CLOG_DEBUG "resolution changed"));
CLock lock(&m_mutex);
if (m_server != NULL) {
CClientInfo info;
m_screen->getShape(info.m_x, info.m_y, info.m_w, info.m_h);
m_screen->getMousePos(info.m_mx, info.m_my);
info.m_zoneSize = m_screen->getJumpZoneSize();
m_server->onInfoChanged("", info);
}
// ignore -- we'll check the clipboard when we leave
}
bool
@ -194,7 +197,6 @@ CClient::enter(SInt32 xAbs, SInt32 yAbs,
{
CLock lock(&m_mutex);
m_active = true;
m_seqNum = seqNum;
}
m_screen->enter(xAbs, yAbs, mask);
@ -337,9 +339,6 @@ CClient::openSecondaryScreen()
// not active
m_active = false;
// reset last sequence number
m_seqNum = 0;
// reset clipboard state
for (ClipboardID id = 0; id < kClipboardEnd; ++id) {
m_ownClipboard[id] = false;
@ -349,12 +348,12 @@ CClient::openSecondaryScreen()
// open screen
log((CLOG_DEBUG1 "creating secondary screen"));
#if WINDOWS_LIKE
m_screen = new CMSWindowsSecondaryScreen;
m_screen = new CMSWindowsSecondaryScreen(this);
#elif UNIX_LIKE
m_screen = new CXWindowsSecondaryScreen;
m_screen = new CXWindowsSecondaryScreen(this);
#endif
log((CLOG_DEBUG1 "opening secondary screen"));
m_screen->open(this);
m_screen->open();
}
void
@ -406,7 +405,7 @@ CClient::sendClipboard(ClipboardID id)
// save and send data if different
if (data != m_dataClipboard[id]) {
m_dataClipboard[id] = data;
m_server->onClipboardChanged(id, m_seqNum, data);
m_server->onClipboardChanged(id, data);
}
}
}

View File

@ -1,6 +1,7 @@
#ifndef CCLIENT_H
#define CCLIENT_H
#include "IScreenReceiver.h"
#include "IClient.h"
#include "IClipboard.h"
#include "CNetworkAddress.h"
@ -10,9 +11,9 @@ class CServerProxy;
class CThread;
class IDataSocket;
class ISecondaryScreen;
class IServer;
class IScreenReceiver;
class CClient : public IClient {
class CClient : public IScreenReceiver, public IClient {
public:
CClient(const CString& clientName);
~CClient();
@ -32,31 +33,21 @@ public:
// after a successful open().
void quit();
// handle events on client's screen
// FIXME -- this should mimic methods on IServer
// FIXME -- maybe create a IScreenReceiver with these methods and
// have CPrimaryClient and CClient inherit from them. IServer
// still needs similar methods with extra parameters, though. so
// CServerProxy
// CPrimaryClient
// CClient
// need IScreenReceiver. these classes effective receive notifications
// from screens. note that there's another class of notifications that
// only the server needs (key, mouyse, screensaver). so maybe we have
// IPrimaryScreenReceiver and ISecondaryScreenReceiver (the latter is
// derived with no extra methods from IScreenReceiver).
void onClipboardChanged(ClipboardID);
void onResolutionChanged();
// accessors
// returns true if the server rejected us
bool wasRejected() const;
// IScreenReceiver overrides
virtual void onInfoChanged(const CClientInfo&);
virtual bool onGrabClipboard(ClipboardID);
virtual void onClipboardChanged(ClipboardID, const CString&);
// IClient overrides
virtual bool open();
virtual void run();
virtual void close();
// FIXME -- can we avoid passing everything here?
virtual void enter(SInt32 xAbs, SInt32 yAbs,
UInt32 seqNum, KeyModifierMask mask,
bool screenSaver);
@ -97,11 +88,10 @@ private:
CMutex m_mutex;
CString m_name;
ISecondaryScreen* m_screen;
IServer* m_server;
IScreenReceiver* m_server;
CNetworkAddress m_serverAddress;
bool m_camp;
bool m_active;
UInt32 m_seqNum;
bool m_rejected;
bool m_ownClipboard[kClipboardEnd];
IClipboard::Time m_timeClipboard[kClipboardEnd];

View File

@ -18,7 +18,8 @@ CServerProxy::CServerProxy(IClient* client,
IInputStream* input, IOutputStream* output) :
m_client(client),
m_input(input),
m_output(output)
m_output(output),
m_seqNum(0)
{
assert(m_client != NULL);
assert(m_input != NULL);
@ -42,6 +43,9 @@ CServerProxy::run()
// not ignoring mouse motions
m_ignoreMouse = false;
// reset sequence number
m_seqNum = 0;
// handle messages from server
CStopwatch heartbeat;
for (;;) {
@ -218,13 +222,7 @@ CServerProxy::getOutputStream() const
}
void
CServerProxy::onError()
{
// ignore
}
void
CServerProxy::onInfoChanged(const CString&, const CClientInfo& info)
CServerProxy::onInfoChanged(const CClientInfo& info)
{
// ignore mouse motion until we receive acknowledgment of our info
// change message.
@ -236,74 +234,19 @@ CServerProxy::onInfoChanged(const CString&, const CClientInfo& info)
}
bool
CServerProxy::onGrabClipboard(const CString&, ClipboardID id, UInt32 seqNum)
CServerProxy::onGrabClipboard(ClipboardID id)
{
log((CLOG_DEBUG1 "sending clipboard %d changed", id));
CLock lock(&m_mutex);
CProtocolUtil::writef(getOutputStream(), kMsgCClipboard, id, seqNum);
CProtocolUtil::writef(getOutputStream(), kMsgCClipboard, id, m_seqNum);
}
void
CServerProxy::onClipboardChanged(ClipboardID id,
UInt32 seqNum, const CString& data)
CServerProxy::onClipboardChanged(ClipboardID id, const CString& data)
{
log((CLOG_DEBUG1 "sending clipboard %d seqnum=%d, size=%d", id, seqNum, data.size()));
CLock lock(&m_mutex);
CProtocolUtil::writef(getOutputStream(), kMsgDClipboard, id, seqNum, &data);
}
void
CServerProxy::onKeyDown(KeyID, KeyModifierMask)
{
// ignore
}
void
CServerProxy::onKeyUp(KeyID, KeyModifierMask)
{
// ignore
}
void
CServerProxy::onKeyRepeat(KeyID, KeyModifierMask, SInt32)
{
// ignore
}
void
CServerProxy::onMouseDown(ButtonID)
{
// ignore
}
void
CServerProxy::onMouseUp(ButtonID)
{
// ignore
}
bool
CServerProxy::onMouseMovePrimary(SInt32, SInt32)
{
return false;
}
void
CServerProxy::onMouseMoveSecondary(SInt32, SInt32)
{
// ignore
}
void
CServerProxy::onMouseWheel(SInt32)
{
// ignore
}
void
CServerProxy::onScreenSaver(bool)
{
// ignore
log((CLOG_DEBUG1 "sending clipboard %d seqnum=%d, size=%d", id, m_seqNum, data.size()));
CProtocolUtil::writef(getOutputStream(), kMsgDClipboard, id, m_seqNum, &data);
}
void
@ -353,6 +296,7 @@ CServerProxy::enter()
{
CLock lock(&m_mutex);
m_compressMouse = false;
m_seqNum = seqNum;
}
// forward

View File

@ -1,14 +1,14 @@
#ifndef CSERVERPROXY_H
#define CSERVERPROXY_H
#include "IServer.h"
#include "IScreenReceiver.h"
#include "CMutex.h"
class IClient;
class IInputStream;
class IOutputStream;
class CServerProxy : public IServer {
class CServerProxy : public IScreenReceiver {
public:
CServerProxy(IClient* client,
IInputStream* adoptedInput,
@ -33,23 +33,10 @@ public:
IInputStream* getInputStream() const;
IOutputStream* getOutputStream() const;
// IServer overrides
virtual void onError();
virtual void onInfoChanged(const CString& clientName,
const CClientInfo&);
virtual bool onGrabClipboard(const CString& clientName,
ClipboardID, UInt32 seqNum);
virtual void onClipboardChanged(ClipboardID,
UInt32 seqNum, const CString& data);
virtual void onKeyDown(KeyID, KeyModifierMask);
virtual void onKeyUp(KeyID, KeyModifierMask);
virtual void onKeyRepeat(KeyID, KeyModifierMask, SInt32 count);
virtual void onMouseDown(ButtonID);
virtual void onMouseUp(ButtonID);
virtual bool onMouseMovePrimary(SInt32 x, SInt32 y);
virtual void onMouseMoveSecondary(SInt32 dx, SInt32 dy);
virtual void onMouseWheel(SInt32 delta);
virtual void onScreenSaver(bool activated);
// IScreenReceiver overrides
virtual void onInfoChanged(const CClientInfo&);
virtual bool onGrabClipboard(ClipboardID);
virtual void onClipboardChanged(ClipboardID, const CString& data);
private:
// if compressing mouse motion then send the last motion now
@ -80,6 +67,8 @@ private:
IInputStream* m_input;
IOutputStream* m_output;
UInt32 m_seqNum;
bool m_compressMouse;
SInt32 m_xMouse, m_yMouse;

View File

@ -24,8 +24,8 @@
// CXWindowsSecondaryScreen
//
CXWindowsSecondaryScreen::CXWindowsSecondaryScreen() :
m_client(NULL),
CXWindowsSecondaryScreen::CXWindowsSecondaryScreen(IScreenReceiver* receiver) :
m_receiver(receiver),
m_window(None)
{
// do nothing
@ -82,13 +82,9 @@ CXWindowsSecondaryScreen::stop()
}
void
CXWindowsSecondaryScreen::open(CClient* client)
CXWindowsSecondaryScreen::open()
{
assert(m_client == NULL);
assert(client != NULL);
// set the client
m_client = client;
assert(m_receiver != NULL);
// open the display
openDisplay();
@ -128,8 +124,6 @@ CXWindowsSecondaryScreen::open(CClient* client)
void
CXWindowsSecondaryScreen::close()
{
assert(m_client != NULL);
// release keys that are logically pressed
releaseKeys();
@ -138,9 +132,6 @@ CXWindowsSecondaryScreen::close()
// close the display
closeDisplay();
// done with client
m_client = NULL;
}
void
@ -396,7 +387,7 @@ void
CXWindowsSecondaryScreen::onLostClipboard(ClipboardID id)
{
// tell client that the clipboard was grabbed locally
m_client->onClipboardChanged(id);
m_receiver->onGrabClipboard(id);
}
void

View File

@ -6,16 +6,18 @@
#include "stdmap.h"
#include "stdvector.h"
class IScreenReceiver;
class CXWindowsSecondaryScreen : public CXWindowsScreen,
public ISecondaryScreen {
public:
CXWindowsSecondaryScreen();
CXWindowsSecondaryScreen(IScreenReceiver*);
virtual ~CXWindowsSecondaryScreen();
// ISecondaryScreen overrides
virtual void run();
virtual void stop();
virtual void open(CClient*);
virtual void open();
virtual void close();
virtual void enter(SInt32 xAbsolute, SInt32 yAbsolute,
KeyModifierMask mask);
@ -81,7 +83,7 @@ private:
static bool isToggleKeysym(KeySym);
private:
CClient* m_client;
IScreenReceiver* m_receiver;
Window m_window;
// note toggle keys that toggles on up/down (false) or on

View File

@ -6,7 +6,6 @@
#include "KeyTypes.h"
#include "MouseTypes.h"
class CClient;
class IClipboard;
class ISecondaryScreen : public IInterface {
@ -23,9 +22,9 @@ public:
virtual void stop() = 0;
// initialize the screen, hide the cursor, and disable the screen
// saver. start reporting certain events to the client (clipboard
// stolen and screen size changed).
virtual void open(CClient*) = 0;
// saver. start reporting events to the IScreenReceiver (which is
// set through some other interface).
virtual void open() = 0;
// close the screen. should restore the screen saver. it should
// also simulate key up events for any keys that have simulate key

View File

@ -25,9 +25,9 @@ CPrimaryClient::CPrimaryClient(IServer* server, const CString& name) :
// create screen
log((CLOG_DEBUG1 "creating primary screen"));
#if WINDOWS_LIKE
m_screen = new CMSWindowsPrimaryScreen(this);
m_screen = new CMSWindowsPrimaryScreen(this, m_server);
#elif UNIX_LIKE
m_screen = new CXWindowsPrimaryScreen(this);
m_screen = new CXWindowsPrimaryScreen(this, m_server);
#endif
}
@ -69,20 +69,14 @@ CPrimaryClient::getToggleMask() const
}
void
CPrimaryClient::onError()
{
m_server->onError();
}
void
CPrimaryClient::onInfoChanged(const CString&, const CClientInfo& info)
CPrimaryClient::onInfoChanged(const CClientInfo& info)
{
m_info = info;
m_server->onInfoChanged(getName(), m_info);
}
bool
CPrimaryClient::onGrabClipboard(const CString&, ClipboardID id, UInt32)
CPrimaryClient::onGrabClipboard(ClipboardID id)
{
bool result = m_server->onGrabClipboard(getName(), id, m_seqNum);
m_clipboardOwner[id] = result;
@ -90,65 +84,11 @@ CPrimaryClient::onGrabClipboard(const CString&, ClipboardID id, UInt32)
}
void
CPrimaryClient::onClipboardChanged(ClipboardID id, UInt32, const CString& data)
CPrimaryClient::onClipboardChanged(ClipboardID id, const CString& data)
{
m_server->onClipboardChanged(id, m_seqNum, data);
}
void
CPrimaryClient::onKeyDown(KeyID id, KeyModifierMask mask)
{
m_server->onKeyDown(id, mask);
}
void
CPrimaryClient::onKeyUp(KeyID id, KeyModifierMask mask)
{
m_server->onKeyUp(id, mask);
}
void
CPrimaryClient::onKeyRepeat(KeyID id, KeyModifierMask mask, SInt32 count)
{
m_server->onKeyRepeat(id, mask, count);
}
void
CPrimaryClient::onMouseDown(ButtonID id)
{
m_server->onMouseDown(id);
}
void
CPrimaryClient::onMouseUp(ButtonID id)
{
m_server->onMouseUp(id);
}
bool
CPrimaryClient::onMouseMovePrimary(SInt32 x, SInt32 y)
{
return m_server->onMouseMovePrimary(x, y);
}
void
CPrimaryClient::onMouseMoveSecondary(SInt32 dx, SInt32 dy)
{
m_server->onMouseMoveSecondary(dx, dy);
}
void
CPrimaryClient::onMouseWheel(SInt32 delta)
{
m_server->onMouseWheel(delta);
}
void
CPrimaryClient::onScreenSaver(bool activated)
{
m_server->onScreenSaver(activated);
}
bool
CPrimaryClient::open()
{

View File

@ -1,15 +1,15 @@
#ifndef CPRIMARYCLIENT_H
#define CPRIMARYCLIENT_H
#include "IServer.h"
#include "IClient.h"
#include "IScreenReceiver.h"
#include "ProtocolTypes.h"
class IClipboard;
class IPrimaryScreen;
class IServer;
class CPrimaryClient : public IServer, public IClient {
class CPrimaryClient : public IScreenReceiver, public IClient {
public:
CPrimaryClient(IServer*, const CString& name);
~CPrimaryClient();
@ -33,23 +33,10 @@ public:
// returns the state of the toggle keys on the primary screen
KeyModifierMask getToggleMask() const;
// 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 onInfoChanged(const CString&, const CClientInfo&);
virtual bool onGrabClipboard(const CString&, ClipboardID, UInt32);
virtual void onClipboardChanged(ClipboardID, UInt32, const CString&);
virtual void onKeyDown(KeyID, KeyModifierMask);
virtual void onKeyUp(KeyID, KeyModifierMask);
virtual void onKeyRepeat(KeyID, KeyModifierMask, SInt32 count);
virtual void onMouseDown(ButtonID);
virtual void onMouseUp(ButtonID);
virtual bool onMouseMovePrimary(SInt32 x, SInt32 y);
virtual void onMouseMoveSecondary(SInt32 dx, SInt32 dy);
virtual void onMouseWheel(SInt32 delta);
virtual void onScreenSaver(bool activated);
// IScreenReceiver overrides
virtual void onInfoChanged(const CClientInfo&);
virtual bool onGrabClipboard(ClipboardID);
virtual void onClipboardChanged(ClipboardID, const CString&);
// IClient overrides
virtual bool open();

View File

@ -53,11 +53,8 @@ public:
// get the sides of the primary screen that have neighbors
UInt32 getActivePrimarySides() const;
// IServer overrides
// IPrimaryScreenReceiver overrides
virtual void onError();
virtual void onInfoChanged(const CString&, const CClientInfo&);
virtual bool onGrabClipboard(const CString&, ClipboardID, UInt32);
virtual void onClipboardChanged(ClipboardID, UInt32, const CString&);
virtual void onKeyDown(KeyID, KeyModifierMask);
virtual void onKeyUp(KeyID, KeyModifierMask);
virtual void onKeyRepeat(KeyID, KeyModifierMask, SInt32 count);
@ -68,6 +65,11 @@ public:
virtual void onMouseWheel(SInt32 delta);
virtual void onScreenSaver(bool activated);
// IServer overrides
virtual void onInfoChanged(const CString&, const CClientInfo&);
virtual bool onGrabClipboard(const CString&, ClipboardID, UInt32);
virtual void onClipboardChanged(ClipboardID, UInt32, const CString&);
protected:
bool onCommandKey(KeyID, KeyModifierMask, bool down);

View File

@ -1,9 +1,10 @@
#include "CXWindowsPrimaryScreen.h"
#include "IScreenReceiver.h"
#include "IPrimaryScreenReceiver.h"
#include "CXWindowsClipboard.h"
#include "CXWindowsScreenSaver.h"
#include "CXWindowsUtil.h"
#include "CClipboard.h"
#include "IServer.h"
#include "ProtocolTypes.h"
#include "CThread.h"
#include "CLog.h"
@ -21,8 +22,11 @@
// CXWindowsPrimaryScreen
//
CXWindowsPrimaryScreen::CXWindowsPrimaryScreen(IServer* server) :
m_server(server),
CXWindowsPrimaryScreen::CXWindowsPrimaryScreen(
IScreenReceiver* receiver,
IPrimaryScreenReceiver* primaryReceiver) :
m_receiver(receiver),
m_primaryReceiver(primaryReceiver),
m_active(false),
m_window(None)
{
@ -67,7 +71,7 @@ CXWindowsPrimaryScreen::run()
if (xevent.xclient.message_type == m_atomScreenSaver ||
xevent.xclient.format == 32) {
// screen saver activation/deactivation event
m_server->onScreenSaver(xevent.xclient.data.l[0] != 0);
m_primaryReceiver->onScreenSaver(xevent.xclient.data.l[0] != 0);
}
break;
@ -77,12 +81,12 @@ CXWindowsPrimaryScreen::run()
const KeyModifierMask mask = mapModifier(xevent.xkey.state);
const KeyID key = mapKey(&xevent.xkey);
if (key != kKeyNone) {
m_server->onKeyDown(key, mask);
m_primaryReceiver->onKeyDown(key, mask);
if (key == XK_Caps_Lock && m_capsLockHalfDuplex) {
m_server->onKeyUp(key, mask | KeyModifierCapsLock);
m_primaryReceiver->onKeyUp(key, mask | KeyModifierCapsLock);
}
else if (key == XK_Num_Lock && m_numLockHalfDuplex) {
m_server->onKeyUp(key, mask | KeyModifierNumLock);
m_primaryReceiver->onKeyUp(key, mask | KeyModifierNumLock);
}
}
}
@ -112,12 +116,12 @@ CXWindowsPrimaryScreen::run()
// 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));
if (key == XK_Caps_Lock && m_capsLockHalfDuplex) {
m_server->onKeyDown(key, mask);
m_primaryReceiver->onKeyDown(key, mask);
}
else if (key == XK_Num_Lock && m_numLockHalfDuplex) {
m_server->onKeyDown(key, mask);
m_primaryReceiver->onKeyDown(key, mask);
}
m_server->onKeyUp(key, mask);
m_primaryReceiver->onKeyUp(key, mask);
}
else {
// found a press event following so it's a repeat.
@ -125,7 +129,7 @@ CXWindowsPrimaryScreen::run()
// repeats but we'll just send a repeat of 1.
// note that we discard the press event.
log((CLOG_DEBUG1 "event: repeat code=%d, state=0x%04x", xevent.xkey.keycode, xevent.xkey.state));
m_server->onKeyRepeat(key, mask, 1);
m_primaryReceiver->onKeyRepeat(key, mask, 1);
}
}
}
@ -136,7 +140,7 @@ CXWindowsPrimaryScreen::run()
log((CLOG_DEBUG1 "event: ButtonPress button=%d", xevent.xbutton.button));
const ButtonID button = mapButton(xevent.xbutton.button);
if (button != kButtonNone) {
m_server->onMouseDown(button);
m_primaryReceiver->onMouseDown(button);
}
}
break;
@ -146,15 +150,15 @@ CXWindowsPrimaryScreen::run()
log((CLOG_DEBUG1 "event: ButtonRelease button=%d", xevent.xbutton.button));
const ButtonID button = mapButton(xevent.xbutton.button);
if (button != kButtonNone) {
m_server->onMouseUp(button);
m_primaryReceiver->onMouseUp(button);
}
else if (xevent.xbutton.button == 4) {
// wheel forward (away from user)
m_server->onMouseWheel(120);
m_primaryReceiver->onMouseWheel(120);
}
else if (xevent.xbutton.button == 5) {
// wheel backward (toward user)
m_server->onMouseWheel(-120);
m_primaryReceiver->onMouseWheel(-120);
}
}
break;
@ -185,7 +189,7 @@ CXWindowsPrimaryScreen::run()
}
else if (!m_active) {
// motion on primary screen
m_server->onMouseMovePrimary(m_x, m_y);
m_primaryReceiver->onMouseMovePrimary(m_x, m_y);
}
else {
// motion on secondary screen. warp mouse back to
@ -216,7 +220,7 @@ CXWindowsPrimaryScreen::run()
// warping to the primary screen's enter position,
// effectively overriding it.
if (x != 0 || y != 0) {
m_server->onMouseMoveSecondary(x, y);
m_primaryReceiver->onMouseMoveSecondary(x, y);
}
}
}
@ -287,7 +291,7 @@ CXWindowsPrimaryScreen::open()
info.m_zoneSize = 1;
info.m_mx = m_x;
info.m_my = m_y;
m_server->onInfoChanged("", info);
m_receiver->onInfoChanged(info);
}
void
@ -498,12 +502,15 @@ CXWindowsPrimaryScreen::getToggleMask() const
// convert to KeyModifierMask
KeyModifierMask mask = 0;
if (state & m_numLockMask)
if (state & m_numLockMask) {
mask |= KeyModifierNumLock;
if (state & m_capsLockMask)
}
if (state & m_capsLockMask) {
mask |= KeyModifierCapsLock;
if (state & m_scrollLockMask)
}
if (state & m_scrollLockMask) {
mask |= KeyModifierScrollLock;
}
return mask;
}
@ -595,14 +602,14 @@ void
CXWindowsPrimaryScreen::onUnexpectedClose()
{
// tell server to shutdown
m_server->onError();
m_primaryReceiver->onError();
}
void
CXWindowsPrimaryScreen::onLostClipboard(ClipboardID id)
{
// tell server that the clipboard was grabbed locally
m_server->onGrabClipboard("", id, 0);
m_receiver->onGrabClipboard(id);
}
void

View File

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

View File

@ -0,0 +1,28 @@
#ifndef IPRIMARYSCREENRECEIVER_H
#define IPRIMARYSCREENRECEIVER_H
#include "IInterface.h"
#include "KeyTypes.h"
#include "MouseTypes.h"
class IPrimaryScreenReceiver : public IInterface {
public:
// notify of serious error. this implies that the server should
// shutdown.
virtual void onError() = 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

23
synergy/IScreenReceiver.h Normal file
View File

@ -0,0 +1,23 @@
#ifndef ISCREENRECEIVER_H
#define ISCREENRECEIVER_H
#include "IInterface.h"
#include "ClipboardTypes.h"
#include "ProtocolTypes.h"
#include "CString.h"
class IScreenReceiver : public IInterface {
public:
// notify of client info change
virtual void onInfoChanged(const CClientInfo&) = 0;
// notify of clipboard grab. returns true if the grab was honored,
// false otherwise.
virtual bool onGrabClipboard(ClipboardID) = 0;
// notify of new clipboard data
virtual void onClipboardChanged(ClipboardID,
const CString& data) = 0;
};
#endif

View File

@ -1,22 +1,16 @@
#ifndef ISERVER_H
#define ISERVER_H
#include "IInterface.h"
#include "IPrimaryScreenReceiver.h"
#include "ClipboardTypes.h"
#include "KeyTypes.h"
#include "MouseTypes.h"
#include "CString.h"
class CClientInfo;
class IServer : public IInterface {
class IServer : public IPrimaryScreenReceiver {
public:
// manipulators
// notify of serious error. this implies that the server should
// shutdown.
virtual void onError() = 0;
// notify of client info change
virtual void onInfoChanged(const CString& clientName,
const CClientInfo&) = 0;
@ -30,8 +24,8 @@ public:
virtual void onClipboardChanged(ClipboardID,
UInt32 seqNum, const CString& data) = 0;
// call to notify of events. onMouseMovePrimary() returns
// true iff the mouse enters a jump zone and jumps.
// IPrimaryScreenReceiver overrides
virtual void onError() = 0;
virtual void onKeyDown(KeyID, KeyModifierMask) = 0;
virtual void onKeyUp(KeyID, KeyModifierMask) = 0;
virtual void onKeyRepeat(KeyID, KeyModifierMask, SInt32 count) = 0;

View File

@ -19,6 +19,8 @@ libsynergy_a_SOURCES = \
ClipboardTypes.h \
IClient.h \
IClipboard.h \
IPrimaryScreenReceiver.h\
IScreenReceiver.h \
IScreenSaver.h \
IServer.h \
ISocketFactory.h \