tags:

views:

87

answers:

1

From the XDrawString man page it seems that it aceepts signed 32 bit x and y coordinates

int XDrawString(Display *display, Drawable d, GC gc, int x, int y, char *string, int length);

Note how both x and y are int ( ie: 32 bit signed Integer on gcc/linux2.6-i386 at least )

The problem is when I pass y = 32767 ( 2^15 - 1) the string is drawn in the correct location but anything above this value the string is not drawn.

I suspect that internally 32 bit integers are not used but instead 16 bit signed integers for the coordinates.

Given that the man pages seem to indicate that the function accepts 32 bit integers, is there some compile option that needs to be turned to allow the use of the longer integers? Or is this a limmitation of Xlib?

+2  A: 

The X11 protocol does specify 16 bits.

Have a look at the definition for xPolyTextReq in <X11/Xproto.h>

typedef struct {
    CARD8 reqType;
    CARD8 pad;
    CARD16 length B16;
    Drawable drawable B32;
    GContext gc B32;
    INT16 x B16, y B16;         /* items (xTextElt) start after struct */
} xPolyTextReq;
Alnitak
Is there anyway around this?
hhafez
Not that I know of - looking at the Xlib source suggests that all coordinates are 16 bit. I can't see why you'd need coordinates larger than that...
Alnitak
I need it ;) It's not an absolute coordinate on a screen but on a scrolling lsit of widgets
hhafez
that's a *big* list of widgets!
Alnitak
yeah a few thousand, it's a customer requirment to able to display all entries in a window :/ not practical to use ever, but it's in the contract and will be tested.
hhafez
In that case, use separate scrollbar widgets that aren't part of a scrolling viewport, and redraw only those entries that are visible based on the scrollbar position.
Alnitak