Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Delaying an action for a period of time

I am currently working on a screensaver launcher, but I want to delay the activation of the screensaver for a period of time to ensure the mouse position is still in the position to activate it, to prevent accidental activation. I am thinking some kind of thread to check the position of the mouse for x secs before execution, would this be a sensible solution?

I'm not writing a screensaver, I have written an application so that when you move your mouse to a designated corner of your desktop, the screensaver comes on... I want to know how to add a delay to when you move the mouse into that corner to prevent accidental launching of the screensaver

If so how?

like image 605
CybrHwk Avatar asked Oct 10 '22 03:10

CybrHwk


1 Answers

so that when you move your mouse to a designated corner of your desktop, the screensaver comes on...

When the mouse gets there, set a boolean and a timer. Make any mouse action clear the boolean.
Only when the timer fires and your flag is still there, proceed.

In other words, use a little state machine.

like image 171
Henk Holterman Avatar answered Oct 13 '22 10:10

Henk Holterman