mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-01-09 17:38:00 +00:00
New backend function to disable resizing.
Some protocols such as SUPDUP does not support resizing the terminal.
This commit is contained in:
parent
269bd7e309
commit
e2b0e90c8c
30
config.c
30
config.c
@ -1472,6 +1472,7 @@ static void clipboard_control(struct controlset *s, const char *label,
|
||||
void setup_config_box(struct controlbox *b, bool midsession,
|
||||
int protocol, int protcfginfo)
|
||||
{
|
||||
const struct BackendVtable *backvt;
|
||||
struct controlset *s;
|
||||
struct sessionsaver_data *ssd;
|
||||
struct charclass_data *ccd;
|
||||
@ -1481,6 +1482,7 @@ void setup_config_box(struct controlbox *b, bool midsession,
|
||||
struct portfwd_data *pfd;
|
||||
struct manual_hostkey_data *mh;
|
||||
union control *c;
|
||||
bool resize_forbidden = false;
|
||||
char *str;
|
||||
|
||||
ssd = (struct sessionsaver_data *)
|
||||
@ -1864,17 +1866,23 @@ void setup_config_box(struct controlbox *b, bool midsession,
|
||||
ctrl_settitle(b, "Window", str);
|
||||
sfree(str);
|
||||
|
||||
s = ctrl_getset(b, "Window", "size", "Set the size of the window");
|
||||
ctrl_columns(s, 2, 50, 50);
|
||||
c = ctrl_editbox(s, "Columns", 'm', 100,
|
||||
HELPCTX(window_size),
|
||||
conf_editbox_handler, I(CONF_width), I(-1));
|
||||
c->generic.column = 0;
|
||||
c = ctrl_editbox(s, "Rows", 'r', 100,
|
||||
HELPCTX(window_size),
|
||||
conf_editbox_handler, I(CONF_height),I(-1));
|
||||
c->generic.column = 1;
|
||||
ctrl_columns(s, 1, 100);
|
||||
backvt = backend_vt_from_proto(protocol);
|
||||
if (backvt)
|
||||
resize_forbidden = (backvt->flags & BACKEND_RESIZE_FORBIDDEN);
|
||||
|
||||
if (!resize_forbidden || !midsession) {
|
||||
s = ctrl_getset(b, "Window", "size", "Set the size of the window");
|
||||
ctrl_columns(s, 2, 50, 50);
|
||||
c = ctrl_editbox(s, "Columns", 'm', 100,
|
||||
HELPCTX(window_size),
|
||||
conf_editbox_handler, I(CONF_width), I(-1));
|
||||
c->generic.column = 0;
|
||||
c = ctrl_editbox(s, "Rows", 'r', 100,
|
||||
HELPCTX(window_size),
|
||||
conf_editbox_handler, I(CONF_height),I(-1));
|
||||
c->generic.column = 1;
|
||||
ctrl_columns(s, 1, 100);
|
||||
}
|
||||
|
||||
s = ctrl_getset(b, "Window", "scrollback",
|
||||
"Control the scrollback in the window");
|
||||
|
4
putty.h
4
putty.h
@ -479,6 +479,10 @@ enum {
|
||||
ADDRTYPE_NAME /* SockAddr storing an unresolved host name */
|
||||
};
|
||||
|
||||
/* Backend flags */
|
||||
#define BACKEND_RESIZE_FORBIDDEN 0x01 /* Backend does not allow
|
||||
resizing terminal */
|
||||
|
||||
struct Backend {
|
||||
const BackendVtable *vt;
|
||||
};
|
||||
|
@ -4445,6 +4445,7 @@ static void compute_geom_hints(GtkFrontend *inst, GdkGeometry *geom)
|
||||
|
||||
void set_geom_hints(GtkFrontend *inst)
|
||||
{
|
||||
const struct BackendVtable *vt;
|
||||
GdkGeometry geom;
|
||||
gint flags = GDK_HINT_MIN_SIZE | GDK_HINT_BASE_SIZE | GDK_HINT_RESIZE_INC;
|
||||
compute_geom_hints(inst, &geom);
|
||||
@ -4452,6 +4453,16 @@ void set_geom_hints(GtkFrontend *inst)
|
||||
if (inst->gotpos)
|
||||
flags |= GDK_HINT_USER_POS;
|
||||
#endif
|
||||
vt = backend_vt_from_proto(conf_get_int(inst->conf, CONF_protocol));
|
||||
if (vt && vt->flags & BACKEND_RESIZE_FORBIDDEN) {
|
||||
/* Window resizing forbidden. Set both minimum and maximum
|
||||
* dimensions to be the initial size. */
|
||||
geom.min_width = inst->width*inst->font_width + 2*inst->window_border;
|
||||
geom.min_height = inst->height*inst->font_height + 2*inst->window_border;
|
||||
geom.max_width = geom.min_width;
|
||||
geom.max_height = geom.min_height;
|
||||
flags |= GDK_HINT_MAX_SIZE;
|
||||
}
|
||||
gtk_window_set_geometry_hints(GTK_WINDOW(inst->window),
|
||||
NULL, &geom, flags);
|
||||
}
|
||||
|
@ -43,6 +43,8 @@ static void variable_pitch_handler(union control *ctrl, dlgparam *dlg,
|
||||
void win_setup_config_box(struct controlbox *b, HWND *hwndp, bool has_help,
|
||||
bool midsession, int protocol)
|
||||
{
|
||||
const struct BackendVtable *backvt;
|
||||
bool resize_forbidden = false;
|
||||
struct controlset *s;
|
||||
union control *c;
|
||||
char *str;
|
||||
@ -313,15 +315,21 @@ void win_setup_config_box(struct controlbox *b, HWND *hwndp, bool has_help,
|
||||
/*
|
||||
* Resize-by-changing-font is a Windows insanity.
|
||||
*/
|
||||
s = ctrl_getset(b, "Window", "size", "Set the size of the window");
|
||||
ctrl_radiobuttons(s, "When window is resized:", 'z', 1,
|
||||
HELPCTX(window_resize),
|
||||
conf_radiobutton_handler,
|
||||
I(CONF_resize_action),
|
||||
"Change the number of rows and columns", I(RESIZE_TERM),
|
||||
"Change the size of the font", I(RESIZE_FONT),
|
||||
"Change font size only when maximised", I(RESIZE_EITHER),
|
||||
"Forbid resizing completely", I(RESIZE_DISABLED), NULL);
|
||||
|
||||
backvt = backend_vt_from_proto(protocol);
|
||||
if (backvt)
|
||||
resize_forbidden = (backvt->flags & BACKEND_RESIZE_FORBIDDEN);
|
||||
if (!midsession || !resize_forbidden) {
|
||||
s = ctrl_getset(b, "Window", "size", "Set the size of the window");
|
||||
ctrl_radiobuttons(s, "When window is resized:", 'z', 1,
|
||||
HELPCTX(window_resize),
|
||||
conf_radiobutton_handler,
|
||||
I(CONF_resize_action),
|
||||
"Change the number of rows and columns", I(RESIZE_TERM),
|
||||
"Change the size of the font", I(RESIZE_FONT),
|
||||
"Change font size only when maximised", I(RESIZE_EITHER),
|
||||
"Forbid resizing completely", I(RESIZE_DISABLED), NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
* Most of the Window/Behaviour stuff is there to mimic Windows
|
||||
|
@ -732,10 +732,16 @@ int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show)
|
||||
{
|
||||
int winmode = WS_OVERLAPPEDWINDOW | WS_VSCROLL;
|
||||
int exwinmode = 0;
|
||||
const struct BackendVtable *vt =
|
||||
backend_vt_from_proto(be_default_protocol);
|
||||
bool resize_forbidden = false;
|
||||
if (vt && vt->flags & BACKEND_RESIZE_FORBIDDEN)
|
||||
resize_forbidden = true;
|
||||
wchar_t *uappname = dup_mb_to_wc(DEFAULT_CODEPAGE, 0, appname);
|
||||
if (!conf_get_bool(conf, CONF_scrollbar))
|
||||
winmode &= ~(WS_VSCROLL);
|
||||
if (conf_get_int(conf, CONF_resize_action) == RESIZE_DISABLED)
|
||||
if (conf_get_int(conf, CONF_resize_action) == RESIZE_DISABLED ||
|
||||
resize_forbidden)
|
||||
winmode &= ~(WS_THICKFRAME | WS_MAXIMIZEBOX);
|
||||
if (conf_get_bool(conf, CONF_alwaysontop))
|
||||
exwinmode |= WS_EX_TOPMOST;
|
||||
@ -1741,6 +1747,7 @@ static void deinit_fonts(void)
|
||||
|
||||
static void wintw_request_resize(TermWin *tw, int w, int h)
|
||||
{
|
||||
const struct BackendVtable *vt;
|
||||
int width, height;
|
||||
|
||||
/* If the window is maximized suppress resizing attempts */
|
||||
@ -1750,6 +1757,9 @@ static void wintw_request_resize(TermWin *tw, int w, int h)
|
||||
}
|
||||
|
||||
if (conf_get_int(conf, CONF_resize_action) == RESIZE_DISABLED) return;
|
||||
vt = backend_vt_from_proto(be_default_protocol);
|
||||
if (vt && vt->flags & BACKEND_RESIZE_FORBIDDEN)
|
||||
return;
|
||||
if (h == term->rows && w == term->cols) return;
|
||||
|
||||
/* Sanity checks ... */
|
||||
|
Loading…
Reference in New Issue
Block a user