[vlc-devel] [PATCH]Win32 screensaver disable change part II

Geoffroy Couprie geo.couprie at gmail.com
Wed May 4 17:49:45 CEST 2011


On Wed, May 4, 2011 at 9:15 AM, Kaarlo Räihä <kaarlo.raiha at gmail.com> wrote:
>
>
> 2011/5/3 Geoffroy Couprie <geo.couprie at gmail.com>
>>
>> Hello,
>>
>> On Tue, May 3, 2011 at 4:04 PM, Juha Jeronen <juha.jeronen at jyu.fi> wrote:
>> >
>> > Hi,
>> >
>> > On 05/03/11 15:43, Rémi Denis-Courmont wrote:
>> >>
>> >>    Hello,
>> >>
>> >> On Tuesday 03 May 2011, Juha Jeronen wrote:
>> >>>
>> >>> - Have an instance data struct for the thread, containing only an exit
>> >>> flag (initialized to false in the main thread, just before it starts
>> >>> the
>> >>> new thread). Malloc it, and pass a pointer as the thread argument. The
>> >>> flag will be used for signaling.
>> >>
>> >> Oh no, never suggest that. This does not fit our (POSIX) threaded
>> >> memory
>> >> synchronization model.
>> >
>> > Ok.
>> >
>> >>> - When the main thread wants to shut down the screensaver prevention
>> >>> thread, it sets the exit flag to true.
>> >>> - When the thread notices that its exit flag has been set to true, it
>> >>> joins.
>> >>> - Finally, we need to take care of the 50-second sleep. How about,
>> >>> instead of
>> >>
>> >> No. Polling timers are for incompetent programmers.
>> >
>> > I did say it was no good :P
>> >
>> >
>> >> In this case, the thread can sleep for 50 seconds, and be terminated by
>> >> thread
>> >> cancellation. Alternetiavely, it can use a condition variable and a
>> >> 50-seconds
>> >> time-out.
>> >
>> > This sounds good.
>> >
>>
>> Thinking a bit out of the box here: did you try applying the method
>> shown in http://msdn.microsoft.com/en-us/library/cc144066(VS.85).aspx
>> ?
>>
>> "Windows does not start the screen saver if [...] the active
>> application receives the WM_SYSCOMMAND message with the wParam
>> parameter set to the SC_SCREENSAVE value, but it does not pass the
>> message to the DefWindowProc function."
>>
>> Basically, you set up a GetMessage loop (in Qt or in the vout), and
>> when you receive a WM_SYSCOMMAND with SC_SCREENSAVE or
>> SC_MONITORPOWER, you don't pass it to DefWindowProc. It will block the
>> screensaver or the monitor power off, unless the user has set a
>> password policy on the screensaver.
>
> Those won't work in certain situations (like screensaver with password you
> mentioned + some message loop design issues cause problems).
> http://stackoverflow.com/questions/463813/programmatically-prevent-windows-screensaver-from-starting
> http://www.codeguru.com/forum/archive/index.php/t-304863.html
> AFAIK there isn't any sane way to prevent screensavers under Windows if the
> software itself doesn't provide inputs.
>

Well, providing inputs isn't really a sane way either :)
Out of corporate environments, you will not find many setups with
password protected screensavers. It is not the perfect solution, but
it's simple and unobstrusive.



More information about the vlc-devel mailing list