1 #include "evas_common.h"
2 #include "evas_engine.h"
3 #include "evas_macros.h"
5 #include <xcb/xcb_image.h>
8 #include <sys/utsname.h>
11 static Evas_List *shmpool = NULL;
12 static int shmsize = 0;
13 static int shmmemlimit = 10 * 1024 * 1024;
14 static int shmcountlimit = 32;
16 static Xcb_Output_Buffer *
17 _find_xcbob(xcb_connection_t *conn, int depth, int w, int h, int shm, void *data)
21 Xcb_Output_Buffer *xcbob = NULL;
22 int fitness = 0x7fffffff;
27 // return evas_software_xcb_x_output_buffer_new(d, v, depth, w, h, shm, data);
29 return evas_software_xcb_x_output_buffer_new(conn, depth, w, h, shm, data);
33 if (bpp == 3) bpp = 4;
34 lbytes = (((w * bpp) + 3) / 4) * 4;
37 lbytes = ((w + 31) / 32) * 4;
39 for (l = shmpool; l; l = l->next)
41 Xcb_Output_Buffer *xcbob2;
45 if ((xcbob2->image->depth != depth) ||
46 (xcbob2->connection != conn))
48 szdif = xcbob2->psize - sz;
49 if (szdif < 0) continue;
63 if ((fitness > (100 * 100)) || (!xcbob))
64 return evas_software_xcb_x_output_buffer_new(conn, depth, w, h, shm, data);
67 shmpool = evas_list_remove_list(shmpool, xl);
71 xcbob->image->width = xcbob->w;
72 xcbob->image->height = xcbob->h;
73 xcbob->image->stride = xcbob->bpl;
74 shmsize -= xcbob->psize * (xcbob->image->depth / 8);
79 _unfind_xcbob(Xcb_Output_Buffer *xcbob, int sync)
81 // evas_software_xcb_x_output_buffer_free(xcbob, sync); return;
84 shmpool = evas_list_prepend(shmpool, xcbob);
85 shmsize += xcbob->psize * xcbob->image->depth / 8;
86 while ((shmsize > (shmmemlimit)) ||
87 (evas_list_count(shmpool) > shmcountlimit))
91 xl = evas_list_last(shmpool);
98 shmpool = evas_list_remove_list(shmpool, xl);
99 evas_software_xcb_x_output_buffer_free(xcbob, sync);
103 evas_software_xcb_x_output_buffer_free(xcbob, sync);
107 _clear_xcbob(int sync)
111 Xcb_Output_Buffer *xcbob;
113 xcbob = shmpool->data;
114 shmpool = evas_list_remove_list(shmpool, shmpool);
115 evas_software_xcb_x_output_buffer_free(xcbob, sync);
121 evas_software_xcb_outbuf_init(void)
126 evas_software_xcb_outbuf_free(Outbuf * buf)
128 while (buf->priv.pending_writes)
133 im = buf->priv.pending_writes->data;
134 buf->priv.pending_writes = evas_list_remove_list(buf->priv.pending_writes, buf->priv.pending_writes);
135 obr = im->extended_info;
136 evas_cache_image_drop(&im->cache_entry);
137 if (obr->xcbob) _unfind_xcbob(obr->xcbob, 0);
138 if (obr->mxcbob) _unfind_xcbob(obr->mxcbob, 0);
141 evas_software_xcb_outbuf_idle_flush(buf);
142 evas_software_xcb_outbuf_flush(buf);
144 xcb_free_gc(buf->priv.x.conn, buf->priv.x.gc);
146 xcb_free_gc(buf->priv.x.conn, buf->priv.x.gcm);
148 evas_software_xcb_x_color_deallocate(buf->priv.x.conn,
157 evas_software_xcb_outbuf_rotation_set(Outbuf *buf, int rot)
163 evas_software_xcb_outbuf_setup_x(int w,
167 xcb_connection_t *conn,
168 xcb_screen_t *screen,
170 xcb_visualtype_t *vis,
177 int destination_alpha)
181 buf = calloc(1, sizeof(Outbuf));
190 buf->priv.x.conn = conn;
191 buf->priv.x.screen = screen;
192 buf->priv.x.vis = vis;
193 buf->priv.x.cmap = cmap;
194 buf->priv.x.depth = x_depth;
196 buf->priv.mask_dither = shape_dither;
197 buf->priv.destination_alpha = destination_alpha;
200 Gfx_Func_Convert conv_func;
201 Xcb_Output_Buffer *xcbob;
203 buf->priv.x.shm = evas_software_xcb_x_can_do_shm(buf->priv.x.conn, buf->priv.x.screen);
204 xcbob = evas_software_xcb_x_output_buffer_new(buf->priv.x.conn,
207 buf->priv.x.shm, NULL);
212 #ifdef WORDS_BIGENDIAN
213 if (evas_software_xcb_x_output_buffer_byte_order(xcbob) == XCB_IMAGE_ORDER_LSB_FIRST)
214 buf->priv.x.swap = 1;
215 if (evas_software_xcb_x_output_buffer_bit_order(xcbob) == XCB_IMAGE_ORDER_MSB_FIRST)
216 buf->priv.x.bit_swap = 1;
218 if (evas_software_xcb_x_output_buffer_byte_order(xcbob) == XCB_IMAGE_ORDER_MSB_FIRST)
219 buf->priv.x.swap = 1;
220 if (evas_software_xcb_x_output_buffer_bit_order(xcbob) == XCB_IMAGE_ORDER_MSB_FIRST)
221 buf->priv.x.bit_swap = 1;
223 if (((vis->_class == XCB_VISUAL_CLASS_TRUE_COLOR) ||
224 (vis->_class == XCB_VISUAL_CLASS_DIRECT_COLOR)) &&
228 buf->priv.mask.r = (DATA32) vis->red_mask;
229 buf->priv.mask.g = (DATA32) vis->green_mask;
230 buf->priv.mask.b = (DATA32) vis->blue_mask;
231 if (buf->priv.x.swap)
233 SWAP32(buf->priv.mask.r);
234 SWAP32(buf->priv.mask.g);
235 SWAP32(buf->priv.mask.b);
238 else if ((vis->_class == XCB_VISUAL_CLASS_STATIC_GRAY) ||
239 (vis->_class == XCB_VISUAL_CLASS_GRAY_SCALE) ||
240 (vis->_class == XCB_VISUAL_CLASS_STATIC_COLOR) ||
241 (vis->_class == XCB_VISUAL_CLASS_PSEUDO_COLOR) ||
244 Convert_Pal_Mode pm = PAL_MODE_RGB332;
246 if ((vis->_class == XCB_VISUAL_CLASS_GRAY_SCALE) ||
247 (vis->_class == XCB_VISUAL_CLASS_STATIC_GRAY))
251 if (max_colors >= 256)
252 pm = PAL_MODE_GRAY256;
253 else if (max_colors >= 64)
254 pm = PAL_MODE_GRAY64;
255 else if (max_colors >= 16)
256 pm = PAL_MODE_GRAY16;
257 else if (max_colors >= 4)
264 if (max_colors >= 256)
265 pm = PAL_MODE_RGB332;
266 else if (max_colors >= 216)
267 pm = PAL_MODE_RGB666;
268 else if (max_colors >= 128)
269 pm = PAL_MODE_RGB232;
270 else if (max_colors >= 64)
271 pm = PAL_MODE_RGB222;
272 else if (max_colors >= 32)
273 pm = PAL_MODE_RGB221;
274 else if (max_colors >= 16)
275 pm = PAL_MODE_RGB121;
276 else if (max_colors >= 8)
277 pm = PAL_MODE_RGB111;
278 else if (max_colors >= 4)
283 /* FIXME: only alloc once per display+cmap */
285 evas_software_xcb_x_color_allocate(conn,
297 if (buf->rot == 0 || buf->rot == 180)
298 conv_func = evas_common_convert_func_get(0,
301 evas_software_xcb_x_output_buffer_depth (xcbob),
305 buf->priv.pal->colors,
307 else if (buf->rot == 90 || buf->rot == 270)
308 conv_func = evas_common_convert_func_get(0,
311 evas_software_xcb_x_output_buffer_depth (xcbob),
315 buf->priv.pal->colors,
320 if (buf->rot == 0 || buf->rot == 180)
321 conv_func = evas_common_convert_func_get(0,
324 evas_software_xcb_x_output_buffer_depth(xcbob),
330 else if (buf->rot == 90 || buf->rot == 270)
331 conv_func = evas_common_convert_func_get(0,
334 evas_software_xcb_x_output_buffer_depth(xcbob),
341 evas_software_xcb_x_output_buffer_free(xcbob, 1);
344 printf(".[ Evas Error ].\n"
347 " RGB format mask: %08x, %08x, %08x\n"
348 " Palette mode: %i\n"
349 " Not supported by and compiled in converters!\n"
355 buf->priv.pal->colors);
358 evas_software_xcb_outbuf_drawable_set(buf, draw);
359 evas_software_xcb_outbuf_mask_set(buf, mask);
366 evas_software_xcb_outbuf_new_region_for_update(Outbuf *buf,
382 if ((buf->onebuf) && (buf->priv.x.shm))
384 Evas_Rectangle *rect;
386 rect = malloc(sizeof(Evas_Rectangle));
387 RECTS_CLIP_TO_RECT(x, y, w, h, 0, 0, buf->w, buf->h);
392 buf->priv.onebuf_regions = evas_list_append(buf->priv.onebuf_regions, rect);
393 if (buf->priv.onebuf)
399 if (!buf->priv.synced)
402 free(xcb_get_input_focus_reply(buf->priv.x.conn, xcb_get_input_focus_unchecked(buf->priv.x.conn), NULL));
403 buf->priv.synced = 1;
405 if ((buf->priv.x.mask) || (buf->priv.destination_alpha))
409 im = buf->priv.onebuf;
410 for (yy = y; yy < (y + h); yy++)
412 memset(im->image.data + (im->cache_entry.w * yy) + x,
413 0, w * sizeof(DATA32));
416 return buf->priv.onebuf;
418 obr = calloc(1, sizeof(Outbuf_Region));
428 alpha = ((buf->priv.x.mask) || (buf->priv.destination_alpha));
430 use_shm = buf->priv.x.shm;
431 if ((buf->rot == 0) &&
432 (buf->priv.mask.r == 0xff0000) &&
433 (buf->priv.mask.g == 0x00ff00) &&
434 (buf->priv.mask.b == 0x0000ff))
436 obr->xcbob = evas_software_xcb_x_output_buffer_new(buf->priv.x.conn,
441 im = (RGBA_Image *) evas_cache_image_data(evas_common_image_cache_get(),
443 (DATA32 *) evas_software_xcb_x_output_buffer_data(obr->xcbob, &bpl),
444 alpha, EVAS_COLORSPACE_ARGB8888);
445 im->extended_info = obr;
446 if (buf->priv.x.mask)
447 obr->mxcbob = evas_software_xcb_x_output_buffer_new(buf->priv.x.conn,
455 im = (RGBA_Image *) evas_cache_image_empty(evas_common_image_cache_get());
456 im->cache_entry.flags.alpha |= alpha ? 1 : 0;
457 evas_cache_image_surface_alloc(&im->cache_entry, buf->w, buf->h);
458 im->extended_info = obr;
459 if ((buf->rot == 0) || (buf->rot == 180))
460 obr->xcbob = evas_software_xcb_x_output_buffer_new(buf->priv.x.conn,
465 else if ((buf->rot == 90) || (buf->rot == 270))
466 obr->xcbob = evas_software_xcb_x_output_buffer_new(buf->priv.x.conn,
471 if (buf->priv.x.mask)
472 obr->mxcbob = evas_software_xcb_x_output_buffer_new(buf->priv.x.conn,
478 /* FIXME: faster memset! */
479 memset(im->image.data, 0, w * h * sizeof(DATA32));
481 buf->priv.onebuf = im;
486 obr = calloc(1, sizeof(Outbuf_Region));
496 use_shm = buf->priv.x.shm;
497 /* FIXME: magic - i found if shm regions are smaller than 200x200 its
498 * faster to use ximages over unix sockets - trial and error
500 // use_shm = 0; /* 630 -> 1006 fps */
501 // if ((w * h) < (200 * 200)) use_shm = 0; /* 630 -> 962 fps */
503 alpha = ((buf->priv.x.mask) || (buf->priv.destination_alpha));
505 if ((buf->rot == 0) &&
506 (buf->priv.mask.r == 0xff0000) &&
507 (buf->priv.mask.g == 0x00ff00) &&
508 (buf->priv.mask.b == 0x0000ff))
510 obr->xcbob = _find_xcbob(buf->priv.x.conn,
515 im = (RGBA_Image *) evas_cache_image_data(evas_common_image_cache_get(),
517 (DATA32 *) evas_software_xcb_x_output_buffer_data(obr->xcbob, &bpl),
518 alpha, EVAS_COLORSPACE_ARGB8888);
519 im->extended_info = obr;
520 if (buf->priv.x.mask)
521 obr->mxcbob = _find_xcbob(buf->priv.x.conn,
525 /* obr->mxcbob = evas_software_xcb_x_output_buffer_new(buf->priv.x.conn, */
534 im = (RGBA_Image *) evas_cache_image_empty(evas_common_image_cache_get());
535 im->cache_entry.flags.alpha |= alpha ? 1 : 0;
536 evas_cache_image_surface_alloc(&im->cache_entry, w, h);
537 im->extended_info = obr;
538 if ((buf->rot == 0) || (buf->rot == 180))
539 obr->xcbob = _find_xcbob(buf->priv.x.conn,
544 /* obr->xcbob = evas_software_xcb_x_output_buffer_new(buf->priv.x.conn, */
545 /* buf->priv.x.depth, */
550 else if ((buf->rot == 90) || (buf->rot == 270))
551 obr->xcbob = _find_xcbob(buf->priv.x.conn,
556 /* obr->xcbob = evas_software_xcb_x_output_buffer_new(buf->priv.x.conn, */
557 /* buf->priv.x.depth, */
562 if (buf->priv.x.mask)
563 obr->mxcbob = _find_xcbob(buf->priv.x.conn,
567 /* obr->mxcbob = evas_software_xcb_x_output_buffer_new(buf->priv.x.conn, */
574 if ((buf->priv.x.mask) || (buf->priv.destination_alpha))
575 /* FIXME: faster memset! */
576 memset(im->image.data, 0, w * h * sizeof(DATA32));
578 buf->priv.pending_writes = evas_list_append(buf->priv.pending_writes, im);
583 evas_software_xcb_outbuf_free_region_for_update(Outbuf *buf,
586 /* no need to do anything - they are cleaned up on flush */
590 evas_software_xcb_outbuf_flush(Outbuf *buf)
594 if ((buf->priv.onebuf) && (buf->priv.onebuf_regions))
598 pixman_region16_t tmpr;
600 im = buf->priv.onebuf;
601 obr = im->extended_info;
602 pixman_region_init(&tmpr);
603 while (buf->priv.onebuf_regions)
605 Evas_Rectangle *rect;
607 rect = buf->priv.onebuf_regions->data;
608 buf->priv.onebuf_regions = evas_list_remove_list(buf->priv.onebuf_regions, buf->priv.onebuf_regions);
609 pixman_region_union_rect(&tmpr, &tmpr,
613 evas_software_xcb_outbuf_debug_show(buf, buf->priv.x.win,
614 rect->x, rect->y, rect->w, rect->h);
617 xcb_set_clip_rectangles(buf->priv.x.conn, XCB_CLIP_ORDERING_YX_BANDED,
619 0, 0, pixman_region_n_rects(&tmpr),
620 (const xcb_rectangle_t *)pixman_region_rectangles(&tmpr, NULL));
621 evas_software_xcb_x_output_buffer_paste(obr->xcbob, buf->priv.x.win,
626 xcb_set_clip_rectangles(buf->priv.x.conn, XCB_CLIP_ORDERING_YX_BANDED,
628 0, 0, pixman_region_n_rects(&tmpr),
629 (const xcb_rectangle_t *)pixman_region_rectangles(&tmpr, NULL));
630 evas_software_xcb_x_output_buffer_paste(obr->mxcbob,
635 buf->priv.synced = 0;
641 free(xcb_get_input_focus_reply(buf->priv.x.conn, xcb_get_input_focus_unchecked(buf->priv.x.conn), NULL));
642 for (l = buf->priv.pending_writes; l; l = l->next)
648 obr = im->extended_info;
650 evas_software_xcb_outbuf_debug_show(buf,
656 evas_software_xcb_x_output_buffer_paste(obr->xcbob,
662 evas_software_xcb_x_output_buffer_paste(obr->mxcbob,
668 while (buf->priv.pending_writes)
673 im = buf->priv.pending_writes->data;
674 buf->priv.pending_writes = evas_list_remove_list(buf->priv.pending_writes,
675 buf->priv.pending_writes);
676 obr = im->extended_info;
677 evas_cache_image_drop(&im->cache_entry);
678 if (obr->xcbob) _unfind_xcbob(obr->xcbob, 0);
679 if (obr->mxcbob) _unfind_xcbob(obr->mxcbob, 0);
680 /* if (obr->xcbob) evas_software_xcb_x_output_buffer_free(obr->xcbob, 0); */
681 /* if (obr->mxcbob) evas_software_xcb_x_output_buffer_free(obr->mxcbob, 0); */
684 buf->priv.prev_pending_writes = buf->priv.pending_writes;
685 buf->priv.pending_writes = NULL;
686 xcb_flush(buf->priv.x.conn);
688 /* XX async push - disable */
690 for (l = buf->priv.pending_writes; l; l = l->next)
696 obr = im->extended_info;
698 evas_software_x11_outbuf_debug_show(buf, buf->priv.x.win,
699 obr->x, obr->y, obr->w, obr->h);
700 evas_software_x11_x_output_buffer_paste(obr->xcbob, buf->priv.x.win,
704 evas_software_x11_x_output_buffer_paste(obr->mxcbob,
711 free(xcb_get_input_focus_reply(buf->priv.x.conn, xcb_get_input_focus_unchecked(buf->priv.x.conn), NULL));
713 while (buf->priv.pending_writes)
718 im = evas_list_data(buf->priv.pending_writes);
719 buf->priv.pending_writes = evas_list_remove_list(buf->priv.pending_writes, buf->priv.pending_writes);
720 obr = im->extended_info;
721 evas_cache_image_drop(&im->cache_entry);
722 if (obr->xcbob) _unfind_xcbob(obr->xcbob, 0);
723 if (obr->mxcbob) _unfind_xcbob(obr->mxcbob, 0);
725 if (obr->xcbob) evas_software_x11_x_output_buffer_free(obr->xcbob, 0);
726 if (obr->mxcbob) evas_software_x11_x_output_buffer_free(obr->mxcbob, 0);
729 evas_cache_image_drop(&im->cache_entry);
733 evas_common_cpu_end_opt();
737 evas_software_xcb_outbuf_idle_flush(Outbuf *buf)
739 if (buf->priv.onebuf)
744 im = buf->priv.onebuf;
745 buf->priv.onebuf = NULL;
746 obr = im->extended_info;
747 if (obr->xcbob) evas_software_xcb_x_output_buffer_free(obr->xcbob, 0);
748 if (obr->mxcbob) evas_software_xcb_x_output_buffer_free(obr->mxcbob, 0);
750 evas_cache_image_drop(&im->cache_entry);
754 if (buf->priv.prev_pending_writes)
755 free(xcb_get_input_focus_reply(buf->priv.x.conn, xcb_get_input_focus_unchecked(buf->priv.x.conn), NULL));
756 while (buf->priv.prev_pending_writes)
761 im = buf->priv.prev_pending_writes->data;
762 buf->priv.prev_pending_writes =
763 evas_list_remove_list(buf->priv.prev_pending_writes,
764 buf->priv.prev_pending_writes);
765 obr = im->extended_info;
766 evas_cache_image_drop(&im->cache_entry);
767 if (obr->xcbob) _unfind_xcbob(obr->xcbob, 0);
768 if (obr->mxcbob) _unfind_xcbob(obr->mxcbob, 0);
776 evas_software_xcb_outbuf_push_updated_region(Outbuf *buf,
783 Gfx_Func_Convert conv_func = NULL;
790 obr = update->extended_info;
793 if ((buf->rot == 0) || (buf->rot == 180))
794 conv_func = evas_common_convert_func_get(0, w, h,
795 evas_software_xcb_x_output_buffer_depth
796 (obr->xcbob), buf->priv.mask.r,
797 buf->priv.mask.g, buf->priv.mask.b,
798 buf->priv.pal->colors, buf->rot);
799 else if ((buf->rot == 90) || (buf->rot == 270))
800 conv_func = evas_common_convert_func_get(0, h, w,
801 evas_software_xcb_x_output_buffer_depth
802 (obr->xcbob), buf->priv.mask.r,
803 buf->priv.mask.g, buf->priv.mask.b,
804 buf->priv.pal->colors, buf->rot);
808 if ((buf->rot == 0) || (buf->rot == 180))
809 conv_func = evas_common_convert_func_get(0, w, h,
810 evas_software_xcb_x_output_buffer_depth
811 (obr->xcbob), buf->priv.mask.r,
812 buf->priv.mask.g, buf->priv.mask.b,
813 PAL_MODE_NONE, buf->rot);
814 else if ((buf->rot == 90) || (buf->rot == 270))
815 conv_func = evas_common_convert_func_get(0, h, w,
816 evas_software_xcb_x_output_buffer_depth
817 (obr->xcbob), buf->priv.mask.r,
818 buf->priv.mask.g, buf->priv.mask.b,
819 PAL_MODE_NONE, buf->rot);
821 if (!conv_func) return;
823 data = evas_software_xcb_x_output_buffer_data(obr->xcbob, &bpl);
824 src_data = update->image.data;
830 else if (buf->rot == 90)
833 obr->y = buf->w - x - w;
835 else if (buf->rot == 180)
837 obr->x = buf->w - x - w;
838 obr->y = buf->h - y - h;
840 else if (buf->rot == 270)
842 obr->x = buf->h - y - h;
845 if ((buf->rot == 0) || (buf->rot == 180))
850 else if ((buf->rot == 90) || (buf->rot == 270))
857 if (data != src_data)
858 conv_func(src_data, data,
861 ((evas_software_xcb_x_output_buffer_depth(obr->xcbob) / 8)) - obr->w,
862 obr->w, obr->h, x, y,
863 buf->priv.pal->lookup);
867 if (data != src_data)
868 conv_func(src_data, data,
871 ((evas_software_xcb_x_output_buffer_depth(obr->xcbob) / 8)) - obr->w,
872 obr->w, obr->h, x, y, NULL);
877 if (!((buf->priv.onebuf) && (buf->priv.onebuf_regions)))
880 evas_software_xcb_outbuf_debug_show(buf, buf->priv.x.win,
881 obr->x, obr->y, obr->w, obr->h);
882 evas_software_xcb_x_output_buffer_paste(obr->xcbob, buf->priv.x.win,
889 for (yy = 0; yy < obr->h; yy++)
890 evas_software_xcb_x_write_mask_line(buf, obr->mxcbob,
891 src_data + (yy * obr->w),
897 if (!((buf->priv.onebuf) && (buf->priv.onebuf_regions)))
898 evas_software_xcb_x_output_buffer_paste(obr->mxcbob,
906 xcb_flush(buf->priv.x.conn);
911 evas_software_xcb_outbuf_reconfigure(Outbuf *buf,
920 (depth == buf->depth)) return;
924 evas_software_xcb_outbuf_idle_flush(buf);
928 evas_software_xcb_outbuf_get_width(Outbuf * buf)
934 evas_software_xcb_outbuf_get_height(Outbuf * buf)
940 evas_software_xcb_outbuf_get_depth(Outbuf * buf)
946 evas_software_xcb_outbuf_get_rot(Outbuf * buf)
952 evas_software_xcb_outbuf_drawable_set(Outbuf *buf,
955 if (buf->priv.x.win == draw) return;
958 xcb_free_gc(buf->priv.x.conn, buf->priv.x.gc);
961 buf->priv.x.win = draw;
962 buf->priv.x.gc = xcb_generate_id(buf->priv.x.conn);
963 xcb_create_gc(buf->priv.x.conn, buf->priv.x.gc, buf->priv.x.win, 0, NULL);
967 evas_software_xcb_outbuf_mask_set(Outbuf *buf,
970 if (buf->priv.x.mask == mask) return;
973 xcb_free_gc(buf->priv.x.conn, buf->priv.x.gcm);
976 buf->priv.x.mask = mask;
977 if (buf->priv.x.mask)
979 buf->priv.x.gcm = xcb_generate_id(buf->priv.x.conn);
980 xcb_create_gc(buf->priv.x.conn, buf->priv.x.gcm, buf->priv.x.win, 0, NULL);
985 evas_software_xcb_outbuf_debug_set(Outbuf *buf,
988 buf->priv.debug = debug;
991 evas_software_xcb_outbuf_debug_show(Outbuf *buf,
999 xcb_screen_t *screen = NULL;
1002 xcb_get_geometry_reply_t *geom;
1003 xcb_drawable_t root;
1004 xcb_screen_iterator_t i;
1006 geom = xcb_get_geometry_reply (buf->priv.x.conn, xcb_get_geometry_unchecked(buf->priv.x.conn, draw), 0);
1009 geom = xcb_get_geometry_reply (buf->priv.x.conn, xcb_get_geometry_unchecked(buf->priv.x.conn, root), 0);
1011 i = xcb_setup_roots_iterator((xcb_setup_t *)xcb_get_setup(buf->priv.x.conn));
1012 for (; i.rem; xcb_screen_next(&i))
1013 if (i.data->root == geom->root)
1020 for (i = 0; i < 20; i++)
1022 /* xcb_image_t *image; */
1023 xcb_rectangle_t rect = { x, y, w, h};
1027 mask = XCB_GC_FOREGROUND | XCB_GC_GRAPHICS_EXPOSURES;
1028 value[0] = screen->black_pixel;
1029 value[1] = XCB_EXPOSURES_NOT_ALLOWED; /* no graphics exposures allowed */
1030 xcb_change_gc(buf->priv.x.conn, buf->priv.x.gc, mask, value);
1031 xcb_poly_fill_rectangle (buf->priv.x.conn, draw, buf->priv.x.gc, 1, &rect);
1033 free(xcb_get_input_focus_reply(buf->priv.x.conn, xcb_get_input_focus_unchecked(buf->priv.x.conn), NULL));
1034 // image = xcb_image_get(buf->priv.x.conn, draw, x, y, w, h, XCB_ALL_PLANES, XCB_IMAGE_FORMAT_Z_PIXMAP);
1036 // xcb_image_destroy(image);
1038 free(xcb_get_input_focus_reply(buf->priv.x.conn, xcb_get_input_focus_unchecked(buf->priv.x.conn), NULL));
1039 mask = XCB_GC_FOREGROUND | XCB_GC_GRAPHICS_EXPOSURES;
1040 value[0] = screen->white_pixel;
1041 value[1] = XCB_EXPOSURES_NOT_ALLOWED; /* no graphics exposures allowed */
1042 xcb_change_gc(buf->priv.x.conn, buf->priv.x.gc, mask, value);
1043 xcb_poly_fill_rectangle (buf->priv.x.conn, draw, buf->priv.x.gc, 1, &rect);
1045 free(xcb_get_input_focus_reply(buf->priv.x.conn, xcb_get_input_focus_unchecked(buf->priv.x.conn), NULL));
1046 // image = xcb_image_get(buf->priv.x.conn, draw, x, y, w, h, XCB_ALL_PLANES, XCB_IMAGE_FORMAT_Z_PIXMAP);
1048 // xcb_image_destroy(image);
1050 free(xcb_get_input_focus_reply(buf->priv.x.conn, xcb_get_input_focus_unchecked(buf->priv.x.conn), NULL));