#include <gtk/gtk.h>

static void 
size_changed_cb (GdkScreen *screen, gpointer data)
{
  GdkWindow *win;
  gint w, h, n, i;
  GdkRectangle mon;

  win = gdk_screen_get_root_window (screen);
  gdk_window_get_geometry (win, NULL, NULL, &w, &h, NULL);
  n = gdk_screen_get_n_monitors (screen);
  g_print ("size-changed\n"
	   "\tscreen      %d %d\n"
	   "\troot window %d %d\n",
	   gdk_screen_get_width (screen),
	   gdk_screen_get_height (screen), 
	   w, h);
  for (i = 0; i < n; i++)
    {
      gdk_screen_get_monitor_geometry (screen, i, &mon);
      g_print ("\tmonitor %d:  %d %d\n", i, mon.width, mon.height);
    }
}

int
main (int argc, char *argv[])
{
  GdkDisplay *display;
  GdkScreen *screen;

  gtk_init (&argc, &argv);

  display = gdk_display_get_default ();
  screen = gdk_display_get_default_screen (display);
  
  g_signal_connect (screen, "size-changed", 
		    G_CALLBACK (size_changed_cb), NULL);
  gtk_main ();

  return 0;
}
