Re: How to identify the idle state of the GTK+ application?



Gus Koppel wrote:
sadhees kumar wrote:


      In my GTK application, If  no action(event) is taken place in
the screen, I need to turn OFF the backlight of an TFT monitor. If any
key pressed, or mouse movement occured, I need to turn ON the
backlight.

I have the API for toggling the backlight. My problem is , how to
identify the idle state of the screen?
[...]
I have no detailed solution for your question at this time, but I can
point you at some areas which you should examine. I think you should use
g_main_context_set_poll_func() for your program to be informed about
every main loop iteration that takes place. Your own function should do
three things:
1. determine whether the iteration was caused by a timeout event
2. set a global timestamp flag if not caused by timeout
3. call original poll() function to maintain operational reliability

Ok I might as well ring in with my 2 cents too...

Firstly, I assume that if your app "owns the backlight"; then it
owns the entire machine... I develop a touchscreen jukebox "kiosk
like" machine where we have to address that problem (we go into
attract mode and play movies etc when the jukebox idles).

Mainloop watching is unsafe for this; as soon as your application
has some buisiness logic (i.e. that timer just woke up to refilter
the content to "country songs only" at 3:00pm) then your box is no
longer idle.

What we've always done (in two generations of linux based jukebox
software... previous version was in DOS)... is to monitor screen
touches in the UI manually... any triggered events reset the idle
timer... this is definitly an undesirable way to go about idleing
(too much code involved)... unless you are dealing with an FSM
that gives you a centralized hub for user events...

Let me quote Gus:
"Creating an ordinary screensaver-like process would be easier, indeed."

strongly agree; I'm not sure how X screensaver works but I would
break out that old "Xlib reference manual" and look in there...
you should be able to query the X server to find the time of the
last event or something similar.

Cheers,
                                -Tristan



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]