// Copyright status: this file is in the public domain. #include #include #include #include #include #include typedef struct queryextents_priv QUERYEXTENTS_PRIV; struct queryextents_priv { unsigned int *shaped; int *bx; int *by; int *bw; int *bh; int *cx; int *cy; int *cw; int *ch; } ; static void done_shape_QueryExtents(LX_CONN *xc, const unsigned char *rep, void *pv, unsigned int flags) { QUERYEXTENTS_PRIV *p; int v; unsigned int shaped; p = pv; do <"ret"> { if (lx_xi_r_card32(rep+4) != 0) { lx_xi_protoerr(xc,"SHAPE QueryExtents response length wrong (%u, expecting 0)",lx_xi_r_card32(rep+4)); break <"ret">; } shaped = 0; v = lx_xi_proto_to_boolean(rep[8]); if (v < 0) { lx_xi_protoerr(xc,"invalid bounding-shaped %d in SHAPE QueryExtents",rep[8]); break <"ret">; } if (v) shaped |= LX_SHAPED_Bounding; v = lx_xi_proto_to_boolean(rep[9]); if (v < 0) { lx_xi_protoerr(xc,"invalid clip-shaped %d in SHAPE QueryExtents",rep[8]); break <"ret">; } if (v) shaped |= LX_SHAPED_Clip; if (! (flags & LX_XI_DONE_NOWRITE)) { if (p->shaped) *p->shaped = shaped; if (p->bx) *p->bx = lx_xi_r_int16(&rep[12]); if (p->by) *p->by = lx_xi_r_int16(&rep[14]); if (p->bw) *p->bw = lx_xi_r_card16(&rep[16]); if (p->bh) *p->bh = lx_xi_r_card16(&rep[18]); if (p->cx) *p->cx = lx_xi_r_int16(&rep[20]); if (p->cy) *p->cy = lx_xi_r_int16(&rep[22]); if (p->cw) *p->cw = lx_xi_r_card16(&rep[24]); if (p->ch) *p->ch = lx_xi_r_card16(&rep[26]); } } while (0); free(p); } LX_OP *lx_shape_QueryExtents(LX_CONN *xc, LX_XID win, unsigned int *shaped, int *bx, int *by, int *bw, int *bh, int *cx, int *cy, int *cw, int *ch) { LX_SHAPE_PRIV *p; QUERYEXTENTS_PRIV *qp; unsigned char req[8]; p = lx_get_private(xc,lx_shape__px); if (! p) { lx_xi_bad_call(xc,"lx_shape_QueryExtents"); return(0); } qp = malloc(sizeof(QUERYEXTENTS_PRIV)); if (! qp) { lx_xi_nomem_fail(xc); return(0); } qp->shaped = shaped; qp->bx = bx; qp->by = by; qp->bw = bw; qp->bh = bh; qp->cx = cx; qp->cy = cy; qp->cw = cw; qp->ch = ch; lx_xi_nochain(xc); req[0] = p->major; req[1] = SHAPE_QueryExtents; lx_xi_w_card16(&req[2],2); lx_xi_w_card32(&req[4],win); return(lx_xi_expect_reply(xc,req,-1,&done_shape_QueryExtents,qp)); } LX_OP *lx_shape_QueryExtents_extents(LX_CONN *xc, LX_XID win, LX_SHAPE_EXTENTS *ep) { LX_SHAPE_PRIV *p; QUERYEXTENTS_PRIV *qp; unsigned char req[8]; if (lx_xi_conn_failed(xc)) { lx_xi_bad_call(xc,"ls_shape_GetRectangles"); return(0); } p = lx_get_private(xc,lx_shape__px); if (! p) { lx_xi_bad_call(xc,"lx_shape_QueryExtents"); return(0); } qp = malloc(sizeof(QUERYEXTENTS_PRIV)); if (! qp) { lx_xi_nomem_fail(xc); return(0); } qp->shaped = ep ? &ep->shaped : 0; qp->bx = ep ? &ep->bounding.x : 0; qp->by = ep ? &ep->bounding.y : 0; qp->bw = ep ? &ep->bounding.w : 0; qp->bh = ep ? &ep->bounding.h : 0; qp->cx = ep ? &ep->clip.x : 0; qp->cy = ep ? &ep->clip.y : 0; qp->cw = ep ? &ep->clip.w : 0; qp->ch = ep ? &ep->clip.h : 0; lx_xi_nochain(xc); req[0] = p->major; req[1] = SHAPE_QueryExtents; lx_xi_w_card16(&req[2],2); lx_xi_w_card32(&req[4],win); return(lx_xi_expect_reply(xc,req,-1,&done_shape_QueryExtents,qp)); }