-void getX11Display(int windowwidth, int windowheight)
-{
- x11Display = XOpenDisplay(0);
-
- if(!x11Display) {
- printf("Error: Unable to open X display\n");
- cleanupAndExit(-1);
- }
-
- 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");
- cleanupAndExit(-1);
- }
-
- 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);
-}
-