<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Problem solved.<br>
<br>
The "values[]" variable was too small to store all values.<br>
<strike> CARD32 values[2]; <br>
<br>
</strike> CARD32 values[10]; <br>
<br>
Thanks.<br>
<br>
-------------------------------------------------------------<br>
This code is OK.<br>
<br>
<br>
sel_rect = XCBGCONTEXTNew (c);
<br>
<br>
mask = XCBGCFunction/*0*/ | XCBGCForeground/*2*/ |
<br>
XCBGCBackground/*3*/ | XCBGCLineWidth/*4*/ |
<br>
XCBGCLineStyle/*5*/ | XCBGCGraphicsExposures/*16*/;
<br>
<br>
// In same order as the mask.
<br>
values[0] = XCBGXxor; // XCBGCFunction
<br>
values[1] = screen->white_pixel; // XCBGCForeground
<br>
values[2] = 0x1ecf48; // XCBGCBackground (light
green)
<br>
values[3] = 1; // XCBGCLineWidth
<br>
values[4] = XCBLineStyleOnOffDash; // XCBGCLineStyle
<br>
values[5] = 0; //
XCBGCGraphicsExposures
<br>
<br>
XCBCreateGC (c, sel_rect, win, mask, values);
<br>
....<br>
<br>
// Draw using the XOR (XCBGXxor) pen.
<br>
<br>
case XCBExpose:
<br>
{
<br>
XCBPolyLine (c, CoordModeOrigin, win, sel_rect, 4, polyline);
<br>
XCBPolyRectangle (c, win, sel_rect, 2, rectangles);
<br>
<br>
XCBSync (c, 0);
<br>
<br>
break;
<br>
}
<br>
<br>
case XCBButtonPress:
<br>
{
<br>
// Each second click will make the lines visible (XOR'ing pixels).<br>
XCBPolyLine (c, CoordModeOrigin, win, sel_rect, 4, polyline);
<br>
XCBPolyRectangle (c, win, sel_rect, 2, rectangles);
<br>
}
<br>
<br>
...<br>
<br>
<br>
<br>
<br>
Osmo Maatta wrote:
<blockquote cite="mid446C38B3.7010606@gmail.com" type="cite">Hello, <br>
<br>
I try to create a GC (graphic context) to draw some rubber lines using
the XOR pen. <br>
<br>
I do this: <br>
<br>
XCBGCONTEXT sel_rect; <br>
.... <br>
<br>
sel_rect = XCBGCONTEXTNew (c); <br>
mask = XCBGCFunction | XCBGCForeground | XCBGCLineStyle |
XCBGCGraphicsExposures; <br>
values[0] = XCBGXxor; values[1] = screen->black_pixel; <br>
values[2] = XCBLineStyleOnOffDash; <br>
values[3] = 0; <br>
XCBCreateGC (c, sel_rect, win, mask, values); <br>
<br>
<br>
and later in <br>
<br>
case XCBExpose: <br>
{ <br>
printf("Debug expose\n"); <br>
<br>
XCBPolyRectangle (c, win, sel_rect, 2, rectangles); <br>
XCBPolyLine (c, CoordModeOrigin, win, sel_rect, 4, polyline);
<br>
<br>
break; <br>
} <br>
--------------------------------- <br>
But it does not draw anything. Only the debug line appears on the
console. <br>
------------------- <br>
<br>
I have even tried with XCBGXcopy value as XCBGCFunction. <br>
<br>
values[0] = XCBGXcopy; <br>
Xlib manual says that GXcopy is the default GCFunction. I suppose it's
the same in XCB. <br>
But it does not work. <br>
<br>
It works (draws lines in a window) if I remove XCBGCFunction from the
mask and remove the value[0]= line. <br>
How to use the values for XCBGCFunction mask ? <br>
------------------------------------------------------------------- <br>
<br>
I follow this tutorial <br>
<a class="moz-txt-link-freetext"
href="http://www.iecn.u-nancy.fr/%7Etorri/files/xcb/doc/">http://www.iecn.u-nancy.fr/~torri/files/xcb/doc/</a>
<br>
<br>
Many TIA. <br>
Osmo <br>
<br>
_______________________________________________ <br>
Xcb mailing list <br>
<a class="moz-txt-link-abbreviated"
href="mailto:Xcb@lists.freedesktop.org">Xcb@lists.freedesktop.org</a> <br>
<a class="moz-txt-link-freetext"
href="http://lists.freedesktop.org/mailman/listinfo/xcb">http://lists.freedesktop.org/mailman/listinfo/xcb</a>
<br>
<br>
</blockquote>
<br>
<br>
</body>
</html>