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

+9 -2
View File
@@ -1079,9 +1079,16 @@ int calllog_run_main(int argc, char** argv) {
int timeoutMs = -1;
if (visible) {
timeoutMs = 200;
if (!initialSoftkeysReleased) {
timeoutMs = 40;
}
if (softkeyDeadlineMs > 0) {
timeoutMs = static_cast<int>(std::max<int64_t>(5, softkeyDeadlineMs - nowMs()));
int rem = static_cast<int>(std::max<int64_t>(5, softkeyDeadlineMs - nowMs()));
timeoutMs = (timeoutMs < 0) ? rem : std::min(timeoutMs, rem);
}
if (!toastMsg.empty() && toastUntilMs > 0) {
int rem = static_cast<int>(std::max<int64_t>(5, toastUntilMs - nowMs()));
timeoutMs = (timeoutMs < 0) ? rem : std::min(timeoutMs, rem);
}
}
+20 -6
View File
@@ -1712,20 +1712,34 @@ int runContactsApp(int argc, char** argv) {
render();
}
if (visible && !statusMsg.empty() && statusUntilMs > 0 &&
nowMs() >= statusUntilMs) {
statusMsg.clear();
statusUntilMs = 0;
render();
}
int timeoutMs = -1;
if (visible) {
timeoutMs = 200;
if (!initialSoftkeysReleased) {
timeoutMs = 40;
}
if (softkeyDeadlineMs > 0) {
timeoutMs =
int rem =
static_cast<int>(std::max<int64_t>(5, softkeyDeadlineMs - nowMs()));
timeoutMs = (timeoutMs < 0) ? rem : std::min(timeoutMs, rem);
}
if (zeroHeld) {
int64_t rem = 420 - (nowMs() - zeroPressMs);
timeoutMs = std::min(timeoutMs, static_cast<int>(std::max<int64_t>(5, rem)));
int rem = static_cast<int>(std::max<int64_t>(5, 420 - (nowMs() - zeroPressMs)));
timeoutMs = (timeoutMs < 0) ? rem : std::min(timeoutMs, rem);
}
if (mode == ViewMode::Edit && lastTapDigit != -1) {
int64_t rem = 851 - (nowMs() - lastTapMs);
timeoutMs = std::min(timeoutMs, static_cast<int>(std::max<int64_t>(5, rem)));
int rem = static_cast<int>(std::max<int64_t>(5, 851 - (nowMs() - lastTapMs)));
timeoutMs = (timeoutMs < 0) ? rem : std::min(timeoutMs, rem);
}
if (!statusMsg.empty() && statusUntilMs > 0) {
int rem = static_cast<int>(std::max<int64_t>(5, statusUntilMs - nowMs()));
timeoutMs = (timeoutMs < 0) ? rem : std::min(timeoutMs, rem);
}
}
+9 -4
View File
@@ -1037,11 +1037,16 @@ int dialer_run_main(int argc, char** argv) {
int timeoutMs = -1;
if (visible) {
timeoutMs = 200;
if (!initialSoftkeysReleased) {
timeoutMs = 40;
}
if (softkeyDeadlineMs > 0) {
timeoutMs = static_cast<int>(std::max<int64_t>(5, softkeyDeadlineMs - nowMs()));
} else if (zeroHeld) {
timeoutMs = 25;
int rem = static_cast<int>(std::max<int64_t>(5, softkeyDeadlineMs - nowMs()));
timeoutMs = (timeoutMs < 0) ? rem : std::min(timeoutMs, rem);
}
if (zeroHeld) {
int rem = static_cast<int>(std::max<int64_t>(5, 420 - (nowMs() - zeroPressMs)));
timeoutMs = (timeoutMs < 0) ? rem : std::min(timeoutMs, rem);
}
}
+1 -1
View File
@@ -1093,7 +1093,7 @@ int email_run_main(int argc, char** argv) {
struct pollfd pfds[2] {};
pfds[0] = { ConnectionNumber(neo.dpy), POLLIN, 0 };
pfds[1] = { fifoFd, POLLIN, 0 };
int timeoutMs = visible ? (neoui_input_is_tap_active() ? 150 : 1000) : -1;
int timeoutMs = visible ? neoui_next_timeout_ms(-1) : -1;
::poll(pfds, (fifoFd >= 0) ? 2 : 1, timeoutMs);
}
+1 -1
View File
@@ -1208,7 +1208,7 @@ int irc_run_main(int argc, char** argv) {
pfds.push_back({ s.net->fd(), POLLIN, 0 });
}
}
int timeoutMs = visible ? (neoui_input_is_tap_active() ? 150 : 1000) : -1;
int timeoutMs = visible ? neoui_next_timeout_ms(-1) : -1;
::poll(pfds.data(), static_cast<nfds_t>(pfds.size()), timeoutMs);
}
+4 -5
View File
@@ -897,17 +897,16 @@ int locker_run_main(int argc, char** argv) {
}
}
if (visible) {
if (visible && !isScreenBlanked()) {
if (!isCallActiveOrRingingFast() && !grabHeld) {
grabLockerInput();
}
if (!isScreenBlanked()) {
render();
}
render();
}
int timeoutMs = -1;
if (visible && !isCallActiveOrRingingFast() && !grabHeld) {
if (visible && !isScreenBlanked() && !isCallActiveOrRingingFast() &&
!grabHeld) {
timeoutMs = 35;
} else if (visible && !isScreenBlanked()) {
int64_t now = nowMs();
+1 -1
View File
@@ -3964,7 +3964,7 @@ int sip_run_main(int argc, char** argv) {
if (callState == SipCallState::Active || callState == SipCallState::Outgoing) {
timeoutMs = 150;
} else if (visible) {
timeoutMs = neoui_input_is_tap_active() ? 150 : 1000;
timeoutMs = neoui_next_timeout_ms(anyEnabled ? 15000 : -1);
} else if (anyEnabled) {
timeoutMs = 15000;
}
+1 -1
View File
@@ -1047,7 +1047,7 @@ int smallweb_run_main(int argc, char** argv) {
struct pollfd pfds[2] {};
pfds[0] = { ConnectionNumber(neo.dpy), POLLIN, 0 };
pfds[1] = { fifoFd, POLLIN, 0 };
int timeoutMs = visible ? (neoui_input_is_tap_active() ? 150 : 1000) : -1;
int timeoutMs = visible ? neoui_next_timeout_ms(-1) : -1;
::poll(pfds, (fifoFd >= 0) ? 2 : 1, timeoutMs);
}
+64 -14
View File
@@ -6,6 +6,7 @@
#include <X11/Xutil.h>
#include <pango/pangoxft.h>
#include <poll.h>
#include <sys/inotify.h>
#include <sys/wait.h>
#include <clocale>
#include <mutex>
@@ -234,7 +235,7 @@ int runSmsApp(int argc, char** argv) {
}
};
auto reloadAllData = [&](bool force = false) {
auto reloadAllData = [&](bool force = false) -> bool {
bool cChanged = contactsStamp.checkAndUpdate(getContactsFilePath());
bool lChanged = modemLogStamp.checkAndUpdate(getModemLogFilePath());
bool bChanged = blockFileStamp.checkAndUpdate(getBlockFilePath());
@@ -258,7 +259,9 @@ int runSmsApp(int argc, char** argv) {
std::max(0, static_cast<int>(threadMessages.size()) - 1);
}
}
return true;
}
return false;
};
reloadAllData(true);
@@ -1337,10 +1340,21 @@ int runSmsApp(int argc, char** argv) {
}
int xfd = ConnectionNumber(dpy);
int inotifyFd = ::inotify_init1(IN_NONBLOCK | IN_CLOEXEC);
if (inotifyFd >= 0) {
ContactBook::ensureParentDir(getModemLogFilePath());
ContactBook::ensureParentDir(getBlockedModemLogFilePath());
::inotify_add_watch(inotifyFd, getModemLogDirPath().c_str(),
IN_MODIFY | IN_CLOSE_WRITE | IN_MOVED_TO | IN_CREATE | IN_DELETE);
::inotify_add_watch(inotifyFd, getBlockDirPath().c_str(),
IN_MODIFY | IN_CLOSE_WRITE | IN_MOVED_TO | IN_CREATE | IN_DELETE);
}
while (gRunning) {
for (const auto& cmd : readFifoLines(fifoFd)) {
if (cmd == "NOP") {
continue;
} else if (cmd == "REFRESH") {
if (reloadAllData(false) && visible) drawUI();
} else if (cmd == "RELOAD_THEME") {
pt.reload();
reloadAllData(true);
@@ -1721,26 +1735,48 @@ int runSmsApp(int argc, char** argv) {
drawUI();
}
int64_t bannerDeadline = 0;
bool bannerExpired = false;
{
std::lock_guard<std::mutex> lk(sendMutex);
if (!statusBanner.empty() && statusBannerUntilMs > 0) {
if (tNow >= statusBannerUntilMs) {
statusBanner.clear();
statusBannerUntilMs = 0;
bannerExpired = true;
} else {
bannerDeadline = statusBannerUntilMs;
}
}
}
if (visible && bannerExpired) {
drawUI();
}
int timeoutMs = -1;
if (visible) {
timeoutMs = 250;
if (!initialSoftkeysReleased) {
timeoutMs = 40;
}
if (softkeyPending != 0) {
timeoutMs = std::min(timeoutMs,
std::max(1, static_cast<int>(softkeyDeadlineMs - tNow)));
int rem = std::max(1, static_cast<int>(softkeyDeadlineMs - tNow));
timeoutMs = (timeoutMs < 0) ? rem : std::min(timeoutMs, rem);
}
if (zeroHeld) {
timeoutMs = std::min(
timeoutMs,
std::max(1, static_cast<int>((zeroPressMs + 420) - tNow)));
int rem = std::max(1, static_cast<int>((zeroPressMs + 420) - tNow));
timeoutMs = (timeoutMs < 0) ? rem : std::min(timeoutMs, rem);
}
if (mode == ViewMode::Compose && lastTapDigit != -1) {
timeoutMs = std::min(
timeoutMs,
std::max(1, static_cast<int>(851 - (tNow - lastTapMs))));
int rem = std::max(1, static_cast<int>(851 - (tNow - lastTapMs)));
timeoutMs = (timeoutMs < 0) ? rem : std::min(timeoutMs, rem);
}
if (bannerDeadline > 0) {
int rem = std::max(1, static_cast<int>(bannerDeadline - tNow));
timeoutMs = (timeoutMs < 0) ? rem : std::min(timeoutMs, rem);
}
}
struct pollfd pfds[3];
struct pollfd pfds[4];
int nfds = 0;
pfds[nfds++] = {xfd, POLLIN, 0};
int fifoIdx = -1;
@@ -1753,12 +1789,19 @@ int runSmsApp(int argc, char** argv) {
pipeIdx = nfds;
pfds[nfds++] = {notifyPipe[0], POLLIN, 0};
}
int inotifyIdx = -1;
if (inotifyFd >= 0 && visible) {
inotifyIdx = nfds;
pfds[nfds++] = {inotifyFd, POLLIN, 0};
}
int pr = ::poll(pfds, nfds, timeoutMs);
if (pr > 0) {
if (fifoIdx >= 0 && (pfds[fifoIdx].revents & POLLIN)) {
for (const auto& cmd : readFifoLines(fifoFd)) {
if (cmd == "RELOAD_THEME") {
if (cmd == "REFRESH") {
if (reloadAllData(false) && visible) drawUI();
} else if (cmd == "RELOAD_THEME") {
pt.reload();
reloadAllData(true);
if (visible) drawUI();
@@ -1782,12 +1825,19 @@ int runSmsApp(int argc, char** argv) {
}
drawUI();
}
} else if (pr == 0 && visible) {
reloadAllData(false);
if (inotifyIdx >= 0 && (pfds[inotifyIdx].revents & POLLIN)) {
char ibuf[512];
while (::read(inotifyFd, ibuf, sizeof(ibuf)) > 0) {
}
if (reloadAllData(false) && visible) {
drawUI();
}
}
}
}
hideWindow();
if (inotifyFd >= 0) ::close(inotifyFd);
if (fifoFd >= 0) ::close(fifoFd);
if (notifyPipe[0] >= 0) ::close(notifyPipe[0]);
if (notifyPipe[1] >= 0) ::close(notifyPipe[1]);
+5 -1
View File
@@ -938,7 +938,11 @@ int tox_run_main(int argc, char** argv) {
if (ctx.inCall && ctx.callActive) {
timeoutMs = 20;
} else if (visible) {
timeoutMs = neoui_input_is_tap_active() ? 100 : 200;
int baseTimeout = shouldIterateTox
? static_cast<int>(std::clamp<uint32_t>(
tox_iteration_interval(tox), 250, 1000))
: -1;
timeoutMs = neoui_next_timeout_ms(baseTimeout);
} else if (shouldIterateTox) {
timeoutMs = static_cast<int>(
std::clamp<uint32_t>(tox_iteration_interval(tox), 250, 1000));
+99 -9
View File
@@ -772,6 +772,26 @@ gboolean onPermissionRequest(WebKitWebView*,
return TRUE;
}
gboolean onLoadFailed(WebKitWebView* webView,
WebKitLoadEvent,
gchar* failingUri,
GError* error,
gpointer userData) {
auto* st = static_cast<BrowserRuntimeState*>(userData);
if (st) {
st->isLoading = false;
if (error && error->message) {
st->statusMsg = std::string("Load failed: ") + error->message;
} else if (failingUri) {
st->statusMsg = std::string("Failed: ") + failingUri;
} else {
st->statusMsg = "Load failed";
}
}
(void)webView;
return FALSE;
}
gboolean onWebProcessTerminated(WebKitWebView* webView,
WebKitWebProcessTerminationReason,
gpointer userData) {
@@ -806,6 +826,8 @@ bool initBrowserEngine(BrowserRuntimeState& st, const std::string& userAgent) {
// Hardware acceleration & Cortex-A7 / 512 MB RAM environment tuning
::setenv("GDK_BACKEND", "x11", 1);
::setenv("GTK_THEME", "Adwaita:dark", 1);
::setenv("NO_AT_BRIDGE", "1", 1);
::setenv("GTK_A11Y", "none", 1);
::setenv("WEBKIT_DISABLE_SANDBOX_THIS_IS_DANGEROUS", "1", 1);
::setenv("WEBKIT_DISABLE_COMPOSITING_MODE", "0", 0);
::setenv("WEBKIT_DISABLE_DMABUF_RENDERER", "0", 0);
@@ -844,8 +866,6 @@ bool initBrowserEngine(BrowserRuntimeState& st, const std::string& userAgent) {
g_object_unref(cssProv);
}
ensureAlsaMultimediaRouting();
// Configure 160 MB memory pressure limit for WebKit processes on 512 MB phone
WebKitMemoryPressureSettings* mp = webkit_memory_pressure_settings_new();
webkit_memory_pressure_settings_set_memory_limit(mp, 160);
@@ -954,6 +974,7 @@ bool initBrowserEngine(BrowserRuntimeState& st, const std::string& userAgent) {
st.webView = WEBKIT_WEB_VIEW(wvWidget);
g_signal_connect(st.webView, "load-changed", G_CALLBACK(onLoadChanged), &st);
g_signal_connect(st.webView, "load-failed", G_CALLBACK(onLoadFailed), &st);
g_signal_connect(st.webView, "notify::uri", G_CALLBACK(onNotifyUriOrTitle), &st);
g_signal_connect(st.webView, "notify::title", G_CALLBACK(onNotifyUriOrTitle), &st);
g_signal_connect(st.webView, "notify::estimated-load-progress",
@@ -1346,6 +1367,10 @@ int webarchy_run_main(int argc, char** argv) {
infoModalOpen = false;
chordPrefix.clear();
if (br.initialized && br.webView) {
if (br.isLoading) {
webkit_web_view_stop_loading(br.webView);
br.isLoading = false;
}
evalJs(br, "try{document.querySelectorAll('audio,video').forEach(function(m){m.pause();});}catch(e){}");
webkit_web_view_set_is_muted(br.webView, TRUE);
}
@@ -1864,16 +1889,81 @@ int webarchy_run_main(int argc, char** argv) {
}
}
struct pollfd pfds[2] {};
pfds[0] = { ConnectionNumber(neo.dpy), POLLIN, 0 };
pfds[1] = { fifoFd, POLLIN, 0 };
GMainContext* gctx = g_main_context_default();
gint maxPriority = 0;
gint glibTimeout = -1;
std::vector<GPollFD> gpfds;
bool useGlibPoll = br.initialized && (visible || br.isLoading);
if (useGlibPoll) {
if (g_main_context_prepare(gctx, &maxPriority)) {
glibTimeout = 0;
}
gpfds.resize(16);
gint nf = g_main_context_query(gctx, maxPriority, &glibTimeout,
gpfds.data(), static_cast<gint>(gpfds.size()));
if (nf > static_cast<gint>(gpfds.size())) {
gpfds.resize(nf);
nf = g_main_context_query(gctx, maxPriority, &glibTimeout,
gpfds.data(), nf);
}
gpfds.resize(std::max(0, nf));
}
std::vector<struct pollfd> pfds;
pfds.reserve(2 + gpfds.size());
pfds.push_back({ ConnectionNumber(neo.dpy), POLLIN, 0 });
if (fifoFd >= 0) {
pfds.push_back({ fifoFd, POLLIN, 0 });
}
size_t glibOffset = pfds.size();
for (const GPollFD& gp : gpfds) {
pfds.push_back({ gp.fd, static_cast<short>(gp.events), 0 });
}
int timeoutMs = -1;
if (visible) {
timeoutMs = 25;
} else if (br.initialized && br.isLoading) {
timeoutMs = 100;
neo.bindAsActiveContext();
timeoutMs = neoui_next_timeout_ms(-1);
if (isPhonePasscodeLocked() && !mutedByLock) {
timeoutMs = 0;
} else if (mutedByLock && (timeoutMs < 0 || timeoutMs > 250)) {
timeoutMs = 250;
}
}
if (useGlibPoll && glibTimeout >= 0) {
if (timeoutMs < 0 || glibTimeout < timeoutMs) {
timeoutMs = glibTimeout;
}
}
::poll(pfds.data(), static_cast<nfds_t>(pfds.size()), timeoutMs);
if (useGlibPoll) {
for (size_t i = 0; i < gpfds.size(); ++i) {
gpfds[i].revents = static_cast<gushort>(pfds[glibOffset + i].revents);
}
std::string prevUrl = br.currentUrl;
std::string prevTitle = br.currentTitle;
std::string prevStatus = br.statusMsg;
bool prevLoading = br.isLoading;
if (g_main_context_check(gctx, maxPriority, gpfds.data(),
static_cast<gint>(gpfds.size()))) {
g_main_context_dispatch(gctx);
}
if (br.htmlInputPending) {
br.htmlInputPending = false;
promptModalOpen = true;
promptIsAddressBar = false;
promptIsCustomUa = false;
promptTitle = "Input: " + br.htmlInputLabel;
neoui_input_reset(br.htmlInputValue.c_str());
if (visible) render();
} else if (visible &&
(br.currentUrl != prevUrl || br.currentTitle != prevTitle ||
br.statusMsg != prevStatus || br.isLoading != prevLoading)) {
render();
}
}
::poll(pfds, (fifoFd >= 0) ? 2 : 1, timeoutMs);
}
if (fifoFd >= 0) ::close(fifoFd);
+65 -1
View File
@@ -400,6 +400,49 @@ static void msm8905_cam_enable_clocks(struct msm8905_cam_dev *cam)
}
}
static void msm8905_cam_hw_deinit(struct msm8905_cam_dev *cam)
{
ssize_t i;
if (!cam->hw_initialized)
return;
/* 1. Stop ISPIF and sensor MIPI CSI-2 stream */
cam_w32(cam->camss_base, ISPIF_BASE + 0x248U, 0xaaaaaaaaU);
wmb();
gc23xx_stream_off(cam);
usleep_range(600, 900);
/* 2. Place sensor in hardware power-down and disable MCLK0 output */
cam_gpio_out(cam, GPIO_CAM_RESET, false);
cam_gpio_out(cam, GPIO_CAM_STANDBY, false);
cam_gpio_out(cam, GPIO_CAM_VDIG, false);
cam_gpio_cfg(cam, GPIO_CAM_MCLK0, 0x0001U);
/* 3. Gate CAMSS branch clocks in reverse order */
for (i = (ssize_t)ARRAY_SIZE(camss_cbcr_offsets) - 1; i >= 0; i--) {
u32 off = camss_cbcr_offsets[i];
cam_w32(cam->gcc_base, off, cam_r32(cam->gcc_base, off) & ~1U);
}
wmb();
/* 4. Gate CAMSS RCG roots (MCLK0 and CSI/VFE RCGs) */
cam_w32(cam->gcc_base, 0x52000U, 0x0U);
cam_w32(cam->gcc_base, 0x4e000U, 0x0U);
cam_w32(cam->gcc_base, 0x4f020U, 0x0U);
cam_w32(cam->gcc_base, 0x4e020U, 0x0U);
cam_w32(cam->gcc_base, 0x58000U, 0x0U);
cam_w32(cam->gcc_base, 0x5a000U, 0x0U);
/* 5. Release SMMU vote clocks and power down VFE GDSC */
cam_w32(cam->gcc_base, 0x4500cU, cam_r32(cam->gcc_base, 0x4500cU) & ~0x3202U);
cam_w32(cam->gcc_base, 0x58034U, cam_r32(cam->gcc_base, 0x58034U) | 1U);
wmb();
cam->hw_initialized = false;
cam->streaming = false;
}
static int msm8905_cam_hw_init(struct msm8905_cam_dev *cam)
{
size_t i;
@@ -921,6 +964,7 @@ static int msm8905_cam_streamoff(struct file *file, void *priv,
cam->streaming = false;
for (idx = 0; idx < CAM_MAX_MMAP_BUFS; idx++)
cam->buf_queued[idx] = false;
msm8905_cam_hw_deinit(cam);
return 0;
}
@@ -994,10 +1038,29 @@ static __poll_t msm8905_cam_poll(struct file *file, poll_table *wait)
return EPOLLIN | EPOLLRDNORM;
}
static int msm8905_cam_release(struct file *file)
{
struct msm8905_cam_dev *cam = video_drvdata(file);
bool is_last;
u32 idx;
int ret;
mutex_lock(&cam->lock);
is_last = v4l2_fh_is_singular_file(file);
ret = v4l2_fh_release(file);
if (is_last) {
for (idx = 0; idx < CAM_MAX_MMAP_BUFS; idx++)
cam->buf_queued[idx] = false;
msm8905_cam_hw_deinit(cam);
}
mutex_unlock(&cam->lock);
return ret;
}
static const struct v4l2_file_operations msm8905_cam_fops = {
.owner = THIS_MODULE,
.open = v4l2_fh_open,
.release = v4l2_fh_release,
.release = msm8905_cam_release,
.read = msm8905_cam_read,
.mmap = msm8905_cam_mmap,
.poll = msm8905_cam_poll,
@@ -1135,6 +1198,7 @@ static void __exit msm8905_cam_exit(void)
video_unregister_device(&cam->vdev);
v4l2_device_unregister(&cam->v4l2_dev);
msm8905_cam_hw_deinit(cam);
iounmap(cam->vbif_base);
iounmap(cam->camss_base);
iounmap(cam->tlmm_base);
+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);
+4 -1
View File
@@ -1274,6 +1274,8 @@ set_hw_backlight(int on)
read_sysfs_str(cfgpath, cur, sizeof(cur));
}
write_sysfs_str("/sys/class/leds/white:kbd_backlight/brightness", (cur[0] != '\0') ? cur : "255");
if (selmon && drw)
drawbar(selmon);
} else {
read_sysfs_str("/sys/class/backlight/backlight/brightness", cur, sizeof(cur));
if (atoi(cur) >= 1) {
@@ -3580,7 +3582,8 @@ updatestatus(void)
len = strlen(stext);
while (len > 0 && (stext[len - 1] == ' ' || stext[len - 1] == '\n' || stext[len - 1] == '\r'))
stext[--len] = '\0';
drawbar(selmon);
if (!is_screen_off())
drawbar(selmon);
}
void
+1 -1
View File
@@ -1293,7 +1293,7 @@ static int xdrawer_run_main(int argc, char** argv) {
}
}
int timeoutMs = visible ? (initialKeysReleased ? 250 : 40) : -1;
int timeoutMs = visible ? (initialKeysReleased ? -1 : 40) : -1;
struct pollfd pfds[2] {};
pfds[0].fd = xfd;
pfds[0].events = POLLIN;