From 339afe07879a7452c0d4de0a53dc30ba2f04e995 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89milie=20Feral?= Date: Mon, 22 May 2017 14:35:02 +0200 Subject: [PATCH] [escher] Add an event "TimerTick" Change-Id: Ib6d1cacdf13226d37b1a8fdf6ecf8a92d077a96f --- apps/apps_container.cpp | 2 +- escher/include/escher/container.h | 1 - escher/include/escher/run_loop.h | 1 - escher/src/container.cpp | 7 ++----- escher/src/run_loop.cpp | 2 +- ion/include/ion/events.h | 1 + 6 files changed, 5 insertions(+), 9 deletions(-) diff --git a/apps/apps_container.cpp b/apps/apps_container.cpp index 255c90133..e01d26fc6 100644 --- a/apps/apps_container.cpp +++ b/apps/apps_container.cpp @@ -130,7 +130,7 @@ bool AppsContainer::dispatchEvent(Ion::Events::Event event) { return true; } if (!didProcessEvent && alphaLockWantsRedraw) { - windowRedraw(); + window()->redraw(); return true; } return didProcessEvent; diff --git a/escher/include/escher/container.h b/escher/include/escher/container.h index 8412274ff..e1e4f299c 100644 --- a/escher/include/escher/container.h +++ b/escher/include/escher/container.h @@ -29,7 +29,6 @@ public: virtual void switchTo(App::Snapshot * snapshot); protected: virtual Window * window() = 0; - void windowRedraw() override; private: void step(); App * m_activeApp; diff --git a/escher/include/escher/run_loop.h b/escher/include/escher/run_loop.h index 81bc7b1fd..83f9396d6 100644 --- a/escher/include/escher/run_loop.h +++ b/escher/include/escher/run_loop.h @@ -9,7 +9,6 @@ public: RunLoop(); void run(); protected: - virtual void windowRedraw() = 0; virtual bool dispatchEvent(Ion::Events::Event e) = 0; virtual int numberOfTimers(); virtual Timer * timerAtIndex(int i); diff --git a/escher/src/container.cpp b/escher/src/container.cpp index 2314eda06..7cbdcb1fd 100644 --- a/escher/src/container.cpp +++ b/escher/src/container.cpp @@ -36,8 +36,8 @@ App * Container::activeApp() { } bool Container::dispatchEvent(Ion::Events::Event event) { - if (m_activeApp->processEvent(event)) { - windowRedraw(); + if (event == Ion::Events::TimerTick || m_activeApp->processEvent(event)) { + window()->redraw(); return true; } return false; @@ -49,6 +49,3 @@ void Container::run() { RunLoop::run(); } -void Container::windowRedraw() { - window()->redraw(); -} diff --git a/escher/src/run_loop.cpp b/escher/src/run_loop.cpp index 2231f34ed..6c14ced8f 100644 --- a/escher/src/run_loop.cpp +++ b/escher/src/run_loop.cpp @@ -49,7 +49,7 @@ bool RunLoop::step() { for (int i=0; itick()) { - windowRedraw(); + dispatchEvent(Ion::Events::TimerTick); } } } diff --git a/ion/include/ion/events.h b/ion/include/ion/events.h index f652098bf..effbe1abb 100644 --- a/ion/include/ion/events.h +++ b/ion/include/ion/events.h @@ -200,6 +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); } }