Window Hints

Currently it is upto 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). Unfortunately, gdk does not provide the required functionality in its hint functions, and so the application must use the corresponding X calls where required.

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 or bottom edges.

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

	  static void
	  size_allocate (GtkWidget *widget)
	  {
	  ZvtTerm *term;
	  XSizeHints sizehints;
	  
	  g_assert (widget != NULL);
	  term = ZVT_TERM (widget);

	  #define PADDING 2  
	  sizehints.base_width = 
	  (GTK_WIDGET (window)->allocation.width) +
	  (GTK_WIDGET (term)->style->klass->xthickness * 2) -
	  (GTK_WIDGET (term)->allocation.width) + PADDING;
	  
	  sizehints.base_height =
	  (GTK_WIDGET (window)->allocation.height) +
	  (GTK_WIDGET (term)->style->klass->ythickness * 2) -
	  (GTK_WIDGET (term)->allocation.height);
	  
	  sizehints.width_inc = term->charwidth;
	  sizehints.height_inc = term->charheight;
	  sizehints.min_width = sizehints.base_width + sizehints.width_inc;
	  sizehints.min_height = sizehints.base_height + sizehints.height_inc;
	  
	  sizehints.flags = (PBaseSize|PMinSize|PResizeInc);
	  
	  XSetWMNormalHints (GDK_DISPLAY(),
	  GDK_WINDOW_XWINDOW (GTK_WIDGET (window)->window),
	  &sizehints);
	  gdk_flush ();
	  }
	

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 attatched to the terminal instance using gtk_signal_attach_after, because gtk/gdk will set its own (incomplete) window hints every time the window is resized and we must over-ride that.

Example 3. Attaching the signal resize handler to the terminal

	  gtk_signal_connect_after (
	  GTK_OBJECT (term),
	  "size_allocate",
	  GTK_SIGNAL_FUNC (size_allocate),
	  term);