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

2006-02-16 Thread Gus Koppel
Daniel Atallah wrote:

 On 2/15/06, Matt Hull wrote:
  that like what gaim does ?
 
 Yes, gaim does essentially the same thing.
 http://cvs.sourceforge.net/viewcvs.py/gaim/gaim/src/gtkidle.c?rev=1.12view=markup
 
  On Wed, 15 Feb 2006, Martyn Russell wrote:
   Gossip needs to know how long the user has been idle (with no mouse
   movement or key presses) for setting users to an away state, this might
   be useful:
   http://cvs.gnome.org/viewcvs/gossip/src/gossip-idle.c?rev=1.8view=markup

A small addendum to the way I suggested (installing an own GPollFunc to
keep track of whenever a main loop iteration occurs, see
http://mail.gnome.org/archives/gtk-app-devel-list/2006-February/msg00164.html )

Possibly gtk_get_current_event() could help to determine whether the
main loop iteration was triggered by any mouse or keyboard event or by
something else, within a custom GPollFunc. This way would have two
different features, compared two either writing a genuine screensaver
module or the way Gaim  Co determine this:

1. it would work in a unique, platform-independent way, i.e. no need for
   any sort of #ifndef _WIN32 at all (even if the Win32 branch is very
   small, indeed)
2. it would determine the idle state of the GTK+ application only, not of
   the entire desktop (including events of / for other running apps).
   I understood the question as this could be the actual goal.

However, for performance reasons, gtk_get_current_event_time() or
gtk_get_event_widget() may be even better suited for this purpose, as
they do without object allocation (and your requirement to deallocate
it) within each main loop iteration. I think all main loop events that
should reset your idle timer would be bound to any widgets of your
application. So if the iteration has an associated widget (as keyboard
and mouse events should do) you would likely reset the idle timer. If
there's no widget you would increase or check your idle timer since
probably other internal events trihggered the main loop iteration.

See:
http://developer.gnome.org/doc/API/2.0/gtk/gtk-General.html#gtk-get-current-event
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


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

2006-02-15 Thread Stefan Kost
hi,

I would write an xscreensaver module and use that :)

stefan

sadhees kumar schrieb:
 Friends,
 
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?
 
 Can you help me.
 
 Thanks in advance..
 
 
 --
 _
 Regards,
 
 K.Sadheeskumar.
 ___
 gtk-app-devel-list mailing list
 gtk-app-devel-list@gnome.org
 http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


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

2006-02-15 Thread Matt Hull
i didnt think the application should do that.  is that a task for the
window manager ?

matt

On Wed, 15 Feb 2006, sadhees kumar wrote:

 Friends,

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?

 Can you help me.

 Thanks in advance..


 --
 _
 Regards,

 K.Sadheeskumar.
 ___
 gtk-app-devel-list mailing list
 gtk-app-devel-list@gnome.org
 http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


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

2006-02-15 Thread Gus Koppel
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?

First, I hope you know that your GTK+ application usually doesn't
represent (or own) the screen. It's just one application of possibly
many, which have windows opened and wait for any user actions or system
events to take place in order to process them. Via GTK+ you can control
and monitor only your own application, not other ones. While your
application could think it's idleing, other applications (or applets)
could feel quite busy at the same time. So intending to turn on / off
the screen based on whether your application feels idle or not sounds
inherently unsuitable, if not dangerous.

However, there are two exceptions when you can assume that your
application has full control over the entire screen. I don't suppose any
of them apply to you. They are
1. GTK+ on framebuffer and
2. GTK+ Cursed.
Apparently both of them are not well (or not at all) maintained lately.

Back to your actual question: what you want are two things:
1. determine whenever the main loop executes an iteration
2. get informed when there are no main loop iterations for some time.

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

Use g_timeout_add() to install a function to be called periodically to
check how old the last main loop iteration timestamp is. If now() -
timestamp  backlight_turn_off_wait_time then you turn off the backlight
using your own API.

The main problem of this strategy is to determine within your own
GPollFunc whether the main loop iteration was triggered by the timeout
function or by anything else. The timestamp must be updated only if not
your timeout function was triggering the iteration. There's no easy way
to determine the sort of event that triggered the main loop iteration
within your GPollFunc. You will have to study GLib sources to check
whether there's a somewhat clean way to determine the type of event from
within it. It's not going to be easy stuff. Creating an ordinary
screensaver-like process would be easier, indeed.

See:
http://developer.gnome.org/doc/API/2.0/glib/glib-The-Main-Event-Loop.html
http://developer.gnome.org/doc/API/2.0/glib/glib-The-Main-Event-Loop.html#g-main-context-default
http://developer.gnome.org/doc/API/2.0/glib/glib-The-Main-Event-Loop.html#g-main-context-set-poll-func
http://developer.gnome.org/doc/API/2.0/glib/glib-The-Main-Event-Loop.html#g-timeout-add
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


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

2006-02-15 Thread Tristan Van Berkom

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
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


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

2006-02-15 Thread Matt Hull
that like what gaim does ?

matt

On Wed, 15 Feb 2006, Martyn Russell wrote:

 On Wed, 2006-02-15 at 17:46 +0600, sadhees kumar wrote:
  Friends,
 
 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?

 Gossip needs to know how long the user has been idle (with no mouse
 movement or key presses) for setting users to an away state, this might
 be useful:
 http://cvs.gnome.org/viewcvs/gossip/src/gossip-idle.c?rev=1.8view=markup

 --
 Regards,
 Martyn

 ___
 gtk-app-devel-list mailing list
 gtk-app-devel-list@gnome.org
 http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


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

2006-02-15 Thread Daniel Atallah
On 2/15/06, Matt Hull [EMAIL PROTECTED] wrote:
 that like what gaim does ?

Yes, gaim does essentially the same thing.
http://cvs.sourceforge.net/viewcvs.py/gaim/gaim/src/gtkidle.c?rev=1.12view=markup
-D


 On Wed, 15 Feb 2006, Martyn Russell wrote:
  Gossip needs to know how long the user has been idle (with no mouse
  movement or key presses) for setting users to an away state, this might
  be useful:
  http://cvs.gnome.org/viewcvs/gossip/src/gossip-idle.c?rev=1.8view=markup
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


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

2006-02-15 Thread sadhees kumar
Thank you Friends
I will try your suggestions..


_
Regards,

K.Sadheeskumar.
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list