2002-10-07 16:45:23 +00:00
|
|
|
#ifndef PUTTY_UNIX_H
|
|
|
|
#define PUTTY_UNIX_H
|
|
|
|
|
2005-04-25 15:55:06 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "uxconfig.h" /* Space to hide it from mkfiles.pl */
|
|
|
|
#endif
|
|
|
|
|
2003-02-01 12:54:40 +00:00
|
|
|
#include <stdio.h> /* for FILENAME_MAX */
|
2010-05-19 18:22:17 +00:00
|
|
|
#include <stdint.h> /* C99 int types */
|
|
|
|
#ifndef NO_LIBDL
|
|
|
|
#include <dlfcn.h> /* Dynamic library loading */
|
|
|
|
#endif /* NO_LIBDL */
|
2002-12-31 12:20:34 +00:00
|
|
|
#include "charset.h"
|
2016-08-07 20:02:55 +00:00
|
|
|
#include <sys/types.h> /* for mode_t */
|
2002-12-31 12:20:34 +00:00
|
|
|
|
2015-08-31 12:05:51 +00:00
|
|
|
#ifdef OSX_GTK
|
|
|
|
/*
|
|
|
|
* Assorted tweaks to various parts of the GTK front end which all
|
|
|
|
* need to be enabled when compiling on OS X. Because I might need the
|
|
|
|
* same tweaks on other systems in future, I don't want to
|
|
|
|
* conditionalise all of them on OSX_GTK directly, so instead, each
|
|
|
|
* one has its own name and we enable them all centrally here if
|
|
|
|
* OSX_GTK is defined at configure time.
|
|
|
|
*/
|
|
|
|
#define NOT_X_WINDOWS /* of course, all the X11 stuff should be disabled */
|
|
|
|
#define NO_PTY_PRE_INIT /* OS X gets very huffy if we try to set[ug]id */
|
|
|
|
#define SET_NONBLOCK_VIA_OPENPT /* work around missing fcntl functionality */
|
2015-09-01 18:00:25 +00:00
|
|
|
#define OSX_META_KEY_CONFIG /* two possible Meta keys to choose from */
|
2015-09-01 18:10:29 +00:00
|
|
|
/* this potential one of the Meta keys needs manual handling */
|
|
|
|
#define META_MANUAL_MASK (GDK_MOD1_MASK)
|
2015-09-02 20:37:33 +00:00
|
|
|
#define JUST_USE_GTK_CLIPBOARD_UTF8 /* low-level gdk_selection_* fails */
|
2017-01-21 14:55:53 +00:00
|
|
|
|
2017-02-22 22:10:05 +00:00
|
|
|
#define BUILDINFO_PLATFORM_GTK "OS X (GTK)"
|
2017-02-15 19:29:05 +00:00
|
|
|
#define BUILDINFO_GTK
|
2017-01-21 14:55:53 +00:00
|
|
|
|
|
|
|
#elif defined NOT_X_WINDOWS
|
|
|
|
|
2017-02-22 22:10:05 +00:00
|
|
|
#define BUILDINFO_PLATFORM_GTK "Unix (pure GTK)"
|
2017-02-15 19:29:05 +00:00
|
|
|
#define BUILDINFO_GTK
|
2017-01-21 14:55:53 +00:00
|
|
|
|
|
|
|
#else
|
|
|
|
|
2017-02-22 22:10:05 +00:00
|
|
|
#define BUILDINFO_PLATFORM_GTK "Unix (GTK + X11)"
|
2017-02-15 19:29:05 +00:00
|
|
|
#define BUILDINFO_GTK
|
2017-01-21 14:55:53 +00:00
|
|
|
|
2015-08-31 12:05:51 +00:00
|
|
|
#endif
|
|
|
|
|
2017-02-22 22:10:05 +00:00
|
|
|
/* BUILDINFO_PLATFORM varies its expansion between the GTK and
|
|
|
|
* pure-CLI utilities, so that Unix Plink, PSFTP etc don't announce
|
|
|
|
* themselves incongruously as having something to do with GTK. */
|
|
|
|
#define BUILDINFO_PLATFORM_CLI "Unix"
|
|
|
|
extern const int buildinfo_gtk_relevant;
|
|
|
|
#define BUILDINFO_PLATFORM (buildinfo_gtk_relevant ? \
|
|
|
|
BUILDINFO_PLATFORM_GTK : BUILDINFO_PLATFORM_CLI)
|
|
|
|
|
2017-02-15 19:29:05 +00:00
|
|
|
char *buildinfo_gtk_version(void);
|
|
|
|
|
2003-02-01 12:54:40 +00:00
|
|
|
struct Filename {
|
2011-10-02 11:01:57 +00:00
|
|
|
char *path;
|
2003-02-01 12:54:40 +00:00
|
|
|
};
|
2011-10-02 11:01:57 +00:00
|
|
|
FILE *f_open(const struct Filename *, char const *, int);
|
2003-02-01 12:54:40 +00:00
|
|
|
|
|
|
|
struct FontSpec {
|
2011-10-01 17:38:59 +00:00
|
|
|
char *name; /* may be "" to indicate no selected font at all */
|
2003-02-01 12:54:40 +00:00
|
|
|
};
|
2011-10-01 17:38:59 +00:00
|
|
|
struct FontSpec *fontspec_new(const char *name);
|
2003-02-01 12:54:40 +00:00
|
|
|
|
2018-09-14 07:30:09 +00:00
|
|
|
typedef struct draw_ctx *Context;
|
2002-10-07 16:45:23 +00:00
|
|
|
|
2018-09-11 15:23:38 +00:00
|
|
|
extern const struct Backend_vtable pty_backend;
|
2002-10-09 18:09:42 +00:00
|
|
|
|
2015-09-25 11:05:55 +00:00
|
|
|
#define BROKEN_PIPE_ERROR_CODE EPIPE /* used in sshshare.c */
|
|
|
|
|
2002-10-13 11:24:25 +00:00
|
|
|
/*
|
|
|
|
* Under GTK, we send MA_CLICK _and_ MA_2CLK, or MA_CLICK _and_
|
|
|
|
* MA_3CLK, when a button is pressed for the second or third time.
|
|
|
|
*/
|
|
|
|
#define MULTICLICK_ONLY_EVENT 0
|
|
|
|
|
2003-03-13 19:52:28 +00:00
|
|
|
/*
|
|
|
|
* Under GTK, there is no context help available.
|
|
|
|
*/
|
|
|
|
#define HELPCTX(x) P(NULL)
|
|
|
|
#define FILTER_KEY_FILES NULL /* FIXME */
|
2010-09-25 07:16:56 +00:00
|
|
|
#define FILTER_DYNLIB_FILES NULL /* FIXME */
|
2003-03-13 19:52:28 +00:00
|
|
|
|
2002-10-13 11:24:25 +00:00
|
|
|
/*
|
|
|
|
* Under X, selection data must not be NUL-terminated.
|
|
|
|
*/
|
|
|
|
#define SELECTION_NUL_TERMINATED 0
|
|
|
|
|
2002-10-14 09:06:31 +00:00
|
|
|
/*
|
|
|
|
* Under X, copying to the clipboard terminates lines with just LF.
|
|
|
|
*/
|
|
|
|
#define SEL_NL { 10 }
|
|
|
|
|
2002-10-07 16:45:23 +00:00
|
|
|
/* Simple wraparound timer function */
|
2016-05-17 11:07:36 +00:00
|
|
|
unsigned long getticks(void);
|
2002-10-07 16:45:23 +00:00
|
|
|
#define GETTICKCOUNT getticks
|
2004-11-27 13:20:21 +00:00
|
|
|
#define TICKSPERSEC 1000 /* we choose to use milliseconds */
|
|
|
|
#define CURSORBLINK 450 /* no standard way to set this */
|
2002-10-07 16:45:23 +00:00
|
|
|
|
|
|
|
#define WCHAR wchar_t
|
|
|
|
#define BYTE unsigned char
|
|
|
|
|
2007-09-29 12:27:45 +00:00
|
|
|
/*
|
|
|
|
* Unix-specific global flag
|
|
|
|
*
|
|
|
|
* FLAG_STDERR_TTY indicates that standard error might be a terminal and
|
|
|
|
* might get its configuration munged, so anything trying to output plain
|
|
|
|
* text (i.e. with newlines in it) will need to put it back into cooked
|
|
|
|
* mode first. Applications setting this flag should also call
|
|
|
|
* stderr_tty_init() before messing with any terminal modes, and can call
|
|
|
|
* premsg() before outputting text to stderr and postmsg() afterwards.
|
|
|
|
*/
|
|
|
|
#define FLAG_STDERR_TTY 0x1000
|
|
|
|
|
2017-12-10 10:23:39 +00:00
|
|
|
#define PLATFORM_CLIPBOARDS(X) \
|
|
|
|
X(CLIP_PRIMARY, "X11 primary selection") \
|
|
|
|
X(CLIP_CLIPBOARD, "XDG clipboard") \
|
2017-12-17 18:44:27 +00:00
|
|
|
X(CLIP_CUSTOM_1, "<custom#1>") \
|
|
|
|
X(CLIP_CUSTOM_2, "<custom#2>") \
|
|
|
|
X(CLIP_CUSTOM_3, "<custom#3>") \
|
2017-12-09 12:00:13 +00:00
|
|
|
/* end of list */
|
|
|
|
|
2017-12-10 10:23:39 +00:00
|
|
|
#ifdef OSX_GTK
|
|
|
|
/* OS X has no PRIMARY selection */
|
2017-12-10 17:16:50 +00:00
|
|
|
#define MOUSE_SELECT_CLIPBOARD CLIP_NULL
|
|
|
|
#define MOUSE_PASTE_CLIPBOARD CLIP_LOCAL
|
|
|
|
#define CLIPNAME_IMPLICIT "Last selected text"
|
|
|
|
#define CLIPNAME_EXPLICIT "System clipboard"
|
|
|
|
#define CLIPNAME_EXPLICIT_OBJECT "system clipboard"
|
|
|
|
/* These defaults are the ones that more or less comply with the OS X
|
|
|
|
* Human Interface Guidelines, i.e. copy/paste to the system clipboard
|
|
|
|
* is _not_ implicit but requires a specific UI action. This is at
|
|
|
|
* odds with all other PuTTY front ends' defaults, but on OS X there
|
|
|
|
* is no multi-decade precedent for PuTTY working the other way. */
|
|
|
|
#define CLIPUI_DEFAULT_AUTOCOPY FALSE
|
|
|
|
#define CLIPUI_DEFAULT_MOUSE CLIPUI_IMPLICIT
|
|
|
|
#define CLIPUI_DEFAULT_INS CLIPUI_EXPLICIT
|
2017-12-18 10:31:42 +00:00
|
|
|
#define MENU_CLIPBOARD CLIP_CLIPBOARD
|
|
|
|
#define COPYALL_CLIPBOARDS CLIP_CLIPBOARD
|
2017-12-10 10:23:39 +00:00
|
|
|
#else
|
|
|
|
#define MOUSE_SELECT_CLIPBOARD CLIP_PRIMARY
|
|
|
|
#define MOUSE_PASTE_CLIPBOARD CLIP_PRIMARY
|
2017-12-10 17:16:50 +00:00
|
|
|
#define CLIPNAME_IMPLICIT "PRIMARY"
|
|
|
|
#define CLIPNAME_EXPLICIT "CLIPBOARD"
|
|
|
|
#define CLIPNAME_EXPLICIT_OBJECT "CLIPBOARD"
|
|
|
|
/* These defaults are the ones Unix PuTTY has historically had since
|
|
|
|
* it was first thought of in 2002 */
|
|
|
|
#define CLIPUI_DEFAULT_AUTOCOPY FALSE
|
|
|
|
#define CLIPUI_DEFAULT_MOUSE CLIPUI_IMPLICIT
|
|
|
|
#define CLIPUI_DEFAULT_INS CLIPUI_IMPLICIT
|
2017-12-17 20:35:45 +00:00
|
|
|
#define MENU_CLIPBOARD CLIP_CLIPBOARD
|
|
|
|
#define COPYALL_CLIPBOARDS CLIP_PRIMARY, CLIP_CLIPBOARD
|
2017-12-17 18:44:27 +00:00
|
|
|
/* X11 supports arbitrary named clipboards */
|
|
|
|
#define NAMED_CLIPBOARDS
|
2017-12-10 10:23:39 +00:00
|
|
|
#endif
|
|
|
|
|
Divide the whole of gtkwin.c into three parts.
This lays further groundwork for the OS X GTK3 port, which is going to
have to deal with multiple sessions sharing the same process. gtkwin.c
was a bit too monolithic for this, since it included some
process-global runtime state (timers, toplevel callbacks), some
process startup stuff (gtk_init, gtk_main, argv processing) and some
per-session-window stuff.
The per-session stuff remains in gtkwin.c, with the top-level function
now being new_session_window() taking a Conf. The new gtkmain.c
contains the outer skeleton of pt_main(), handling argv processing and
one-off startup stuff like setlocale; and the new gtkcomm.c contains
the pieces of PuTTY infrastructure like timers and uxsel that are
shared between multiple sessions rather than reinstantiated per
session, which have been rewritten to use global variables rather than
fields in 'inst' (since it's now clear to me that they'll have to
apply to all the insts in existence at once).
There are still some lurking assumptions of one-session-per-process,
e.g. the use of gtk_main_quit when a session finishes, and the fact
that the config box insists on running as a separate invocation of
gtk_main so that one session's preliminary config box can't coexist
with another session already active. But this should make it possible
to at least write an OS X app good enough to start testing with, even
if it doesn't get everything quite right yet.
This change is almost entirely rearranging existing code, so it
shouldn't be seriously destabilising. But two noticeable actual
changes have happened, both pleasantly simplifying:
Firstly, the global-variables rewrite of gtkcomm.c has allowed the
post_main edifice to become a great deal simpler. Most of its
complexity was about remembering what 'inst' it had to call back to,
and in fact the right answer is that it shouldn't be calling back to
one at all. So now the post_main() called by gtkdlg.c has become the
same function as the old inst_post_main() that actually did the work,
instead of the two having to be connected by a piece of ugly plumbing.
Secondly, a piece of code that's vanished completely in this
refactoring is the temporary blocking of SIGCHLD around most of the
session setup code. This turns out to have been introduced in 2002,
_before_ I switched to using the intra-process signal pipe strategy
for SIGCHLD handling in 2003. So I now expect that we should be robust
in any case against receiving SIGCHLD at an inconvenient moment, and
hence there's no need to block it.
2016-03-22 21:24:30 +00:00
|
|
|
/* The per-session frontend structure managed by gtkwin.c */
|
|
|
|
struct gui_data;
|
Make the configuration dialog non-modal.
Now every call to do_config_box is replaced with a call to
create_config_box, which returns immediately having constructed the
new GTK window object, and is passed a callback function which it will
arrange to be called when the dialog terminates (whether by OK or by
Cancel). That callback is now what triggers the construction of a
session window after 'Open' is pressed in the initial config box, or
the actual mid-session reconfiguration action after 'Apply' is pressed
in a Change Settings box.
We were already prepared to ignore the re-selection of 'Change
Settings' from the context menu of a window that already had a Change
Settings box open (and not accidentally create a second config box for
the same window); but now we do slightly better, by finding the
existing config box and un-minimising and raising it, in case the user
had forgotten it was there.
That's a useful featurelet, but not the main purpose of this change.
The mani point, of course, is that now the multi-window GtkApplication
based front ends now don't do anything confusing to the nesting of
gtk_main() when config boxes are involved. Whether you're changing the
settings of one (or more than one) of your already-running sessions,
preparing to start up a new PuTTY connection, or both at once, we stay
in the same top-level instance of gtk_main() and all sessions' top-
level callbacks continue to run sensibly.
2017-11-26 11:58:02 +00:00
|
|
|
|
2017-11-26 17:07:47 +00:00
|
|
|
/* Callback when a dialog box finishes, and a no-op implementation of it */
|
Make the configuration dialog non-modal.
Now every call to do_config_box is replaced with a call to
create_config_box, which returns immediately having constructed the
new GTK window object, and is passed a callback function which it will
arrange to be called when the dialog terminates (whether by OK or by
Cancel). That callback is now what triggers the construction of a
session window after 'Open' is pressed in the initial config box, or
the actual mid-session reconfiguration action after 'Apply' is pressed
in a Change Settings box.
We were already prepared to ignore the re-selection of 'Change
Settings' from the context menu of a window that already had a Change
Settings box open (and not accidentally create a second config box for
the same window); but now we do slightly better, by finding the
existing config box and un-minimising and raising it, in case the user
had forgotten it was there.
That's a useful featurelet, but not the main purpose of this change.
The mani point, of course, is that now the multi-window GtkApplication
based front ends now don't do anything confusing to the nesting of
gtk_main() when config boxes are involved. Whether you're changing the
settings of one (or more than one) of your already-running sessions,
preparing to start up a new PuTTY connection, or both at once, we stay
in the same top-level instance of gtk_main() and all sessions' top-
level callbacks continue to run sensibly.
2017-11-26 11:58:02 +00:00
|
|
|
typedef void (*post_dialog_fn_t)(void *ctx, int result);
|
2017-11-26 17:07:47 +00:00
|
|
|
void trivial_post_dialog_fn(void *vctx, int result);
|
Make the configuration dialog non-modal.
Now every call to do_config_box is replaced with a call to
create_config_box, which returns immediately having constructed the
new GTK window object, and is passed a callback function which it will
arrange to be called when the dialog terminates (whether by OK or by
Cancel). That callback is now what triggers the construction of a
session window after 'Open' is pressed in the initial config box, or
the actual mid-session reconfiguration action after 'Apply' is pressed
in a Change Settings box.
We were already prepared to ignore the re-selection of 'Change
Settings' from the context menu of a window that already had a Change
Settings box open (and not accidentally create a second config box for
the same window); but now we do slightly better, by finding the
existing config box and un-minimising and raising it, in case the user
had forgotten it was there.
That's a useful featurelet, but not the main purpose of this change.
The mani point, of course, is that now the multi-window GtkApplication
based front ends now don't do anything confusing to the nesting of
gtk_main() when config boxes are involved. Whether you're changing the
settings of one (or more than one) of your already-running sessions,
preparing to start up a new PuTTY connection, or both at once, we stay
in the same top-level instance of gtk_main() and all sessions' top-
level callbacks continue to run sensibly.
2017-11-26 11:58:02 +00:00
|
|
|
|
|
|
|
/* Start up a session window, with or without a preliminary config box */
|
|
|
|
void initial_config_box(Conf *conf, post_dialog_fn_t after, void *afterctx);
|
|
|
|
void new_session_window(Conf *conf, const char *geometry_string);
|
Divide the whole of gtkwin.c into three parts.
This lays further groundwork for the OS X GTK3 port, which is going to
have to deal with multiple sessions sharing the same process. gtkwin.c
was a bit too monolithic for this, since it included some
process-global runtime state (timers, toplevel callbacks), some
process startup stuff (gtk_init, gtk_main, argv processing) and some
per-session-window stuff.
The per-session stuff remains in gtkwin.c, with the top-level function
now being new_session_window() taking a Conf. The new gtkmain.c
contains the outer skeleton of pt_main(), handling argv processing and
one-off startup stuff like setlocale; and the new gtkcomm.c contains
the pieces of PuTTY infrastructure like timers and uxsel that are
shared between multiple sessions rather than reinstantiated per
session, which have been rewritten to use global variables rather than
fields in 'inst' (since it's now clear to me that they'll have to
apply to all the insts in existence at once).
There are still some lurking assumptions of one-session-per-process,
e.g. the use of gtk_main_quit when a session finishes, and the fact
that the config box insists on running as a separate invocation of
gtk_main so that one session's preliminary config box can't coexist
with another session already active. But this should make it possible
to at least write an OS X app good enough to start testing with, even
if it doesn't get everything quite right yet.
This change is almost entirely rearranging existing code, so it
shouldn't be seriously destabilising. But two noticeable actual
changes have happened, both pleasantly simplifying:
Firstly, the global-variables rewrite of gtkcomm.c has allowed the
post_main edifice to become a great deal simpler. Most of its
complexity was about remembering what 'inst' it had to call back to,
and in fact the right answer is that it shouldn't be calling back to
one at all. So now the post_main() called by gtkdlg.c has become the
same function as the old inst_post_main() that actually did the work,
instead of the two having to be connected by a piece of ugly plumbing.
Secondly, a piece of code that's vanished completely in this
refactoring is the temporary blocking of SIGCHLD around most of the
session setup code. This turns out to have been introduced in 2002,
_before_ I switched to using the intra-process signal pipe strategy
for SIGCHLD handling in 2003. So I now expect that we should be robust
in any case against receiving SIGCHLD at an inconvenient moment, and
hence there's no need to block it.
2016-03-22 21:24:30 +00:00
|
|
|
|
|
|
|
/* Defined in gtkmain.c */
|
|
|
|
void launch_duplicate_session(Conf *conf);
|
|
|
|
void launch_new_session(void);
|
|
|
|
void launch_saved_session(const char *str);
|
Make the configuration dialog non-modal.
Now every call to do_config_box is replaced with a call to
create_config_box, which returns immediately having constructed the
new GTK window object, and is passed a callback function which it will
arrange to be called when the dialog terminates (whether by OK or by
Cancel). That callback is now what triggers the construction of a
session window after 'Open' is pressed in the initial config box, or
the actual mid-session reconfiguration action after 'Apply' is pressed
in a Change Settings box.
We were already prepared to ignore the re-selection of 'Change
Settings' from the context menu of a window that already had a Change
Settings box open (and not accidentally create a second config box for
the same window); but now we do slightly better, by finding the
existing config box and un-minimising and raising it, in case the user
had forgotten it was there.
That's a useful featurelet, but not the main purpose of this change.
The mani point, of course, is that now the multi-window GtkApplication
based front ends now don't do anything confusing to the nesting of
gtk_main() when config boxes are involved. Whether you're changing the
settings of one (or more than one) of your already-running sessions,
preparing to start up a new PuTTY connection, or both at once, we stay
in the same top-level instance of gtk_main() and all sessions' top-
level callbacks continue to run sensibly.
2017-11-26 11:58:02 +00:00
|
|
|
void session_window_closed(void);
|
2017-11-27 20:09:54 +00:00
|
|
|
void window_setup_error(const char *errmsg);
|
2016-03-23 22:03:46 +00:00
|
|
|
#ifdef MAY_REFER_TO_GTK_IN_HEADERS
|
2018-09-12 08:10:51 +00:00
|
|
|
GtkWidget *make_gtk_toplevel_window(Frontend *frontend);
|
2016-03-23 22:03:46 +00:00
|
|
|
#endif
|
Divide the whole of gtkwin.c into three parts.
This lays further groundwork for the OS X GTK3 port, which is going to
have to deal with multiple sessions sharing the same process. gtkwin.c
was a bit too monolithic for this, since it included some
process-global runtime state (timers, toplevel callbacks), some
process startup stuff (gtk_init, gtk_main, argv processing) and some
per-session-window stuff.
The per-session stuff remains in gtkwin.c, with the top-level function
now being new_session_window() taking a Conf. The new gtkmain.c
contains the outer skeleton of pt_main(), handling argv processing and
one-off startup stuff like setlocale; and the new gtkcomm.c contains
the pieces of PuTTY infrastructure like timers and uxsel that are
shared between multiple sessions rather than reinstantiated per
session, which have been rewritten to use global variables rather than
fields in 'inst' (since it's now clear to me that they'll have to
apply to all the insts in existence at once).
There are still some lurking assumptions of one-session-per-process,
e.g. the use of gtk_main_quit when a session finishes, and the fact
that the config box insists on running as a separate invocation of
gtk_main so that one session's preliminary config box can't coexist
with another session already active. But this should make it possible
to at least write an OS X app good enough to start testing with, even
if it doesn't get everything quite right yet.
This change is almost entirely rearranging existing code, so it
shouldn't be seriously destabilising. But two noticeable actual
changes have happened, both pleasantly simplifying:
Firstly, the global-variables rewrite of gtkcomm.c has allowed the
post_main edifice to become a great deal simpler. Most of its
complexity was about remembering what 'inst' it had to call back to,
and in fact the right answer is that it shouldn't be calling back to
one at all. So now the post_main() called by gtkdlg.c has become the
same function as the old inst_post_main() that actually did the work,
instead of the two having to be connected by a piece of ugly plumbing.
Secondly, a piece of code that's vanished completely in this
refactoring is the temporary blocking of SIGCHLD around most of the
session setup code. This turns out to have been introduced in 2002,
_before_ I switched to using the intra-process signal pipe strategy
for SIGCHLD handling in 2003. So I now expect that we should be robust
in any case against receiving SIGCHLD at an inconvenient moment, and
hence there's no need to block it.
2016-03-22 21:24:30 +00:00
|
|
|
|
2018-09-11 15:23:38 +00:00
|
|
|
const struct Backend_vtable *select_backend(Conf *conf);
|
|
|
|
|
Divide the whole of gtkwin.c into three parts.
This lays further groundwork for the OS X GTK3 port, which is going to
have to deal with multiple sessions sharing the same process. gtkwin.c
was a bit too monolithic for this, since it included some
process-global runtime state (timers, toplevel callbacks), some
process startup stuff (gtk_init, gtk_main, argv processing) and some
per-session-window stuff.
The per-session stuff remains in gtkwin.c, with the top-level function
now being new_session_window() taking a Conf. The new gtkmain.c
contains the outer skeleton of pt_main(), handling argv processing and
one-off startup stuff like setlocale; and the new gtkcomm.c contains
the pieces of PuTTY infrastructure like timers and uxsel that are
shared between multiple sessions rather than reinstantiated per
session, which have been rewritten to use global variables rather than
fields in 'inst' (since it's now clear to me that they'll have to
apply to all the insts in existence at once).
There are still some lurking assumptions of one-session-per-process,
e.g. the use of gtk_main_quit when a session finishes, and the fact
that the config box insists on running as a separate invocation of
gtk_main so that one session's preliminary config box can't coexist
with another session already active. But this should make it possible
to at least write an OS X app good enough to start testing with, even
if it doesn't get everything quite right yet.
This change is almost entirely rearranging existing code, so it
shouldn't be seriously destabilising. But two noticeable actual
changes have happened, both pleasantly simplifying:
Firstly, the global-variables rewrite of gtkcomm.c has allowed the
post_main edifice to become a great deal simpler. Most of its
complexity was about remembering what 'inst' it had to call back to,
and in fact the right answer is that it shouldn't be calling back to
one at all. So now the post_main() called by gtkdlg.c has become the
same function as the old inst_post_main() that actually did the work,
instead of the two having to be connected by a piece of ugly plumbing.
Secondly, a piece of code that's vanished completely in this
refactoring is the temporary blocking of SIGCHLD around most of the
session setup code. This turns out to have been introduced in 2002,
_before_ I switched to using the intra-process signal pipe strategy
for SIGCHLD handling in 2003. So I now expect that we should be robust
in any case against receiving SIGCHLD at an inconvenient moment, and
hence there's no need to block it.
2016-03-22 21:24:30 +00:00
|
|
|
/* Defined in gtkcomm.c */
|
|
|
|
void gtkcomm_setup(void);
|
|
|
|
|
2017-12-18 11:15:44 +00:00
|
|
|
/* Used to pass application-menu operations from gtkapp.c to gtkwin.c */
|
|
|
|
enum MenuAction {
|
2017-12-18 11:46:48 +00:00
|
|
|
MA_COPY, MA_PASTE, MA_COPY_ALL, MA_DUPLICATE_SESSION,
|
|
|
|
MA_RESTART_SESSION, MA_CHANGE_SETTINGS, MA_CLEAR_SCROLLBACK,
|
|
|
|
MA_RESET_TERMINAL, MA_EVENT_LOG
|
2017-12-18 11:15:44 +00:00
|
|
|
};
|
2018-09-12 08:10:51 +00:00
|
|
|
void app_menu_action(Frontend *frontend, enum MenuAction);
|
2017-12-09 12:00:13 +00:00
|
|
|
|
2002-10-15 15:16:21 +00:00
|
|
|
/* Things pty.c needs from pterm.c */
|
2018-09-12 08:10:51 +00:00
|
|
|
const char *get_x_display(Frontend *frontend);
|
|
|
|
int font_dimension(Frontend *frontend, int which);/* 0 for width, 1 for height */
|
|
|
|
int get_windowid(Frontend *frontend, long *id);
|
2002-10-15 12:29:52 +00:00
|
|
|
|
2003-03-31 11:21:07 +00:00
|
|
|
/* Things gtkdlg.c needs from pterm.c */
|
2017-11-26 14:55:15 +00:00
|
|
|
#ifdef MAY_REFER_TO_GTK_IN_HEADERS
|
2018-09-12 08:10:51 +00:00
|
|
|
GtkWidget *get_window(Frontend *frontend);
|
2017-11-26 16:51:19 +00:00
|
|
|
enum DialogSlot {
|
|
|
|
DIALOG_SLOT_RECONFIGURE,
|
|
|
|
DIALOG_SLOT_NETWORK_PROMPT,
|
2017-11-26 16:56:03 +00:00
|
|
|
DIALOG_SLOT_LOGFILE_PROMPT,
|
2017-11-26 17:21:32 +00:00
|
|
|
DIALOG_SLOT_WARN_ON_CLOSE,
|
2017-11-26 19:59:24 +00:00
|
|
|
DIALOG_SLOT_CONNECTION_FATAL,
|
2017-11-26 16:51:19 +00:00
|
|
|
DIALOG_SLOT_LIMIT /* must remain last */
|
|
|
|
};
|
2018-09-12 08:10:51 +00:00
|
|
|
void register_dialog(Frontend *frontend, enum DialogSlot slot, GtkWidget *dialog);
|
|
|
|
void unregister_dialog(Frontend *frontend, enum DialogSlot slot);
|
2017-11-26 14:55:15 +00:00
|
|
|
#endif
|
2003-03-31 11:21:07 +00:00
|
|
|
|
2003-04-01 18:10:25 +00:00
|
|
|
/* Things pterm.c needs from gtkdlg.c */
|
Make the configuration dialog non-modal.
Now every call to do_config_box is replaced with a call to
create_config_box, which returns immediately having constructed the
new GTK window object, and is passed a callback function which it will
arrange to be called when the dialog terminates (whether by OK or by
Cancel). That callback is now what triggers the construction of a
session window after 'Open' is pressed in the initial config box, or
the actual mid-session reconfiguration action after 'Apply' is pressed
in a Change Settings box.
We were already prepared to ignore the re-selection of 'Change
Settings' from the context menu of a window that already had a Change
Settings box open (and not accidentally create a second config box for
the same window); but now we do slightly better, by finding the
existing config box and un-minimising and raising it, in case the user
had forgotten it was there.
That's a useful featurelet, but not the main purpose of this change.
The mani point, of course, is that now the multi-window GtkApplication
based front ends now don't do anything confusing to the nesting of
gtk_main() when config boxes are involved. Whether you're changing the
settings of one (or more than one) of your already-running sessions,
preparing to start up a new PuTTY connection, or both at once, we stay
in the same top-level instance of gtk_main() and all sessions' top-
level callbacks continue to run sensibly.
2017-11-26 11:58:02 +00:00
|
|
|
#ifdef MAY_REFER_TO_GTK_IN_HEADERS
|
|
|
|
GtkWidget *create_config_box(const char *title, Conf *conf,
|
|
|
|
int midsession, int protcfginfo,
|
|
|
|
post_dialog_fn_t after, void *afterctx);
|
|
|
|
#endif
|
2015-05-15 10:15:42 +00:00
|
|
|
void nonfatal_message_box(void *window, const char *msg);
|
2003-04-10 08:53:43 +00:00
|
|
|
void about_box(void *window);
|
2003-04-09 18:46:45 +00:00
|
|
|
void *eventlogstuff_new(void);
|
|
|
|
void showeventlog(void *estuff, void *parentwin);
|
2003-05-04 14:18:18 +00:00
|
|
|
void logevent_dlg(void *estuff, const char *string);
|
2013-01-13 21:59:10 +00:00
|
|
|
#ifdef MAY_REFER_TO_GTK_IN_HEADERS
|
2017-11-26 14:05:02 +00:00
|
|
|
struct message_box_button {
|
|
|
|
const char *title;
|
|
|
|
char shortcut;
|
|
|
|
int type; /* more negative means more appropriate to be the Esc action */
|
|
|
|
int value; /* message box's return value if this is pressed */
|
|
|
|
};
|
|
|
|
struct message_box_buttons {
|
|
|
|
const struct message_box_button *buttons;
|
|
|
|
int nbuttons;
|
|
|
|
};
|
|
|
|
extern const struct message_box_buttons buttons_yn, buttons_ok;
|
2017-11-26 17:05:51 +00:00
|
|
|
GtkWidget *create_message_box(
|
|
|
|
GtkWidget *parentwin, const char *title, const char *msg, int minwid,
|
|
|
|
int selectable, const struct message_box_buttons *buttons,
|
|
|
|
post_dialog_fn_t after, void *afterctx);
|
2013-01-13 21:59:10 +00:00
|
|
|
#endif
|
2003-04-01 18:10:25 +00:00
|
|
|
|
2003-03-31 11:42:45 +00:00
|
|
|
/* Things pterm.c needs from {ptermm,uxputty}.c */
|
|
|
|
char *make_default_wintitle(char *hostname);
|
|
|
|
|
2003-04-27 11:10:48 +00:00
|
|
|
/* pterm.c needs this special function in xkeysym.c */
|
|
|
|
int keysym_to_unicode(int keysym);
|
|
|
|
|
2002-10-16 14:32:06 +00:00
|
|
|
/* Things uxstore.c needs from pterm.c */
|
2003-01-14 18:43:45 +00:00
|
|
|
char *x_get_default(const char *key);
|
2002-10-16 14:32:06 +00:00
|
|
|
|
2002-10-16 22:54:58 +00:00
|
|
|
/* Things uxstore.c provides to pterm.c */
|
|
|
|
void provide_xrm_string(char *string);
|
|
|
|
|
2007-09-29 12:27:45 +00:00
|
|
|
/* Things provided by uxcons.c */
|
|
|
|
struct termios;
|
|
|
|
void stderr_tty_init(void);
|
|
|
|
void premsg(struct termios *);
|
|
|
|
void postmsg(struct termios *);
|
|
|
|
|
2003-03-29 16:47:06 +00:00
|
|
|
/* The interface used by uxsel.c */
|
2015-08-16 11:50:46 +00:00
|
|
|
typedef struct uxsel_id uxsel_id;
|
2003-03-29 16:47:06 +00:00
|
|
|
void uxsel_init(void);
|
2016-05-30 21:52:30 +00:00
|
|
|
typedef void (*uxsel_callback_fn)(int fd, int event);
|
2003-03-29 16:47:06 +00:00
|
|
|
void uxsel_set(int fd, int rwx, uxsel_callback_fn callback);
|
|
|
|
void uxsel_del(int fd);
|
2016-05-30 21:37:32 +00:00
|
|
|
void select_result(int fd, int event);
|
2003-03-29 16:47:06 +00:00
|
|
|
int first_fd(int *state, int *rwx);
|
|
|
|
int next_fd(int *state, int *rwx);
|
2003-03-29 18:30:14 +00:00
|
|
|
/* The following are expected to be provided _to_ uxsel.c by the frontend */
|
2015-08-16 11:50:46 +00:00
|
|
|
uxsel_id *uxsel_input_add(int fd, int rwx); /* returns an id */
|
|
|
|
void uxsel_input_remove(uxsel_id *id);
|
2002-10-31 19:49:52 +00:00
|
|
|
|
2003-03-14 18:35:01 +00:00
|
|
|
/* uxcfg.c */
|
|
|
|
struct controlbox;
|
2006-08-29 09:18:09 +00:00
|
|
|
void unix_setup_config_box(struct controlbox *b, int midsession, int protocol);
|
2003-03-14 18:35:01 +00:00
|
|
|
|
2005-02-14 07:41:41 +00:00
|
|
|
/* gtkcfg.c */
|
|
|
|
void gtk_setup_config_box(struct controlbox *b, int midsession, void *window);
|
|
|
|
|
2002-12-31 12:20:34 +00:00
|
|
|
/*
|
|
|
|
* In the Unix Unicode layer, DEFAULT_CODEPAGE is a special value
|
|
|
|
* which causes mb_to_wc and wc_to_mb to call _libc_ rather than
|
|
|
|
* libcharset. That way, we can interface the various charsets
|
|
|
|
* supported by libcharset with the one supported by mbstowcs and
|
|
|
|
* wcstombs (which will be the character set in which stuff read
|
|
|
|
* from the command line or config files is assumed to be encoded).
|
|
|
|
*/
|
|
|
|
#define DEFAULT_CODEPAGE 0xFFFF
|
|
|
|
#define CP_UTF8 CS_UTF8 /* from libcharset */
|
2002-10-07 16:45:23 +00:00
|
|
|
|
2002-10-30 17:57:31 +00:00
|
|
|
#define strnicmp strncasecmp
|
|
|
|
#define stricmp strcasecmp
|
|
|
|
|
2004-12-17 14:25:53 +00:00
|
|
|
/* BSD-semantics version of signal(), and another helpful function */
|
2002-11-02 14:35:57 +00:00
|
|
|
void (*putty_signal(int sig, void (*func)(int)))(int);
|
2004-12-17 14:25:53 +00:00
|
|
|
void block_signal(int sig, int block_it);
|
2002-11-02 14:35:57 +00:00
|
|
|
|
2006-12-09 15:44:31 +00:00
|
|
|
/* uxmisc.c */
|
2013-07-19 18:10:02 +00:00
|
|
|
void cloexec(int);
|
|
|
|
void noncloexec(int);
|
|
|
|
int nonblock(int);
|
|
|
|
int no_nonblock(int);
|
2015-05-05 19:16:22 +00:00
|
|
|
char *make_dir_and_check_ours(const char *dirname);
|
2016-08-07 20:02:55 +00:00
|
|
|
char *make_dir_path(const char *path, mode_t mode);
|
2006-12-09 15:44:31 +00:00
|
|
|
|
2003-01-01 22:25:25 +00:00
|
|
|
/*
|
|
|
|
* Exports from unicode.c.
|
|
|
|
*/
|
2003-01-14 18:28:23 +00:00
|
|
|
struct unicode_data;
|
2004-10-16 14:17:58 +00:00
|
|
|
int init_ucs(struct unicode_data *ucsdata, char *line_codepage,
|
|
|
|
int utf8_override, int font_charset, int vtmode);
|
2003-01-01 22:25:25 +00:00
|
|
|
|
2003-01-11 09:31:54 +00:00
|
|
|
/*
|
|
|
|
* Spare function exported directly from uxnet.c.
|
|
|
|
*/
|
Get rid of lots of implicit pointer types.
All the main backend structures - Ssh, Telnet, Pty, Serial etc - now
describe structure types themselves rather than pointers to them. The
same goes for the codebase-wide trait types Socket and Plug, and the
supporting types SockAddr and Pinger.
All those things that were typedefed as pointers are older types; the
newer ones have the explicit * at the point of use, because that's
what I now seem to be preferring. But whichever one of those is
better, inconsistently using a mixture of the two styles is worse, so
let's make everything consistent.
A few types are still implicitly pointers, such as Bignum and some of
the GSSAPI types; generally this is either because they have to be
void *, or because they're typedefed differently on different
platforms and aren't always pointers at all. Can't be helped. But I've
got rid of the main ones, at least.
2018-10-04 18:10:23 +00:00
|
|
|
void *sk_getxdmdata(Socket *sock, int *lenp);
|
2003-01-11 09:31:54 +00:00
|
|
|
|
2003-08-24 13:22:17 +00:00
|
|
|
/*
|
|
|
|
* General helpful Unix stuff: more helpful version of the FD_SET
|
|
|
|
* macro, which also handles maxfd.
|
|
|
|
*/
|
|
|
|
#define FD_SET_MAX(fd, max, set) do { \
|
|
|
|
FD_SET(fd, &set); \
|
|
|
|
if (max < fd + 1) max = fd + 1; \
|
|
|
|
} while (0)
|
|
|
|
|
2006-08-28 14:29:02 +00:00
|
|
|
/*
|
2018-09-11 15:23:38 +00:00
|
|
|
* Exports from uxser.c.
|
2006-08-28 14:29:02 +00:00
|
|
|
*/
|
2018-09-11 15:23:38 +00:00
|
|
|
extern const struct Backend_vtable serial_backend;
|
2006-08-28 14:29:02 +00:00
|
|
|
|
2015-05-18 12:57:45 +00:00
|
|
|
/*
|
|
|
|
* uxpeer.c, wrapping getsockopt(SO_PEERCRED).
|
|
|
|
*/
|
|
|
|
int so_peercred(int fd, int *pid, int *uid, int *gid);
|
|
|
|
|
2015-08-31 12:24:09 +00:00
|
|
|
/*
|
|
|
|
* Default font setting, which can vary depending on NOT_X_WINDOWS.
|
|
|
|
*/
|
|
|
|
#ifdef NOT_X_WINDOWS
|
|
|
|
#define DEFAULT_GTK_FONT "client:Monospace 12"
|
|
|
|
#else
|
|
|
|
#define DEFAULT_GTK_FONT "server:fixed"
|
|
|
|
#endif
|
|
|
|
|
2002-10-07 16:45:23 +00:00
|
|
|
#endif
|