Whole document tree
    

Whole document tree

Window Hints

Window Hints

Currently it is up to the calling application to appropriately setup the window hints for the application so the terminal will size properly (i.e. to the nearest character cell position). This can be set using the gtk function gtk_window_set_geometry_hints().

If the application's main window area is not the terminal then it may not make sense to set these hints - the terminal will still operate and resize correctly, but may be resized to fractions of a character cell, which will leave a blank space along the right and/or bottom edges.

Example 2. A realize signal handler which sets the window hints for character-accurate window resizing.

static void
set_hints (GtkWidget *widget)
{
        ZvtTerm *term;
	GdkGeometry hints;
	GtkWidget *app;

	g_assert (widget != NULL);
	term = ZVT_TERM (widget);

	app = gtk_widget_get_toplevel(widget);
	g_assert (app != NULL);

#define PADDING 2
	hints.base_width = (GTK_WIDGET (term)->style->klass->xthickness * 2) + PADDING;
	hints.base_height =  (GTK_WIDGET (term)->style->klass->ythickness * 2);

	hints.width_inc = term->charwidth;
	hints.height_inc = term->charheight;
	hints.min_width = hints.base_width + hints.width_inc;
	hints.min_height = hints.base_height + hints.height_inc;

	gtk_window_set_geometry_hints(GTK_WINDOW(app),
				      GTK_WIDGET(term),
				      &hints,
				      GDK_HINT_RESIZE_INC|GDK_HINT_MIN_SIZE|GDK_HINT_BASE_SIZE);
}
	

The example above sets the window hints so that the window manager will force resizes to the nearest character, and report the character dimensions if it provides that functionality.

It should be attached to the terminal instance using gtk_signal_connect_after() so that the hints are set after the window is realized.

Example 3. Attaching the realize handler to the terminal

  gtk_signal_connect_after (
      GTK_OBJECT (term),
      "realize",
      GTK_SIGNAL_FUNC (set_hints),
      term);
        

It must also be called whenever the font is changed, to get the correct behavior. Only do this if the terminal is realized. Simply call this set_hints() function immediately after calling one of the zvt_term_set_font*() functions, after checking that the given terminal is actually realized (using GTK_WIDGET_IS_REALIZED()).