Optimize kernel-to-userspace battery life across CAMSS, SPI runtime PM, dwm, NeoUI, and plugins

This commit is contained in:
Luxferre committed 2026-11-01 11:56:28 +02:00
1 parent f112b6ae72
commit 456d3fbc42
61 files changed
+466 -148

No files matched your search

+41 -14
View File
@@ -2709,6 +2709,31 @@ int neoui_clear_toast(void) {
// 5. Event Loop, Keypad & Multi-Tap Input Management
// ---------------------------------------------------------------------------
int neoui_next_timeout_ms(int default_timeout_ms) {
NeoContext* ctx = ensureCtx();
int waitMs = default_timeout_ms;
int64_t now = bananarchy::monotonicMs();
if (ctx->visible && ctx->grabYielded) {
if (waitMs < 0 || waitMs > 100) waitMs = 100;
}
if (ctx->softkeyPending != 0) {
int rem = static_cast<int>(
std::max<int64_t>(1, ctx->softkeyDeadlineMs - now));
if (waitMs < 0 || rem < waitMs) waitMs = rem;
}
if (ctx->tapActive) {
int rem = static_cast<int>(
std::max<int64_t>(1, (ctx->lastTapMs + 850) - now));
if (waitMs < 0 || rem < waitMs) waitMs = rem;
}
if (ctx->toastUntilMs > 0) {
int rem = static_cast<int>(
std::max<int64_t>(1, ctx->toastUntilMs - now));
if (waitMs < 0 || rem < waitMs) waitMs = rem;
}
return waitMs;
}
int neoui_poll_event(int timeout_ms) {
NeoContext* ctx = ensureCtx();
ctx->lastEventType = NEO_EV_NONE;
@@ -2763,6 +2788,14 @@ int neoui_poll_event(int timeout_ms) {
return NEO_EV_EXPOSE;
}
// Check if toast expired
if (ctx->toastUntilMs > 0 && now >= ctx->toastUntilMs) {
ctx->toastUntilMs = 0;
ctx->toastMsg.clear();
ctx->lastEventType = NEO_EV_EXPOSE;
return NEO_EV_EXPOSE;
}
// Check if pending softkey chord timer expired -> emit single softkey
if (ctx->softkeyPending != 0 && now >= ctx->softkeyDeadlineMs) {
int pend = ctx->softkeyPending;
@@ -2932,20 +2965,7 @@ int neoui_poll_event(int timeout_ms) {
if (imm != NEO_EV_NONE) return imm;
// Calculate effective poll timeout
int waitMs = timeout_ms;
if (ctx->visible && ctx->grabYielded && waitMs != 0) {
if (waitMs < 0 || waitMs > 100) waitMs = 100;
}
if (ctx->softkeyPending != 0) {
int rem = static_cast<int>(
std::max<int64_t>(1, ctx->softkeyDeadlineMs - bananarchy::monotonicMs()));
if (waitMs < 0 || rem < waitMs) waitMs = rem;
}
if (ctx->tapActive) {
int rem = static_cast<int>(
std::max<int64_t>(1, (ctx->lastTapMs + 850) - bananarchy::monotonicMs()));
if (waitMs < 0 || rem < waitMs) waitMs = rem;
}
int waitMs = (timeout_ms == 0) ? 0 : neoui_next_timeout_ms(timeout_ms);
struct pollfd pfds[2];
int nfds = 0;
@@ -3004,6 +3024,13 @@ int neoui_poll_event(int timeout_ms) {
return NEO_EV_EXPOSE;
}
if (ctx->toastUntilMs > 0 && now >= ctx->toastUntilMs) {
ctx->toastUntilMs = 0;
ctx->toastMsg.clear();
ctx->lastEventType = NEO_EV_EXPOSE;
return NEO_EV_EXPOSE;
}
ovEv = syncOverlayGrabState();
int postEv = processNextXEvent();
if (postEv != NEO_EV_NONE) return postEv;
+1
View File
@@ -281,6 +281,7 @@ int neoui_clear_toast(void);
// 5. Event Loop, Keypad & Multi-Tap Input Management
// ---------------------------------------------------------------------------
int neoui_poll_event(int timeout_ms);
int neoui_next_timeout_ms(int default_timeout_ms);
int neoui_event_key(void);
int neoui_event_keycode(void);
int neoui_event_keysym(void);