void init_x_and_imlib(void) { disp = XOpenDisplay(NULL); if (!disp) eprintf("Can't open X display. It *is* running, yeah?"); vis = DefaultVisual(disp, DefaultScreen(disp)); depth = DefaultDepth(disp, DefaultScreen(disp)); cm = DefaultColormap(disp, DefaultScreen(disp)); root = RootWindow(disp, DefaultScreen(disp)); scr = ScreenOfDisplay(disp, DefaultScreen(disp)); xid_context = XUniqueContext(); #ifdef HAVE_LIBXINERAMA init_xinerama(); #endif /* HAVE_LIBXINERAMA */ imlib_context_set_display(disp); imlib_context_set_visual(vis); imlib_context_set_colormap(cm); imlib_context_set_color_modifier(NULL); imlib_context_set_progress_function(NULL); imlib_context_set_operation(IMLIB_OP_COPY); wmDeleteWindow = XInternAtom(disp, "WM_DELETE_WINDOW", False); /* Initialise random numbers */ srand(getpid() * time(NULL) % ((unsigned int) -1)); return; }
void init_render(struct xinfo *X, struct panel *P) { bbwidth = P->width; bbheight = P->theme->height; bb = imlib_create_image(bbwidth, bbheight); bbcolor = imlib_create_image(bbwidth, bbheight); imlib_context_set_image(bb); imlib_image_set_has_alpha(1); bbdpy = X->display; bbvis = X->visual; bbwin = P->win; bbcm = X->colmap; bbx = P->x; bby = P->y; rootpmap = &X->rootpmap; theme = P->theme; imlib_context_set_display(bbdpy); imlib_context_set_visual(bbvis); imlib_context_set_colormap(bbcm); #ifdef WITH_COMPOSITE if (P->theme->use_composite) { XRenderPictFormat *fmt = XRenderFindStandardFormat(bbdpy, PictStandardARGB32); bbalpha = imlib_create_image(bbwidth, bbheight); pixcolor = XCreatePixmap(bbdpy, bbwin, bbwidth, bbheight, 32); pixalpha = XCreatePixmap(bbdpy, bbwin, bbwidth, bbheight, 32); piccolor = XRenderCreatePicture(bbdpy, pixcolor, fmt, 0, 0); picalpha = XRenderCreatePicture(bbdpy, pixalpha, fmt, 0, 0); XRenderPictureAttributes pwin; pwin.subwindow_mode = IncludeInferiors; rootpic = XRenderCreatePicture(bbdpy, bbwin, XRenderFindVisualFormat(bbdpy, bbvis), CPSubwindowMode, &pwin); } else #endif if (*rootpmap) { update_bg(); } else { set_bg(); } imlib_context_set_blend(0); imlib_context_set_operation(IMLIB_OP_COPY); }