#ifndef	ARCH_WINLIB_X11_H
#define	ARCH_WINLIB_X11_H

#include <locale.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/keysym.h>

#ifdef	CONFIG_HAVE_XF86_VIDMODE
#include <X11/extensions/xf86vmode.h>
#endif	/* CONFIG_HAVE_XF86_VIDMODE */

typedef struct x11_display_connection_s
{
	int ref_count;
	Window root;
	int scrnum;
	int screen_width, screen_height;
	char *lang;
	Display *dpy;
	XIM im;
	Atom delete_atom;
	Cursor null_cursor;
	vboolean grab_keyboard;
	int connection_fd;
#ifdef	CONFIG_HAVE_XF86_VIDMODE
	int num_vidmodes;
	vboolean vidmode_active;
	XF86VidModeModeInfo **xf86_vidmodes;
	vidmode_p vidmodes;
#endif	/* CONFIG_HAVE_XF86_VIDMODE */
}	x11_display_connection_t, *x11_display_connection_p;

/*
 * Global data: hold biglock before writing.
 * If coded properly, read access should be safe without lock.
 */
extern x11_display_connection_t x11_display_connection;

typedef struct arch_window_s
{
	ARCH_COMMON_WINDOW_FIELDS
	Window		parent, wnd;
	XIC			ic;
	unsigned	event_mask;
	unsigned	keycode_to_scan[256];
	Colormap	cmap;
}	arch_window_t, *arch_window_p;

#ifdef __cplusplus
extern "C" {
#endif
	x11_display_connection_p V_CALL x11_open_connection();
	void V_CALL x11_close_connection();
#ifdef __cplusplus
}
#endif

#endif	/* !ARCH_WINLIB_X11_H */
