سؤال

The depth value of visuals on my machine is 24. Is it possible to create X window of lower depth (for example 16) ? If yes how ? Any pointer to sample code would be useful.

XSetWindowAttributes attrs;

attrs.colormap = XCreateColormap(dpy, XDefaultRootWindow(dpy), visual, AllocNone);
attrs.background_pixel = 0;
attrs.border_pixel = 0;

XCreateWindow(dpy, parent, 10, 10, 150, 100, 0, 16, InputOutput,
                visual, CWBackPixel | CWColormap | CWBorderPixel, &attrs);

The above code gave me bad match error. The visual parameter is having 24 bit depth.

Thanks in advance.

هل كانت مفيدة؟

المحلول

Not all possible depths are available in all servers. Run xdpyinfo | grep depths to see what yours support, or call XListDepths from your application.

For example, on my home computer the X server supports depth of 16, but on my work computer it doesn't.

EDIT Window depth must exactly match visual depth, or BadMatch error occurs.

XListDepths may be used to query which visuals support given depth. If all visuals have depth of 24, then every window must have depth of 24. Not all listed depths may be realised as visuals on a given server.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top