AmendHub

Download:

jcs

/

subtext

/

amendments

/

160

blanker: Don't start if there any sessions active, log when it runs


jcs made amendment 160 about 1 year ago
--- main.c Tue Jun 21 16:12:17 2022 +++ main.c Wed Jun 22 15:23:13 2022 @@ -226,14 +226,14 @@ void handle_exit(void) { short n; + + blanker_unblank(); for (n = 0; n < nfocusables; n++) { if (focusables[n]->atexit) focusables[n]->atexit(focusables[n]); } - - RestoreHiddenMenuBar(); - + if (db->config.telnet_port) telnet_atexit(); if (db->config.modem_port) @@ -337,10 +337,10 @@ blanker_idle(void) { unsigned long t; - if (!blanker_on && + if (!blanker_on && !nsessions && (Time - blanker_last_blank > db->config.blanker_idle_seconds)) { HideMenuBar(); - + blanker_win = NewWindow(0L, &screenBits.bounds, "\p", false, plainDBox, (WindowPtr)-1L, true, 0); if (!blanker_win) @@ -362,13 +362,24 @@ blanker_idle(void) void blanker_unblank(void) { + unsigned long rt; + if (!blanker_on || !blanker_win) return; + rt = Time - blanker_last_blank; + ShowCursor(); DisposeWindow(blanker_win); blanker_win = NULL; RestoreHiddenMenuBar(); blanker_last_blank = Time; blanker_on = false; + + /* + * This will call back to blanker_unblank, so it must be done after + * blanker_on = false + */ + logger_printf(logger, "[blanker] Blanked screen for %ld second%s", + rt, rt == 1 ? "" : "s"); }