mirror of
https://gitee.com/houstudio/Cdroid.git
synced 2024-12-09 23:57:39 +08:00
skip all inputevents while app is not running
This commit is contained in:
parent
a2c5a36cf8
commit
55cfedd0c1
@ -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);
|
||||
|
@ -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*/
|
||||
|
Loading…
Reference in New Issue
Block a user