Relax PuTTY: Suppress „Fatal Error“ Dialog

When using PuTTY in „Multi-Tabbed“-Wrapper-Applications like MRemote-NG, Super-Putty, Putty-Connection-Manager, you name it, it’s absolute annoying that every connection-timeout pushes a modal pop-up window to the front (for every opened connection!) like this:

Since in those Applications the PuTTY-Window/Tab won’t get closed, or with „only on clean exit“

putty: close window only on clean exit

these modal alerts are absolutely pointless – when:

  1. PuTTY is running as standalone application
  2. the config-parameters set to „close window“ the original implemtation makes sense indeed.

So there is some code required, to distinguish between:

  • a quiet (Text-)Message, inline within the PuTTY-Screen when the window wont get closed
  • an modal alert before closing the putty window.

Original Code

Find it in „/windows/window.c“ – notice, that the modal popup will appear even when the PuTTY-Window won’t get closed.

/*
 * Print a message box and close the connection.
 */
static void win_seat_connection_fatal(Seat *seat, const char *msg)
{
    char *title = dupprintf("%s Fatal Error", appname);
    show_mouseptr(true);
    MessageBox(wgs.term_hwnd, msg, title, MB_ICONERROR | MB_OK);
    sfree(title);

    if (conf_get_int(conf, CONF_close_on_exit) == FORCE_ON)
        PostQuitMessage(1);
    else {
        queue_toplevel_callback(close_session, NULL);
    }
}

Improvement: Show the Dialog only, when PuTTY-Window will get closed

Much better for daily use – no annoyance anymore:

/*
 * Print a message box and close the connection.
 */
static void win_seat_connection_fatal(Seat *seat, const char *msg)
{
    char *title = dupprintf("%s Fatal Error", appname);

    if (conf_get_int(conf, CONF_close_on_exit) == FORCE_ON) {
        //show MessageBox before closing the PuTTY-Window
        show_mouseptr(true);
        MessageBox(wgs.term_hwnd, msg, title, MB_ICONERROR | MB_OK);

        PostQuitMessage(1);
    } else {
        //print message into the PuTTY-Console
        win_seat_output(seat,true,"\r\n\r\n",4);
        win_seat_output(seat,0,"------------------- ",20);
        win_seat_output(seat,0,title,strlen(title));
        win_seat_output(seat,0," ------------------\r\n",22);
        win_seat_output(seat,0,"- ",2);
        win_seat_output(seat,0,msg,strlen(msg));
        win_seat_output(seat,0,"\r\n\r\n",4);

        queue_toplevel_callback(close_session, NULL);
    }

    sfree(title);
}

Result: Relaxed Putty

Take a deep breath 🙂

relaxed putty

isn’t it beautiful?

Donate PuTTY

It is possible 😉 to donate to the original PuTTY developers – look here: https://www.chiark.greenend.org.uk/~sgtatham/putty/faq.html#faq-donations

Schreibe einen Kommentar