#include #include "lx.h" #include "proto.h" #include "internal.h" typedef struct priv_GetGeometry PRIV_GetGeometry; struct priv_GetGeometry { LX_GET_GEOMETRY *geom; } ; static void done_GetGeometry(LX_OP *op, const unsigned char *rep) { PRIV_GetGeometry *p; LX_GET_GEOMETRY g; p = op->reqpriv; do <"ret"> { if (r_card32(rep+4) != 0) { lx__protoerr(op->conn,"GetGeometry response length wrong (%u, expecting 0)",r_card32(rep+4)); break <"ret">; } if (p->geom) { g.depth = rep[1]; g.root = r_card32(rep+8); g.x = r_int16(rep+12); g.y = r_int16(rep+14); g.w = r_card16(rep+16); g.h = r_card16(rep+18); g.borderwidth = r_card16(rep+20); *p->geom = g; } } while (0); op->reqpriv = 0; free(p); } LX_OP *lx_GetGeometry(LX_CONN *xc, LX_XID drawable, LX_GET_GEOMETRY *geom) { unsigned char req[8]; PRIV_GetGeometry *p; if (xc->flags & XCF_FAIL) { lx__bad_call(xc,"lx_GetGeometry"); return(0); } p = malloc(sizeof(PRIV_GetGeometry)); if (! p) { lx__nomem_fail(xc); return(0); } p->geom = geom; req[0] = XP_REQ_GetGeometry; req[1] = 0; w_card16(&req[2],2); w_card32(&req[4],drawable); return(lx__expect_reply(xc,&req[0],8,&done_GetGeometry,p,0)); }