checkpoint. changed CScreenMap to CConfig. must still change
CScreenMap.cpp to CConfig.cpp.
This commit is contained in:
parent
ed96354bad
commit
67b149d3a4
|
@ -1,11 +1,11 @@
|
|||
#ifndef CSCREENMAP_H
|
||||
#define CSCREENMAP_H
|
||||
#ifndef CCONFIG_H
|
||||
#define CCONFIG_H
|
||||
|
||||
#include "BasicTypes.h"
|
||||
#include "CString.h"
|
||||
#include <map>
|
||||
|
||||
class CScreenMap {
|
||||
class CConfig {
|
||||
public:
|
||||
enum EDirection { kLeft, kRight, kTop, kBottom,
|
||||
kFirstDirection = kLeft, kLastDirection = kBottom };
|
||||
|
@ -45,11 +45,11 @@ public:
|
|||
}
|
||||
|
||||
private:
|
||||
CScreenMap::internal_const_iterator m_i;
|
||||
CConfig::internal_const_iterator m_i;
|
||||
};
|
||||
|
||||
CScreenMap();
|
||||
virtual ~CScreenMap();
|
||||
CConfig();
|
||||
virtual ~CConfig();
|
||||
|
||||
// manipulators
|
||||
|
||||
|
|
|
@ -163,10 +163,10 @@ void CHTTPServer::doProcessGetEditMap(
|
|||
// convert screen map into a temporary screen map
|
||||
CScreenArray screens;
|
||||
{
|
||||
CScreenMap currentMap;
|
||||
m_server->getScreenMap(¤tMap);
|
||||
screens.convertFrom(currentMap);
|
||||
// FIXME -- note to user if currentMap couldn't be exactly represented
|
||||
CConfig config;
|
||||
m_server->getConfig(&config);
|
||||
screens.convertFrom(config);
|
||||
// FIXME -- note to user if config couldn't be exactly represented
|
||||
}
|
||||
|
||||
// insert blank columns and rows around array (to allow the user
|
||||
|
@ -300,11 +300,11 @@ void CHTTPServer::doProcessPostEditMap(
|
|||
}
|
||||
|
||||
// convert temporary screen map into a regular map
|
||||
CScreenMap newMap;
|
||||
screens.convertTo(newMap);
|
||||
CConfig config;
|
||||
screens.convertTo(config);
|
||||
|
||||
// set new screen map on server
|
||||
m_server->setScreenMap(newMap);
|
||||
m_server->setConfig(config);
|
||||
|
||||
// now reply with current map
|
||||
doProcessGetEditMap(request, reply);
|
||||
|
@ -634,13 +634,13 @@ bool CHTTPServer::CScreenArray::isValid() const
|
|||
}
|
||||
|
||||
bool CHTTPServer::CScreenArray::convertFrom(
|
||||
const CScreenMap& screenMap)
|
||||
const CConfig& config)
|
||||
{
|
||||
typedef std::set<CString> ScreenSet;
|
||||
|
||||
// insert the first screen
|
||||
CScreenMap::const_iterator index = screenMap.begin();
|
||||
if (index == screenMap.end()) {
|
||||
CConfig::const_iterator index = config.begin();
|
||||
if (index == config.end()) {
|
||||
// no screens
|
||||
resize(0, 0);
|
||||
return true;
|
||||
|
@ -655,7 +655,7 @@ bool CHTTPServer::CScreenArray::convertFrom(
|
|||
|
||||
// put all but the first screen on the stack
|
||||
// note -- if all screens are 4-connected then we can skip this
|
||||
while (++index != screenMap.end()) {
|
||||
while (++index != config.end()) {
|
||||
screenStack.push_back(*index);
|
||||
}
|
||||
|
||||
|
@ -686,7 +686,7 @@ bool CHTTPServer::CScreenArray::convertFrom(
|
|||
// insert the screen's neighbors
|
||||
// FIXME -- handle edge wrapping
|
||||
CString neighbor;
|
||||
neighbor = screenMap.getNeighbor(name, CScreenMap::kLeft);
|
||||
neighbor = config.getNeighbor(name, CConfig::kLeft);
|
||||
if (!neighbor.empty() && doneSet.count(neighbor) == 0) {
|
||||
// insert left neighbor, adding a column if necessary
|
||||
if (x == 0 || get(x - 1, y) != neighbor) {
|
||||
|
@ -696,7 +696,7 @@ bool CHTTPServer::CScreenArray::convertFrom(
|
|||
}
|
||||
screenStack.push_back(neighbor);
|
||||
}
|
||||
neighbor = screenMap.getNeighbor(name, CScreenMap::kRight);
|
||||
neighbor = config.getNeighbor(name, CConfig::kRight);
|
||||
if (!neighbor.empty() && doneSet.count(neighbor) == 0) {
|
||||
// insert right neighbor, adding a column if necessary
|
||||
if (x == m_w - 1 || get(x + 1, y) != neighbor) {
|
||||
|
@ -705,7 +705,7 @@ bool CHTTPServer::CScreenArray::convertFrom(
|
|||
}
|
||||
screenStack.push_back(neighbor);
|
||||
}
|
||||
neighbor = screenMap.getNeighbor(name, CScreenMap::kTop);
|
||||
neighbor = config.getNeighbor(name, CConfig::kTop);
|
||||
if (!neighbor.empty() && doneSet.count(neighbor) == 0) {
|
||||
// insert top neighbor, adding a row if necessary
|
||||
if (y == 0 || get(x, y - 1) != neighbor) {
|
||||
|
@ -715,7 +715,7 @@ bool CHTTPServer::CScreenArray::convertFrom(
|
|||
}
|
||||
screenStack.push_back(neighbor);
|
||||
}
|
||||
neighbor = screenMap.getNeighbor(name, CScreenMap::kBottom);
|
||||
neighbor = config.getNeighbor(name, CConfig::kBottom);
|
||||
if (!neighbor.empty() && doneSet.count(neighbor) == 0) {
|
||||
// insert bottom neighbor, adding a row if necessary
|
||||
if (y == m_h - 1 || get(x, y + 1) != neighbor) {
|
||||
|
@ -728,7 +728,7 @@ bool CHTTPServer::CScreenArray::convertFrom(
|
|||
|
||||
// check symmetry
|
||||
// FIXME -- handle edge wrapping
|
||||
for (index = screenMap.begin(); index != screenMap.end(); ++index) {
|
||||
for (index = config.begin(); index != config.end(); ++index) {
|
||||
const CString& name = *index;
|
||||
SInt32 x, y;
|
||||
if (!find(name, x, y)) {
|
||||
|
@ -736,25 +736,25 @@ bool CHTTPServer::CScreenArray::convertFrom(
|
|||
}
|
||||
|
||||
CString neighbor;
|
||||
neighbor = screenMap.getNeighbor(name, CScreenMap::kLeft);
|
||||
neighbor = config.getNeighbor(name, CConfig::kLeft);
|
||||
if ((x == 0 && !neighbor.empty()) ||
|
||||
(x > 0 && get(x - 1, y) != neighbor)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
neighbor = screenMap.getNeighbor(name, CScreenMap::kRight);
|
||||
neighbor = config.getNeighbor(name, CConfig::kRight);
|
||||
if ((x == m_w - 1 && !neighbor.empty()) ||
|
||||
(x < m_w - 1 && get(x + 1, y) != neighbor)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
neighbor = screenMap.getNeighbor(name, CScreenMap::kTop);
|
||||
neighbor = config.getNeighbor(name, CConfig::kTop);
|
||||
if ((y == 0 && !neighbor.empty()) ||
|
||||
(y > 0 && get(x, y - 1) != neighbor)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
neighbor = screenMap.getNeighbor(name, CScreenMap::kBottom);
|
||||
neighbor = config.getNeighbor(name, CConfig::kBottom);
|
||||
if ((y == m_h - 1 && !neighbor.empty()) ||
|
||||
(y < m_h - 1 && get(x, y + 1) != neighbor)) {
|
||||
return false;
|
||||
|
@ -765,14 +765,14 @@ bool CHTTPServer::CScreenArray::convertFrom(
|
|||
}
|
||||
|
||||
void CHTTPServer::CScreenArray::convertTo(
|
||||
CScreenMap& screenMap) const
|
||||
CConfig& config) const
|
||||
{
|
||||
// add screens and find smallest box containing all screens
|
||||
SInt32 x0 = m_w, x1 = 0, y0 = m_h, y1 = 0;
|
||||
for (SInt32 y = 0; y < m_h; ++y) {
|
||||
for (SInt32 x = 0; x < m_w; ++x) {
|
||||
if (isSet(x, y)) {
|
||||
screenMap.addScreen(get(x, y));
|
||||
config.addScreen(get(x, y));
|
||||
if (x < x0) {
|
||||
x0 = x;
|
||||
}
|
||||
|
@ -799,23 +799,23 @@ void CHTTPServer::CScreenArray::convertTo(
|
|||
continue;
|
||||
}
|
||||
if (x > x0 && isSet(x - 1, y)) {
|
||||
screenMap.connect(get(x, y),
|
||||
CScreenMap::kLeft,
|
||||
config.connect(get(x, y),
|
||||
CConfig::kLeft,
|
||||
get(x - 1, y));
|
||||
}
|
||||
if (x < x1 && isSet(x + 1, y)) {
|
||||
screenMap.connect(get(x, y),
|
||||
CScreenMap::kRight,
|
||||
config.connect(get(x, y),
|
||||
CConfig::kRight,
|
||||
get(x + 1, y));
|
||||
}
|
||||
if (y > y0 && isSet(x, y - 1)) {
|
||||
screenMap.connect(get(x, y),
|
||||
CScreenMap::kTop,
|
||||
config.connect(get(x, y),
|
||||
CConfig::kTop,
|
||||
get(x, y - 1));
|
||||
}
|
||||
if (y < y1 && isSet(x, y + 1)) {
|
||||
screenMap.connect(get(x, y),
|
||||
CScreenMap::kBottom,
|
||||
config.connect(get(x, y),
|
||||
CConfig::kBottom,
|
||||
get(x, y + 1));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
#include <vector>
|
||||
|
||||
class CServer;
|
||||
class CScreenMap;
|
||||
class CConfig;
|
||||
class CHTTPRequest;
|
||||
class CHTTPReply;
|
||||
class ISocket;
|
||||
|
@ -56,10 +56,10 @@ protected:
|
|||
void remove(SInt32 x, SInt32 y);
|
||||
void set(SInt32 x, SInt32 y, const CString&);
|
||||
|
||||
// convert a CScreenMap to a CScreenArray. returns true iff
|
||||
// convert a CConfig to a CScreenArray. returns true iff
|
||||
// all connections are symmetric and therefore exactly
|
||||
// representable by a CScreenArray.
|
||||
bool convertFrom(const CScreenMap&);
|
||||
bool convertFrom(const CConfig&);
|
||||
|
||||
// accessors
|
||||
|
||||
|
@ -84,8 +84,8 @@ protected:
|
|||
// to other screens.
|
||||
bool isValid() const;
|
||||
|
||||
// convert this to a CScreenMap
|
||||
void convertTo(CScreenMap&) const;
|
||||
// convert this to a CConfig
|
||||
void convertTo(CConfig&) const;
|
||||
|
||||
private:
|
||||
typedef std::vector<CString> CNames;
|
||||
|
|
|
@ -2,20 +2,20 @@
|
|||
#include <assert.h>
|
||||
|
||||
//
|
||||
// CScreenMap
|
||||
// CConfig
|
||||
//
|
||||
|
||||
CScreenMap::CScreenMap()
|
||||
CConfig::CConfig()
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
CScreenMap::~CScreenMap()
|
||||
CConfig::~CConfig()
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
void CScreenMap::addScreen(const CString& name)
|
||||
void CConfig::addScreen(const CString& name)
|
||||
{
|
||||
if (m_map.count(name) != 0) {
|
||||
assert(0 && "name already in map"); // FIXME -- throw instead
|
||||
|
@ -23,7 +23,7 @@ void CScreenMap::addScreen(const CString& name)
|
|||
m_map.insert(std::make_pair(name, CCell()));
|
||||
}
|
||||
|
||||
void CScreenMap::removeScreen(const CString& name)
|
||||
void CConfig::removeScreen(const CString& name)
|
||||
{
|
||||
CCellMap::iterator index = m_map.find(name);
|
||||
if (index == m_map.end()) {
|
||||
|
@ -43,12 +43,12 @@ void CScreenMap::removeScreen(const CString& name)
|
|||
}
|
||||
}
|
||||
|
||||
void CScreenMap::removeAllScreens()
|
||||
void CConfig::removeAllScreens()
|
||||
{
|
||||
m_map.clear();
|
||||
}
|
||||
|
||||
void CScreenMap::connect(const CString& srcName,
|
||||
void CConfig::connect(const CString& srcName,
|
||||
EDirection srcSide,
|
||||
const CString& dstName)
|
||||
{
|
||||
|
@ -62,7 +62,7 @@ void CScreenMap::connect(const CString& srcName,
|
|||
index->second.m_neighbor[srcSide - kFirstDirection] = dstName;
|
||||
}
|
||||
|
||||
void CScreenMap::disconnect(const CString& srcName,
|
||||
void CConfig::disconnect(const CString& srcName,
|
||||
EDirection srcSide)
|
||||
{
|
||||
// find source cell
|
||||
|
@ -75,19 +75,17 @@ void CScreenMap::disconnect(const CString& srcName,
|
|||
index->second.m_neighbor[srcSide - kFirstDirection].erase();
|
||||
}
|
||||
|
||||
CScreenMap::const_iterator
|
||||
CScreenMap::begin() const
|
||||
CConfig::const_iterator CConfig::begin() const
|
||||
{
|
||||
return const_iterator(m_map.begin());
|
||||
}
|
||||
|
||||
CScreenMap::const_iterator
|
||||
CScreenMap::end() const
|
||||
CConfig::const_iterator CConfig::end() const
|
||||
{
|
||||
return const_iterator(m_map.end());
|
||||
}
|
||||
|
||||
CString CScreenMap::getNeighbor(const CString& srcName,
|
||||
CString CConfig::getNeighbor(const CString& srcName,
|
||||
EDirection srcSide) const
|
||||
{
|
||||
// find source cell
|
||||
|
@ -100,7 +98,7 @@ CString CScreenMap::getNeighbor(const CString& srcName,
|
|||
return index->second.m_neighbor[srcSide - kFirstDirection];
|
||||
}
|
||||
|
||||
const char* CScreenMap::dirName(EDirection dir)
|
||||
const char* CConfig::dirName(EDirection dir)
|
||||
{
|
||||
static const char* s_name[] = { "left", "right", "top", "bottom" };
|
||||
return s_name[dir - kFirstDirection];
|
||||
|
|
|
@ -110,13 +110,13 @@ void CServer::quit()
|
|||
m_primary->stop();
|
||||
}
|
||||
|
||||
void CServer::setScreenMap(const CScreenMap& screenMap)
|
||||
void CServer::setConfig(const CConfig& config)
|
||||
{
|
||||
CLock lock(&m_mutex);
|
||||
// FIXME -- must disconnect screens no longer listed
|
||||
// (that may include warping back to server's screen)
|
||||
// FIXME -- server screen must be in new map or map is rejected
|
||||
m_screenMap = screenMap;
|
||||
m_config = config;
|
||||
}
|
||||
|
||||
CString CServer::getPrimaryScreenName() const
|
||||
|
@ -125,26 +125,26 @@ CString CServer::getPrimaryScreenName() const
|
|||
return (m_primaryInfo == NULL) ? "" : m_primaryInfo->m_name;
|
||||
}
|
||||
|
||||
void CServer::getScreenMap(CScreenMap* screenMap) const
|
||||
void CServer::getConfig(CConfig* config) const
|
||||
{
|
||||
assert(screenMap != NULL);
|
||||
assert(config != NULL);
|
||||
|
||||
CLock lock(&m_mutex);
|
||||
*screenMap = m_screenMap;
|
||||
*config = m_config;
|
||||
}
|
||||
|
||||
UInt32 CServer::getActivePrimarySides() const
|
||||
{
|
||||
UInt32 sides = 0;
|
||||
CLock lock(&m_mutex);
|
||||
if (!m_screenMap.getNeighbor("primary", CScreenMap::kLeft).empty())
|
||||
sides |= CScreenMap::kLeftMask;
|
||||
if (!m_screenMap.getNeighbor("primary", CScreenMap::kRight).empty())
|
||||
sides |= CScreenMap::kRightMask;
|
||||
if (!m_screenMap.getNeighbor("primary", CScreenMap::kTop).empty())
|
||||
sides |= CScreenMap::kTopMask;
|
||||
if (!m_screenMap.getNeighbor("primary", CScreenMap::kBottom).empty())
|
||||
sides |= CScreenMap::kBottomMask;
|
||||
if (!m_config.getNeighbor("primary", CConfig::kLeft).empty())
|
||||
sides |= CConfig::kLeftMask;
|
||||
if (!m_config.getNeighbor("primary", CConfig::kRight).empty())
|
||||
sides |= CConfig::kRightMask;
|
||||
if (!m_config.getNeighbor("primary", CConfig::kTop).empty())
|
||||
sides |= CConfig::kTopMask;
|
||||
if (!m_config.getNeighbor("primary", CConfig::kBottom).empty())
|
||||
sides |= CConfig::kBottomMask;
|
||||
return sides;
|
||||
}
|
||||
|
||||
|
@ -388,25 +388,25 @@ bool CServer::onMouseMovePrimary(SInt32 x, SInt32 y)
|
|||
}
|
||||
|
||||
// see if we should change screens
|
||||
CScreenMap::EDirection dir;
|
||||
CConfig::EDirection dir;
|
||||
if (x < m_active->m_zoneSize) {
|
||||
x -= m_active->m_zoneSize;
|
||||
dir = CScreenMap::kLeft;
|
||||
dir = CConfig::kLeft;
|
||||
log((CLOG_DEBUG1 "switch to left"));
|
||||
}
|
||||
else if (x >= m_active->m_width - m_active->m_zoneSize) {
|
||||
x += m_active->m_zoneSize;
|
||||
dir = CScreenMap::kRight;
|
||||
dir = CConfig::kRight;
|
||||
log((CLOG_DEBUG1 "switch to right"));
|
||||
}
|
||||
else if (y < m_active->m_zoneSize) {
|
||||
y -= m_active->m_zoneSize;
|
||||
dir = CScreenMap::kTop;
|
||||
dir = CConfig::kTop;
|
||||
log((CLOG_DEBUG1 "switch to top"));
|
||||
}
|
||||
else if (y >= m_active->m_height - m_active->m_zoneSize) {
|
||||
y += m_active->m_zoneSize;
|
||||
dir = CScreenMap::kBottom;
|
||||
dir = CConfig::kBottom;
|
||||
log((CLOG_DEBUG1 "switch to bottom"));
|
||||
}
|
||||
else {
|
||||
|
@ -451,21 +451,21 @@ void CServer::onMouseMoveSecondary(SInt32 dx, SInt32 dy)
|
|||
CScreenInfo* newScreen = NULL;
|
||||
if (!isLockedToScreen()) {
|
||||
// find direction of neighbor
|
||||
CScreenMap::EDirection dir;
|
||||
CConfig::EDirection dir;
|
||||
if (m_x < 0)
|
||||
dir = CScreenMap::kLeft;
|
||||
dir = CConfig::kLeft;
|
||||
else if (m_x > m_active->m_width - 1)
|
||||
dir = CScreenMap::kRight;
|
||||
dir = CConfig::kRight;
|
||||
else if (m_y < 0)
|
||||
dir = CScreenMap::kTop;
|
||||
dir = CConfig::kTop;
|
||||
else if (m_y > m_active->m_height - 1)
|
||||
dir = CScreenMap::kBottom;
|
||||
dir = CConfig::kBottom;
|
||||
else
|
||||
newScreen = m_active;
|
||||
|
||||
// get neighbor if we should switch
|
||||
if (newScreen == NULL) {
|
||||
log((CLOG_DEBUG1 "leave \"%s\" on %s", m_active->m_name.c_str(), CScreenMap::dirName(dir)));
|
||||
log((CLOG_DEBUG1 "leave \"%s\" on %s", m_active->m_name.c_str(), CConfig::dirName(dir)));
|
||||
|
||||
SInt32 x = m_x, y = m_y;
|
||||
newScreen = getNeighbor(m_active, dir, x, y);
|
||||
|
@ -612,20 +612,20 @@ void CServer::switchScreen(CScreenInfo* dst,
|
|||
}
|
||||
|
||||
CServer::CScreenInfo* CServer::getNeighbor(CScreenInfo* src,
|
||||
CScreenMap::EDirection dir) const
|
||||
CConfig::EDirection dir) const
|
||||
{
|
||||
assert(src != NULL);
|
||||
|
||||
CString srcName = src->m_name;
|
||||
assert(!srcName.empty());
|
||||
log((CLOG_DEBUG2 "find neighbor on %s of \"%s\"", CScreenMap::dirName(dir), srcName.c_str()));
|
||||
log((CLOG_DEBUG2 "find neighbor on %s of \"%s\"", CConfig::dirName(dir), srcName.c_str()));
|
||||
for (;;) {
|
||||
// look up name of neighbor
|
||||
const CString dstName(m_screenMap.getNeighbor(srcName, dir));
|
||||
const CString dstName(m_config.getNeighbor(srcName, dir));
|
||||
|
||||
// if nothing in that direction then return NULL
|
||||
if (dstName.empty()) {
|
||||
log((CLOG_DEBUG2 "no neighbor on %s of \"%s\"", CScreenMap::dirName(dir), srcName.c_str()));
|
||||
log((CLOG_DEBUG2 "no neighbor on %s of \"%s\"", CConfig::dirName(dir), srcName.c_str()));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -634,17 +634,17 @@ CServer::CScreenInfo* CServer::getNeighbor(CScreenInfo* src,
|
|||
// screen.
|
||||
CScreenList::const_iterator index = m_screens.find(dstName);
|
||||
if (index != m_screens.end()) {
|
||||
log((CLOG_DEBUG2 "\"%s\" is on %s of \"%s\"", dstName.c_str(), CScreenMap::dirName(dir), srcName.c_str()));
|
||||
log((CLOG_DEBUG2 "\"%s\" is on %s of \"%s\"", dstName.c_str(), CConfig::dirName(dir), srcName.c_str()));
|
||||
return index->second;
|
||||
}
|
||||
|
||||
log((CLOG_DEBUG2 "ignored \"%s\" on %s of \"%s\"", dstName.c_str(), CScreenMap::dirName(dir), srcName.c_str()));
|
||||
log((CLOG_DEBUG2 "ignored \"%s\" on %s of \"%s\"", dstName.c_str(), CConfig::dirName(dir), srcName.c_str()));
|
||||
srcName = dstName;
|
||||
}
|
||||
}
|
||||
|
||||
CServer::CScreenInfo* CServer::getNeighbor(CScreenInfo* src,
|
||||
CScreenMap::EDirection srcSide,
|
||||
CConfig::EDirection srcSide,
|
||||
SInt32& x, SInt32& y) const
|
||||
{
|
||||
assert(src != NULL);
|
||||
|
@ -658,7 +658,7 @@ CServer::CScreenInfo* CServer::getNeighbor(CScreenInfo* src,
|
|||
|
||||
// find destination screen, adjusting x or y (but not both)
|
||||
switch (srcSide) {
|
||||
case CScreenMap::kLeft:
|
||||
case CConfig::kLeft:
|
||||
while (dst != NULL) {
|
||||
lastGoodScreen = dst;
|
||||
w = lastGoodScreen->m_width;
|
||||
|
@ -672,7 +672,7 @@ CServer::CScreenInfo* CServer::getNeighbor(CScreenInfo* src,
|
|||
}
|
||||
break;
|
||||
|
||||
case CScreenMap::kRight:
|
||||
case CConfig::kRight:
|
||||
while (dst != NULL) {
|
||||
lastGoodScreen = dst;
|
||||
x -= w;
|
||||
|
@ -686,7 +686,7 @@ CServer::CScreenInfo* CServer::getNeighbor(CScreenInfo* src,
|
|||
}
|
||||
break;
|
||||
|
||||
case CScreenMap::kTop:
|
||||
case CConfig::kTop:
|
||||
while (dst != NULL) {
|
||||
lastGoodScreen = dst;
|
||||
w = lastGoodScreen->m_width;
|
||||
|
@ -700,7 +700,7 @@ CServer::CScreenInfo* CServer::getNeighbor(CScreenInfo* src,
|
|||
}
|
||||
break;
|
||||
|
||||
case CScreenMap::kBottom:
|
||||
case CConfig::kBottom:
|
||||
while (dst != NULL) {
|
||||
lastGoodScreen = dst;
|
||||
y -= h;
|
||||
|
@ -727,26 +727,26 @@ CServer::CScreenInfo* CServer::getNeighbor(CScreenInfo* src,
|
|||
if (lastGoodScreen->m_protocol == NULL) {
|
||||
const CString dstName(lastGoodScreen->m_name);
|
||||
switch (srcSide) {
|
||||
case CScreenMap::kLeft:
|
||||
if (!m_screenMap.getNeighbor(dstName, CScreenMap::kRight).empty() &&
|
||||
case CConfig::kLeft:
|
||||
if (!m_config.getNeighbor(dstName, CConfig::kRight).empty() &&
|
||||
x > w - 1 - lastGoodScreen->m_zoneSize)
|
||||
x = w - 1 - lastGoodScreen->m_zoneSize;
|
||||
break;
|
||||
|
||||
case CScreenMap::kRight:
|
||||
if (!m_screenMap.getNeighbor(dstName, CScreenMap::kLeft).empty() &&
|
||||
case CConfig::kRight:
|
||||
if (!m_config.getNeighbor(dstName, CConfig::kLeft).empty() &&
|
||||
x < lastGoodScreen->m_zoneSize)
|
||||
x = lastGoodScreen->m_zoneSize;
|
||||
break;
|
||||
|
||||
case CScreenMap::kTop:
|
||||
if (!m_screenMap.getNeighbor(dstName, CScreenMap::kBottom).empty() &&
|
||||
case CConfig::kTop:
|
||||
if (!m_config.getNeighbor(dstName, CConfig::kBottom).empty() &&
|
||||
y > h - 1 - lastGoodScreen->m_zoneSize)
|
||||
y = h - 1 - lastGoodScreen->m_zoneSize;
|
||||
break;
|
||||
|
||||
case CScreenMap::kBottom:
|
||||
if (!m_screenMap.getNeighbor(dstName, CScreenMap::kTop).empty() &&
|
||||
case CConfig::kBottom:
|
||||
if (!m_config.getNeighbor(dstName, CConfig::kTop).empty() &&
|
||||
y < lastGoodScreen->m_zoneSize)
|
||||
y = lastGoodScreen->m_zoneSize;
|
||||
break;
|
||||
|
@ -757,18 +757,18 @@ CServer::CScreenInfo* CServer::getNeighbor(CScreenInfo* src,
|
|||
}
|
||||
|
||||
void CServer::mapPosition(CScreenInfo* src,
|
||||
CScreenMap::EDirection srcSide,
|
||||
CConfig::EDirection srcSide,
|
||||
CScreenInfo* dst,
|
||||
SInt32& x, SInt32& y) const
|
||||
{
|
||||
assert(src != NULL);
|
||||
assert(dst != NULL);
|
||||
assert(srcSide >= CScreenMap::kFirstDirection &&
|
||||
srcSide <= CScreenMap::kLastDirection);
|
||||
assert(srcSide >= CConfig::kFirstDirection &&
|
||||
srcSide <= CConfig::kLastDirection);
|
||||
|
||||
switch (srcSide) {
|
||||
case CScreenMap::kLeft:
|
||||
case CScreenMap::kRight:
|
||||
case CConfig::kLeft:
|
||||
case CConfig::kRight:
|
||||
if (y < 0)
|
||||
y = 0;
|
||||
else if (y >= src->m_height)
|
||||
|
@ -779,8 +779,8 @@ void CServer::mapPosition(CScreenInfo* src,
|
|||
(src->m_height - 1));
|
||||
break;
|
||||
|
||||
case CScreenMap::kTop:
|
||||
case CScreenMap::kBottom:
|
||||
case CConfig::kTop:
|
||||
case CConfig::kBottom:
|
||||
if (x < 0)
|
||||
x = 0;
|
||||
else if (x >= src->m_width)
|
||||
|
|
|
@ -33,7 +33,7 @@ public:
|
|||
void quit();
|
||||
|
||||
// update screen map
|
||||
void setScreenMap(const CScreenMap&);
|
||||
void setConfig(const CConfig&);
|
||||
|
||||
// handle events on server's screen. onMouseMovePrimary() returns
|
||||
// true iff the mouse enters a jump zone and jumps.
|
||||
|
@ -67,7 +67,7 @@ public:
|
|||
bool isLockedToScreen() const;
|
||||
|
||||
// get the current screen map
|
||||
void getScreenMap(CScreenMap*) const;
|
||||
void getConfig(CConfig*) const;
|
||||
|
||||
// get the primary screen's name
|
||||
CString getPrimaryScreenName() const;
|
||||
|
@ -116,21 +116,21 @@ private:
|
|||
void switchScreen(CScreenInfo*, SInt32 x, SInt32 y);
|
||||
|
||||
// lookup neighboring screen
|
||||
CScreenInfo* getNeighbor(CScreenInfo*, CScreenMap::EDirection) const;
|
||||
CScreenInfo* getNeighbor(CScreenInfo*, CConfig::EDirection) const;
|
||||
|
||||
// lookup neighboring screen. given a position relative to the
|
||||
// source screen, find the screen we should move onto and where.
|
||||
// if the position is sufficiently far from the source then we
|
||||
// cross multiple screens.
|
||||
CScreenInfo* getNeighbor(CScreenInfo*,
|
||||
CScreenMap::EDirection,
|
||||
CConfig::EDirection,
|
||||
SInt32& x, SInt32& y) const;
|
||||
|
||||
// adjust coordinates to account for resolution differences. the
|
||||
// position is converted to a resolution independent form then
|
||||
// converted back to screen coordinates on the destination screen.
|
||||
void mapPosition(CScreenInfo* src,
|
||||
CScreenMap::EDirection srcSide,
|
||||
CConfig::EDirection srcSide,
|
||||
CScreenInfo* dst,
|
||||
SInt32& x, SInt32& y) const;
|
||||
|
||||
|
@ -207,7 +207,7 @@ private:
|
|||
// current mouse position (in absolute secondary screen coordinates)
|
||||
SInt32 m_x, m_y;
|
||||
|
||||
CScreenMap m_screenMap;
|
||||
CConfig m_config;
|
||||
|
||||
CClipboardInfo m_clipboards[kClipboardEnd];
|
||||
|
||||
|
|
|
@ -187,16 +187,16 @@ static LRESULT CALLBACK mouseHook(int code, WPARAM wParam, LPARAM lParam)
|
|||
const MOUSEHOOKSTRUCT* info = (const MOUSEHOOKSTRUCT*)lParam;
|
||||
SInt32 x = (SInt32)info->pt.x;
|
||||
SInt32 y = (SInt32)info->pt.y;
|
||||
if (!inside && (g_zoneSides & CScreenMap::kLeftMask) != 0) {
|
||||
if (!inside && (g_zoneSides & CConfig::kLeftMask) != 0) {
|
||||
inside = (x < g_zoneSize);
|
||||
}
|
||||
if (!inside && (g_zoneSides & CScreenMap::kRightMask) != 0) {
|
||||
if (!inside && (g_zoneSides & CConfig::kRightMask) != 0) {
|
||||
inside = (x >= g_wScreen - g_zoneSize);
|
||||
}
|
||||
if (!inside && (g_zoneSides & CScreenMap::kTopMask) != 0) {
|
||||
if (!inside && (g_zoneSides & CConfig::kTopMask) != 0) {
|
||||
inside = (y < g_zoneSize);
|
||||
}
|
||||
if (!inside && (g_zoneSides & CScreenMap::kBottomMask) != 0) {
|
||||
if (!inside && (g_zoneSides & CConfig::kBottomMask) != 0) {
|
||||
inside = (y >= g_hScreen - g_zoneSize);
|
||||
}
|
||||
|
||||
|
|
|
@ -41,19 +41,19 @@ void realMain()
|
|||
// initialize network library
|
||||
CNetwork::init();
|
||||
|
||||
CScreenMap screenMap;
|
||||
screenMap.addScreen("primary");
|
||||
screenMap.addScreen("secondary");
|
||||
screenMap.addScreen("secondary2");
|
||||
screenMap.connect("primary", CScreenMap::kRight, "secondary");
|
||||
screenMap.connect("secondary", CScreenMap::kLeft, "primary");
|
||||
screenMap.connect("secondary", CScreenMap::kRight, "secondary2");
|
||||
screenMap.connect("secondary2", CScreenMap::kLeft, "secondary");
|
||||
CConfig config;
|
||||
config.addScreen("primary");
|
||||
config.addScreen("secondary");
|
||||
config.addScreen("secondary2");
|
||||
config.connect("primary", CConfig::kRight, "secondary");
|
||||
config.connect("secondary", CConfig::kLeft, "primary");
|
||||
config.connect("secondary", CConfig::kRight, "secondary2");
|
||||
config.connect("secondary2", CConfig::kLeft, "secondary");
|
||||
|
||||
CServer* server = NULL;
|
||||
try {
|
||||
server = new CServer();
|
||||
server->setScreenMap(screenMap);
|
||||
server->setConfig(config);
|
||||
server->run();
|
||||
delete server;
|
||||
CNetwork::cleanup();
|
||||
|
|
Loading…
Reference in New Issue