checkpoint. changed CScreenMap to CConfig. must still change

CScreenMap.cpp to CConfig.cpp.
This commit is contained in:
crs 2002-05-31 14:43:23 +00:00
parent ed96354bad
commit 67b149d3a4
8 changed files with 122 additions and 124 deletions

View File

@ -1,11 +1,11 @@
#ifndef CSCREENMAP_H #ifndef CCONFIG_H
#define CSCREENMAP_H #define CCONFIG_H
#include "BasicTypes.h" #include "BasicTypes.h"
#include "CString.h" #include "CString.h"
#include <map> #include <map>
class CScreenMap { class CConfig {
public: public:
enum EDirection { kLeft, kRight, kTop, kBottom, enum EDirection { kLeft, kRight, kTop, kBottom,
kFirstDirection = kLeft, kLastDirection = kBottom }; kFirstDirection = kLeft, kLastDirection = kBottom };
@ -45,11 +45,11 @@ public:
} }
private: private:
CScreenMap::internal_const_iterator m_i; CConfig::internal_const_iterator m_i;
}; };
CScreenMap(); CConfig();
virtual ~CScreenMap(); virtual ~CConfig();
// manipulators // manipulators

View File

@ -163,10 +163,10 @@ void CHTTPServer::doProcessGetEditMap(
// convert screen map into a temporary screen map // convert screen map into a temporary screen map
CScreenArray screens; CScreenArray screens;
{ {
CScreenMap currentMap; CConfig config;
m_server->getScreenMap(&currentMap); m_server->getConfig(&config);
screens.convertFrom(currentMap); screens.convertFrom(config);
// FIXME -- note to user if currentMap couldn't be exactly represented // FIXME -- note to user if config couldn't be exactly represented
} }
// insert blank columns and rows around array (to allow the user // 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 // convert temporary screen map into a regular map
CScreenMap newMap; CConfig config;
screens.convertTo(newMap); screens.convertTo(config);
// set new screen map on server // set new screen map on server
m_server->setScreenMap(newMap); m_server->setConfig(config);
// now reply with current map // now reply with current map
doProcessGetEditMap(request, reply); doProcessGetEditMap(request, reply);
@ -634,13 +634,13 @@ bool CHTTPServer::CScreenArray::isValid() const
} }
bool CHTTPServer::CScreenArray::convertFrom( bool CHTTPServer::CScreenArray::convertFrom(
const CScreenMap& screenMap) const CConfig& config)
{ {
typedef std::set<CString> ScreenSet; typedef std::set<CString> ScreenSet;
// insert the first screen // insert the first screen
CScreenMap::const_iterator index = screenMap.begin(); CConfig::const_iterator index = config.begin();
if (index == screenMap.end()) { if (index == config.end()) {
// no screens // no screens
resize(0, 0); resize(0, 0);
return true; return true;
@ -655,7 +655,7 @@ bool CHTTPServer::CScreenArray::convertFrom(
// put all but the first screen on the stack // put all but the first screen on the stack
// note -- if all screens are 4-connected then we can skip this // note -- if all screens are 4-connected then we can skip this
while (++index != screenMap.end()) { while (++index != config.end()) {
screenStack.push_back(*index); screenStack.push_back(*index);
} }
@ -686,7 +686,7 @@ bool CHTTPServer::CScreenArray::convertFrom(
// insert the screen's neighbors // insert the screen's neighbors
// FIXME -- handle edge wrapping // FIXME -- handle edge wrapping
CString neighbor; CString neighbor;
neighbor = screenMap.getNeighbor(name, CScreenMap::kLeft); neighbor = config.getNeighbor(name, CConfig::kLeft);
if (!neighbor.empty() && doneSet.count(neighbor) == 0) { if (!neighbor.empty() && doneSet.count(neighbor) == 0) {
// insert left neighbor, adding a column if necessary // insert left neighbor, adding a column if necessary
if (x == 0 || get(x - 1, y) != neighbor) { if (x == 0 || get(x - 1, y) != neighbor) {
@ -696,7 +696,7 @@ bool CHTTPServer::CScreenArray::convertFrom(
} }
screenStack.push_back(neighbor); screenStack.push_back(neighbor);
} }
neighbor = screenMap.getNeighbor(name, CScreenMap::kRight); neighbor = config.getNeighbor(name, CConfig::kRight);
if (!neighbor.empty() && doneSet.count(neighbor) == 0) { if (!neighbor.empty() && doneSet.count(neighbor) == 0) {
// insert right neighbor, adding a column if necessary // insert right neighbor, adding a column if necessary
if (x == m_w - 1 || get(x + 1, y) != neighbor) { if (x == m_w - 1 || get(x + 1, y) != neighbor) {
@ -705,7 +705,7 @@ bool CHTTPServer::CScreenArray::convertFrom(
} }
screenStack.push_back(neighbor); screenStack.push_back(neighbor);
} }
neighbor = screenMap.getNeighbor(name, CScreenMap::kTop); neighbor = config.getNeighbor(name, CConfig::kTop);
if (!neighbor.empty() && doneSet.count(neighbor) == 0) { if (!neighbor.empty() && doneSet.count(neighbor) == 0) {
// insert top neighbor, adding a row if necessary // insert top neighbor, adding a row if necessary
if (y == 0 || get(x, y - 1) != neighbor) { if (y == 0 || get(x, y - 1) != neighbor) {
@ -715,7 +715,7 @@ bool CHTTPServer::CScreenArray::convertFrom(
} }
screenStack.push_back(neighbor); screenStack.push_back(neighbor);
} }
neighbor = screenMap.getNeighbor(name, CScreenMap::kBottom); neighbor = config.getNeighbor(name, CConfig::kBottom);
if (!neighbor.empty() && doneSet.count(neighbor) == 0) { if (!neighbor.empty() && doneSet.count(neighbor) == 0) {
// insert bottom neighbor, adding a row if necessary // insert bottom neighbor, adding a row if necessary
if (y == m_h - 1 || get(x, y + 1) != neighbor) { if (y == m_h - 1 || get(x, y + 1) != neighbor) {
@ -728,7 +728,7 @@ bool CHTTPServer::CScreenArray::convertFrom(
// check symmetry // check symmetry
// FIXME -- handle edge wrapping // FIXME -- handle edge wrapping
for (index = screenMap.begin(); index != screenMap.end(); ++index) { for (index = config.begin(); index != config.end(); ++index) {
const CString& name = *index; const CString& name = *index;
SInt32 x, y; SInt32 x, y;
if (!find(name, x, y)) { if (!find(name, x, y)) {
@ -736,25 +736,25 @@ bool CHTTPServer::CScreenArray::convertFrom(
} }
CString neighbor; CString neighbor;
neighbor = screenMap.getNeighbor(name, CScreenMap::kLeft); neighbor = config.getNeighbor(name, CConfig::kLeft);
if ((x == 0 && !neighbor.empty()) || if ((x == 0 && !neighbor.empty()) ||
(x > 0 && get(x - 1, y) != neighbor)) { (x > 0 && get(x - 1, y) != neighbor)) {
return false; return false;
} }
neighbor = screenMap.getNeighbor(name, CScreenMap::kRight); neighbor = config.getNeighbor(name, CConfig::kRight);
if ((x == m_w - 1 && !neighbor.empty()) || if ((x == m_w - 1 && !neighbor.empty()) ||
(x < m_w - 1 && get(x + 1, y) != neighbor)) { (x < m_w - 1 && get(x + 1, y) != neighbor)) {
return false; return false;
} }
neighbor = screenMap.getNeighbor(name, CScreenMap::kTop); neighbor = config.getNeighbor(name, CConfig::kTop);
if ((y == 0 && !neighbor.empty()) || if ((y == 0 && !neighbor.empty()) ||
(y > 0 && get(x, y - 1) != neighbor)) { (y > 0 && get(x, y - 1) != neighbor)) {
return false; return false;
} }
neighbor = screenMap.getNeighbor(name, CScreenMap::kBottom); neighbor = config.getNeighbor(name, CConfig::kBottom);
if ((y == m_h - 1 && !neighbor.empty()) || if ((y == m_h - 1 && !neighbor.empty()) ||
(y < m_h - 1 && get(x, y + 1) != neighbor)) { (y < m_h - 1 && get(x, y + 1) != neighbor)) {
return false; return false;
@ -765,14 +765,14 @@ bool CHTTPServer::CScreenArray::convertFrom(
} }
void CHTTPServer::CScreenArray::convertTo( void CHTTPServer::CScreenArray::convertTo(
CScreenMap& screenMap) const CConfig& config) const
{ {
// add screens and find smallest box containing all screens // add screens and find smallest box containing all screens
SInt32 x0 = m_w, x1 = 0, y0 = m_h, y1 = 0; SInt32 x0 = m_w, x1 = 0, y0 = m_h, y1 = 0;
for (SInt32 y = 0; y < m_h; ++y) { for (SInt32 y = 0; y < m_h; ++y) {
for (SInt32 x = 0; x < m_w; ++x) { for (SInt32 x = 0; x < m_w; ++x) {
if (isSet(x, y)) { if (isSet(x, y)) {
screenMap.addScreen(get(x, y)); config.addScreen(get(x, y));
if (x < x0) { if (x < x0) {
x0 = x; x0 = x;
} }
@ -799,23 +799,23 @@ void CHTTPServer::CScreenArray::convertTo(
continue; continue;
} }
if (x > x0 && isSet(x - 1, y)) { if (x > x0 && isSet(x - 1, y)) {
screenMap.connect(get(x, y), config.connect(get(x, y),
CScreenMap::kLeft, CConfig::kLeft,
get(x - 1, y)); get(x - 1, y));
} }
if (x < x1 && isSet(x + 1, y)) { if (x < x1 && isSet(x + 1, y)) {
screenMap.connect(get(x, y), config.connect(get(x, y),
CScreenMap::kRight, CConfig::kRight,
get(x + 1, y)); get(x + 1, y));
} }
if (y > y0 && isSet(x, y - 1)) { if (y > y0 && isSet(x, y - 1)) {
screenMap.connect(get(x, y), config.connect(get(x, y),
CScreenMap::kTop, CConfig::kTop,
get(x, y - 1)); get(x, y - 1));
} }
if (y < y1 && isSet(x, y + 1)) { if (y < y1 && isSet(x, y + 1)) {
screenMap.connect(get(x, y), config.connect(get(x, y),
CScreenMap::kBottom, CConfig::kBottom,
get(x, y + 1)); get(x, y + 1));
} }
} }

View File

@ -6,7 +6,7 @@
#include <vector> #include <vector>
class CServer; class CServer;
class CScreenMap; class CConfig;
class CHTTPRequest; class CHTTPRequest;
class CHTTPReply; class CHTTPReply;
class ISocket; class ISocket;
@ -56,10 +56,10 @@ protected:
void remove(SInt32 x, SInt32 y); void remove(SInt32 x, SInt32 y);
void set(SInt32 x, SInt32 y, const CString&); 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 // all connections are symmetric and therefore exactly
// representable by a CScreenArray. // representable by a CScreenArray.
bool convertFrom(const CScreenMap&); bool convertFrom(const CConfig&);
// accessors // accessors
@ -84,8 +84,8 @@ protected:
// to other screens. // to other screens.
bool isValid() const; bool isValid() const;
// convert this to a CScreenMap // convert this to a CConfig
void convertTo(CScreenMap&) const; void convertTo(CConfig&) const;
private: private:
typedef std::vector<CString> CNames; typedef std::vector<CString> CNames;

View File

@ -2,20 +2,20 @@
#include <assert.h> #include <assert.h>
// //
// CScreenMap // CConfig
// //
CScreenMap::CScreenMap() CConfig::CConfig()
{ {
// do nothing // do nothing
} }
CScreenMap::~CScreenMap() CConfig::~CConfig()
{ {
// do nothing // do nothing
} }
void CScreenMap::addScreen(const CString& name) void CConfig::addScreen(const CString& name)
{ {
if (m_map.count(name) != 0) { if (m_map.count(name) != 0) {
assert(0 && "name already in map"); // FIXME -- throw instead 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())); 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); CCellMap::iterator index = m_map.find(name);
if (index == m_map.end()) { if (index == m_map.end()) {
@ -43,12 +43,12 @@ void CScreenMap::removeScreen(const CString& name)
} }
} }
void CScreenMap::removeAllScreens() void CConfig::removeAllScreens()
{ {
m_map.clear(); m_map.clear();
} }
void CScreenMap::connect(const CString& srcName, void CConfig::connect(const CString& srcName,
EDirection srcSide, EDirection srcSide,
const CString& dstName) const CString& dstName)
{ {
@ -62,7 +62,7 @@ void CScreenMap::connect(const CString& srcName,
index->second.m_neighbor[srcSide - kFirstDirection] = dstName; index->second.m_neighbor[srcSide - kFirstDirection] = dstName;
} }
void CScreenMap::disconnect(const CString& srcName, void CConfig::disconnect(const CString& srcName,
EDirection srcSide) EDirection srcSide)
{ {
// find source cell // find source cell
@ -75,19 +75,17 @@ void CScreenMap::disconnect(const CString& srcName,
index->second.m_neighbor[srcSide - kFirstDirection].erase(); index->second.m_neighbor[srcSide - kFirstDirection].erase();
} }
CScreenMap::const_iterator CConfig::const_iterator CConfig::begin() const
CScreenMap::begin() const
{ {
return const_iterator(m_map.begin()); return const_iterator(m_map.begin());
} }
CScreenMap::const_iterator CConfig::const_iterator CConfig::end() const
CScreenMap::end() const
{ {
return const_iterator(m_map.end()); return const_iterator(m_map.end());
} }
CString CScreenMap::getNeighbor(const CString& srcName, CString CConfig::getNeighbor(const CString& srcName,
EDirection srcSide) const EDirection srcSide) const
{ {
// find source cell // find source cell
@ -100,7 +98,7 @@ CString CScreenMap::getNeighbor(const CString& srcName,
return index->second.m_neighbor[srcSide - kFirstDirection]; 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" }; static const char* s_name[] = { "left", "right", "top", "bottom" };
return s_name[dir - kFirstDirection]; return s_name[dir - kFirstDirection];

View File

@ -110,13 +110,13 @@ void CServer::quit()
m_primary->stop(); m_primary->stop();
} }
void CServer::setScreenMap(const CScreenMap& screenMap) void CServer::setConfig(const CConfig& config)
{ {
CLock lock(&m_mutex); CLock lock(&m_mutex);
// FIXME -- must disconnect screens no longer listed // FIXME -- must disconnect screens no longer listed
// (that may include warping back to server's screen) // (that may include warping back to server's screen)
// FIXME -- server screen must be in new map or map is rejected // FIXME -- server screen must be in new map or map is rejected
m_screenMap = screenMap; m_config = config;
} }
CString CServer::getPrimaryScreenName() const CString CServer::getPrimaryScreenName() const
@ -125,26 +125,26 @@ CString CServer::getPrimaryScreenName() const
return (m_primaryInfo == NULL) ? "" : m_primaryInfo->m_name; 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); CLock lock(&m_mutex);
*screenMap = m_screenMap; *config = m_config;
} }
UInt32 CServer::getActivePrimarySides() const UInt32 CServer::getActivePrimarySides() const
{ {
UInt32 sides = 0; UInt32 sides = 0;
CLock lock(&m_mutex); CLock lock(&m_mutex);
if (!m_screenMap.getNeighbor("primary", CScreenMap::kLeft).empty()) if (!m_config.getNeighbor("primary", CConfig::kLeft).empty())
sides |= CScreenMap::kLeftMask; sides |= CConfig::kLeftMask;
if (!m_screenMap.getNeighbor("primary", CScreenMap::kRight).empty()) if (!m_config.getNeighbor("primary", CConfig::kRight).empty())
sides |= CScreenMap::kRightMask; sides |= CConfig::kRightMask;
if (!m_screenMap.getNeighbor("primary", CScreenMap::kTop).empty()) if (!m_config.getNeighbor("primary", CConfig::kTop).empty())
sides |= CScreenMap::kTopMask; sides |= CConfig::kTopMask;
if (!m_screenMap.getNeighbor("primary", CScreenMap::kBottom).empty()) if (!m_config.getNeighbor("primary", CConfig::kBottom).empty())
sides |= CScreenMap::kBottomMask; sides |= CConfig::kBottomMask;
return sides; return sides;
} }
@ -388,25 +388,25 @@ bool CServer::onMouseMovePrimary(SInt32 x, SInt32 y)
} }
// see if we should change screens // see if we should change screens
CScreenMap::EDirection dir; CConfig::EDirection dir;
if (x < m_active->m_zoneSize) { if (x < m_active->m_zoneSize) {
x -= m_active->m_zoneSize; x -= m_active->m_zoneSize;
dir = CScreenMap::kLeft; dir = CConfig::kLeft;
log((CLOG_DEBUG1 "switch to left")); log((CLOG_DEBUG1 "switch to left"));
} }
else if (x >= m_active->m_width - m_active->m_zoneSize) { else if (x >= m_active->m_width - m_active->m_zoneSize) {
x += m_active->m_zoneSize; x += m_active->m_zoneSize;
dir = CScreenMap::kRight; dir = CConfig::kRight;
log((CLOG_DEBUG1 "switch to right")); log((CLOG_DEBUG1 "switch to right"));
} }
else if (y < m_active->m_zoneSize) { else if (y < m_active->m_zoneSize) {
y -= m_active->m_zoneSize; y -= m_active->m_zoneSize;
dir = CScreenMap::kTop; dir = CConfig::kTop;
log((CLOG_DEBUG1 "switch to top")); log((CLOG_DEBUG1 "switch to top"));
} }
else if (y >= m_active->m_height - m_active->m_zoneSize) { else if (y >= m_active->m_height - m_active->m_zoneSize) {
y += m_active->m_zoneSize; y += m_active->m_zoneSize;
dir = CScreenMap::kBottom; dir = CConfig::kBottom;
log((CLOG_DEBUG1 "switch to bottom")); log((CLOG_DEBUG1 "switch to bottom"));
} }
else { else {
@ -451,21 +451,21 @@ void CServer::onMouseMoveSecondary(SInt32 dx, SInt32 dy)
CScreenInfo* newScreen = NULL; CScreenInfo* newScreen = NULL;
if (!isLockedToScreen()) { if (!isLockedToScreen()) {
// find direction of neighbor // find direction of neighbor
CScreenMap::EDirection dir; CConfig::EDirection dir;
if (m_x < 0) if (m_x < 0)
dir = CScreenMap::kLeft; dir = CConfig::kLeft;
else if (m_x > m_active->m_width - 1) else if (m_x > m_active->m_width - 1)
dir = CScreenMap::kRight; dir = CConfig::kRight;
else if (m_y < 0) else if (m_y < 0)
dir = CScreenMap::kTop; dir = CConfig::kTop;
else if (m_y > m_active->m_height - 1) else if (m_y > m_active->m_height - 1)
dir = CScreenMap::kBottom; dir = CConfig::kBottom;
else else
newScreen = m_active; newScreen = m_active;
// get neighbor if we should switch // get neighbor if we should switch
if (newScreen == NULL) { 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; SInt32 x = m_x, y = m_y;
newScreen = getNeighbor(m_active, dir, x, y); newScreen = getNeighbor(m_active, dir, x, y);
@ -612,20 +612,20 @@ void CServer::switchScreen(CScreenInfo* dst,
} }
CServer::CScreenInfo* CServer::getNeighbor(CScreenInfo* src, CServer::CScreenInfo* CServer::getNeighbor(CScreenInfo* src,
CScreenMap::EDirection dir) const CConfig::EDirection dir) const
{ {
assert(src != NULL); assert(src != NULL);
CString srcName = src->m_name; CString srcName = src->m_name;
assert(!srcName.empty()); 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 (;;) { for (;;) {
// look up name of neighbor // 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 nothing in that direction then return NULL
if (dstName.empty()) { 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; return NULL;
} }
@ -634,17 +634,17 @@ CServer::CScreenInfo* CServer::getNeighbor(CScreenInfo* src,
// screen. // screen.
CScreenList::const_iterator index = m_screens.find(dstName); CScreenList::const_iterator index = m_screens.find(dstName);
if (index != m_screens.end()) { 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; 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; srcName = dstName;
} }
} }
CServer::CScreenInfo* CServer::getNeighbor(CScreenInfo* src, CServer::CScreenInfo* CServer::getNeighbor(CScreenInfo* src,
CScreenMap::EDirection srcSide, CConfig::EDirection srcSide,
SInt32& x, SInt32& y) const SInt32& x, SInt32& y) const
{ {
assert(src != NULL); assert(src != NULL);
@ -658,7 +658,7 @@ CServer::CScreenInfo* CServer::getNeighbor(CScreenInfo* src,
// find destination screen, adjusting x or y (but not both) // find destination screen, adjusting x or y (but not both)
switch (srcSide) { switch (srcSide) {
case CScreenMap::kLeft: case CConfig::kLeft:
while (dst != NULL) { while (dst != NULL) {
lastGoodScreen = dst; lastGoodScreen = dst;
w = lastGoodScreen->m_width; w = lastGoodScreen->m_width;
@ -672,7 +672,7 @@ CServer::CScreenInfo* CServer::getNeighbor(CScreenInfo* src,
} }
break; break;
case CScreenMap::kRight: case CConfig::kRight:
while (dst != NULL) { while (dst != NULL) {
lastGoodScreen = dst; lastGoodScreen = dst;
x -= w; x -= w;
@ -686,7 +686,7 @@ CServer::CScreenInfo* CServer::getNeighbor(CScreenInfo* src,
} }
break; break;
case CScreenMap::kTop: case CConfig::kTop:
while (dst != NULL) { while (dst != NULL) {
lastGoodScreen = dst; lastGoodScreen = dst;
w = lastGoodScreen->m_width; w = lastGoodScreen->m_width;
@ -700,7 +700,7 @@ CServer::CScreenInfo* CServer::getNeighbor(CScreenInfo* src,
} }
break; break;
case CScreenMap::kBottom: case CConfig::kBottom:
while (dst != NULL) { while (dst != NULL) {
lastGoodScreen = dst; lastGoodScreen = dst;
y -= h; y -= h;
@ -727,26 +727,26 @@ CServer::CScreenInfo* CServer::getNeighbor(CScreenInfo* src,
if (lastGoodScreen->m_protocol == NULL) { if (lastGoodScreen->m_protocol == NULL) {
const CString dstName(lastGoodScreen->m_name); const CString dstName(lastGoodScreen->m_name);
switch (srcSide) { switch (srcSide) {
case CScreenMap::kLeft: case CConfig::kLeft:
if (!m_screenMap.getNeighbor(dstName, CScreenMap::kRight).empty() && if (!m_config.getNeighbor(dstName, CConfig::kRight).empty() &&
x > w - 1 - lastGoodScreen->m_zoneSize) x > w - 1 - lastGoodScreen->m_zoneSize)
x = w - 1 - lastGoodScreen->m_zoneSize; x = w - 1 - lastGoodScreen->m_zoneSize;
break; break;
case CScreenMap::kRight: case CConfig::kRight:
if (!m_screenMap.getNeighbor(dstName, CScreenMap::kLeft).empty() && if (!m_config.getNeighbor(dstName, CConfig::kLeft).empty() &&
x < lastGoodScreen->m_zoneSize) x < lastGoodScreen->m_zoneSize)
x = lastGoodScreen->m_zoneSize; x = lastGoodScreen->m_zoneSize;
break; break;
case CScreenMap::kTop: case CConfig::kTop:
if (!m_screenMap.getNeighbor(dstName, CScreenMap::kBottom).empty() && if (!m_config.getNeighbor(dstName, CConfig::kBottom).empty() &&
y > h - 1 - lastGoodScreen->m_zoneSize) y > h - 1 - lastGoodScreen->m_zoneSize)
y = h - 1 - lastGoodScreen->m_zoneSize; y = h - 1 - lastGoodScreen->m_zoneSize;
break; break;
case CScreenMap::kBottom: case CConfig::kBottom:
if (!m_screenMap.getNeighbor(dstName, CScreenMap::kTop).empty() && if (!m_config.getNeighbor(dstName, CConfig::kTop).empty() &&
y < lastGoodScreen->m_zoneSize) y < lastGoodScreen->m_zoneSize)
y = lastGoodScreen->m_zoneSize; y = lastGoodScreen->m_zoneSize;
break; break;
@ -757,18 +757,18 @@ CServer::CScreenInfo* CServer::getNeighbor(CScreenInfo* src,
} }
void CServer::mapPosition(CScreenInfo* src, void CServer::mapPosition(CScreenInfo* src,
CScreenMap::EDirection srcSide, CConfig::EDirection srcSide,
CScreenInfo* dst, CScreenInfo* dst,
SInt32& x, SInt32& y) const SInt32& x, SInt32& y) const
{ {
assert(src != NULL); assert(src != NULL);
assert(dst != NULL); assert(dst != NULL);
assert(srcSide >= CScreenMap::kFirstDirection && assert(srcSide >= CConfig::kFirstDirection &&
srcSide <= CScreenMap::kLastDirection); srcSide <= CConfig::kLastDirection);
switch (srcSide) { switch (srcSide) {
case CScreenMap::kLeft: case CConfig::kLeft:
case CScreenMap::kRight: case CConfig::kRight:
if (y < 0) if (y < 0)
y = 0; y = 0;
else if (y >= src->m_height) else if (y >= src->m_height)
@ -779,8 +779,8 @@ void CServer::mapPosition(CScreenInfo* src,
(src->m_height - 1)); (src->m_height - 1));
break; break;
case CScreenMap::kTop: case CConfig::kTop:
case CScreenMap::kBottom: case CConfig::kBottom:
if (x < 0) if (x < 0)
x = 0; x = 0;
else if (x >= src->m_width) else if (x >= src->m_width)

View File

@ -33,7 +33,7 @@ public:
void quit(); void quit();
// update screen map // update screen map
void setScreenMap(const CScreenMap&); void setConfig(const CConfig&);
// handle events on server's screen. onMouseMovePrimary() returns // handle events on server's screen. onMouseMovePrimary() returns
// true iff the mouse enters a jump zone and jumps. // true iff the mouse enters a jump zone and jumps.
@ -67,7 +67,7 @@ public:
bool isLockedToScreen() const; bool isLockedToScreen() const;
// get the current screen map // get the current screen map
void getScreenMap(CScreenMap*) const; void getConfig(CConfig*) const;
// get the primary screen's name // get the primary screen's name
CString getPrimaryScreenName() const; CString getPrimaryScreenName() const;
@ -116,21 +116,21 @@ private:
void switchScreen(CScreenInfo*, SInt32 x, SInt32 y); void switchScreen(CScreenInfo*, SInt32 x, SInt32 y);
// lookup neighboring screen // lookup neighboring screen
CScreenInfo* getNeighbor(CScreenInfo*, CScreenMap::EDirection) const; CScreenInfo* getNeighbor(CScreenInfo*, CConfig::EDirection) const;
// lookup neighboring screen. given a position relative to the // lookup neighboring screen. given a position relative to the
// source screen, find the screen we should move onto and where. // source screen, find the screen we should move onto and where.
// if the position is sufficiently far from the source then we // if the position is sufficiently far from the source then we
// cross multiple screens. // cross multiple screens.
CScreenInfo* getNeighbor(CScreenInfo*, CScreenInfo* getNeighbor(CScreenInfo*,
CScreenMap::EDirection, CConfig::EDirection,
SInt32& x, SInt32& y) const; SInt32& x, SInt32& y) const;
// adjust coordinates to account for resolution differences. the // adjust coordinates to account for resolution differences. the
// position is converted to a resolution independent form then // position is converted to a resolution independent form then
// converted back to screen coordinates on the destination screen. // converted back to screen coordinates on the destination screen.
void mapPosition(CScreenInfo* src, void mapPosition(CScreenInfo* src,
CScreenMap::EDirection srcSide, CConfig::EDirection srcSide,
CScreenInfo* dst, CScreenInfo* dst,
SInt32& x, SInt32& y) const; SInt32& x, SInt32& y) const;
@ -207,7 +207,7 @@ private:
// current mouse position (in absolute secondary screen coordinates) // current mouse position (in absolute secondary screen coordinates)
SInt32 m_x, m_y; SInt32 m_x, m_y;
CScreenMap m_screenMap; CConfig m_config;
CClipboardInfo m_clipboards[kClipboardEnd]; CClipboardInfo m_clipboards[kClipboardEnd];

View File

@ -187,16 +187,16 @@ static LRESULT CALLBACK mouseHook(int code, WPARAM wParam, LPARAM lParam)
const MOUSEHOOKSTRUCT* info = (const MOUSEHOOKSTRUCT*)lParam; const MOUSEHOOKSTRUCT* info = (const MOUSEHOOKSTRUCT*)lParam;
SInt32 x = (SInt32)info->pt.x; SInt32 x = (SInt32)info->pt.x;
SInt32 y = (SInt32)info->pt.y; SInt32 y = (SInt32)info->pt.y;
if (!inside && (g_zoneSides & CScreenMap::kLeftMask) != 0) { if (!inside && (g_zoneSides & CConfig::kLeftMask) != 0) {
inside = (x < g_zoneSize); inside = (x < g_zoneSize);
} }
if (!inside && (g_zoneSides & CScreenMap::kRightMask) != 0) { if (!inside && (g_zoneSides & CConfig::kRightMask) != 0) {
inside = (x >= g_wScreen - g_zoneSize); inside = (x >= g_wScreen - g_zoneSize);
} }
if (!inside && (g_zoneSides & CScreenMap::kTopMask) != 0) { if (!inside && (g_zoneSides & CConfig::kTopMask) != 0) {
inside = (y < g_zoneSize); inside = (y < g_zoneSize);
} }
if (!inside && (g_zoneSides & CScreenMap::kBottomMask) != 0) { if (!inside && (g_zoneSides & CConfig::kBottomMask) != 0) {
inside = (y >= g_hScreen - g_zoneSize); inside = (y >= g_hScreen - g_zoneSize);
} }

View File

@ -41,19 +41,19 @@ void realMain()
// initialize network library // initialize network library
CNetwork::init(); CNetwork::init();
CScreenMap screenMap; CConfig config;
screenMap.addScreen("primary"); config.addScreen("primary");
screenMap.addScreen("secondary"); config.addScreen("secondary");
screenMap.addScreen("secondary2"); config.addScreen("secondary2");
screenMap.connect("primary", CScreenMap::kRight, "secondary"); config.connect("primary", CConfig::kRight, "secondary");
screenMap.connect("secondary", CScreenMap::kLeft, "primary"); config.connect("secondary", CConfig::kLeft, "primary");
screenMap.connect("secondary", CScreenMap::kRight, "secondary2"); config.connect("secondary", CConfig::kRight, "secondary2");
screenMap.connect("secondary2", CScreenMap::kLeft, "secondary"); config.connect("secondary2", CConfig::kLeft, "secondary");
CServer* server = NULL; CServer* server = NULL;
try { try {
server = new CServer(); server = new CServer();
server->setScreenMap(screenMap); server->setConfig(config);
server->run(); server->run();
delete server; delete server;
CNetwork::cleanup(); CNetwork::cleanup();