1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-07-03 20:42:48 -05:00

Remove the 'Frontend' type and replace it with a vtable.

After the recent Seat and LogContext revamps, _nearly_ all the
remaining uses of the type 'Frontend' were in terminal.c, which needs
all sorts of interactions with the GUI window the terminal lives in,
from the obvious (actually drawing text on the window, reading and
writing the clipboard) to the obscure (minimising, maximising and
moving the window in response to particular escape sequences).

All of those functions are now provided by an abstraction called
TermWin. The few remaining uses of Frontend after _that_ are internal
to a particular platform directory, so as to spread the implementation
of that particular kind of Frontend between multiple source files; so
I've renamed all of those so that they take a more specifically named
type that refers to the particular implementation rather than the
general abstraction.

So now the name 'Frontend' no longer exists in the code base at all,
and everywhere one used to be used, it's completely clear whether it
was operating in one of Frontend's three abstract roles (and if so,
which), or whether it was specific to a particular implementation.

Another type that's disappeared is 'Context', which used to be a
typedef defined to something different on each platform, describing
whatever short-lived resources were necessary to draw on the terminal
window: the front end would provide a ready-made one when calling
term_paint, and the terminal could request one with get_ctx/free_ctx
if it wanted to do proactive window updates. Now that drawing context
lives inside the TermWin itself, because there was never any need to
have two of those contexts live at the same time.

(Another minor API change is that the window-title functions - both
reading and writing - have had a missing 'const' added to their char *
parameters / return values.)

I don't expect this change to enable any particularly interesting new
functionality (in particular, I have no plans that need more than one
implementation of TermWin in the same application). But it completes
the tidying-up that began with the Seat and LogContext rework.
This commit is contained in:
Simon Tatham
2018-10-25 18:44:04 +01:00
parent 291c1b07f2
commit 64f8f68a34
12 changed files with 839 additions and 568 deletions

View File

@ -65,8 +65,6 @@ struct FontSpec {
};
struct FontSpec *fontspec_new(const char *name);
typedef struct draw_ctx *Context;
extern const struct BackendVtable pty_backend;
#define BROKEN_PIPE_ERROR_CODE EPIPE /* used in sshshare.c */
@ -158,7 +156,7 @@ unsigned long getticks(void);
#endif
/* The per-session frontend structure managed by gtkwin.c */
struct gui_data;
typedef struct GtkFrontend GtkFrontend;
/* Callback when a dialog box finishes, and a no-op implementation of it */
typedef void (*post_dialog_fn_t)(void *ctx, int result);
@ -175,7 +173,7 @@ void launch_saved_session(const char *str);
void session_window_closed(void);
void window_setup_error(const char *errmsg);
#ifdef MAY_REFER_TO_GTK_IN_HEADERS
GtkWidget *make_gtk_toplevel_window(Frontend *frontend);
GtkWidget *make_gtk_toplevel_window(GtkFrontend *frontend);
#endif
const struct BackendVtable *select_backend(Conf *conf);
@ -189,7 +187,7 @@ enum MenuAction {
MA_RESTART_SESSION, MA_CHANGE_SETTINGS, MA_CLEAR_SCROLLBACK,
MA_RESET_TERMINAL, MA_EVENT_LOG
};
void app_menu_action(Frontend *frontend, enum MenuAction);
void app_menu_action(GtkFrontend *frontend, enum MenuAction);
/* Things gtkdlg.c needs from pterm.c */
#ifdef MAY_REFER_TO_GTK_IN_HEADERS