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

Geoffroy Couprie geo.couprie at gmail.com
Tue May 3 21:49:56 CEST 2011


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.

More information about the vlc-devel mailing list