Fixed a resource leak. Also fixed the detection of the screen saver

closing on windows 2000 and XP.
This commit is contained in:
crs 2004-11-01 18:22:45 +00:00
parent 58de7a21fe
commit 2a3015f06a
1 changed files with 34 additions and 26 deletions

View File

@ -376,33 +376,41 @@ CMSWindowsScreenSaver::watchDesktopThread(void*)
// wait a bit // wait a bit
ARCH->sleep(0.2); ARCH->sleep(0.2);
// get current desktop if (m_isNT) {
HDESK desk = OpenInputDesktop(0, FALSE, GENERIC_READ); // get current desktop
if (desk == NULL) { HDESK desk = OpenInputDesktop(0, FALSE, GENERIC_READ);
// can't open desktop so keep waiting if (desk == NULL) {
continue; // can't open desktop so keep waiting
continue;
}
// get current desktop name length
DWORD size;
GetUserObjectInformation(desk, UOI_NAME, NULL, 0, &size);
// allocate more space for the name, if necessary
if (size > reserved) {
reserved = size;
name = (TCHAR*)alloca(reserved + sizeof(TCHAR));
}
// get current desktop name
GetUserObjectInformation(desk, UOI_NAME, name, size, &size);
CloseDesktop(desk);
// compare name to screen saver desktop name
if (_tcsicmp(name, TEXT("Screen-saver")) == 0) {
// still the screen saver desktop so keep waiting
continue;
}
} }
else {
// get current desktop name length // 2000/XP have a sane way to detect a runnin screensaver.
DWORD size; BOOL running;
GetUserObjectInformation(desk, UOI_NAME, NULL, 0, &size); SystemParametersInfo(SPI_GETSCREENSAVERRUNNING, 0, &running, 0);
if (running) {
// allocate more space for the name, if necessary continue;
if (size > reserved) { }
reserved = size;
name = (TCHAR*)alloca(reserved + sizeof(TCHAR));
}
// get current desktop name
GetUserObjectInformation(desk, UOI_NAME, name, size, &size);
// compare name to screen saver desktop name
if (_tcsicmp(name, TEXT("Screen-saver")) == 0) {
// XXX -- getting "Default" as desk when screen saver was running
// before we started checking on it. can it be "Default" at other
// times to? how do we properly detect a running screen saver?
// still the screen saver desktop so keep waiting
continue;
} }
// send screen saver deactivation message // send screen saver deactivation message