(Maybe) fixed a problem detecting when win32 screen saver started.
This commit is contained in:
parent
a80ddb4a78
commit
ccb45bc2bc
|
@ -115,6 +115,8 @@ CMSWindowsDesks::~CMSWindowsDesks()
|
|||
void
|
||||
CMSWindowsDesks::enable()
|
||||
{
|
||||
m_threadID = GetCurrentThreadId();
|
||||
|
||||
// set the active desk and (re)install the hooks
|
||||
checkDesk();
|
||||
|
||||
|
@ -844,6 +846,10 @@ CMSWindowsDesks::checkDesk()
|
|||
sendMessage(SYNERGY_MSG_LEAVE, (WPARAM)m_keyLayout, 0);
|
||||
}
|
||||
}
|
||||
else if (name != m_activeDeskName) {
|
||||
// screen saver might have started
|
||||
PostThreadMessage(m_threadID, SYNERGY_MSG_SCREEN_SAVER, TRUE, 0);
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
|
|
|
@ -233,6 +233,7 @@ private:
|
|||
CEventQueueTimer* m_timer;
|
||||
|
||||
// screen saver stuff
|
||||
DWORD m_threadID;
|
||||
const IScreenSaver* m_screensaver;
|
||||
bool m_screensaverNotify;
|
||||
|
||||
|
|
|
@ -43,7 +43,8 @@ CMSWindowsScreenSaver::CMSWindowsScreenSaver() :
|
|||
m_wasSecureAnInt(false),
|
||||
m_process(NULL),
|
||||
m_watch(NULL),
|
||||
m_threadID(0)
|
||||
m_threadID(0),
|
||||
m_active(false)
|
||||
{
|
||||
// detect OS
|
||||
m_is95Family = false;
|
||||
|
@ -76,6 +77,11 @@ CMSWindowsScreenSaver::~CMSWindowsScreenSaver()
|
|||
bool
|
||||
CMSWindowsScreenSaver::checkStarted(UINT msg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
// if already started then say it didn't just start
|
||||
if (m_active) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// screen saver may have started. look for it and get
|
||||
// the process. if we can't find it then assume it
|
||||
// didn't really start. we wait a moment before
|
||||
|
@ -322,7 +328,8 @@ CMSWindowsScreenSaver::watchDesktop()
|
|||
|
||||
// watch desktop in another thread
|
||||
LOG((CLOG_DEBUG "watching screen saver desktop"));
|
||||
m_watch = new CThread(new TMethodJob<CMSWindowsScreenSaver>(this,
|
||||
m_active = true;
|
||||
m_watch = new CThread(new TMethodJob<CMSWindowsScreenSaver>(this,
|
||||
&CMSWindowsScreenSaver::watchDesktopThread));
|
||||
}
|
||||
|
||||
|
@ -336,6 +343,7 @@ CMSWindowsScreenSaver::watchProcess(HANDLE process)
|
|||
if (process != NULL) {
|
||||
LOG((CLOG_DEBUG "watching screen saver process"));
|
||||
m_process = process;
|
||||
m_active = true;
|
||||
m_watch = new CThread(new TMethodJob<CMSWindowsScreenSaver>(this,
|
||||
&CMSWindowsScreenSaver::watchProcessThread));
|
||||
}
|
||||
|
@ -349,7 +357,8 @@ CMSWindowsScreenSaver::unwatchProcess()
|
|||
m_watch->cancel();
|
||||
m_watch->wait();
|
||||
delete m_watch;
|
||||
m_watch = NULL;
|
||||
m_watch = NULL;
|
||||
m_active = false;
|
||||
}
|
||||
if (m_process != NULL) {
|
||||
CloseHandle(m_process);
|
||||
|
@ -394,6 +403,7 @@ CMSWindowsScreenSaver::watchDesktopThread(void*)
|
|||
}
|
||||
|
||||
// send screen saver deactivation message
|
||||
m_active = false;
|
||||
PostThreadMessage(m_threadID, m_msg, m_wParam, m_lParam);
|
||||
return;
|
||||
}
|
||||
|
@ -409,6 +419,7 @@ CMSWindowsScreenSaver::watchProcessThread(void*)
|
|||
LOG((CLOG_DEBUG "screen saver died"));
|
||||
|
||||
// send screen saver deactivation message
|
||||
m_active = false;
|
||||
PostThreadMessage(m_threadID, m_msg, m_wParam, m_lParam);
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -83,6 +83,10 @@ private:
|
|||
UINT m_msg;
|
||||
WPARAM m_wParam;
|
||||
LPARAM m_lParam;
|
||||
|
||||
// checkActive state. true if the screen saver is being watched
|
||||
// for deactivation (and is therefore active).
|
||||
bool m_active;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue