Merge pull request #247 from jpirnay/fix-gate-statusupdates
chore: Suppress status-bar updates if nothing had changed
This commit is contained in:
+4
-2
@@ -138,9 +138,11 @@ inline const std::vector<SettingInfo> list = {
|
|||||||
StrId::STR_CAT_READER),
|
StrId::STR_CAT_READER),
|
||||||
SettingInfo::Enum(StrId::STR_IMAGES, &CrossPointSettings::imageRendering,
|
SettingInfo::Enum(StrId::STR_IMAGES, &CrossPointSettings::imageRendering,
|
||||||
{StrId::STR_IMAGES_DISPLAY, StrId::STR_IMAGES_PLACEHOLDER, StrId::STR_IMAGES_SUPPRESS},
|
{StrId::STR_IMAGES_DISPLAY, StrId::STR_IMAGES_PLACEHOLDER, StrId::STR_IMAGES_SUPPRESS},
|
||||||
"imageRendering", StrId::STR_CAT_READER),
|
"imageRendering", StrId::STR_CAT_READER)
|
||||||
|
.withSubmenu(StrId::STR_IMAGES),
|
||||||
SettingInfo::Toggle(StrId::STR_LARGE_IMAGE_PLACEHOLDER, &CrossPointSettings::largeImagePlaceholder,
|
SettingInfo::Toggle(StrId::STR_LARGE_IMAGE_PLACEHOLDER, &CrossPointSettings::largeImagePlaceholder,
|
||||||
"largeImagePlaceholder", StrId::STR_CAT_READER),
|
"largeImagePlaceholder", StrId::STR_CAT_READER)
|
||||||
|
.withSubmenu(StrId::STR_IMAGES),
|
||||||
SettingInfo::Value(StrId::STR_SCREEN_MARGIN, &CrossPointSettings::screenMargin, {5, 40, 5}, "screenMargin",
|
SettingInfo::Value(StrId::STR_SCREEN_MARGIN, &CrossPointSettings::screenMargin, {5, 40, 5}, "screenMargin",
|
||||||
StrId::STR_CAT_READER)
|
StrId::STR_CAT_READER)
|
||||||
.withSubmenu(StrId::STR_MENU_READER_SPACING),
|
.withSubmenu(StrId::STR_MENU_READER_SPACING),
|
||||||
|
|||||||
@@ -47,6 +47,11 @@ class Activity {
|
|||||||
virtual bool preventAutoSleep() { return false; }
|
virtual bool preventAutoSleep() { return false; }
|
||||||
virtual bool isReaderActivity() const { return false; }
|
virtual bool isReaderActivity() const { return false; }
|
||||||
|
|
||||||
|
// Return true to suppress the minute-tick requestUpdate() from ActivityManager when nothing
|
||||||
|
// status-bar-relevant has changed since the last render. Skipping avoids a no-op page render
|
||||||
|
// followed by a no-diff e-ink refresh, which on X3 panels accumulates visible speckle.
|
||||||
|
virtual bool shouldSkipPeriodicUpdate() const { return false; }
|
||||||
|
|
||||||
// Called by ActivityManager when a globally-configured button action targets the
|
// Called by ActivityManager when a globally-configured button action targets the
|
||||||
// current activity. Override in reader activities to handle reader-specific actions.
|
// current activity. Override in reader activities to handle reader-specific actions.
|
||||||
// Non-reader activities can ignore this (default is no-op).
|
// Non-reader activities can ignore this (default is no-op).
|
||||||
|
|||||||
@@ -111,7 +111,9 @@ void ActivityManager::loop() {
|
|||||||
time_t minute = now / 60;
|
time_t minute = now / 60;
|
||||||
if (minute != lastMinute) {
|
if (minute != lastMinute) {
|
||||||
lastMinute = minute;
|
lastMinute = minute;
|
||||||
requestUpdate();
|
if (!currentActivity || !currentActivity->shouldSkipPeriodicUpdate()) {
|
||||||
|
requestUpdate();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,8 @@
|
|||||||
#include <FontDecompressor.h>
|
#include <FontDecompressor.h>
|
||||||
#include <FsHelpers.h>
|
#include <FsHelpers.h>
|
||||||
#include <GfxRenderer.h>
|
#include <GfxRenderer.h>
|
||||||
|
#include <HalClock.h>
|
||||||
|
#include <HalPowerManager.h>
|
||||||
#include <HalStorage.h>
|
#include <HalStorage.h>
|
||||||
#include <I18n.h>
|
#include <I18n.h>
|
||||||
#include <Logging.h>
|
#include <Logging.h>
|
||||||
@@ -2256,6 +2258,30 @@ void EpubReaderActivity::renderStatusBar() const {
|
|||||||
const bool isStarred = section && bookmarkStore.has(static_cast<uint16_t>(currentSpineIndex),
|
const bool isStarred = section && bookmarkStore.has(static_cast<uint16_t>(currentSpineIndex),
|
||||||
static_cast<uint16_t>(section->currentPage));
|
static_cast<uint16_t>(section->currentPage));
|
||||||
GUI.drawStatusBar(renderer, bookProgress, currentPage, pageCount, title, 0, isStarred);
|
GUI.drawStatusBar(renderer, bookProgress, currentPage, pageCount, title, 0, isStarred);
|
||||||
|
|
||||||
|
lastStatusBarPage = currentPage;
|
||||||
|
lastStatusBarBattery = SETTINGS.statusBarBattery ? static_cast<int>(powerManager.getBatteryPercentage()) : -1;
|
||||||
|
if (SETTINGS.useClock && SETTINGS.statusBarClock && HalClock::isSynced()) {
|
||||||
|
const time_t now = HalClock::now();
|
||||||
|
lastStatusBarClockMinute = now > 0 ? static_cast<int>(now / 60) : -1;
|
||||||
|
} else {
|
||||||
|
lastStatusBarClockMinute = -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool EpubReaderActivity::shouldSkipPeriodicUpdate() const {
|
||||||
|
if (lastStatusBarPage < 0) return false; // no baseline yet — let the first render happen
|
||||||
|
const int currentPage = section ? section->currentPage + 1 : -1;
|
||||||
|
if (currentPage != lastStatusBarPage) return false;
|
||||||
|
if (SETTINGS.statusBarBattery) {
|
||||||
|
if (static_cast<int>(powerManager.getBatteryPercentage()) != lastStatusBarBattery) return false;
|
||||||
|
}
|
||||||
|
if (SETTINGS.useClock && SETTINGS.statusBarClock && HalClock::isSynced()) {
|
||||||
|
const time_t now = HalClock::now();
|
||||||
|
const int minute = now > 0 ? static_cast<int>(now / 60) : -1;
|
||||||
|
if (minute != lastStatusBarClockMinute) return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void EpubReaderActivity::navigateToHref(const std::string& hrefStr, const bool savePosition) {
|
void EpubReaderActivity::navigateToHref(const std::string& hrefStr, const bool savePosition) {
|
||||||
|
|||||||
@@ -262,6 +262,12 @@ class EpubReaderActivity final : public Activity {
|
|||||||
void displayPreRenderedPage(const Page& page, int orientedMarginTop, int orientedMarginRight,
|
void displayPreRenderedPage(const Page& page, int orientedMarginTop, int orientedMarginRight,
|
||||||
int orientedMarginBottom, int orientedMarginLeft);
|
int orientedMarginBottom, int orientedMarginLeft);
|
||||||
void renderStatusBar() const;
|
void renderStatusBar() const;
|
||||||
|
// Snapshot of the three status-bar signals that can change while a page is otherwise idle.
|
||||||
|
// Compared in shouldSkipPeriodicUpdate() to suppress no-op minute-tick re-renders that on
|
||||||
|
// X3 panels accumulate visible speckle via repeated no-diff FAST refreshes.
|
||||||
|
mutable int lastStatusBarPage = -1;
|
||||||
|
mutable int lastStatusBarBattery = -1;
|
||||||
|
mutable int lastStatusBarClockMinute = -1;
|
||||||
void silentIndexNextChapterIfNeeded(uint16_t viewportWidth, uint16_t viewportHeight);
|
void silentIndexNextChapterIfNeeded(uint16_t viewportWidth, uint16_t viewportHeight);
|
||||||
void saveProgress(int spineIndex, int currentPage, int pageCount);
|
void saveProgress(int spineIndex, int currentPage, int pageCount);
|
||||||
// Jump to a percentage of the book (0-100), mapping it to spine and page.
|
// Jump to a percentage of the book (0-100), mapping it to spine and page.
|
||||||
@@ -314,6 +320,7 @@ class EpubReaderActivity final : public Activity {
|
|||||||
void loop() override;
|
void loop() override;
|
||||||
void render(RenderLock&& lock) override;
|
void render(RenderLock&& lock) override;
|
||||||
bool isReaderActivity() const override { return true; }
|
bool isReaderActivity() const override { return true; }
|
||||||
|
bool shouldSkipPeriodicUpdate() const override;
|
||||||
void onButtonAction(CrossPointSettings::BUTTON_ACTION action) override;
|
void onButtonAction(CrossPointSettings::BUTTON_ACTION action) override;
|
||||||
|
|
||||||
// Renders the last saved page to the frame buffer without flushing to display.
|
// Renders the last saved page to the frame buffer without flushing to display.
|
||||||
|
|||||||
@@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
#include <FontCacheManager.h>
|
#include <FontCacheManager.h>
|
||||||
#include <GfxRenderer.h>
|
#include <GfxRenderer.h>
|
||||||
|
#include <HalClock.h>
|
||||||
|
#include <HalPowerManager.h>
|
||||||
#include <HalStorage.h>
|
#include <HalStorage.h>
|
||||||
#include <I18n.h>
|
#include <I18n.h>
|
||||||
#include <Serialization.h>
|
#include <Serialization.h>
|
||||||
@@ -881,6 +883,29 @@ void MdReaderActivity::renderStatusBar() const {
|
|||||||
title = txt->getTitle();
|
title = txt->getTitle();
|
||||||
}
|
}
|
||||||
GUI.drawStatusBar(renderer, progress, currentPage + 1, totalPages, title);
|
GUI.drawStatusBar(renderer, progress, currentPage + 1, totalPages, title);
|
||||||
|
|
||||||
|
lastStatusBarPage = currentPage + 1;
|
||||||
|
lastStatusBarBattery = SETTINGS.statusBarBattery ? static_cast<int>(powerManager.getBatteryPercentage()) : -1;
|
||||||
|
if (SETTINGS.useClock && SETTINGS.statusBarClock && HalClock::isSynced()) {
|
||||||
|
const time_t now = HalClock::now();
|
||||||
|
lastStatusBarClockMinute = now > 0 ? static_cast<int>(now / 60) : -1;
|
||||||
|
} else {
|
||||||
|
lastStatusBarClockMinute = -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool MdReaderActivity::shouldSkipPeriodicUpdate() const {
|
||||||
|
if (lastStatusBarPage < 0) return false;
|
||||||
|
if (currentPage + 1 != lastStatusBarPage) return false;
|
||||||
|
if (SETTINGS.statusBarBattery) {
|
||||||
|
if (static_cast<int>(powerManager.getBatteryPercentage()) != lastStatusBarBattery) return false;
|
||||||
|
}
|
||||||
|
if (SETTINGS.useClock && SETTINGS.statusBarClock && HalClock::isSynced()) {
|
||||||
|
const time_t now = HalClock::now();
|
||||||
|
const int minute = now > 0 ? static_cast<int>(now / 60) : -1;
|
||||||
|
if (minute != lastStatusBarClockMinute) return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MdReaderActivity::saveProgress() const {
|
void MdReaderActivity::saveProgress() const {
|
||||||
|
|||||||
@@ -60,6 +60,10 @@ class MdReaderActivity final : public Activity {
|
|||||||
|
|
||||||
void renderPage();
|
void renderPage();
|
||||||
void renderStatusBar() const;
|
void renderStatusBar() const;
|
||||||
|
// See EpubReaderActivity for rationale — suppresses no-op minute-tick re-renders.
|
||||||
|
mutable int lastStatusBarPage = -1;
|
||||||
|
mutable int lastStatusBarBattery = -1;
|
||||||
|
mutable int lastStatusBarClockMinute = -1;
|
||||||
|
|
||||||
void initializeReader();
|
void initializeReader();
|
||||||
bool loadPageAtOffset(size_t offset, bool startInCodeBlock, std::vector<RenderedLine>& outLines, size_t& nextOffset,
|
bool loadPageAtOffset(size_t offset, bool startInCodeBlock, std::vector<RenderedLine>& outLines, size_t& nextOffset,
|
||||||
@@ -91,5 +95,6 @@ class MdReaderActivity final : public Activity {
|
|||||||
void loop() override;
|
void loop() override;
|
||||||
void render(RenderLock&&) override;
|
void render(RenderLock&&) override;
|
||||||
bool isReaderActivity() const override { return true; }
|
bool isReaderActivity() const override { return true; }
|
||||||
|
bool shouldSkipPeriodicUpdate() const override;
|
||||||
void onButtonAction(CrossPointSettings::BUTTON_ACTION action) override;
|
void onButtonAction(CrossPointSettings::BUTTON_ACTION action) override;
|
||||||
};
|
};
|
||||||
@@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
#include <FontCacheManager.h>
|
#include <FontCacheManager.h>
|
||||||
#include <GfxRenderer.h>
|
#include <GfxRenderer.h>
|
||||||
|
#include <HalClock.h>
|
||||||
|
#include <HalPowerManager.h>
|
||||||
#include <HalStorage.h>
|
#include <HalStorage.h>
|
||||||
#include <I18n.h>
|
#include <I18n.h>
|
||||||
#include <Serialization.h>
|
#include <Serialization.h>
|
||||||
@@ -482,6 +484,29 @@ void TxtReaderActivity::renderStatusBar() const {
|
|||||||
}
|
}
|
||||||
const bool isStarred = bookmarkStore.has(0, static_cast<uint16_t>(currentPage));
|
const bool isStarred = bookmarkStore.has(0, static_cast<uint16_t>(currentPage));
|
||||||
GUI.drawStatusBar(renderer, progress, currentPage + 1, totalPages, title, 0, isStarred);
|
GUI.drawStatusBar(renderer, progress, currentPage + 1, totalPages, title, 0, isStarred);
|
||||||
|
|
||||||
|
lastStatusBarPage = currentPage + 1;
|
||||||
|
lastStatusBarBattery = SETTINGS.statusBarBattery ? static_cast<int>(powerManager.getBatteryPercentage()) : -1;
|
||||||
|
if (SETTINGS.useClock && SETTINGS.statusBarClock && HalClock::isSynced()) {
|
||||||
|
const time_t now = HalClock::now();
|
||||||
|
lastStatusBarClockMinute = now > 0 ? static_cast<int>(now / 60) : -1;
|
||||||
|
} else {
|
||||||
|
lastStatusBarClockMinute = -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool TxtReaderActivity::shouldSkipPeriodicUpdate() const {
|
||||||
|
if (lastStatusBarPage < 0) return false;
|
||||||
|
if (currentPage + 1 != lastStatusBarPage) return false;
|
||||||
|
if (SETTINGS.statusBarBattery) {
|
||||||
|
if (static_cast<int>(powerManager.getBatteryPercentage()) != lastStatusBarBattery) return false;
|
||||||
|
}
|
||||||
|
if (SETTINGS.useClock && SETTINGS.statusBarClock && HalClock::isSynced()) {
|
||||||
|
const time_t now = HalClock::now();
|
||||||
|
const int minute = now > 0 ? static_cast<int>(now / 60) : -1;
|
||||||
|
if (minute != lastStatusBarClockMinute) return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TxtReaderActivity::saveProgress() const {
|
void TxtReaderActivity::saveProgress() const {
|
||||||
|
|||||||
@@ -39,6 +39,10 @@ class TxtReaderActivity final : public Activity {
|
|||||||
|
|
||||||
void renderPage();
|
void renderPage();
|
||||||
void renderStatusBar() const;
|
void renderStatusBar() const;
|
||||||
|
// See EpubReaderActivity for rationale — suppresses no-op minute-tick re-renders.
|
||||||
|
mutable int lastStatusBarPage = -1;
|
||||||
|
mutable int lastStatusBarBattery = -1;
|
||||||
|
mutable int lastStatusBarClockMinute = -1;
|
||||||
|
|
||||||
void initializeReader();
|
void initializeReader();
|
||||||
bool loadPageAtOffset(size_t offset, std::vector<std::string>& outLines, size_t& nextOffset);
|
bool loadPageAtOffset(size_t offset, std::vector<std::string>& outLines, size_t& nextOffset);
|
||||||
@@ -60,6 +64,7 @@ class TxtReaderActivity final : public Activity {
|
|||||||
void loop() override;
|
void loop() override;
|
||||||
void render(RenderLock&&) override;
|
void render(RenderLock&&) override;
|
||||||
bool isReaderActivity() const override { return true; }
|
bool isReaderActivity() const override { return true; }
|
||||||
|
bool shouldSkipPeriodicUpdate() const override;
|
||||||
void onButtonAction(CrossPointSettings::BUTTON_ACTION action) override;
|
void onButtonAction(CrossPointSettings::BUTTON_ACTION action) override;
|
||||||
|
|
||||||
// Renders the last saved page to the frame buffer without flushing to display.
|
// Renders the last saved page to the frame buffer without flushing to display.
|
||||||
|
|||||||
Reference in New Issue
Block a user