Fix 2720 closed-flip call wakeups/preservation, live timezone sync, and Power menu
- Default CPU_RPM_SLEEP=0, CPU_L2_SLEEP=0, and MODEM_DRX_MODE=0 across bananarchy-power-policy.conf, bananarchy-power-policy.sh, bananarchy-display-power-sync, and kernel patch 0010 so closed-flip incoming calls wake APSS promptly via smd-edge without AT port contention. - Serialize sxmo_modem.sh incoming/finished call checks, expire stale /tmp/sxmo_hangup_requested flags, re-verify live ModemManager call state before ringing/raising callscreen, guard idle/flip-open HANGUP_CLOSE paths in locker.so, callscreen.so, bananarchy-idle-lock.sh, and bananarchy-lid, preserve calls on flip-open (UNGRAB/RAISE), and add closed-flip cover call controls (bananarchy-cover-idle, bananarchy-cover-event.sh, bananarchy-volume-keys). - Propagate live network/manual timezone updates across statusbar, locker.so, bananarchy-cover-idle, bananarchy-dsds, callscreen.so, and bananarchy-run-aligned without reboot (scripts/test-time-timezone-sync.py), remove non-functional Logout from the Power menu, ignore post-call sxmo_calls markers, add scripts/build-dwm-plugins.sh, and update a1114 (carbonara) hashes and docs.
This commit is contained in:
1 parent
786480a08f
commit
8b466ef8ae
110 files changed
+2728
-285
No files matched your search
@@ -22,7 +22,9 @@
|
||||
*/
|
||||
#include <ctype.h>
|
||||
#include <dlfcn.h>
|
||||
#include <errno.h>
|
||||
#include <poll.h>
|
||||
#include <signal.h>
|
||||
#include <strings.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/un.h>
|
||||
@@ -295,6 +297,12 @@ static const struct glyph font[] = {
|
||||
{':', {0x00, 0x36, 0x36, 0x00, 0x00}}, {'-', {0x08, 0x08, 0x08, 0x08, 0x08}},
|
||||
{'.', {0x00, 0x60, 0x60, 0x00, 0x00}}, {'/', {0x20, 0x10, 0x08, 0x04, 0x02}},
|
||||
{'%', {0x23, 0x13, 0x08, 0x64, 0x62}}, {'|', {0x00, 0x00, 0x7f, 0x00, 0x00}},
|
||||
{'+', {0x08, 0x08, 0x3e, 0x08, 0x08}}, {'(', {0x00, 0x1c, 0x22, 0x41, 0x00}},
|
||||
{')', {0x00, 0x41, 0x22, 0x1c, 0x00}}, {'*', {0x14, 0x08, 0x3e, 0x08, 0x14}},
|
||||
{'#', {0x14, 0x7f, 0x14, 0x7f, 0x14}}, {',', {0x00, 0x50, 0x30, 0x00, 0x00}},
|
||||
{'!', {0x00, 0x00, 0x5f, 0x00, 0x00}}, {'?', {0x02, 0x01, 0x51, 0x09, 0x06}},
|
||||
{'_', {0x40, 0x40, 0x40, 0x40, 0x40}}, {'[', {0x00, 0x7f, 0x41, 0x41, 0x00}},
|
||||
{']', {0x00, 0x41, 0x41, 0x7f, 0x00}}, {'\'', {0x00, 0x05, 0x03, 0x00, 0x00}},
|
||||
{' ', {0x00, 0x00, 0x00, 0x00, 0x00}},
|
||||
};
|
||||
|
||||
@@ -422,6 +430,91 @@ static void frame_text_centered(struct frame *fb, const char *text, int y,
|
||||
frame_text(fb, text, x, y, scale, color);
|
||||
}
|
||||
|
||||
/* Transliterate basic Cyrillic UTF-8 and sanitize caller labels to 5x7 ASCII. */
|
||||
static void sanitize_cover_text(const char *src, char *dst, size_t dstlen)
|
||||
{
|
||||
static const char *const cyr_map[32] = {
|
||||
"A", "B", "V", "G", "D", "E", "ZH", "Z",
|
||||
"I", "Y", "K", "L", "M", "N", "O", "P",
|
||||
"R", "S", "T", "U", "F", "KH", "TS", "CH",
|
||||
"SH", "SHCH", "", "Y", "", "E", "YU", "YA"
|
||||
};
|
||||
const unsigned char *p = (const unsigned char *)(src ? src : "");
|
||||
size_t out = 0;
|
||||
if(!dst || dstlen == 0)
|
||||
return;
|
||||
while(*p && out + 1 < dstlen) {
|
||||
unsigned char b = *p;
|
||||
if(b < 0x80) {
|
||||
char ch = (b >= 0x20 && b < 0x7f) ? (char)toupper(b) : ' ';
|
||||
if(ch == ' ' && (out == 0 || dst[out - 1] == ' ')) {
|
||||
p++;
|
||||
continue;
|
||||
}
|
||||
dst[out++] = ch;
|
||||
p++;
|
||||
continue;
|
||||
}
|
||||
if((b == 0xd0 || b == 0xd1 || b == 0xd2) && p[1] >= 0x80 && p[1] <= 0xbf) {
|
||||
unsigned char b2 = p[1];
|
||||
const char *rep = NULL;
|
||||
if(b == 0xd0 && b2 == 0x81)
|
||||
rep = "YO";
|
||||
else if(b == 0xd1 && b2 == 0x91)
|
||||
rep = "YO";
|
||||
else if((b == 0xd0 && b2 == 0x84) || (b == 0xd1 && b2 == 0x94))
|
||||
rep = "YE";
|
||||
else if((b == 0xd0 && b2 == 0x86) || (b == 0xd1 && b2 == 0x96))
|
||||
rep = "I";
|
||||
else if((b == 0xd0 && b2 == 0x87) || (b == 0xd1 && b2 == 0x97))
|
||||
rep = "YI";
|
||||
else if(b == 0xd2 && (b2 == 0x90 || b2 == 0x91))
|
||||
rep = "G";
|
||||
else if(b == 0xd0 && b2 >= 0x90 && b2 <= 0xbf)
|
||||
rep = cyr_map[(b2 - 0x90) % 32];
|
||||
else if(b == 0xd1 && b2 >= 0x80 && b2 <= 0x8f)
|
||||
rep = cyr_map[(b2 - 0x80 + 16) % 32];
|
||||
if(rep) {
|
||||
while(*rep && out + 1 < dstlen)
|
||||
dst[out++] = *rep++;
|
||||
}
|
||||
p += 2;
|
||||
continue;
|
||||
}
|
||||
p++;
|
||||
while((*p & 0xc0) == 0x80)
|
||||
p++;
|
||||
}
|
||||
while(out > 0 && dst[out - 1] == ' ')
|
||||
out--;
|
||||
dst[out] = '\0';
|
||||
}
|
||||
|
||||
static void draw_fit_centered(struct frame *fb, const char *text, int y,
|
||||
int pref_scale, uint32_t color)
|
||||
{
|
||||
char buf[64];
|
||||
int max_chars;
|
||||
int scale = pref_scale;
|
||||
size_t len;
|
||||
if(!text || !*text)
|
||||
return;
|
||||
sanitize_cover_text(text, buf, sizeof(buf));
|
||||
if(!buf[0])
|
||||
return;
|
||||
len = strlen(buf);
|
||||
max_chars = ((int)fb->width - 8) / (6 * scale);
|
||||
if(max_chars < 1)
|
||||
max_chars = 1;
|
||||
if((int)len > max_chars && scale > 1) {
|
||||
scale = 1;
|
||||
max_chars = ((int)fb->width - 8) / 6;
|
||||
}
|
||||
if((int)len > max_chars)
|
||||
buf[max_chars] = '\0';
|
||||
frame_text_centered(fb, buf, y, scale, color);
|
||||
}
|
||||
|
||||
static int read_uint_file(const char *path, unsigned int *value)
|
||||
{
|
||||
FILE *handle = fopen(path, "r");
|
||||
@@ -505,6 +598,9 @@ struct state {
|
||||
char lid[16];
|
||||
char backend[16];
|
||||
char call[64];
|
||||
char call_num[64];
|
||||
char call_name[64];
|
||||
char call_sim[16];
|
||||
char message[128];
|
||||
char network[96];
|
||||
int enabled;
|
||||
@@ -520,6 +616,12 @@ struct state {
|
||||
int backlight_level;
|
||||
};
|
||||
|
||||
static int cover_hold_awake(const struct state *state)
|
||||
{
|
||||
return strcmp(state->call, "incoming") == 0 ||
|
||||
strcmp(state->call, "muted") == 0;
|
||||
}
|
||||
|
||||
/* A lit cover needs a lit framebuffer, a lit backlight and an unblanked fbdev;
|
||||
* everything else is "fully off". TEST modes are diagnostic overrides. */
|
||||
static int cover_is_lit(const struct state *state)
|
||||
@@ -557,10 +659,12 @@ static void render_frame(struct frame *fb, const struct state *state)
|
||||
char clock[16];
|
||||
char date[32];
|
||||
char battery[32];
|
||||
time_t now = time(NULL);
|
||||
time_t now;
|
||||
struct tm tm;
|
||||
unsigned int width = fb->width;
|
||||
unsigned int height = fb->height;
|
||||
ba_refresh_tz();
|
||||
now = time(NULL);
|
||||
localtime_r(&now, &tm);
|
||||
strftime(clock, sizeof(clock), "%H:%M", &tm);
|
||||
strftime(date, sizeof(date), "%d.%m.%Y", &tm);
|
||||
@@ -578,6 +682,42 @@ static void render_frame(struct frame *fb, const struct state *state)
|
||||
rgb888(245, 245, 245));
|
||||
} else if(!cover_is_lit(state)) {
|
||||
frame_rect(fb, 0, 0, (int)width, (int)height, rgb888(0, 0, 0));
|
||||
} else if(cover_hold_awake(state)) {
|
||||
int muted = strcmp(state->call, "muted") == 0;
|
||||
char subhdr[48];
|
||||
char name_san[64];
|
||||
char num_san[64];
|
||||
uint32_t accent = muted ? rgb888(250, 210, 60) : rgb888(80, 220, 120);
|
||||
frame_rect(fb, 0, 0, (int)width, (int)height, rgb888(8, 12, 26));
|
||||
frame_rect(fb, 0, 0, (int)width, 4, accent);
|
||||
frame_text_centered(fb, muted ? "RING MUTED" : "INCOMING CALL",
|
||||
18, 2, accent);
|
||||
if(state->call_sim[0])
|
||||
snprintf(subhdr, sizeof(subhdr), "%s %s", state->call_sim, clock);
|
||||
else
|
||||
snprintf(subhdr, sizeof(subhdr), "%s", clock);
|
||||
frame_text_centered(fb, subhdr, 44, 1, rgb888(140, 180, 240));
|
||||
sanitize_cover_text(state->call_name, name_san, sizeof(name_san));
|
||||
sanitize_cover_text(state->call_num, num_san, sizeof(num_san));
|
||||
if(name_san[0] && num_san[0] && strcmp(name_san, num_san) != 0) {
|
||||
draw_fit_centered(fb, name_san, 78, 2, rgb888(245, 248, 255));
|
||||
draw_fit_centered(fb, num_san, 112, 2, rgb888(160, 210, 250));
|
||||
} else if(name_san[0]) {
|
||||
draw_fit_centered(fb, name_san, 96, 2, rgb888(245, 248, 255));
|
||||
} else {
|
||||
if(!num_san[0])
|
||||
safe_copy(num_san, sizeof(num_san), "UNKNOWN");
|
||||
draw_fit_centered(fb, num_san, 96, 2, rgb888(245, 248, 255));
|
||||
}
|
||||
if(state->battery >= 0) {
|
||||
snprintf(battery, sizeof(battery), "BAT %d%%", state->battery);
|
||||
frame_text_centered(fb, battery, (int)height - 52, 1,
|
||||
rgb888(250, 210, 60));
|
||||
}
|
||||
frame_text_centered(fb, muted ? "RINGER MUTED" : "VOL: MUTE RING",
|
||||
(int)height - 34, 1, rgb888(250, 210, 60));
|
||||
frame_text_centered(fb, "PWR: HANG UP",
|
||||
(int)height - 18, 1, rgb888(255, 110, 110));
|
||||
} else {
|
||||
int clock_scale = width >= 220 ? 5 : 3;
|
||||
int clock_h = 7 * clock_scale;
|
||||
@@ -2210,6 +2350,21 @@ static int test_value(const char *mode)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void spawn_cover_event(const char *action, const char *arg)
|
||||
{
|
||||
const char *cmd = getenv("BANANARCHY_COVER_EVENT_CMD");
|
||||
const char *bin = (cmd && *cmd) ? cmd : "/usr/bin/bananarchy-cover-event.sh";
|
||||
char *const argv_with_arg[] = {
|
||||
(char *)bin, (char *)action, (char *)arg, NULL
|
||||
};
|
||||
char *const argv_no_arg[] = {
|
||||
(char *)bin, (char *)action, NULL
|
||||
};
|
||||
if(!action || !*action)
|
||||
return;
|
||||
spawn_async_cmd((arg && *arg) ? argv_with_arg : argv_no_arg);
|
||||
}
|
||||
|
||||
/* A closed flip lights the outer panel only. Status updates (NETWORK,
|
||||
* BATTERY) refresh an already visible cover but never wake it; real events
|
||||
* (BUTTON, WAKE, CALL, NOTIFY, SMS) do. */
|
||||
@@ -2281,6 +2436,7 @@ static void handle_command(char *buffer, struct state *state,
|
||||
}
|
||||
} else if(strcmp(command, "BUTTON") == 0 ||
|
||||
strcmp(command, "WAKE") == 0) {
|
||||
char *sub = strtok_r(NULL, " \t\r\n", &save);
|
||||
/* Trusted external side button, or a main-panel wake request that the
|
||||
* closed-lid gate forwarded to the cover display. Ignore WAKE (never
|
||||
* BUTTON) during the 450 ms close-settle window so dwm's spurious
|
||||
@@ -2289,6 +2445,29 @@ static void handle_command(char *buffer, struct state *state,
|
||||
state->closed_since_ms > 0 &&
|
||||
now_ms() - state->closed_since_ms < 450)
|
||||
return;
|
||||
if(strcmp(command, "BUTTON") == 0 && sub &&
|
||||
strcmp(state->lid, "closed") == 0 && cover_hold_awake(state)) {
|
||||
upper_string(sub);
|
||||
if(strcmp(sub, "VOLUP") == 0 || strcmp(sub, "VOLDOWN") == 0) {
|
||||
if(strcmp(state->call, "incoming") == 0) {
|
||||
safe_copy(state->call, sizeof(state->call), "muted");
|
||||
spawn_cover_event("mute-ring", state->call_num);
|
||||
}
|
||||
cover_wake(state, redraw);
|
||||
*redraw = 1;
|
||||
return;
|
||||
}
|
||||
if(strcmp(sub, "POWER") == 0) {
|
||||
safe_copy(state->call, sizeof(state->call), "none");
|
||||
state->call_num[0] = '\0';
|
||||
state->call_name[0] = '\0';
|
||||
state->call_sim[0] = '\0';
|
||||
spawn_cover_event("hangup-call", "");
|
||||
cover_wake(state, redraw);
|
||||
*redraw = 1;
|
||||
return;
|
||||
}
|
||||
}
|
||||
cover_wake(state, redraw);
|
||||
} else if(strcmp(command, "NETWORK") == 0) {
|
||||
char *rest = save;
|
||||
@@ -2308,12 +2487,107 @@ static void handle_command(char *buffer, struct state *state,
|
||||
if(state->visible)
|
||||
*redraw = 1;
|
||||
} else if(strcmp(command, "CALL") == 0) {
|
||||
char *value = strtok_r(NULL, " \t\r\n", &save);
|
||||
if(value) {
|
||||
safe_copy(state->call, sizeof(state->call), value);
|
||||
lower_string(state->call);
|
||||
if(strcmp(state->call, "none") != 0)
|
||||
char *rest = save;
|
||||
char status[64] = "";
|
||||
char num[64] = "";
|
||||
char name[64] = "";
|
||||
char sim[16] = "";
|
||||
while(rest && (*rest == ' ' || *rest == '\t'))
|
||||
rest++;
|
||||
if(rest && *rest) {
|
||||
trim(rest);
|
||||
if(strchr(rest, '|')) {
|
||||
char *parts[4] = { NULL, NULL, NULL, NULL };
|
||||
int idx = 0;
|
||||
char *p = rest;
|
||||
parts[idx++] = p;
|
||||
while((p = strchr(p, '|')) != NULL && idx < 4) {
|
||||
*p++ = '\0';
|
||||
parts[idx++] = p;
|
||||
}
|
||||
if(parts[0]) safe_copy(status, sizeof(status), parts[0]);
|
||||
if(parts[1]) safe_copy(num, sizeof(num), parts[1]);
|
||||
if(parts[2]) safe_copy(name, sizeof(name), parts[2]);
|
||||
if(parts[3]) safe_copy(sim, sizeof(sim), parts[3]);
|
||||
} else {
|
||||
char *t0 = strtok_r(rest, " \t\r\n", &save);
|
||||
char *t1 = t0 ? strtok_r(NULL, " \t\r\n", &save) : NULL;
|
||||
char *t2 = t1 ? strtok_r(NULL, " \t\r\n", &save) : NULL;
|
||||
char *t3 = t2 ? strtok_r(NULL, " \t\r\n", &save) : NULL;
|
||||
if(t0) safe_copy(status, sizeof(status), t0);
|
||||
if(t1) safe_copy(num, sizeof(num), t1);
|
||||
if(t2) safe_copy(name, sizeof(name), t2);
|
||||
if(t3) safe_copy(sim, sizeof(sim), t3);
|
||||
}
|
||||
trim(status);
|
||||
lower_string(status);
|
||||
trim(num);
|
||||
trim(name);
|
||||
trim(sim);
|
||||
if(strcmp(num, "-") == 0) num[0] = '\0';
|
||||
if(strcmp(name, "-") == 0) name[0] = '\0';
|
||||
if(strcmp(sim, "-") == 0) sim[0] = '\0';
|
||||
if(strcmp(status, "none") == 0) {
|
||||
safe_copy(state->call, sizeof(state->call), "none");
|
||||
state->call_num[0] = '\0';
|
||||
state->call_name[0] = '\0';
|
||||
state->call_sim[0] = '\0';
|
||||
state->last_input_ms = now_ms();
|
||||
if(state->visible)
|
||||
*redraw = 1;
|
||||
} else if(strcmp(status, "muted") == 0) {
|
||||
if(strcmp(state->call, "incoming") != 0 &&
|
||||
strcmp(state->call, "muted") != 0)
|
||||
return;
|
||||
safe_copy(state->call, sizeof(state->call), "muted");
|
||||
if(num[0]) safe_copy(state->call_num, sizeof(state->call_num), num);
|
||||
if(name[0]) safe_copy(state->call_name, sizeof(state->call_name), name);
|
||||
if(sim[0]) safe_copy(state->call_sim, sizeof(state->call_sim), sim);
|
||||
cover_wake(state, redraw);
|
||||
*redraw = 1;
|
||||
} else if(strcmp(status, "incoming") == 0) {
|
||||
if(num[0] && strcmp(state->call_num, num) != 0) {
|
||||
safe_copy(state->call_num, sizeof(state->call_num), num);
|
||||
state->call_name[0] = '\0';
|
||||
}
|
||||
if(name[0])
|
||||
safe_copy(state->call_name, sizeof(state->call_name), name);
|
||||
if(sim[0])
|
||||
safe_copy(state->call_sim, sizeof(state->call_sim), sim);
|
||||
safe_copy(state->call, sizeof(state->call), "incoming");
|
||||
cover_wake(state, redraw);
|
||||
*redraw = 1;
|
||||
} else if(strcmp(status, "missed") == 0) {
|
||||
const char *who = name[0] ? name :
|
||||
(num[0] ? num :
|
||||
(state->call_name[0] ? state->call_name :
|
||||
state->call_num));
|
||||
if(who && *who) {
|
||||
char clean_who[64];
|
||||
sanitize_cover_text(who, clean_who, sizeof(clean_who));
|
||||
if(clean_who[0])
|
||||
snprintf(state->message, sizeof(state->message),
|
||||
"MISSED: %s", clean_who);
|
||||
else
|
||||
snprintf(state->message, sizeof(state->message), "MISSED CALL");
|
||||
} else {
|
||||
snprintf(state->message, sizeof(state->message), "MISSED CALL");
|
||||
}
|
||||
safe_copy(state->call, sizeof(state->call), "missed");
|
||||
state->call_num[0] = '\0';
|
||||
state->call_name[0] = '\0';
|
||||
state->call_sim[0] = '\0';
|
||||
cover_wake(state, redraw);
|
||||
*redraw = 1;
|
||||
} else if(strcmp(status, "active") == 0) {
|
||||
safe_copy(state->call, sizeof(state->call), "active");
|
||||
state->last_input_ms = now_ms();
|
||||
if(state->visible)
|
||||
*redraw = 1;
|
||||
} else if(status[0]) {
|
||||
safe_copy(state->call, sizeof(state->call), status);
|
||||
cover_wake(state, redraw);
|
||||
}
|
||||
}
|
||||
} else if(strcmp(command, "SMS") == 0) {
|
||||
char *value = strtok_r(NULL, " \t\r\n", &save);
|
||||
@@ -2438,6 +2712,7 @@ static void handle_command(char *buffer, struct state *state,
|
||||
} else if(strcmp(command, "REFRESH") == 0 ||
|
||||
strcmp(command, "RELOAD_THEME") == 0 ||
|
||||
strcmp(command, "STATUS") == 0) {
|
||||
ba_refresh_tz();
|
||||
refresh_blank_timeout(state);
|
||||
if(state->visible && strcmp(command, "STATUS") != 0)
|
||||
*redraw = 1;
|
||||
@@ -2480,6 +2755,24 @@ static void reply_for(char *buffer, const struct state *state,
|
||||
}
|
||||
}
|
||||
|
||||
static volatile sig_atomic_t g_stop_requested = 0;
|
||||
|
||||
static void handle_stop_signal(int sig)
|
||||
{
|
||||
(void)sig;
|
||||
g_stop_requested = 1;
|
||||
}
|
||||
|
||||
static void install_stop_handlers(void)
|
||||
{
|
||||
struct sigaction sa;
|
||||
memset(&sa, 0, sizeof(sa));
|
||||
sa.sa_handler = handle_stop_signal;
|
||||
sigemptyset(&sa.sa_mask);
|
||||
sigaction(SIGTERM, &sa, NULL);
|
||||
sigaction(SIGINT, &sa, NULL);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
const char *lock_path = getenv("BANANARCHY_COVER_LOCK");
|
||||
@@ -2501,6 +2794,7 @@ int main(int argc, char **argv)
|
||||
return 1;
|
||||
(void)lock_fd;
|
||||
install_reaper();
|
||||
install_stop_handlers();
|
||||
if(argc > 2 && strcmp(argv[1], "--config") == 0)
|
||||
config = argv[2];
|
||||
memset(&state, 0, sizeof(state));
|
||||
@@ -2532,7 +2826,7 @@ int main(int argc, char **argv)
|
||||
return 1;
|
||||
chmod(socket_path, 0660);
|
||||
chown(socket_path, 0, SESSION_GID);
|
||||
while(1) {
|
||||
while(!g_stop_requested) {
|
||||
struct pollfd pfds[2];
|
||||
nfds_t nfds = 1;
|
||||
char buffer[512];
|
||||
@@ -2542,6 +2836,7 @@ int main(int argc, char **argv)
|
||||
socklen_t peer_len = sizeof(peer);
|
||||
ssize_t nread;
|
||||
long long now = now_ms();
|
||||
int pr;
|
||||
/* With the cover off there is no timer at all: poll blocks until IPC. */
|
||||
int timeout_ms = -1;
|
||||
if(state.visible) {
|
||||
@@ -2551,7 +2846,9 @@ int main(int argc, char **argv)
|
||||
refresh_blank_timeout(&state);
|
||||
if(next < 1)
|
||||
next = 1;
|
||||
if(state.blank_ms > 0) {
|
||||
if(cover_hold_awake(&state)) {
|
||||
state.last_input_ms = now;
|
||||
} else if(state.blank_ms > 0) {
|
||||
long long remaining = state.blank_ms - (now - state.last_input_ms);
|
||||
if(remaining <= 0) {
|
||||
state.visible = 0;
|
||||
@@ -2580,7 +2877,9 @@ int main(int argc, char **argv)
|
||||
long long interval = strcmp(hw.backend, "kernel") == 0 ?
|
||||
KERNEL_REDRAW_MS : CLOCK_REDRAW_MS;
|
||||
long long next = interval;
|
||||
if(state.blank_ms > 0) {
|
||||
if(cover_hold_awake(&state)) {
|
||||
state.last_input_ms = now;
|
||||
} else if(state.blank_ms > 0) {
|
||||
long long remaining = state.blank_ms - (now - state.last_input_ms);
|
||||
if(remaining < 1)
|
||||
remaining = 1;
|
||||
@@ -2603,7 +2902,15 @@ int main(int argc, char **argv)
|
||||
pfds[1].revents = 0;
|
||||
nfds = 2;
|
||||
}
|
||||
if(poll(pfds, nfds, timeout_ms) == 0 && pending_until > now &&
|
||||
pr = poll(pfds, nfds, timeout_ms);
|
||||
if(pr < 0) {
|
||||
if(errno == EINTR && g_stop_requested)
|
||||
break;
|
||||
continue;
|
||||
}
|
||||
if(g_stop_requested)
|
||||
break;
|
||||
if(pr == 0 && pending_until > now &&
|
||||
strcmp(state.backend, "pending") == 0) {
|
||||
redraw = 1;
|
||||
}
|
||||
@@ -2624,14 +2931,20 @@ int main(int argc, char **argv)
|
||||
sendto(server, reply, strlen(reply), 0,
|
||||
(struct sockaddr *)&peer, peer_len);
|
||||
if(strncasecmp(original, "QUIT", 4) == 0) {
|
||||
set_backlight(&state, 0);
|
||||
cover_hw_shutdown(&hw);
|
||||
close(server);
|
||||
unlink(socket_path);
|
||||
return 0;
|
||||
g_stop_requested = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
state.visible = 0;
|
||||
state.test = 0;
|
||||
set_backlight(&state, 0);
|
||||
if(strcmp(state.lid, "closed") == 0 &&
|
||||
(hw.kernel_lit > 0 || hw.mux_claimed))
|
||||
cover_draw(&hw, fb_path, &state);
|
||||
cover_hw_shutdown(&hw);
|
||||
close(server);
|
||||
unlink(socket_path);
|
||||
return 0;
|
||||
}
|
||||
Reference in new issue
Block a user