Merged primary and secondary screens into one class.

This commit is contained in:
crs
2003-09-02 22:05:47 +00:00
parent 4fea7719f3
commit 47ca409ff9
57 changed files with 8263 additions and 9809 deletions

View File

@@ -13,11 +13,11 @@
*/
#include "CPrimaryClient.h"
#include "IPrimaryScreenFactory.h"
#include "CScreen.h"
#include "IScreenFactory.h"
#include "IServer.h"
#include "XScreen.h"
#include "XSynergy.h"
#include "CPrimaryScreen.h"
#include "CClipboard.h"
#include "CLog.h"
@@ -25,7 +25,7 @@
// CPrimaryClient
//
CPrimaryClient::CPrimaryClient(IPrimaryScreenFactory* screenFactory,
CPrimaryClient::CPrimaryClient(IScreenFactory* screenFactory,
IServer* server,
IPrimaryScreenReceiver* receiver,
const CString& name) :
@@ -38,7 +38,11 @@ CPrimaryClient::CPrimaryClient(IPrimaryScreenFactory* screenFactory,
// create screen
LOG((CLOG_DEBUG1 "creating primary screen"));
if (screenFactory != NULL) {
m_screen = screenFactory->create(this, receiver);
IPlatformScreen* platformScreen =
screenFactory->create(this, receiver);
if (platformScreen != NULL) {
m_screen = new CScreen(platformScreen, this);
}
}
if (m_screen == NULL) {
throw XScreenOpenFailure();
@@ -86,7 +90,7 @@ CPrimaryClient::isLockedToScreen() const
KeyModifierMask
CPrimaryClient::getToggleMask() const
{
return m_screen->getToggleMask();
return m_screen->getActiveModifiers();
}
void
@@ -149,13 +153,28 @@ CPrimaryClient::close()
m_screen->close();
}
void
CPrimaryClient::enable()
{
m_screen->enable();
}
void
CPrimaryClient::disable()
{
m_screen->disable();
}
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);
if (!screensaver) {
m_screen->warpCursor(xAbs, yAbs);
}
m_screen->enter();
}
bool

View File

@@ -19,9 +19,9 @@
#include "IScreenReceiver.h"
#include "ProtocolTypes.h"
class CScreen;
class IClipboard;
class CPrimaryScreen;
class IPrimaryScreenFactory;
class IScreenFactory;
class IPrimaryScreenReceiver;
class IServer;
@@ -38,7 +38,7 @@ public:
\c factory. Throws XScreenOpenFailure or whatever the factory can
throw if the screen cannot be created.
*/
CPrimaryClient(IPrimaryScreenFactory* factory, IServer*,
CPrimaryClient(IScreenFactory* factory, IServer*,
IPrimaryScreenReceiver*, const CString& name);
~CPrimaryClient();
@@ -96,6 +96,9 @@ public:
virtual bool onGrabClipboard(ClipboardID);
virtual void onClipboardChanged(ClipboardID, const CString&);
// XXX -- these go in IClient
virtual void enable();
virtual void disable();
// IClient overrides
virtual void open();
virtual void mainLoop();
@@ -127,7 +130,7 @@ public:
private:
IServer* m_server;
CPrimaryScreen* m_screen;
CScreen* m_screen;
CString m_name;
UInt32 m_seqNum;
CClientInfo m_info;

View File

@@ -15,7 +15,7 @@
#include "CServer.h"
#include "CHTTPServer.h"
#include "CPrimaryClient.h"
#include "IPrimaryScreenFactory.h"
#include "IScreenFactory.h"
#include "CInputPacketStream.h"
#include "COutputPacketStream.h"
#include "CProtocolUtil.h"
@@ -89,6 +89,7 @@ CServer::open()
LOG((CLOG_INFO "opening screen"));
openPrimaryScreen();
setStatus(kNotRunning);
m_primaryClient->enable();
}
catch (XScreen& e) {
// can't open screen
@@ -212,6 +213,7 @@ void
CServer::close()
{
if (m_primaryClient != NULL) {
m_primaryClient->disable();
closePrimaryScreen();
}
LOG((CLOG_INFO "closed screen"));
@@ -280,7 +282,7 @@ CServer::setConfig(const CConfig& config)
}
void
CServer::setScreenFactory(IPrimaryScreenFactory* adopted)
CServer::setScreenFactory(IScreenFactory* adopted)
{
CLock lock(&m_mutex);
delete m_screenFactory;
@@ -1601,7 +1603,7 @@ CServer::runClient(void* vsocket)
try {
CProtocolUtil::writef(proxy->getOutputStream(), kMsgEBusy);
}
catch (XSocket&) {
catch (XIO&) {
// ignore
}
delete proxy;
@@ -1614,7 +1616,7 @@ CServer::runClient(void* vsocket)
try {
CProtocolUtil::writef(proxy->getOutputStream(), kMsgEUnknown);
}
catch (XSocket&) {
catch (XIO&) {
// ignore
}
delete proxy;
@@ -1646,7 +1648,7 @@ CServer::runClient(void* vsocket)
try {
CProtocolUtil::writef(proxy->getOutputStream(), kMsgEBad);
}
catch (XSocket&) {
catch (XIO&) {
// ignore. client probably aborted the connection.
}
}
@@ -1766,7 +1768,7 @@ CServer::handshakeClient(IDataSocket* socket)
CProtocolUtil::writef(output, kMsgEIncompatible,
kProtocolMajorVersion, kProtocolMinorVersion);
}
catch (XSocket&) {
catch (XIO&) {
// ignore
}
}
@@ -1776,7 +1778,7 @@ CServer::handshakeClient(IDataSocket* socket)
try {
CProtocolUtil::writef(output, kMsgEBad);
}
catch (XSocket&) {
catch (XIO&) {
// ignore. client probably aborted the connection.
}
}

View File

@@ -33,7 +33,7 @@ class CHTTPServer;
class CPrimaryClient;
class IClient;
class IDataSocket;
class IPrimaryScreenFactory;
class IScreenFactory;
class IServerProtocol;
class ISocketFactory;
class IStreamFilterFactory;
@@ -102,13 +102,12 @@ public:
*/
bool setConfig(const CConfig&);
//! Set primary screen factory
//! Set screen factory
/*!
Sets the factory for creating primary screens. This must be
set before calling open(). This object takes ownership of the
factory.
Sets the factory for creating screens. This must be set before
calling open(). This object takes ownership of the factory.
*/
void setScreenFactory(IPrimaryScreenFactory*);
void setScreenFactory(IScreenFactory*);
//! Set socket factory
/*!
@@ -341,8 +340,8 @@ private:
double m_bindTimeout;
// factories
IPrimaryScreenFactory* m_screenFactory;
ISocketFactory* m_socketFactory;
IScreenFactory* m_screenFactory;
ISocketFactory* m_socketFactory;
IStreamFilterFactory* m_streamFilterFactory;
// running threads