Skip to content
Snippets Groups Projects
Commit da955fd4 authored by Yann Leboulanger's avatar Yann Leboulanger
Browse files

[hildjj] go away under windows too when screensaver is active. Fixes #4178

parent 384283d2
No related branches found
No related tags found
No related merge requests found
......@@ -43,6 +43,11 @@ try:
lastInputInfo = LASTINPUTINFO()
lastInputInfo.cbSize = ctypes.sizeof(lastInputInfo)
# one or more of these may not be supported before XP.
OpenInputDesktop = ctypes.windll.user32.OpenInputDesktop
CloseDesktop = ctypes.windll.user32.CloseDesktop
SystemParametersInfo = ctypes.windll.user32.SystemParametersInfoW
else: # unix
from common import idle
except Exception:
......@@ -65,6 +70,21 @@ class SleepyWindows:
if not SUPPORTED:
return False
# screen saver, in windows >= XP
saver_runing = ctypes.c_int(0)
# 0x72 is SPI_GETSCREENSAVERRUNNING
if SystemParametersInfo(0x72, 0, ctypes.byref(saver_runing), 0) and \
saver_runing.value:
self.state = STATE_XA
return True
desk = OpenInputDesktop(0, False, 0)
if not desk:
# Screen locked
self.state = STATE_XA
return True
CloseDesktop(desk)
idleTime = self.getIdleSec()
# xa is stronger than away so check for xa first
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment