mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-06-30 11:02:48 -05:00
Rationalisation of the system of frontend handles. Most modular bits
of PuTTY (terminal, backend, logctx etc) take a `void *' handle passed to them from the frontend, and used as a context for all their callbacks. Most of these point at the frontend structure itself (on platforms where this is meaningful), except that the handle passed to the backend has always pointed at the terminal because from_backend() was implemented in terminal.c. This has finally bitten Unix PuTTY, because both backend and logctx have been passing their respective and very different frontend handles to logevent(), so I've fixed it. from_backend() is now a function supplied by the _frontend_ itself, in all cases, and the frontend handle passed to backends must be the same as that passed to everything else. What was from_backend() in terminal.c is now called term_data(), and the typical implementation of from_backend() in a GUI frontend will just extract the terminal handle from the frontend structure and delegate to that. This appears to work on Unix and Windows, but has most likely broken the Mac build. [originally from svn r3100]
This commit is contained in:
29
unix/pterm.c
29
unix/pterm.c
@ -93,8 +93,7 @@ char *x_get_default(const char *key)
|
||||
|
||||
void connection_fatal(void *frontend, char *p, ...)
|
||||
{
|
||||
Terminal *term = (Terminal *)frontend;
|
||||
struct gui_data *inst = (struct gui_data *)term->frontend;
|
||||
struct gui_data *inst = (struct gui_data *)frontend;
|
||||
|
||||
va_list ap;
|
||||
char *msg;
|
||||
@ -164,10 +163,15 @@ int askappend(void *frontend, Filename filename)
|
||||
return 2;
|
||||
}
|
||||
|
||||
int from_backend(void *frontend, int is_stderr, const char *data, int len)
|
||||
{
|
||||
struct gui_data *inst = (struct gui_data *)frontend;
|
||||
return term_data(inst->term, is_stderr, data, len);
|
||||
}
|
||||
|
||||
void logevent(void *frontend, char *string)
|
||||
{
|
||||
Terminal *term = (Terminal *)frontend;
|
||||
struct gui_data *inst = (struct gui_data *)term->frontend;
|
||||
struct gui_data *inst = (struct gui_data *)frontend;
|
||||
|
||||
log_eventlog(inst->logctx, string);
|
||||
|
||||
@ -212,8 +216,7 @@ static Mouse_Button translate_button(Mouse_Button button)
|
||||
*/
|
||||
void *get_window(void *frontend)
|
||||
{
|
||||
Terminal *term = (Terminal *)frontend;
|
||||
struct gui_data *inst = (struct gui_data *)term->frontend;
|
||||
struct gui_data *inst = (struct gui_data *)frontend;
|
||||
return inst->window;
|
||||
}
|
||||
|
||||
@ -351,7 +354,7 @@ gint delete_window(GtkWidget *widget, GdkEvent *event, gpointer data)
|
||||
{
|
||||
struct gui_data *inst = (struct gui_data *)data;
|
||||
if (inst->cfg.warn_on_close) {
|
||||
if (!reallyclose(inst->term))
|
||||
if (!reallyclose(inst))
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
@ -1981,8 +1984,7 @@ char *get_x_display(void *frontend)
|
||||
|
||||
long get_windowid(void *frontend)
|
||||
{
|
||||
Terminal *term = (Terminal *)frontend;
|
||||
struct gui_data *inst = (struct gui_data *)(term->frontend);
|
||||
struct gui_data *inst = (struct gui_data *)frontend;
|
||||
return (long)GDK_WINDOW_XWINDOW(inst->area->window);
|
||||
}
|
||||
|
||||
@ -2508,8 +2510,6 @@ void change_settings_menuitem(GtkMenuItem *item, gpointer data)
|
||||
oldcfg.window_border != cfg2.window_border || need_size) {
|
||||
set_geom_hints(inst);
|
||||
request_resize(inst, cfg2.width, cfg2.height);
|
||||
//term_size(inst->term, cfg2.height, cfg2.width, cfg2.savelines);
|
||||
// where TF is our configure event going?!
|
||||
}
|
||||
|
||||
term_invalidate(inst->term);
|
||||
@ -2519,8 +2519,7 @@ void change_settings_menuitem(GtkMenuItem *item, gpointer data)
|
||||
|
||||
void update_specials_menu(void *frontend)
|
||||
{
|
||||
Terminal *term = (Terminal *)frontend;
|
||||
struct gui_data *inst = (struct gui_data *)term->frontend;
|
||||
struct gui_data *inst = (struct gui_data *)frontend;
|
||||
|
||||
const struct telnet_special *specials;
|
||||
|
||||
@ -2737,7 +2736,7 @@ int pt_main(int argc, char **argv)
|
||||
{
|
||||
char *realhost, *error;
|
||||
|
||||
error = inst->back->init((void *)inst->term, &inst->backhandle,
|
||||
error = inst->back->init((void *)inst, &inst->backhandle,
|
||||
&inst->cfg, inst->cfg.host, inst->cfg.port,
|
||||
&realhost, inst->cfg.tcp_nodelay);
|
||||
|
||||
@ -2759,7 +2758,7 @@ int pt_main(int argc, char **argv)
|
||||
}
|
||||
}
|
||||
inst->back->provide_logctx(inst->backhandle, inst->logctx);
|
||||
update_specials_menu(inst->term);
|
||||
update_specials_menu(inst);
|
||||
|
||||
term_provide_resize_fn(inst->term, inst->back->size, inst->backhandle);
|
||||
|
||||
|
@ -14,11 +14,15 @@
|
||||
/*
|
||||
* TODO:
|
||||
*
|
||||
* - Copy-and-paste from the Event Log.
|
||||
* - Go through all the config options and ensure they can all be
|
||||
* configured and reconfigured properly.
|
||||
*
|
||||
* - Remainder of the context menu:
|
||||
*
|
||||
* - New Session and Duplicate Session (perhaps in pterm, in fact?!)
|
||||
* - New Session, Duplicate Session and the Saved Sessions
|
||||
* submenu.
|
||||
* + at least New and Duplicate probably _should_ be in
|
||||
* pterm.
|
||||
* + Duplicate Session will be fun, since we must work out
|
||||
* how to pass the config data through.
|
||||
* + In fact this should be easier on Unix, since fork() is
|
||||
@ -42,10 +46,6 @@
|
||||
* already have dropped privileges by this point, so we
|
||||
* can't get another pty. Sigh. Looks like exec has to be
|
||||
* the way forward then :-/
|
||||
*
|
||||
* - Saved Sessions submenu (not in pterm of course)
|
||||
*
|
||||
* - Copy All to Clipboard (for what that's worth)
|
||||
*/
|
||||
|
||||
/*
|
||||
|
Reference in New Issue
Block a user