Added global configuration option to disable screen saver

synchronization.
This commit is contained in:
crs 2003-05-03 14:38:36 +00:00
parent 65de05e3ec
commit ed439ec33c
6 changed files with 112 additions and 15 deletions

View File

@ -300,13 +300,13 @@ CMSWindowsSecondaryScreen::mouseWheel(SInt32 delta)
void
CMSWindowsSecondaryScreen::resetOptions()
{
// no options
CSecondaryScreen::resetOptions();
}
void
CMSWindowsSecondaryScreen::setOptions(const COptionsList& /*options*/)
CMSWindowsSecondaryScreen::setOptions(const COptionsList& options)
{
// no options
CSecondaryScreen::setOptions(options);
}
IScreen*

View File

@ -287,6 +287,7 @@ CXWindowsSecondaryScreen::resetOptions()
{
m_numLockHalfDuplex = false;
m_capsLockHalfDuplex = false;
CSecondaryScreen::resetOptions();
}
void
@ -302,6 +303,7 @@ CXWindowsSecondaryScreen::setOptions(const COptionsList& options)
LOG((CLOG_DEBUG1 "half-duplex num-lock %s", m_numLockHalfDuplex ? "on" : "off"));
}
}
CSecondaryScreen::setOptions(options);
}
IScreen*

View File

@ -640,6 +640,9 @@ CConfig::getOptionName(OptionID id)
if (id == kOptionScreenSwitchTwoTap) {
return "switchDoubleTap";
}
if (id == kOptionScreenSaverSync) {
return "screenSaverSync";
}
return NULL;
}
@ -647,7 +650,8 @@ CString
CConfig::getOptionValue(OptionID id, OptionValue value)
{
if (id == kOptionHalfDuplexCapsLock ||
id == kOptionHalfDuplexNumLock) {
id == kOptionHalfDuplexNumLock ||
id == kOptionScreenSaverSync) {
return (value != 0) ? "true" : "false";
}
if (id == kOptionModifierMapForShift ||
@ -791,6 +795,9 @@ CConfig::readSectionOptions(std::istream& s)
else if (name == "switchDoubleTap") {
addOption("", kOptionScreenSwitchTwoTap, parseInt(value));
}
else if (name == "screenSaverSync") {
addOption("", kOptionScreenSaverSync, parseBoolean(value));
}
else {
throw XConfigRead("unknown argument");
}

View File

@ -23,8 +23,10 @@
//
CSecondaryScreen::CSecondaryScreen() :
m_remoteReady(false),
m_active(false),
m_toggleKeys(0)
m_toggleKeys(0),
m_screenSaverSync(true)
{
// do nothing
}
@ -106,14 +108,23 @@ CSecondaryScreen::remoteControl()
// update keyboard state
updateKeys();
// disable the screen saver
getScreen()->openScreensaver(false);
// hide the cursor
// now remote ready. fake being active for call to leave().
bool screenSaverSync;
{
CLock lock(&m_mutex);
m_active = true;
m_remoteReady = true;
m_active = true;
// copy screen saver synchronization state
screenSaverSync = m_screenSaverSync;
}
// disable the screen saver if synchronization is enabled
if (screenSaverSync) {
getScreen()->openScreensaver(false);
}
// hide the cursor
leave();
}
@ -121,6 +132,10 @@ void
CSecondaryScreen::localControl()
{
getScreen()->closeScreensaver();
// not remote ready anymore
CLock lock(&m_mutex);
m_remoteReady = false;
}
void
@ -204,7 +219,71 @@ CSecondaryScreen::grabClipboard(ClipboardID id)
void
CSecondaryScreen::screensaver(bool activate)
{
getScreen()->screensaver(activate);
// get screen saver synchronization flag
bool screenSaverSync;
{
CLock lock(&m_mutex);
screenSaverSync = m_screenSaverSync;
}
// activate/deactivation screen saver iff synchronization enabled
if (screenSaverSync) {
LOG((CLOG_INFO "screensaver(%s)", activate ? "on" : "off"));
getScreen()->screensaver(activate);
}
else {
LOG((CLOG_INFO "screensaver(%s) ignored", activate ? "on" : "off"));
}
}
void
CSecondaryScreen::resetOptions()
{
// set screen saver synchronization flag and see if we need to
// update the screen saver synchronization.
bool screenSaverSyncOn;
{
CLock lock(&m_mutex);
screenSaverSyncOn = (!m_screenSaverSync && m_remoteReady);
m_screenSaverSync = true;
}
// update screen saver synchronization
if (screenSaverSyncOn) {
getScreen()->openScreensaver(false);
}
}
void
CSecondaryScreen::setOptions(const COptionsList& options)
{
// update options
bool updateScreenSaverSync = false;
bool oldScreenSaverSync;
{
CLock lock(&m_mutex);
oldScreenSaverSync = m_screenSaverSync;
for (UInt32 i = 0, n = options.size(); i < n; i += 2) {
if (options[i] == kOptionScreenSaverSync) {
updateScreenSaverSync = true;
m_screenSaverSync = (options[i + 1] != 0);
LOG((CLOG_DEBUG1 "screen saver synchronization %s", m_screenSaverSync ? "on" : "off"));
}
}
if (!m_remoteReady || oldScreenSaverSync == m_screenSaverSync) {
updateScreenSaverSync = false;
}
}
// update screen saver synchronization
if (updateScreenSaverSync) {
if (oldScreenSaverSync) {
getScreen()->closeScreensaver();
}
else {
getScreen()->openScreensaver(false);
}
}
}
bool

View File

@ -177,16 +177,18 @@ public:
//! Notify of options changes
/*!
Reset all options to their default values.
Reset all options to their default values. Overrides should call
the superclass's method.
*/
virtual void resetOptions() = 0;
virtual void resetOptions();
//! Notify of options changes
/*!
Set options to given values. Ignore unknown options and don't
modify our options that aren't given in \c options.
modify our options that aren't given in \c options. Overrides
should call the superclass's method.
*/
virtual void setOptions(const COptionsList& options) = 0;
virtual void setOptions(const COptionsList& options);
//@}
//! @name accessors
@ -372,11 +374,17 @@ protected:
private:
CMutex m_mutex;
// true if ready for remote control
bool m_remoteReady;
// m_active is true if this screen has been entered
bool m_active;
// the toggle key state when this screen was last entered
KeyModifierMask m_toggleKeys;
// true if screen saver should be synchronized to server
bool m_screenSaverSync;
};
#endif

View File

@ -53,6 +53,7 @@ static const OptionID kOptionModifierMapForSuper = OPTION_CODE("MMFR");
static const OptionID kOptionHeartbeat = OPTION_CODE("HART");
static const OptionID kOptionScreenSwitchDelay = OPTION_CODE("SSWT");
static const OptionID kOptionScreenSwitchTwoTap = OPTION_CODE("SSTT");
static const OptionID kOptionScreenSaverSync = OPTION_CODE("SSVR");
//@}
#undef OPTION_CODE