[Xcb] A simple question on XCBGCFunction [SOLVED]

Osmo Maatta osmoma at online.no
Thu May 18 07:30:59 PDT 2006


Problem solved.

The "values[]" variable was too small to store all values.
  CARD32   values[2];  

  CARD32   values[10];  

Thanks.

-------------------------------------------------------------
This code is OK.


sel_rect = XCBGCONTEXTNew (c);

mask = XCBGCFunction/*0*/      | XCBGCForeground/*2*/   |
             XCBGCBackground/*3*/ | XCBGCLineWidth/*4*/      |
            XCBGCLineStyle/*5*/       | XCBGCGraphicsExposures/*16*/;

// In same order as the mask.
values[0] = XCBGXxor;                      // XCBGCFunction
values[1] = screen->white_pixel;     // XCBGCForeground
values[2] = 0x1ecf48;                        // XCBGCBackground (light 
green)
values[3] = 1;                                     // XCBGCLineWidth
values[4] = XCBLineStyleOnOffDash;  // XCBGCLineStyle
values[5] = 0;                                         // 
XCBGCGraphicsExposures

XCBCreateGC (c, sel_rect, win, mask, values);
....

// Draw using the XOR (XCBGXxor) pen.

case XCBExpose:
  {
    XCBPolyLine (c, CoordModeOrigin, win, sel_rect, 4, polyline);
    XCBPolyRectangle (c, win, sel_rect, 2, rectangles);

    XCBSync (c, 0);

    break;
  }

case XCBButtonPress:
 {
    // Each second click will make the lines visible (XOR'ing pixels).
    XCBPolyLine (c, CoordModeOrigin, win, sel_rect, 4, polyline);
    XCBPolyRectangle (c, win, sel_rect, 2, rectangles);
 }

...




Osmo Maatta wrote:
> Hello,
>
> I try to create a GC (graphic context) to draw some rubber lines using 
> the XOR pen.
>
> I do this:
>
>  XCBGCONTEXT    sel_rect;
>  ....
>
>  sel_rect = XCBGCONTEXTNew (c);
>  mask =   XCBGCFunction | XCBGCForeground | XCBGCLineStyle | 
> XCBGCGraphicsExposures;
>  values[0] = XCBGXxor;  values[1] = screen->black_pixel;
>  values[2] = XCBLineStyleOnOffDash;
>  values[3] = 0;
>  XCBCreateGC (c, sel_rect,  win, mask, values);
>
>
> and later in
>
> case XCBExpose:
> {
>     printf("Debug expose\n");
>
>     XCBPolyRectangle (c, win, sel_rect, 2, rectangles);
>           XCBPolyLine (c, CoordModeOrigin, win, sel_rect, 4, polyline);
>
>     break;
> }
> ---------------------------------
>   But it does not draw anything. Only the debug line appears on the 
> console.
> -------------------
>
> I have even tried with  XCBGXcopy  value as XCBGCFunction.
>
> values[0] = XCBGXcopy;
> Xlib manual says that GXcopy is the default GCFunction. I suppose it's 
> the same in XCB.
> But it does not work.
>
> It works (draws lines in a window) if I remove XCBGCFunction from the 
> mask and remove the value[0]= line.
> How to use the values for XCBGCFunction mask ?
> -------------------------------------------------------------------
>
> I follow this tutorial
> http://www.iecn.u-nancy.fr/~torri/files/xcb/doc/
>
> Many TIA.
>  Osmo
>
> _______________________________________________
> Xcb mailing list
> Xcb at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/xcb
>


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freedesktop.org/archives/xcb/attachments/20060518/f4a44b1a/attachment.html


More information about the Xcb mailing list