Screensaver detection

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Screensaver detection

Uwe Loew
Hello squeak professionals,
 
in our process monitoring software we use a background process to update the displayed values.
 
 
breakFlag := false.
delay := Delay forMilliseconds: 10.
Processor fork: [
            [ breakFlag ] whileFalse: [
                backgroundProcess := true.      "Process is now active "
                    delay wait.
                    ........................................."calling the GUI update methods displaying the measured values from the process"
                   delay wait.
            ].
            backgroundProcess := false.         "Process is going to terminate "
        ] at: Processor userPriority - 5
 
Processor is an instance of ProcessScheduler.
 
 
Something in our GUI update software wastes memory and over some days crashes the system. So the user has to stop the background display process when leaving the system and to restart it when coming back. We now want to automate this switching on and off of the GUI updates by checking the screensaver status of windows. Our wish is to check in each update cycle, whether the windows-screensaver is on, and depending on this status, to update the GUI display or not.
Can anybody of you give us a hint, how to check, whether windows has switched of the desktop-display and displaying the screensaver, or is still displaying the desktop containing the squeak window?
 
Thank you very much.
 
Best regards    
 
Uwe

_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: Screensaver detection

Michael van der Gulik-2


On Feb 13, 2008 10:53 AM, Uwe Loew <[hidden email]> wrote:
Hello squeak professionals,
 
in our process monitoring software we use a background process to update the displayed values.
 
 
breakFlag := false.
delay := Delay forMilliseconds: 10.
Processor fork: [
            [ breakFlag ] whileFalse: [
                backgroundProcess := true.      "Process is now active "
                    delay wait.
                    ........................................."calling the GUI update methods displaying the measured values from the process"
                   delay wait.
            ].
            backgroundProcess := false.         "Process is going to terminate "
        ] at: Processor userPriority - 5
 
Processor is an instance of ProcessScheduler.
 
 
Something in our GUI update software wastes memory and over some days crashes the system. So the user has to stop the background display process when leaving the system and to restart it when coming back. We now want to automate this switching on and off of the GUI updates by checking the screensaver status of windows. Our wish is to check in each update cycle, whether the windows-screensaver is on, and depending on this status, to update the GUI display or not.
Can anybody of you give us a hint, how to check, whether windows has switched of the desktop-display and displaying the screensaver, or is still displaying the desktop containing the squeak window?



Which OS? Windows, Mac, Linux, other?

One option is to find and fix your memory leak. I haven't tried this before in Squeak (my applications crash much earlier than that :-P ), but I'd probably start by doing something like:

Smalltalk collect: [ :each | (each isMemberOf: Class) ifTrue: [
    each name, ': ', each allInstances size, ' instances'
].

(there might be a #numInstances method on Behavior; I don't have an image handy right now)

Inspecting the result after running your program for some time might give some clues as to what is using up your memory.

You could write a custom screensaver in C, or maybe even in Squeak if you're keen, and then that screensaver could somehow send a signal to your application - maybe using TCP/IP, or maybe sending a signal to Squeak (can Squeak capture POSIX signals?), or some other mechanism.

Gulik.

--
http://people.squeakfoundation.org/person/mikevdg
http://gulik.pbwiki.com/
_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: Screensaver detection

Andrew Tween
In reply to this post by Uwe Loew
Hi,
Attached is a class that should do what you want.
You will need to install FFI before filing it in.
To test it, evaluate the following...

[Win32ScreenSaver  active]
 whileFalse:[
  (Delay forSeconds: 1) wait].
'screensaver active' inspect

and wait for your screen saver to activate.

I have only tested it on Vista.
It probably won't work on older Windows versions (95 / 98).

Cheers,
Andy

"Uwe Loew" <[hidden email]> wrote in message
news:001f01c86dc1$c6a866e0$0200a8c0@uwe...
Hello squeak professionals,

in our process monitoring software we use a background process to update the
displayed values.


breakFlag := false.
delay := Delay forMilliseconds: 10.
Processor fork: [
            [ breakFlag ] whileFalse: [
                backgroundProcess := true.      "Process is now active "
                    delay wait.
                    ........................................."calling the
GUI update methods displaying the measured values from the process"
                   delay wait.
            ].
            backgroundProcess := false.         "Process is going to
terminate "
        ] at: Processor userPriority - 5

Processor is an instance of ProcessScheduler.


Something in our GUI update software wastes memory and over some days
crashes the system. So the user has to stop the background display process
when leaving the system and to restart it when coming back. We now want to
automate this switching on and off of the GUI updates by checking the
screensaver status of windows. Our wish is to check in each update cycle,
whether the windows-screensaver is on, and depending on this status, to
update the GUI display or not.
Can anybody of you give us a hint, how to check, whether windows has
switched of the desktop-display and displaying the screensaver, or is still
displaying the desktop containing the squeak window?

Thank you very much.

Best regards

Uwe



_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners 

_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners

Win32ScreenSaver.st (995 bytes) Download Attachment