/*
 * Example code showing that wnck_window_set_geometry doesn't work
 * 
 * Compile with
 * gcc -g -Wall `pkg-config --libs --cflags libwnck-1.0 gtk+-2.0` wnck-test-set_geometry.c 
 * 
 */

#define WNCK_I_KNOW_THIS_IS_UNSTABLE

#include <libwnck/window.h>
#include <libwnck/screen.h>
#include <gtk/gtk.h>

#define RESIZE_FLAGS WNCK_WINDOW_CHANGE_WIDTH | WNCK_WINDOW_CHANGE_HEIGHT | WNCK_WINDOW_CHANGE_X | WNCK_WINDOW_CHANGE_Y

static gboolean
do_maximize (WnckWindow* window) {
	wnck_window_maximize (window);
	return FALSE;
}

static gboolean
do_set_geometry (WnckWindow* window) {
	wnck_window_set_geometry (window, 
							  WNCK_WINDOW_GRAVITY_CURRENT,
							  RESIZE_FLAGS,
							  0, 0, 100, 100);
	return FALSE;
}	

int
main (int argc, char** argv) {
	WnckScreen* screen;
	WnckWindow* active;
	
	gtk_init (&argc, &argv);
	
	screen = wnck_screen_get_default ();
	wnck_screen_force_update (screen);
	
	active = wnck_screen_get_active_window (screen);
	
	// If we use do_maximize here instead everything works
	g_timeout_add (10, (GSourceFunc)do_set_geometry, active);
	g_timeout_add (100, (GSourceFunc)gtk_main_quit, NULL);
	
	gtk_main ();
	
	return 0;	
}
