fix(ui): add authoritative suspend flag gating redraws over the editor
All checks were successful
CI Code / Check spelling (pull_request) Successful in 19s
CI Code / Check coding style (pull_request) Successful in 32s
CI Code / Code Coverage (pull_request) Successful in 2m37s
CI Code / Linux (debian) (pull_request) Successful in 4m41s
CI Code / Linux (ubuntu) (pull_request) Successful in 4m50s
CI Code / Linux (arch) (pull_request) Successful in 5m39s
All checks were successful
CI Code / Check spelling (pull_request) Successful in 19s
CI Code / Check coding style (pull_request) Successful in 32s
CI Code / Code Coverage (pull_request) Successful in 2m37s
CI Code / Linux (debian) (pull_request) Successful in 4m41s
CI Code / Linux (ubuntu) (pull_request) Successful in 4m50s
CI Code / Linux (arch) (pull_request) Successful in 5m39s
Builds on the upstream "guard terminal writes while suspended" fix. That fix keeps isendwin() a valid "suspended" signal by guarding stray writes (_inp_write, beep, flash) so the existing isendwin() checks in ui_update/ui_resize/ui_redraw hold. That is correct but fail-open: any future unguarded doupdate()/refresh() reachable during an editor session clears isendwin() and the ~10Hz ui_update() repaints over the editor again (the original bug class). Track suspension explicitly with a ui_suspended flag set in ui_suspend()/ui_resume() and gate the three redraw entry points on ui_suspended || isendwin() via _ui_redraw_suspended(). The flag is set exactly at the suspend/resume boundary, so the dominant repaint path fails safe regardless of isendwin() flapping. isendwin() is kept in the condition for the shutdown/closed-screen case.
This commit is contained in:
@@ -54,6 +54,7 @@
|
||||
|
||||
static int inp_size;
|
||||
static gboolean perform_resize = FALSE;
|
||||
static gboolean ui_suspended = FALSE;
|
||||
static GTimer* ui_idle_time;
|
||||
static WINDOW* main_scr;
|
||||
|
||||
@@ -63,6 +64,16 @@ static Display* display;
|
||||
|
||||
static void _ui_draw_term_title(void);
|
||||
|
||||
// Skip drawing while an external editor is active (ui_suspended) or after the
|
||||
// screen has been closed (endwin). The flag is authoritative and does not rely
|
||||
// on isendwin() staying TRUE, which a stray doupdate() during the session could
|
||||
// otherwise clear.
|
||||
static gboolean
|
||||
_ui_redraw_suspended(void)
|
||||
{
|
||||
return ui_suspended || isendwin();
|
||||
}
|
||||
|
||||
static void
|
||||
_ui_close(void)
|
||||
{
|
||||
@@ -120,8 +131,7 @@ ui_sigwinch_handler(int sig)
|
||||
void
|
||||
ui_update(void)
|
||||
{
|
||||
// UI is suspended
|
||||
if (isendwin()) {
|
||||
if (_ui_redraw_suspended()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -179,6 +189,7 @@ ui_reset_idle_time(void)
|
||||
void
|
||||
ui_suspend(void)
|
||||
{
|
||||
ui_suspended = TRUE;
|
||||
inp_suspend();
|
||||
doupdate();
|
||||
endwin();
|
||||
@@ -187,6 +198,7 @@ ui_suspend(void)
|
||||
void
|
||||
ui_resume(void)
|
||||
{
|
||||
ui_suspended = FALSE;
|
||||
refresh();
|
||||
inp_resume();
|
||||
}
|
||||
@@ -210,8 +222,7 @@ ui_flash(void)
|
||||
void
|
||||
ui_resize(void)
|
||||
{
|
||||
// UI is suspended
|
||||
if (isendwin()) {
|
||||
if (_ui_redraw_suspended()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -233,8 +244,7 @@ ui_resize(void)
|
||||
void
|
||||
ui_redraw(void)
|
||||
{
|
||||
// UI is suspended
|
||||
if (isendwin()) {
|
||||
if (_ui_redraw_suspended()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user