-#include <X11/Xutil.h>
-
-Window x11Window = 0;
-Display* x11Display = 0;
-long x11Screen = 0;
-XVisualInfo* x11Visual = 0;
-Colormap x11Colormap = 0;
-
-int getX11Display(int windowwidth, int windowheight)
-{
- x11Display = XOpenDisplay(0);
-
- if(!x11Display) {
- printf("Error: Unable to open X display\n");
- return 0;
- }
-
- x11Screen = XDefaultScreen(x11Display);
- Window rootWindow = RootWindow(x11Display, x11Screen);
- int depth = DefaultDepth(x11Display, x11Screen);
- x11Visual = malloc(sizeof(XVisualInfo));
- XMatchVisualInfo(x11Display, x11Screen, depth, TrueColor, x11Visual);
-
- if(!x11Visual) {
- printf("Error: Unable to acquire visual\n");
- return 0;
- }
-
- x11Colormap = XCreateColormap(x11Display, rootWindow, x11Visual->visual, AllocNone);
- XSetWindowAttributes XSWA;
- XSWA.colormap = x11Colormap;
- XSWA.event_mask = StructureNotifyMask | ExposureMask |
- ButtonPressMask | ButtonReleaseMask | KeyPressMask | KeyReleaseMask;
- unsigned int cwmask = CWBackPixel | CWBorderPixel | CWEventMask | CWColormap;
-
- x11Window = XCreateWindow(x11Display, RootWindow(x11Display, x11Screen), 0, 0, windowwidth, windowheight,
- 0, CopyFromParent, InputOutput, CopyFromParent, cwmask, &XSWA);
- XMapWindow(x11Display, x11Window);
- XFlush(x11Display);
-
- eglX11Display = (EGLNativeDisplayType)x11Display;
- eglX11Window = (EGLNativeWindowType) x11Window;
-
- return 1;
-}
-
-void cleanupX11()
-{
- if(x11Window) XDestroyWindow(x11Display, x11Window);
- if(x11Colormap) XFreeColormap( x11Display, x11Colormap);
- if(x11Display) XCloseDisplay( x11Display);
-}
-
-void forKernel()
-{
- int nm = XPending(x11Display);
- int m;
- for(m=0; m< nm; m++) {
- XEvent event;
- XNextEvent(x11Display, &event);
- switch(event.type){
- case ButtonPress:
- break;
- case KeyPress:
- break;
- default:
- break;
- }
- }
-}
-
-/* ------------------------------------------------------------- */
-