#include <gdk/gdk.h>
#include <glib.h>
#include <stdio.h>

int getMonitorWidth(GdkScreen *screen, int monitorNum) 
{
	GdkRectangle monitor;
   	gdk_screen_get_monitor_geometry (screen, monitorNum, &monitor);
   	return monitor.width;
}

int main (int argc, char **argv)
{
#define X_LOCATION		getMonitorWidth(screen, 0) - 10
#define Y_LOCATION		10
#define WIDTH			200
#define HEIGHT			200
#define EXPECTED 		1

	GdkWindow *window = NULL;
	GdkWindowAttr attr;
	GdkScreen *screen = NULL;
	
	gdk_init(&argc, &argv);
	
	screen = gdk_screen_get_default();
	
	gint num_monitors = gdk_screen_get_n_monitors (screen);
	
	attr.title = "NEW_WINDOW";
	attr.x = X_LOCATION;
	attr.y = Y_LOCATION;
	attr.width = WIDTH;
	attr.height = HEIGHT;
	attr.wclass = GDK_INPUT_OUTPUT;
	attr.window_type = GDK_WINDOW_TOPLEVEL;

	window = gdk_window_new(NULL, &attr, GDK_WA_X | GDK_WA_Y |GDK_WA_TITLE);
	if (window == NULL)
	{
		printf("The gdk_window_new function returned NULL, unable to create GdkWindow.\n");
		return 0;
	}
	gdk_window_show(window);

	gint monitorNum = gdk_screen_get_monitor_at_window(screen, window);
    printf("monitorNum = %d", monitorNum);
   	
	if(window != NULL)
	{
		gdk_window_destroy(window);
	}
 	return 0;
}


