mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-18 16:27:34 +01:00
[escher] Fix bug: do not redraw window at each timer fire but only for
timer requiring redraw Change-Id: Ia39a35185a4836809970f5ba77cc76a8b2e6ee26
This commit is contained in:
@@ -151,10 +151,13 @@ void AppsContainer::switchTo(App::Snapshot * snapshot) {
|
||||
}
|
||||
}
|
||||
|
||||
void AppsContainer::updateBatteryState() {
|
||||
m_window.updateBatteryLevel();
|
||||
m_window.updateIsChargingState();
|
||||
m_window.updatePluggedState();
|
||||
bool AppsContainer::updateBatteryState() {
|
||||
if (m_window.updateBatteryLevel() ||
|
||||
m_window.updateIsChargingState() ||
|
||||
m_window.updatePluggedState()) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void AppsContainer::refreshPreferences() {
|
||||
|
||||
@@ -43,7 +43,7 @@ public:
|
||||
void suspend(bool checkIfPowerKeyReleased = false);
|
||||
virtual bool dispatchEvent(Ion::Events::Event event) override;
|
||||
void switchTo(App::Snapshot * snapshot) override;
|
||||
void updateBatteryState();
|
||||
bool updateBatteryState();
|
||||
void refreshPreferences();
|
||||
void displayExamModePopUp(bool activate);
|
||||
void shutdownDueToLowBattery();
|
||||
|
||||
@@ -5,6 +5,7 @@ BacklightDimmingTimer::BacklightDimmingTimer() :
|
||||
{
|
||||
}
|
||||
|
||||
void BacklightDimmingTimer::fire() {
|
||||
bool BacklightDimmingTimer::fire() {
|
||||
Ion::Backlight::setBrightness(k_dimBacklightBrightness);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ public:
|
||||
private:
|
||||
constexpr static int k_idleBeforeDimmingDuration = 30*1000; // In miliseconds
|
||||
constexpr static int k_dimBacklightBrightness = 0;
|
||||
void fire() override;
|
||||
bool fire() override;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -7,9 +7,10 @@ BatteryTimer::BatteryTimer(AppsContainer * container) :
|
||||
{
|
||||
}
|
||||
|
||||
void BatteryTimer::fire() {
|
||||
m_container->updateBatteryState();
|
||||
bool BatteryTimer::fire() {
|
||||
bool needRedrawing = m_container->updateBatteryState();
|
||||
if (Ion::Battery::level() == Ion::Battery::Charge::EMPTY) {
|
||||
m_container->shutdownDueToLowBattery();
|
||||
}
|
||||
return needRedrawing;
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ class BatteryTimer : public Timer {
|
||||
public:
|
||||
BatteryTimer(AppsContainer * container);
|
||||
private:
|
||||
void fire() override;
|
||||
bool fire() override;
|
||||
AppsContainer * m_container;
|
||||
};
|
||||
|
||||
|
||||
@@ -6,8 +6,9 @@ LedTimer::LedTimer() :
|
||||
{
|
||||
}
|
||||
|
||||
void LedTimer::fire() {
|
||||
bool LedTimer::fire() {
|
||||
m_on = !m_on;
|
||||
KDColor ledColor = m_on ? KDColorRed : KDColorBlack;
|
||||
Ion::LED::setColor(ledColor);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ class LedTimer : public Timer {
|
||||
public:
|
||||
LedTimer();
|
||||
private:
|
||||
void fire() override;
|
||||
bool fire() override;
|
||||
bool m_on;
|
||||
};
|
||||
|
||||
|
||||
@@ -14,8 +14,9 @@ View * LogoController::view() {
|
||||
return &m_logoView;
|
||||
}
|
||||
|
||||
void LogoController::fire() {
|
||||
bool LogoController::fire() {
|
||||
app()->dismissModalViewController();
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ public:
|
||||
LogoController();
|
||||
View * view() override;
|
||||
private:
|
||||
void fire() override;
|
||||
bool fire() override;
|
||||
LogoView m_logoView;
|
||||
};
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ SuspendTimer::SuspendTimer(AppsContainer * container) :
|
||||
{
|
||||
}
|
||||
|
||||
void SuspendTimer::fire() {
|
||||
bool SuspendTimer::fire() {
|
||||
m_container->suspend();
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ public:
|
||||
SuspendTimer(AppsContainer * container);
|
||||
private:
|
||||
constexpr static int k_idleBeforeSuspendDuration = 5*60*1000; // In miliseconds
|
||||
void fire() override;
|
||||
bool fire() override;
|
||||
AppsContainer * m_container;
|
||||
};
|
||||
|
||||
|
||||
@@ -9,10 +9,12 @@ USBTimer::USBTimer(AppsContainer * container) :
|
||||
{
|
||||
}
|
||||
|
||||
void USBTimer::fire() {
|
||||
bool USBTimer::fire() {
|
||||
bool needRedrawing = false;
|
||||
if (Ion::USB::isPlugged()) {
|
||||
if (!m_previousPluggedState && GlobalPreferences::sharedGlobalPreferences()->examMode() == GlobalPreferences::ExamMode::Activate) {
|
||||
m_container->displayExamModePopUp(false);
|
||||
needRedrawing = true;
|
||||
}
|
||||
#if LED_WHILE_CHARGING
|
||||
KDColor LEDColor = Ion::Battery::isCharging() ? KDColorYellow : KDColorGreen;
|
||||
@@ -27,4 +29,5 @@ void USBTimer::fire() {
|
||||
m_previousPluggedState = false;
|
||||
}
|
||||
}
|
||||
return needRedrawing;
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ class USBTimer : public Timer {
|
||||
public:
|
||||
USBTimer(AppsContainer * container);
|
||||
private:
|
||||
void fire() override;
|
||||
bool fire() override;
|
||||
AppsContainer * m_container;
|
||||
bool m_previousPluggedState;
|
||||
};
|
||||
|
||||
@@ -22,7 +22,6 @@ objs += $(addprefix escher/src/,\
|
||||
highlight_cell.o\
|
||||
image_view.o\
|
||||
invocation.o\
|
||||
invocation_timer.o\
|
||||
input_view_controller.o\
|
||||
key_view.o\
|
||||
list_view_data_source.o\
|
||||
|
||||
@@ -25,7 +25,6 @@
|
||||
#include <escher/image_view.h>
|
||||
#include <escher/input_view_controller.h>
|
||||
#include <escher/invocation.h>
|
||||
#include <escher/invocation_timer.h>
|
||||
#include <escher/i18n.h>
|
||||
#include <escher/key_view.h>
|
||||
#include <escher/list_view_data_source.h>
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
#ifndef ESCHER_INVOCATION_TIMER_H
|
||||
#define ESCHER_INVOCATION_TIMER_H
|
||||
|
||||
#include <escher/timer.h>
|
||||
#include <escher/invocation.h>
|
||||
|
||||
class InvocationTimer : public Timer {
|
||||
public:
|
||||
InvocationTimer(Invocation invocation, uint32_t period);
|
||||
private:
|
||||
void fire() override;
|
||||
Invocation m_invocation;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -19,7 +19,7 @@ public:
|
||||
bool tick();
|
||||
void reset();
|
||||
protected:
|
||||
virtual void fire() = 0;
|
||||
virtual bool fire() = 0;
|
||||
private:
|
||||
uint32_t m_period;
|
||||
uint32_t m_numberOfTicksBeforeFire;
|
||||
|
||||
@@ -35,7 +35,7 @@ App * Container::activeApp() {
|
||||
}
|
||||
|
||||
bool Container::dispatchEvent(Ion::Events::Event event) {
|
||||
if (event == Ion::Events::TimerTick || m_activeApp->processEvent(event)) {
|
||||
if (event == Ion::Events::TimerFire || m_activeApp->processEvent(event)) {
|
||||
window()->redraw();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
#include <escher/invocation_timer.h>
|
||||
|
||||
InvocationTimer::InvocationTimer(Invocation invocation, uint32_t period) :
|
||||
Timer(period),
|
||||
m_invocation(invocation)
|
||||
{
|
||||
}
|
||||
|
||||
void InvocationTimer::fire() {
|
||||
m_invocation.perform(this);
|
||||
}
|
||||
@@ -49,7 +49,7 @@ bool RunLoop::step() {
|
||||
for (int i=0; i<numberOfTimers(); i++) {
|
||||
Timer * timer = timerAtIndex(i);
|
||||
if (timer->tick()) {
|
||||
dispatchEvent(Ion::Events::TimerTick);
|
||||
dispatchEvent(Ion::Events::TimerFire);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,9 +9,9 @@ Timer::Timer(uint32_t period) :
|
||||
bool Timer::tick() {
|
||||
m_numberOfTicksBeforeFire--;
|
||||
if (m_numberOfTicksBeforeFire == 0) {
|
||||
fire();
|
||||
bool needRedraw = fire();
|
||||
reset();
|
||||
return true;
|
||||
return needRedraw;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -200,7 +200,7 @@ constexpr Event UpperZ = Event::ShiftAlphaKey(Keyboard::Key::H4);
|
||||
|
||||
constexpr Event None = Event::Special(0);
|
||||
constexpr Event Termination = Event::Special(1);
|
||||
constexpr Event TimerTick = Event::Special(2);
|
||||
constexpr Event TimerFire = Event::Special(2);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user