[Lazarus] "Defeating" a screen saver

Paul Breneman list2010 at BrenemanLabs.com
Fri Sep 28 14:55:38 CEST 2012


Mark Morgan Lloyd wrote:
> Mark Morgan Lloyd wrote:
>> Mark Morgan Lloyd wrote:
>>> Graeme Geldenhuys wrote:
>>>> On 2012-09-25 17:57, Mark Morgan Lloyd wrote:
>>>>> suggestion of looking at the VLC sources I see they use it which 
>>>>> has to
>>>>> be a recommendation.
>>>>
>>>> Interesting... I was wondering what they did. :)
>>>>
>>>>
>>>>> I'll see what I can work in, but particularly allowing that
>>>>> xdg-screensaver can take several seconds to run it's more suited to
>>>>> being run at the start and end of a program session than "on the fly"
> 
>> Needs a window ID. I think I can get that from a shell variable if 
>> there's a shell, but not if started directly from the desktop: anybody 
>> got any thoughts?
> 
> Health warning: 
> http://lists.lazarus.freepascal.org/pipermail/lazarus/2008-August/037407.html 
> suggests following a handle in TForm to arrive at a window ID, but that 
> appears to depend on the combination of widget set and window manager: 
> as a particular example, it's unreliable with gtk2 on top of KDE.
> 
> Without delving into the raw X API, the only reliable way of doing this 
> appears to be to run xwininfo and parse the output. The window ID from 
> that is compatible with xdg-screensaver.
> 

Just a little warning that seems related to this topic...

In my Delphi communication programs I used PostMessage *very* much.  I 
used to pass the main form's handle down into my threads so they could 
post to that handle.  But a form's handle is not guaranteed to remain 
the same.  Therefore I now pass a TForm reference down so the handle can 
be obtained when needed.

A month ago some of my code that still passed just the handle failed 
under Win7.  Seems that Win7 was doing something to an *invisible* form 
and changing the form's handle so my messages went nowhere.  Passing the 
TForm reference fixed the bug.




More information about the Lazarus mailing list