
struct overlay_data { CARD32 visual_id; CARD32 transparency; /**< 0: none; 1: pixel; 2: mask (?) */ CARD32 value; /**< the transparent pixel */ CARD32 layer; /**< -1: underlay; 0: normal; 1: popup; 2: overlay */ }; static int get_overlay_prop ( Screen *screen, struct overlay_data **data_ret) { int result; Atom actual_type; int actual_format; unsigned long nitems, bytes_after; struct overlay_data *data = 0; Display *dpy = DisplayOfScreen(screen); Window window = RootWindowOfScreen(screen); Atom XA_SERVER_OVERLAY_VISUALS = XInternAtom (dpy, "SERVER_OVERLAY_VISUALS", False); *data_ret = 0; result = XGetWindowProperty (dpy, window, XA_SERVER_OVERLAY_VISUALS, 0, (65536 / sizeof (long)), False, XA_SERVER_OVERLAY_VISUALS, &actual_type, &actual_format, &nitems, &bytes_after, (unsigned char **) &data); if (result != Success || actual_type != XA_SERVER_OVERLAY_VISUALS || actual_format != 32 || nitems < 1) { if (data) { XFree(data); } return 0; } else { *data_ret = data; return nitems / (sizeof(*data) / sizeof(CARD32)); } } Visual * get_overlay_visual ( Screen *screen, unsigned long *transparent_pixel_ret) { struct overlay_data *data = 0; int n_visuals = get_overlay_prop (screen, &data); Visual *visual = 0; int depth = 0; unsigned long pixel = 0; unsigned int layer = 0; int i; if (data) for (i = 0; i < n_visuals; i++) /* Only accept the ones that have a transparent pixel. */ if (data[i].transparency == 1) { XVisualInfo vi_in, *vi_out; int out_count; vi_in.visualid = data[i].visual_id; vi_out = XGetVisualInfo( DisplayOfScreen(screen), VisualIDMask, &vi_in, &out_count); if (vi_out) { /* Prefer the one at the topmost layer; after that, prefer the one with the greatest depth (most colors.) */ if (layer < data[i].layer || (layer == data[i].layer && depth < vi_out[0].depth)) { visual = vi_out[0].visual; depth = vi_out[0].depth; layer = data[i].layer; pixel = data[i].value; } XFree(vi_out); } } if (data) { XFree(data); } if (visual && transparent_pixel_ret) *transparent_pixel_ret = pixel; return visual; }還有,XShapeCombineMask 這個 API 的使用也要小心。
想請教一下,您寫 blog 時,通常都用甚麼工具來將你的
source code 轉成 html 的?
To Yukuan,
程式碼排版可使用 http://rafb.net/
張貼後,會產生 HTML 輸出,可以選擇是否要行號。
謝謝!
我最後決定使用 Dev-C++ 的 Export to html 功能。