Xnest: replace XDrawString[8|16]() by xcb_poly_text_[8|16]()
Replace XDrawString8() by xcb_poly_text_8(), as well as XDrawString16() by xcb_poly_text_16(). Some care needs to be taken to prepend the xTextElt header before sending the request out. GC operation handlers don't need to care about poly-strings or length above 254, as this is already handled by their caller, doPolyText(). Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
This commit is contained in:
parent
63627a9b9b
commit
d1d10dc245
|
@ -315,8 +315,24 @@ xnestPolyText8(DrawablePtr pDrawable, GCPtr pGC, int x, int y, int count,
|
||||||
{
|
{
|
||||||
int width;
|
int width;
|
||||||
|
|
||||||
XDrawString(xnestDisplay, xnestDrawable(pDrawable), xnestGC(pGC),
|
// we need to prepend a xTextElt struct before our actual characters
|
||||||
x, y, string, count);
|
// won't get more than 254 elements, since it's already processed by doPolyText()
|
||||||
|
int const bufsize = sizeof(xTextElt) + count;
|
||||||
|
uint8_t *buffer = malloc(bufsize);
|
||||||
|
xTextElt *elt = (xTextElt*)buffer;
|
||||||
|
elt->len = count;
|
||||||
|
elt->delta = 0;
|
||||||
|
memcpy(buffer+2, string, count);
|
||||||
|
|
||||||
|
xcb_poly_text_8(xnestUpstreamInfo.conn,
|
||||||
|
xnestDrawable(pDrawable),
|
||||||
|
xnest_upstream_gc(pGC),
|
||||||
|
x,
|
||||||
|
y,
|
||||||
|
bufsize,
|
||||||
|
(uint8_t*)buffer);
|
||||||
|
|
||||||
|
free(buffer);
|
||||||
|
|
||||||
width = XTextWidth(xnestFontStruct(pGC->font), string, count);
|
width = XTextWidth(xnestFontStruct(pGC->font), string, count);
|
||||||
|
|
||||||
|
@ -329,8 +345,24 @@ xnestPolyText16(DrawablePtr pDrawable, GCPtr pGC, int x, int y, int count,
|
||||||
{
|
{
|
||||||
int width;
|
int width;
|
||||||
|
|
||||||
XDrawString16(xnestDisplay, xnestDrawable(pDrawable), xnestGC(pGC),
|
// we need to prepend a xTextElt struct before our actual characters
|
||||||
x, y, (XChar2b *) string, count);
|
// won't get more than 254 elements, since it's already processed by doPolyText()
|
||||||
|
int const bufsize = sizeof(xTextElt) + count*2;
|
||||||
|
uint8_t *buffer = malloc(bufsize);
|
||||||
|
xTextElt *elt = (xTextElt*)buffer;
|
||||||
|
elt->len = count;
|
||||||
|
elt->delta = 0;
|
||||||
|
memcpy(buffer+2, string, count*2);
|
||||||
|
|
||||||
|
xcb_poly_text_16(xnestUpstreamInfo.conn,
|
||||||
|
xnestDrawable(pDrawable),
|
||||||
|
xnest_upstream_gc(pGC),
|
||||||
|
x,
|
||||||
|
y,
|
||||||
|
bufsize,
|
||||||
|
buffer);
|
||||||
|
|
||||||
|
free(buffer);
|
||||||
|
|
||||||
width = XTextWidth16(xnestFontStruct(pGC->font), (XChar2b *) string, count);
|
width = XTextWidth16(xnestFontStruct(pGC->font), (XChar2b *) string, count);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue