mirror of
git://projects.qi-hardware.com/gmenu2x.git
synced 2024-11-22 17:51:34 +02:00
Reinitialize the powersaver timer when a suspend has been detected.
This commit is contained in:
parent
78b607033a
commit
2d81b13459
@ -9,7 +9,16 @@
|
||||
|
||||
PowerSaver *PowerSaver::instance = NULL;
|
||||
|
||||
Uint32 screenTimerCallback(Uint32, void *) {
|
||||
Uint32 screenTimerCallback(Uint32 timeout, void *d) {
|
||||
unsigned int * old_ticks = (unsigned int *) d;
|
||||
unsigned int new_ticks = SDL_GetTicks();
|
||||
|
||||
if (new_ticks > *old_ticks + timeout + 1000) {
|
||||
DEBUG("Suspend occured, restarting timer\n");
|
||||
*old_ticks = new_ticks;
|
||||
return timeout;
|
||||
}
|
||||
|
||||
DEBUG("Disable Backlight Event\n");
|
||||
PowerSaver::getInstance()->disableScreen();
|
||||
return 0;
|
||||
@ -62,7 +71,8 @@ void PowerSaver::addScreenTimer() {
|
||||
return;
|
||||
}
|
||||
|
||||
screenTimer = SDL_AddTimer(screenTimeout * 1000, screenTimerCallback, NULL);
|
||||
timeout_startms = SDL_GetTicks();
|
||||
screenTimer = SDL_AddTimer(screenTimeout * 1000, screenTimerCallback, &timeout_startms);
|
||||
if (screenTimer == NULL) {
|
||||
ERROR("Could not initialize SDLTimer: %s\n", SDL_GetError());
|
||||
}
|
||||
|
@ -23,6 +23,7 @@ private:
|
||||
static PowerSaver *instance;
|
||||
bool screenState;
|
||||
unsigned int screenTimeout;
|
||||
unsigned int timeout_startms;
|
||||
SDL_TimerID screenTimer;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user