Revert "Refactor Issue #5041 workaround to make sure we still send the SCREENSAVER message"

This reverts commit 43ba3e889f88e526673ff70caf2b3efe26b13363.
This commit is contained in:
Jerry (Xinyu Hou) 2015-12-02 15:02:38 -08:00 committed by Xinyu Hou
parent 4d19941428
commit da5e9527a3
1 changed files with 20 additions and 27 deletions

View File

@ -851,24 +851,30 @@ MSWindowsDesks::checkDesk()
desk = index->second;
}
// if we are told to shut down on desk switch, and this is not the
// first switch, then shut down.
// Issue #5041 workaround - prevent synergys from shutting down when screen
// saver activates - if it is restarted while the screen saver is active,
// the clipboard no longer works.
if (m_stopOnDeskSwitch && m_activeDesk != NULL && name != m_activeDeskName) {
if (!m_screensaver->isActive()) {
LOG((CLOG_DEBUG "shutting down because of desk switch \"%s\"->\"%s\"",
m_activeDeskName.c_str(), name.c_str()));
m_events->addEvent(Event(Event::kQuit));
return;
}
LOG((CLOG_DEBUG "screen saver active, ignoring desk switch \"%s\"->\"%s\"",
m_activeDeskName.c_str(), name.c_str()));
m_activeDesk = desk;
m_activeDeskName = name;
}
// if active desktop changed then tell the old and new desk threads
// about the change. don't switch desktops when the screensaver is
// active becaue we'd most likely switch to the screensaver desktop
// which would have the side effect of forcing the screensaver to
// stop.
if (name != m_activeDeskName && !m_screensaver->isActive()) {
// if we are told to shut down on desk switch, and this is not the
// first switch, then shut down.
// Issue #5041 workaround - prevent synergys from shutting down when
// screen saver activates - if it is restarted while the screen saver
// is active, the clipboard no longer works.
if (m_stopOnDeskSwitch && m_activeDesk != NULL) {
LOG((CLOG_DEBUG "shutting down because of desk switch \"%s\"->\"%s\"",
m_activeDeskName.c_str(), name.c_str()));
m_events->addEvent(Event(Event::kQuit));
return;
}
// show cursor on previous desk
bool wasOnScreen = m_isOnScreen;
if (!wasOnScreen) {
@ -879,10 +885,7 @@ MSWindowsDesks::checkDesk()
// from an inaccessible desktop so when we switch from an
// inaccessible desktop to an accessible one we have to
// update the keyboard state.
if (m_activeDesk != NULL) {
LOG((CLOG_DEBUG "switched desk \"%s\"->\"%s\"",
m_activeDeskName.c_str(), name.c_str()));
}
LOG((CLOG_DEBUG "switched to desk \"%s\"", name.c_str()));
bool syncKeys = false;
bool isAccessible = isDeskAccessible(desk);
if (isDeskAccessible(m_activeDesk) != isAccessible) {
@ -911,18 +914,8 @@ MSWindowsDesks::checkDesk()
}
}
else if (name != m_activeDeskName) {
if (m_activeDesk != NULL) {
LOG((CLOG_DEBUG "switched desk \"%s\"->\"%s\"",
m_activeDeskName.c_str(), name.c_str()));
}
// screen saver is active (see check above)
// screen saver might have started
PostThreadMessage(m_threadID, SYNERGY_MSG_SCREEN_SAVER, TRUE, 0);
// Prevent this from retriggering over and over if screen saver stays
// active:
m_activeDesk = desk;
m_activeDeskName = name;
}
}