skip all inputevents while app is not running

This commit is contained in:
houzh 2023-11-23 18:34:58 +08:00
parent a2c5a36cf8
commit 55cfedd0c1
2 changed files with 5 additions and 0 deletions

View File

@ -15,6 +15,7 @@ namespace cdroid{
InputEventSource::InputEventSource(){
InputInit();
mScreenSaveTimeOut = -1;
mRunning = false;
mIsPlayback = false;
mIsScreenSaveActived = false;
mLastPlaybackEventTime = SystemClock::uptimeMillis();
@ -31,6 +32,7 @@ InputEventSource::InputEventSource(){
onDeviceChanged(es+i);
continue;
}
if(mRunning==false)break;
mRawEvents.push(es[i]);
}
}
@ -100,6 +102,8 @@ std::shared_ptr<InputDevice>InputEventSource::getdevice(int fd){
int InputEventSource::checkEvents(){
std::lock_guard<std::mutex> lock(mtxEvents);
nsecs_t now = SystemClock::uptimeMillis();
if(mRunning==false)
mRunning = true;
if( ((now - mLastInputEventTime) > mScreenSaveTimeOut) && (mScreenSaveTimeOut>0)
&& ( mIsScreenSaveActived == false ) && mScreenSaver){
mScreenSaver(true);

View File

@ -19,6 +19,7 @@ private:
std::mutex mtxEvents;
ScreenSaver mScreenSaver;
int mScreenSaveTimeOut;
bool mRunning;
bool mIsPlayback;
bool mIsScreenSaveActived;
nsecs_t mLastPlaybackEventTime;/*for event record and playback*/