mirror of
https://github.com/debauchee/barrier.git
synced 2024-12-24 03:23:15 +03:00
Fixed lookup of neighbor screens. The first problem was an old
code in a conditional for moving left that blew an assert verifying that the mouse position was really on the screen if the neighbor screen wasn't connected. After that was fixed there was another problem when one screen linked to another which then linked (in the same direction) to itself. If the latter screen wasn't connected then it'd get into an infinite loop.
This commit is contained in:
parent
a8bd4e7ff0
commit
24c0b3fd32
@ -841,30 +841,44 @@ CServer::getNeighbor(IClient* src, EDirection dir) const
|
||||
|
||||
assert(src != NULL);
|
||||
|
||||
// get source screen name
|
||||
CString srcName = src->getName();
|
||||
assert(!srcName.empty());
|
||||
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_config.getNeighbor(srcName, dir));
|
||||
|
||||
// if nothing in that direction then return NULL
|
||||
if (dstName.empty()) {
|
||||
// get first neighbor. if it's the source then the source jumps
|
||||
// to itself and we return the source.
|
||||
CString dstName(m_config.getNeighbor(srcName, dir));
|
||||
if (dstName == srcName) {
|
||||
LOG((CLOG_DEBUG2 "\"%s\" is on %s of \"%s\"", dstName.c_str(), CConfig::dirName(dir), srcName.c_str()));
|
||||
return src;
|
||||
}
|
||||
|
||||
// keep checking
|
||||
for (;;) {
|
||||
// if nothing in that direction then return NULL. if the
|
||||
// destination is the source then we can make no more
|
||||
// progress in this direction. since we haven't found a
|
||||
// connected neighbor we return NULL.
|
||||
if (dstName.empty() || dstName == srcName) {
|
||||
LOG((CLOG_DEBUG2 "no neighbor on %s of \"%s\"", CConfig::dirName(dir), srcName.c_str()));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// look up neighbor cell. if the screen is connected and
|
||||
// ready then we can stop. otherwise we skip over an
|
||||
// unconnected screen.
|
||||
// ready then we can stop.
|
||||
CClientList::const_iterator index = m_clients.find(dstName);
|
||||
if (index != m_clients.end()) {
|
||||
LOG((CLOG_DEBUG2 "\"%s\" is on %s of \"%s\"", dstName.c_str(), CConfig::dirName(dir), srcName.c_str()));
|
||||
return index->second;
|
||||
}
|
||||
|
||||
// skip over unconnected screen
|
||||
LOG((CLOG_DEBUG2 "ignored \"%s\" on %s of \"%s\"", dstName.c_str(), CConfig::dirName(dir), srcName.c_str()));
|
||||
srcName = dstName;
|
||||
|
||||
// look up name of neighbor of skipped screen
|
||||
dstName = m_config.getNeighbor(srcName, dir);
|
||||
}
|
||||
}
|
||||
|
||||
@ -897,7 +911,7 @@ CServer::getNeighbor(IClient* src,
|
||||
switch (srcSide) {
|
||||
case kLeft:
|
||||
x -= dx;
|
||||
while (dst != NULL && dst != lastGoodScreen) {
|
||||
while (dst != NULL) {
|
||||
lastGoodScreen = dst;
|
||||
lastGoodScreen->getShape(dx, dy, dw, dh);
|
||||
x += dw;
|
||||
|
Loading…
Reference in New Issue
Block a user