Compare commits

..

3 Commits

Author SHA1 Message Date
56e0305017 fix(ui): add authoritative suspend flag gating redraws over the editor
All checks were successful
CI Code / Check spelling (pull_request) Successful in 16s
CI Code / Check coding style (pull_request) Successful in 2m15s
CI Code / Code Coverage (pull_request) Successful in 2m35s
CI Code / Linux (debian) (pull_request) Successful in 4m35s
CI Code / Linux (ubuntu) (pull_request) Successful in 4m46s
CI Code / Linux (arch) (pull_request) Successful in 5m32s
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.
2026-05-27 22:03:47 +03:00
aa5edea26d fix(ui): guard password/TLS prompt redraw while suspended
inp_get_line()/inp_get_password() issued an unconditional doupdate()
before their input loop. If such a prompt is raised while an external
editor is active (e.g. a reconnect password or TLS-cert prompt arriving
via session_process_events), that doupdate() writes over the editor and
clears isendwin(). Guard it with isendwin(), matching the _inp_write()
guard from the upstream "guard terminal writes while suspended" fix;
this closes the one suspended-write path upstream left open.
2026-05-27 22:03:47 +03:00
Michael Vetter
562bd28cff fix(ui): guard terminal writes while suspended
We forgot to guard `beep()` and `flush()`.

Ref: 36ec2b0ae1
Ref: dd76f9087f
Signed-off-by: Michael Vetter <jubalh@iodoru.org>
Fixes: https://github.com/profanity-im/profanity/issues/2162
(cherry picked from commit 5e4b5d313a9e055e039e2feb4efae58b6aaead78)
2026-05-27 21:59:27 +03:00
7 changed files with 49 additions and 10 deletions

View File

@@ -341,7 +341,7 @@ sv_ev_room_message(ProfMessage* message)
status_bar_active(num, WIN_MUC, mucwin->roomjid);
if ((g_strcmp0(mynick, message->from_jid->resourcepart) != 0) && (prefs_get_boolean(PREF_BEEP))) {
beep();
ui_beep();
}
// not currently on groupchat window
@@ -349,7 +349,7 @@ sv_ev_room_message(ProfMessage* message)
status_bar_new(num, WIN_MUC, mucwin->roomjid);
if ((g_strcmp0(mynick, message->from_jid->resourcepart) != 0) && (prefs_get_boolean(PREF_FLASH))) {
flash();
ui_flash();
}
cons_show_incoming_room_message(message->from_jid->resourcepart, mucwin->roomjid, num, mention, triggers, mucwin->unread, window);

View File

@@ -327,7 +327,7 @@ chatwin_incoming_msg(ProfChatWin* chatwin, ProfMessage* message, gboolean win_cr
cons_show_incoming_message(display_name, num, chatwin->unread, window);
if (prefs_get_boolean(PREF_FLASH)) {
flash();
ui_flash();
}
chatwin->unread++;
@@ -364,7 +364,7 @@ chatwin_incoming_msg(ProfChatWin* chatwin, ProfMessage* message, gboolean win_cr
wins_add_quotes_ac(window, message->plain, FALSE);
if (prefs_get_boolean(PREF_BEEP)) {
beep();
ui_beep();
}
}

View File

@@ -65,7 +65,9 @@ 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).
// 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)
{
@@ -189,6 +191,7 @@ ui_suspend(void)
{
ui_suspended = TRUE;
inp_suspend();
doupdate();
endwin();
}
@@ -200,6 +203,22 @@ ui_resume(void)
inp_resume();
}
void
ui_beep(void)
{
if (!isendwin()) {
beep();
}
}
void
ui_flash(void)
{
if (!isendwin()) {
flash();
}
}
void
ui_resize(void)
{

View File

@@ -311,7 +311,10 @@ inp_get_line(void)
werase(inp_win);
wmove(inp_win, 0, 0);
_inp_win_update_virtual();
doupdate();
// Don't write to the terminal while suspended (external editor active).
if (!isendwin()) {
doupdate();
}
char* line = NULL;
while (!line) {
line = inp_readline();
@@ -338,7 +341,10 @@ inp_get_password(void)
werase(inp_win);
wmove(inp_win, 0, 0);
_inp_win_update_virtual();
doupdate();
// Don't write to the terminal while suspended (external editor active).
if (!isendwin()) {
doupdate();
}
char* password = NULL;
get_password = TRUE;
while (!password) {
@@ -459,7 +465,9 @@ _inp_write(char* line, int offset)
_inp_win_handle_scroll();
_inp_win_update_virtual();
doupdate();
if (!isendwin()) {
doupdate();
}
}
static int

View File

@@ -57,7 +57,7 @@ privwin_incoming_msg(ProfPrivateWin* privatewin, ProfMessage* message)
privatewin->unread++;
if (prefs_get_boolean(PREF_FLASH)) {
flash();
ui_flash();
}
}
@@ -65,7 +65,7 @@ privwin_incoming_msg(ProfPrivateWin* privatewin, ProfMessage* message)
wins_add_quotes_ac(window, message->plain, TRUE);
if (prefs_get_boolean(PREF_BEEP)) {
beep();
ui_beep();
}
if (notify) {

View File

@@ -84,6 +84,8 @@ void ui_handle_recipient_error(const char* const recipient, const char* const er
void ui_handle_error(const char* const err_msg);
void ui_clear_win_title(void);
void ui_goodbye_title(void);
void ui_beep(void);
void ui_flash(void);
void ui_handle_room_configuration_form_error(const char* const roomjid, const char* const message);
void ui_handle_room_config_submit_result(const char* const roomjid);
void ui_handle_room_config_submit_result_error(const char* const roomjid, const char* const message);

View File

@@ -1475,3 +1475,13 @@ ui_is_suspended(void)
{
return FALSE;
}
void
ui_beep(void)
{
}
void
ui_flash(void)
{
}