I am building an application that needs a user to login in order to use the system. BUT I need it to auto-lock if the user walks away from the terminal.
I know of plenty of ways to do this, but am open to suggestions.
First off, if i use the IdleEvent to start a timer to disable the interface, I need to know when the IdleEvent fires. If, say, on windows, the IdleEvent fires when the screensaver kicks in, then it is pointless because the total time from the user walking away to it disabling would be the time for the screensaver PLUS whatever my timer is.
So, when does the IdleEvent fire? How could I interrupt the timer if it was started during the IdleEvent? (is there a WakeEvent?) And more importantly, what would you do to basically make a "screensaver" for JUST your application?
Quick question.... when does the IdleEvent fire? Topic is solved
-
- Earned some good credits
- Posts: 149
- Joined: Fri Dec 14, 2007 3:40 pm
- Location: Midland, TX
- Contact:
Quick question.... when does the IdleEvent fire?
John A. Mason
Midland, TX
Midland, TX
-
- Earned some good credits
- Posts: 149
- Joined: Fri Dec 14, 2007 3:40 pm
- Location: Midland, TX
- Contact:
I just found this in some mailing list:
So apparently the IdleEvent is NOT what I need. So what could work better?Kevin Altis wrote:
>AFAIK, it isn't a "true idle" where the event fires when your app isn't
>doing anything. Instead, idle fires when the event queue empties. That means
>you'll get an idle after a mouse move event, which I find annoying since it
>means that my idle handler definitely needs some kind of flag and check for
>the last time it ran so that whatever I really wanted to doesn't eat up all
>the CPU by running a lot.
>
>Anyway, what you'll need to do is use an event timer instead. Or you can
>bind a timer that guarantees idle fires say once a second, but again it
>isn't a true idle. Hmm, maybe idle should be renamed to EventQueueEmpty?
>
>ka
John A. Mason
Midland, TX
Midland, TX
wxTimerEvent is what you need. Use a wxTimer, check every second / minute if the user didn't perform any mouse movement / keystroke and then lock the screen. You should also catch EVT_MOUSE and simply update the last time (wxDateTime) that an event occured. Then don't event.Skip() the event handler to le wxWidgets call other handlers for that event. Same goes for the keystroke events.
Regards,
- Jorgen
Regards,
- Jorgen
Forensic Software Engineer
Netherlands Forensic Insitute
http://english.forensischinstituut.nl/
-------------------------------------
Jorg's WasteBucket
http://www.xs4all.nl/~jorgb/wb
Netherlands Forensic Insitute
http://english.forensischinstituut.nl/
-------------------------------------
Jorg's WasteBucket
http://www.xs4all.nl/~jorgb/wb
Definitely idleProc is not designed for this kind of work. Look for EVT_MOUSE_EVENTS(), EVT_CHAR() and EVT_KEY_DOWN() to handle keyboard events.Jorg wrote:wxTimerEvent is what you need. Use a wxTimer, check every second / minute if the user didn't perform any mouse movement / keystroke and then lock the screen. You should also catch EVT_MOUSE and simply update the last time (wxDateTime) that an event occured. Then don't event.Skip() the event handler to le wxWidgets call other handlers for that event. Same goes for the keystroke events.
Regards,
- Jorgen
-
- Earned some good credits
- Posts: 149
- Joined: Fri Dec 14, 2007 3:40 pm
- Location: Midland, TX
- Contact:
I've accepted the answer, but I would like some more clarification.
If I use EVT_KEY_DOWN() do I need EVT_CHAR()? Having done a lot of javascript not too long ago for our company website, I am now a little confused as to the purpose of EVT_KEY_DOWN, EVT_KEY_UP and EVT_CHAR.... because that project just needed key_up and key_down to keep track of it all.
If I use EVT_KEY_DOWN() do I need EVT_CHAR()? Having done a lot of javascript not too long ago for our company website, I am now a little confused as to the purpose of EVT_KEY_DOWN, EVT_KEY_UP and EVT_CHAR.... because that project just needed key_up and key_down to keep track of it all.
John A. Mason
Midland, TX
Midland, TX
No, you won't need the EVT_CHAR.
For the original purpose of this topic, I would like to share an experience:
Once I put the updating work of a wxGauge in the idle event handling function, like this:
myGuage->Update(myGuage->Value()+a_delta);
or
myGuage->Pulse();
I found that the faster I move my mouse, the faster the progress of the guage grows. It's interesting. I guess the conclusion is that the idle event will be fired everytime the event queue is emptied.
Regards,
Utensil
For the original purpose of this topic, I would like to share an experience:
Once I put the updating work of a wxGauge in the idle event handling function, like this:
myGuage->Update(myGuage->Value()+a_delta);
or
myGuage->Pulse();
I found that the faster I move my mouse, the faster the progress of the guage grows. It's interesting. I guess the conclusion is that the idle event will be fired everytime the event queue is emptied.
Regards,
Utensil
In fascination of creating worlds by words, and in pursuit of words behind the world.
On Github: http://utensil.github.com
Technical Blog in Chinese: http://utensil.iteye.com/
On Github: http://utensil.github.com
Technical Blog in Chinese: http://utensil.iteye.com/
-
- Earned some good credits
- Posts: 149
- Joined: Fri Dec 14, 2007 3:40 pm
- Location: Midland, TX
- Contact:
A quick note: DON'T USE THE IDLE EVENTS UNLESS YOU ARE SURE YOU NEED TO. MY APP BROKE BECAUSE OF 1 STATEMENT...
See I use lots of the wxTreeListCtrl (enhanced version from twinforms.com) and they require idle events to refresh the display.... but I didn't know that until it broke.
After three days of figuring it out I am allowed to make a general statement... IDLE EVENTS SHOULD ONLY BE USED IF YOU ARE CERTAIN YOU NEED THEM. These really should not be called Idle events anyway... they are EventQueueEmpty events. In any case, be sure to save a backup before and after you try to use Idle Events. That way if anything breaks, you can start adding wxWS_EX_PROCESS_IDLE to any windows that need it. In my case, that was EVERY window.
Hope this helps SOMEONE... probably won't though.
... Oh yeah.And I fixed my app by removing the SetMode line above... I didn't need the IdleEvents and didn't want to go through all my windows to put the wxWS_EX_PROCESS_IDLE flag for each so they would get the idle event. [/b]
Code: Select all
wxIdleEvent::SetMode(wxIDLE_PROCESS_SPECIFIED);
After three days of figuring it out I am allowed to make a general statement... IDLE EVENTS SHOULD ONLY BE USED IF YOU ARE CERTAIN YOU NEED THEM. These really should not be called Idle events anyway... they are EventQueueEmpty events. In any case, be sure to save a backup before and after you try to use Idle Events. That way if anything breaks, you can start adding wxWS_EX_PROCESS_IDLE to any windows that need it. In my case, that was EVERY window.
Hope this helps SOMEONE... probably won't though.
... Oh yeah.And I fixed my app by removing the SetMode line above... I didn't need the IdleEvents and didn't want to go through all my windows to put the wxWS_EX_PROCESS_IDLE flag for each so they would get the idle event. [/b]
John A. Mason
Midland, TX
Midland, TX