added better handling of X server disconnecting unexpectedly.

the apps still exit but they do it in a mostly controlled
manner.  in particular, the server threads except the one
processing primary screen events will terminate gracefully.
this will be important should the server ever allow HTTP
clients to rewrite the configuration file.

note that X makes it effectively impossible to continue once
the X server disconnects.  even if it didn't it would be
difficult for synergy to recover.  users will have to add
synergy to the X display manager's startup script if they
expect the server to be restarted.  alternatively, we could
add code to fork synergy at startup;  the child would do
the normal work while the parent would simply wait for the
child to exit and restart it.
This commit is contained in:
crs
2002-06-03 13:45:30 +00:00
parent ddbb465540
commit 1cbdaee31b
13 changed files with 242 additions and 70 deletions

View File

@@ -179,6 +179,7 @@ void CXWindowsPrimaryScreen::run()
void CXWindowsPrimaryScreen::stop()
{
CDisplayLock display(this);
doStop();
}
@@ -187,12 +188,12 @@ void CXWindowsPrimaryScreen::open(CServer* server)
assert(m_server == NULL);
assert(server != NULL);
// set the server
m_server = server;
// open the display
openDisplay();
// set the server
m_server = server;
// check for peculiarities
// FIXME -- may have to get these from some database
m_numLockHalfDuplex = false;
@@ -419,12 +420,10 @@ bool CXWindowsPrimaryScreen::isLockedToScreen() const
return false;
}
void CXWindowsPrimaryScreen::onOpenDisplay()
void CXWindowsPrimaryScreen::onOpenDisplay(Display* display)
{
assert(m_window == None);
CDisplayLock display(this);
// get size of screen
SInt32 w, h;
getScreenSize(&w, &h);
@@ -458,16 +457,25 @@ CXWindowsClipboard* CXWindowsPrimaryScreen::createClipboard(
return new CXWindowsClipboard(display, m_window, id);
}
void CXWindowsPrimaryScreen::onCloseDisplay()
void CXWindowsPrimaryScreen::onCloseDisplay(Display* display)
{
assert(m_window != None);
// destroy window
CDisplayLock display(this);
XDestroyWindow(display, m_window);
if (display != NULL) {
XDestroyWindow(display, m_window);
}
m_window = None;
}
void CXWindowsPrimaryScreen::onUnexpectedClose()
{
// tell server to shutdown
if (m_server != NULL) {
m_server->shutdown();
}
}
void CXWindowsPrimaryScreen::onLostClipboard(
ClipboardID id)
{