#include ONCE "window9.bi"

sub CenterWindow(hw as HWND) export
	
	dim as GdkWindow ptr root
	
	dim as gint width_, height, rwidth, rheight
	
	gtk_window_get_size (GTK_WINDOW(hw), @width_, @height)
	
	root = gtk_widget_get_root_window (GTK_WIDGET (hw))
	
	#ifdef __USE_GTK3__
	
		gdk_window_get_geometry (root, NULL, NULL, @rwidth, @rheight)
	
	#else
	
		gdk_window_get_geometry (root, NULL, NULL, @rwidth, @rheight , NULL)
	
	#endif
	
	gtk_window_move (GTK_WINDOW(hw), (rwidth - width_) / 2, (rheight - height) / 2)
	
End Sub