Fixed screensaver detection on XP.
This commit is contained in:
parent
01dc8fa337
commit
57fddf4cdc
|
@ -62,6 +62,31 @@ CArchMiscWindows::isWindows95Family()
|
|||
return result;
|
||||
}
|
||||
|
||||
bool
|
||||
CArchMiscWindows::isWindowsModern()
|
||||
{
|
||||
static bool init = false;
|
||||
static bool result = false;
|
||||
|
||||
if (!init) {
|
||||
OSVERSIONINFO version;
|
||||
version.dwOSVersionInfoSize = sizeof(version);
|
||||
if (GetVersionEx(&version) == 0) {
|
||||
// cannot determine OS; assume not modern
|
||||
result = false;
|
||||
}
|
||||
else {
|
||||
result = ((version.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS &&
|
||||
version.dwMajorVersion == 4 &&
|
||||
version.dwMinorVersion > 0) ||
|
||||
(version.dwPlatformId == VER_PLATFORM_WIN32_NT &&
|
||||
version.dwMajorVersion > 4));
|
||||
}
|
||||
init = true;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
int
|
||||
CArchMiscWindows::runDaemon(RunFunc runFunc)
|
||||
{
|
||||
|
|
|
@ -49,6 +49,13 @@ public:
|
|||
*/
|
||||
static bool isWindows95Family();
|
||||
|
||||
//! Test if windows 95, et al.
|
||||
/*!
|
||||
Returns true iff the platform is win98 or win2k or higher (i.e.
|
||||
not windows 95 or windows NT).
|
||||
*/
|
||||
static bool isWindowsModern();
|
||||
|
||||
//! Run the daemon
|
||||
/*!
|
||||
Delegates to CArchDaemonWindows.
|
||||
|
|
|
@ -33,6 +33,9 @@
|
|||
#if !defined(SPI_SETMOUSESPEED)
|
||||
#define SPI_SETMOUSESPEED 113
|
||||
#endif
|
||||
#if !defined(SPI_GETSCREENSAVERRUNNING)
|
||||
#define SPI_GETSCREENSAVERRUNNING 114
|
||||
#endif
|
||||
|
||||
// X button stuff
|
||||
#if !defined(WM_XBUTTONDOWN)
|
||||
|
@ -84,6 +87,7 @@ CMSWindowsDesks::CMSWindowsDesks(
|
|||
const IScreenSaver* screensaver, IJob* updateKeys) :
|
||||
m_isPrimary(isPrimary),
|
||||
m_is95Family(CArchMiscWindows::isWindows95Family()),
|
||||
m_isModernFamily(CArchMiscWindows::isWindowsModern()),
|
||||
m_isOnScreen(m_isPrimary),
|
||||
m_x(0), m_y(0),
|
||||
m_w(0), m_h(0),
|
||||
|
@ -622,8 +626,22 @@ CMSWindowsDesks::deskLeave(CDesk* desk, HKL keyLayout)
|
|||
strcmp(className, "ConsoleWindowClass") == 0) {
|
||||
EnableWindow(desk->m_window, TRUE);
|
||||
SetActiveWindow(desk->m_window);
|
||||
|
||||
// force our window to the foreground. we can't
|
||||
// simply call SetForegroundWindow() because that
|
||||
// will only alert the user that the window wants
|
||||
// to be the foreground as of windows 98/2000. we
|
||||
// have to attach to the thread of the current
|
||||
// foreground window then call it on our window
|
||||
// and finally detach the threads.
|
||||
DWORD thisThread =
|
||||
GetWindowThreadProcessId(desk->m_window, NULL);
|
||||
DWORD thatThread =
|
||||
GetWindowThreadProcessId(foreground, NULL);
|
||||
AttachThreadInput(thatThread, thisThread, TRUE);
|
||||
SetForegroundWindow(desk->m_window);
|
||||
AttachThreadInput(thatThread, thisThread, FALSE);
|
||||
}
|
||||
LOG((CLOG_DEBUG1 "active window class: %s", className));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -901,6 +919,14 @@ void
|
|||
CMSWindowsDesks::handleCheckDesk(const CEvent&, void*)
|
||||
{
|
||||
checkDesk();
|
||||
|
||||
// also check if screen saver is running if on a modern OS and
|
||||
// this is the primary screen.
|
||||
if (m_isPrimary && m_isModernFamily) {
|
||||
BOOL running;
|
||||
SystemParametersInfo(SPI_GETSCREENSAVERRUNNING, 0, &running, FALSE);
|
||||
PostThreadMessage(m_threadID, SYNERGY_MSG_SCREEN_SAVER, running, 0);
|
||||
}
|
||||
}
|
||||
|
||||
HDESK
|
||||
|
|
|
@ -214,6 +214,9 @@ private:
|
|||
// true if windows 95/98/me
|
||||
bool m_is95Family;
|
||||
|
||||
// true if windows 98/2k or higher (i.e. not 95/nt)
|
||||
bool m_isModernFamily;
|
||||
|
||||
// true if mouse has entered the screen
|
||||
bool m_isOnScreen;
|
||||
|
||||
|
|
|
@ -94,6 +94,7 @@ CMSWindowsScreen::CMSWindowsScreen(bool isPrimary,
|
|||
m_fixTimer(NULL),
|
||||
m_screensaver(NULL),
|
||||
m_screensaverNotify(false),
|
||||
m_screensaverActive(false),
|
||||
m_window(NULL),
|
||||
m_nextClipboardWindow(NULL),
|
||||
m_ownClipboard(false),
|
||||
|
@ -1133,7 +1134,9 @@ CMSWindowsScreen::onScreensaver(bool activated)
|
|||
}
|
||||
|
||||
if (activated) {
|
||||
if (m_screensaver->checkStarted(SYNERGY_MSG_SCREEN_SAVER, FALSE, 0)) {
|
||||
if (!m_screensaverActive &&
|
||||
m_screensaver->checkStarted(SYNERGY_MSG_SCREEN_SAVER, FALSE, 0)) {
|
||||
m_screensaverActive = true;
|
||||
sendEvent(getScreensaverActivatedEvent());
|
||||
|
||||
// enable display power down
|
||||
|
@ -1141,10 +1144,13 @@ CMSWindowsScreen::onScreensaver(bool activated)
|
|||
}
|
||||
}
|
||||
else {
|
||||
sendEvent(getScreensaverDeactivatedEvent());
|
||||
if (m_screensaverActive) {
|
||||
m_screensaverActive = false;
|
||||
sendEvent(getScreensaverDeactivatedEvent());
|
||||
|
||||
// disable display power down
|
||||
CArchMiscWindows::addBusyState(CArchMiscWindows::kDISPLAY);
|
||||
// disable display power down
|
||||
CArchMiscWindows::addBusyState(CArchMiscWindows::kDISPLAY);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
|
@ -238,6 +238,7 @@ private:
|
|||
// screen saver stuff
|
||||
CMSWindowsScreenSaver* m_screensaver;
|
||||
bool m_screensaverNotify;
|
||||
bool m_screensaverActive;
|
||||
|
||||
// clipboard stuff. our window is used mainly as a clipboard
|
||||
// owner and as a link in the clipboard viewer chain.
|
||||
|
|
Loading…
Reference in New Issue