1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-01-10 01:48: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:
Lars Brinkhoff 2020-02-14 13:49:56 +01:00 committed by Simon Tatham
parent 269bd7e309
commit e2b0e90c8c
5 changed files with 62 additions and 21 deletions

View File

@ -1472,6 +1472,7 @@ static void clipboard_control(struct controlset *s, const char *label,
void setup_config_box(struct controlbox *b, bool midsession, void setup_config_box(struct controlbox *b, bool midsession,
int protocol, int protcfginfo) int protocol, int protcfginfo)
{ {
const struct BackendVtable *backvt;
struct controlset *s; struct controlset *s;
struct sessionsaver_data *ssd; struct sessionsaver_data *ssd;
struct charclass_data *ccd; struct charclass_data *ccd;
@ -1481,6 +1482,7 @@ void setup_config_box(struct controlbox *b, bool midsession,
struct portfwd_data *pfd; struct portfwd_data *pfd;
struct manual_hostkey_data *mh; struct manual_hostkey_data *mh;
union control *c; union control *c;
bool resize_forbidden = false;
char *str; char *str;
ssd = (struct sessionsaver_data *) ssd = (struct sessionsaver_data *)
@ -1864,17 +1866,23 @@ void setup_config_box(struct controlbox *b, bool midsession,
ctrl_settitle(b, "Window", str); ctrl_settitle(b, "Window", str);
sfree(str); sfree(str);
s = ctrl_getset(b, "Window", "size", "Set the size of the window"); backvt = backend_vt_from_proto(protocol);
ctrl_columns(s, 2, 50, 50); if (backvt)
c = ctrl_editbox(s, "Columns", 'm', 100, resize_forbidden = (backvt->flags & BACKEND_RESIZE_FORBIDDEN);
HELPCTX(window_size),
conf_editbox_handler, I(CONF_width), I(-1)); if (!resize_forbidden || !midsession) {
c->generic.column = 0; s = ctrl_getset(b, "Window", "size", "Set the size of the window");
c = ctrl_editbox(s, "Rows", 'r', 100, ctrl_columns(s, 2, 50, 50);
HELPCTX(window_size), c = ctrl_editbox(s, "Columns", 'm', 100,
conf_editbox_handler, I(CONF_height),I(-1)); HELPCTX(window_size),
c->generic.column = 1; conf_editbox_handler, I(CONF_width), I(-1));
ctrl_columns(s, 1, 100); 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", s = ctrl_getset(b, "Window", "scrollback",
"Control the scrollback in the window"); "Control the scrollback in the window");

View File

@ -479,6 +479,10 @@ enum {
ADDRTYPE_NAME /* SockAddr storing an unresolved host name */ ADDRTYPE_NAME /* SockAddr storing an unresolved host name */
}; };
/* Backend flags */
#define BACKEND_RESIZE_FORBIDDEN 0x01 /* Backend does not allow
resizing terminal */
struct Backend { struct Backend {
const BackendVtable *vt; const BackendVtable *vt;
}; };

View File

@ -4445,6 +4445,7 @@ static void compute_geom_hints(GtkFrontend *inst, GdkGeometry *geom)
void set_geom_hints(GtkFrontend *inst) void set_geom_hints(GtkFrontend *inst)
{ {
const struct BackendVtable *vt;
GdkGeometry geom; GdkGeometry geom;
gint flags = GDK_HINT_MIN_SIZE | GDK_HINT_BASE_SIZE | GDK_HINT_RESIZE_INC; gint flags = GDK_HINT_MIN_SIZE | GDK_HINT_BASE_SIZE | GDK_HINT_RESIZE_INC;
compute_geom_hints(inst, &geom); compute_geom_hints(inst, &geom);
@ -4452,6 +4453,16 @@ void set_geom_hints(GtkFrontend *inst)
if (inst->gotpos) if (inst->gotpos)
flags |= GDK_HINT_USER_POS; flags |= GDK_HINT_USER_POS;
#endif #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), gtk_window_set_geometry_hints(GTK_WINDOW(inst->window),
NULL, &geom, flags); NULL, &geom, flags);
} }

View File

@ -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, void win_setup_config_box(struct controlbox *b, HWND *hwndp, bool has_help,
bool midsession, int protocol) bool midsession, int protocol)
{ {
const struct BackendVtable *backvt;
bool resize_forbidden = false;
struct controlset *s; struct controlset *s;
union control *c; union control *c;
char *str; 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. * 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, backvt = backend_vt_from_proto(protocol);
HELPCTX(window_resize), if (backvt)
conf_radiobutton_handler, resize_forbidden = (backvt->flags & BACKEND_RESIZE_FORBIDDEN);
I(CONF_resize_action), if (!midsession || !resize_forbidden) {
"Change the number of rows and columns", I(RESIZE_TERM), s = ctrl_getset(b, "Window", "size", "Set the size of the window");
"Change the size of the font", I(RESIZE_FONT), ctrl_radiobuttons(s, "When window is resized:", 'z', 1,
"Change font size only when maximised", I(RESIZE_EITHER), HELPCTX(window_resize),
"Forbid resizing completely", I(RESIZE_DISABLED), NULL); 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 * Most of the Window/Behaviour stuff is there to mimic Windows

View File

@ -732,10 +732,16 @@ int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show)
{ {
int winmode = WS_OVERLAPPEDWINDOW | WS_VSCROLL; int winmode = WS_OVERLAPPEDWINDOW | WS_VSCROLL;
int exwinmode = 0; 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); wchar_t *uappname = dup_mb_to_wc(DEFAULT_CODEPAGE, 0, appname);
if (!conf_get_bool(conf, CONF_scrollbar)) if (!conf_get_bool(conf, CONF_scrollbar))
winmode &= ~(WS_VSCROLL); 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); winmode &= ~(WS_THICKFRAME | WS_MAXIMIZEBOX);
if (conf_get_bool(conf, CONF_alwaysontop)) if (conf_get_bool(conf, CONF_alwaysontop))
exwinmode |= WS_EX_TOPMOST; exwinmode |= WS_EX_TOPMOST;
@ -1741,6 +1747,7 @@ static void deinit_fonts(void)
static void wintw_request_resize(TermWin *tw, int w, int h) static void wintw_request_resize(TermWin *tw, int w, int h)
{ {
const struct BackendVtable *vt;
int width, height; int width, height;
/* If the window is maximized suppress resizing attempts */ /* 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; 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; if (h == term->rows && w == term->cols) return;
/* Sanity checks ... */ /* Sanity checks ... */