On 14.03.2012 16:00, MacArthur, Ian (SELEX GALILEO, UK) wrote: > >> I need to exit from application after some inactivity time. >> How can I implement this? Is there any method's to do such thing. My >> application consists of input, output box's, browser, buttons and choices >> box's. Am using FLTK 1.3.0 and ARM processor based linux platform. > > > There's not really any mechanism in fltk to detect inactivity - this might be > easier done from the host OS, which presumably does know which applications > are being scheduled, and then have it kill the process after a period of > inactivity. > > However, if you are keen to try and do it from within fltk (and what follows > is speculative...) I'd suggest deriving your own window for the apps main > window, and in its handle() method keep a note of any mouse movements (enter > / leave / click / etc.) or keyboard events that get sent to your app. > > Then, have a Fl::add_timeout(); function that fires off (say every 10 seconds > or whatever) and checks to see if the outer window has flagged any activity. > It can then count up, and after (say) 10 periods of inactivity it can hide > all the app windows and allow the app to expire. > > Something like that anyway...
Yup, something like that... Unfortunately it's not THAT easy, although even what you suggest wouldn't be like beginner's stuff. The problem is that there are some events that get delivered directly to some base widgets and NOT to the window, e.g. mouse click events to the Fl::belowmouse() widget, or maybe also FL_MOVE events to the belowmouse() widget, or keypress events to the Fl::focus() widget - beware, this is off the top of my head, not tested, not confirmed by the docs, but you get the idea... > I'm sure others will have alternate (and very possibly better!) suggestions. I've done it, but in my application *ALL* widgets are derived in their own classes, so that I can easily detect activity and start/stop a timer, as you, Ian, suggested. And, as another hint, I don't accept simple mouse move events as "activity", since I think that if someone moves the mouse out of the window, or you have "focus follows mouse", then you'd get activities that are not really relevant for your application. YMMV. Albrecht _______________________________________________ fltk mailing list [email protected] http://lists.easysw.com/mailman/listinfo/fltk

