All pastes #559844 Raw Edit

Unnamed

public text v1 · immutable
·published 2007-06-11 22:34 UTC
rendered paste body
//ORIGIONAL XLIB CODE

Pixmap
mb_util_get_root_pixmap(Display *dpy)
{
  Pixmap root_pxm = None;
  Atom atom_root_pixmap_id = XInternAtom(dpy, "_XROOTPMAP_ID", False);

  Atom type;
  int format;
  Pixmap *data = NULL;
  unsigned long n_items, bytes_after;
  int result;

  result =  XGetWindowProperty (dpy, RootWindow(dpy, DefaultScreen(dpy)),
                                atom_root_pixmap_id,
                                0, 16L,
                                False, XA_PIXMAP,
                                &type, &format, &n_items,
                                &bytes_after, (unsigned char **)&data);

  if (result == Success && n_items)
    root_pxm = *data;

  if (data) XFree(data);

  return root_pxm;
}

//MY XCB CODE:
void getRootPixmap(){
	xcb_intern_atom_cookie_t cookie_atom = xcb_intern_atom(conn, 0, 13, "_XROOTPMAP_ID");
	xcb_intern_atom_reply_t* r_atom = xcb_intern_atom_reply (conn, cookie_atom, null);
	
	if (!r_atom) writefln("Failure on atoms");

	xcb_get_property_cookie_t cookie_prop = xcb_get_property(conn, 0, root.id, r_atom.atom, PIXMAP, 0, 16L);
	xcb_get_property_reply_t* r_prop = xcb_get_property_reply(conn, cookie_prop, null);
	
	if (!r_prop) {
		free (r_atom);
		writefln("Failure2 on atoms");
	}
	
	xcb_pixmap_t pid =*cast(xcb_pixmap_t *)xcb_get_property_value(r_prop);

	free (r_atom);
	free (r_prop);
	
	writefln(pid);
	
	rootPixmap = new Image(pid);
}