1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-01-10 01:48:00 +00:00

Switch to using gtk_window_parse_geometry in GTK 2.

On GTK versions where it's available, this is a much nicer way of
handling the -geometry command-line option, since not only do we get
all the faffing about with gravity for free, it also automatically
sets the user-position WM hints.
This commit is contained in:
Simon Tatham 2015-08-08 18:22:05 +01:00
parent fbb7c8c481
commit 5e55b7a978

View File

@ -84,7 +84,11 @@ struct gui_data {
GtkIMContext *imc;
#endif
unifont *fonts[4]; /* normal, bold, wide, widebold */
#if GTK_CHECK_VERSION(2,0,0)
const char *geometry;
#else
int xpos, ypos, gotpos, gravity;
#endif
GdkCursor *rawcursor, *textcursor, *blankcursor, *waitcursor, *currcursor;
GdkColor cols[NALLCOLOURS];
GdkColormap *colmap;
@ -2830,13 +2834,17 @@ int do_cmdline(int argc, char **argv, int do_everything, int *allow_launch,
SECOND_PASS_ONLY;
conf_set_str(conf, CONF_line_codepage, val);
#ifndef NOT_X_WINDOWS
} else if (!strcmp(p, "-geometry")) {
int flags, x, y;
unsigned int w, h;
EXPECTS_ARG;
SECOND_PASS_ONLY;
#if GTK_CHECK_VERSION(2,0,0)
inst->geometry = val;
#else
/* On GTK 1, we have to do this using raw Xlib */
{
int flags, x, y;
unsigned int w, h;
flags = XParseGeometry(val, &x, &y, &w, &h);
if (flags & WidthValue)
conf_set_int(conf, CONF_width, w);
@ -2850,6 +2858,7 @@ int do_cmdline(int argc, char **argv, int do_everything, int *allow_launch,
inst->gravity = ((flags & XNegative ? 1 : 0) |
(flags & YNegative ? 2 : 0));
}
}
#endif
} else if (!strcmp(p, "-sl")) {
@ -3839,6 +3848,11 @@ int pt_main(int argc, char **argv)
gtk_widget_hide(inst->sbar);
gtk_widget_show(GTK_WIDGET(inst->hbox));
#if GTK_CHECK_VERSION(2,0,0)
if (inst->geometry) {
gtk_window_parse_geometry(GTK_WINDOW(inst->window), inst->geometry);
}
#else
if (inst->gotpos) {
int x = inst->xpos, y = inst->ypos;
GtkRequisition req;
@ -3848,6 +3862,7 @@ int pt_main(int argc, char **argv)
gtk_window_set_position(GTK_WINDOW(inst->window), GTK_WIN_POS_NONE);
gtk_widget_set_uposition(GTK_WIDGET(inst->window), x, y);
}
#endif
g_signal_connect(G_OBJECT(inst->window), "destroy",
G_CALLBACK(destroy), inst);