[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference bulova::decw_jan-89_to_nov-90

Title:DECWINDOWS 26-JAN-89 to 29-NOV-90
Notice:See 1639.0 for VMS V5.3 kit; 2043.0 for 5.4 IFT kit
Moderator:STAR::VATNE
Created:Mon Oct 30 1989
Last Modified:Mon Dec 31 1990
Last Successful Update:Fri Jun 06 1997
Number of topics:3726
Total number of notes:19516

1168.0. "How to detect noactivity " by TAVPRO::HAREL_B (Hanoch Harel SWAS Israel) Tue Jul 25 1989 03:21

Hello !!!
	I'd like to create an application that detects no (key,mouse) activity.
	thru a period of time then turns itself off.
	How can it be done???

T.RTitleUserPersonal
Name
DateLines
1168.1timers?LENSMN::boniniWe apologize for the inconvenience.Tue Jul 25 1989 10:335

	Why not simply set a timer at startup and reset the timer when you get
a mouse or key press event from X?  If the timer expires, your program exits.

1168.2TAVPRO::HAREL_BHanoch Harel SWAS IsraelTue Jul 25 1989 13:146
>	Why not simply set a timer at startup and reset the timer when you get
>  a mouse or key press event from X?  If the timer expires, your program exits.

Its quite costly to reset timers every pointer motion.

1168.3Depending on granularity, it can be easyPRNSYS::LOMICKAJJeff LomickaTue Jul 25 1989 13:5713
If the exact duration of the delay is not critical, you can start a
timer, and keep a counter for each "activity" you detect.  Incrementing
the counter on each event should not be very expensive.  When the timer
expires, if the counter is non-zero, you have seen activity.  Zero the
counter and re-submit the timer.  If the counter is still zero, then
there was no activity during the preceeding timer interval.

If you wanted, say, a 30 minute timer, you could fire it at 1-minute
intervals without incurring much overhead at all.  When you accumulate
30 of them with no activity, you triger your inactivity event handler.



1168.4No X magic...just a little hackingDECWIN::FISHERBurns Fisher 381-1466, ZKO3-4/W23Tue Jul 25 1989 14:0119
Try something like this:  (A little crude, but...)

Clear flag1, set flag2.

Set a timer to go off every n minutes

When you get an event, set flag1.

When the timer goes off, if flag1 and flag2 are both clear, then timeout,
  else if flag2 = flag1; clear flag1


This should give you a timeout with no activity in n minutes � n.  For
finer granularity make flag 2 a counter, set n to the granularity you want
and increment flag2 to count the number of times you have come through the
timer without having an event.

Burns

1168.5CASEE::LACROIXObject oriented dog food? No, sorryTue Jul 25 1989 14:0412
>>	Why not simply set a timer at startup and reset the timer when you get
>>  a mouse or key press event from X?  If the timer expires, your program exits.
>
> Its quite costly to reset timers every pointer motion.

    You don't have to reset the timer for every event! Just remember the
    time when you got the last event, and when the timer triggers, decide
    whether you want to reset the timer (with a new computed value) or
    exit.
    
    Denis.

1168.6Three great minds...DECWIN::FISHERBurns Fisher 381-1466, ZKO3-4/W23Tue Jul 25 1989 14:101
1168.7Thanx you allTAVPRO::HAREL_BHanoch Harel SWAS IsraelThu Jul 27 1989 01:522