I am trying to block the function XNextEvent from returning when DPMS is actively blanking the screen, so that I do not receive keyboard or mouse inputs while my screen is black.
I want to block the function from returning entirely, because I have already tried to query DPMS for its state once the function returns, but it seems that the DPMS system is somehow processing all of my inputs before X receives them, because every query within XNextEvent is telling me that DPMS is no longer blanking:
while (running && !XNextEvent(dpy, &ev))
{
if (!DPMSInfo(dpy, &pwr, &state))
{
fprintf(stderr, "%s: DPMSInfo failed!\n", argv[0]);
running = 0;
}
else if (!state || pwr == DPMSModeOn)
{
// sans a critical error, this will ALWAYS return true
// regardless of the current state of the screen
if (ev.type == KeyPress)
{
// now I am handling keyboard input
// while the screen is still potentially blank
}
}
}
Is there some underlying feature of DPMS or X that will block all inputs while blanked, and require at least one input to awaken the display before continuing to listen to them?
I've found a way to make use of the XScreenSaver extension by reading the code for the
xssstartprogram:Note that the major drawback of this solution is that when the keyboard is relinquished, the keyboard input will be fed into any other random application in the background (in the case of a screen locker such as
slock). This is ultimately the subject of another question though. I might be able to focus on a fake window and purge the input there...