#include #include "lx.h" #include "proto.h" #include "internal.h" typedef struct priv_GetWindowAttributes PRIV_GetWindowAttributes; struct priv_GetWindowAttributes { LX_GET_WINDOW_ATTRIBUTES *attrs; } ; static void done_GetWindowAttributes(LX_OP *op, const unsigned char *rep) { PRIV_GetWindowAttributes *p; LX_GET_WINDOW_ATTRIBUTES a; p = op->reqpriv; do <"ret"> { if (r_card32(rep+4) != 3) { lx__protoerr(op->conn,"GetWindowAttributes response length wrong (%u, expecting 3)",r_card32(rep+4)); break <"ret">; } a.backing_store = lx__proto_to_backingstore(rep[1]); if (a.backing_store == LX__map_error) { lx__protoerr(op->conn,"GetWindowAttributes returned invalid backing-store value %u",rep[1]); break <"ret">; } a.visual = r_card32(rep+8); a.class = lx__proto_to_wclass(r_card16(rep+12)); if (a.class == LX__map_error) { lx__protoerr(op->conn,"GetWindowAttributes returned invalid class value %u",r_card16(rep+12)); break <"ret">; } a.bit_gravity = lx__proto_to_bitgravity(rep[14]); if (a.bit_gravity == LX__map_error) { lx__protoerr(op->conn,"GetWindowAttributes returned invalid bit-gravity value %u",rep[14]); break <"ret">; } a.win_gravity = lx__proto_to_wingravity(rep[15]); if (a.win_gravity == LX__map_error) { lx__protoerr(op->conn,"GetWindowAttributes returned invalid win-gravity value %u",rep[14]); break <"ret">; } a.backing_planes = r_card32(rep+16); a.backing_pixel = r_card32(rep+20); a.save_under = lx__proto_to_boolean(rep[24]); if (a.save_under < 0) { lx__protoerr(op->conn,"GetWindowAttributes returned invalid save-under value %u",rep[24]); break <"ret">; } a.cmap_installed = lx__proto_to_boolean(rep[25]); if (a.cmap_installed < 0) { lx__protoerr(op->conn,"GetWindowAttributes returned invalid map-is-installed value %u",rep[25]); break <"ret">; } a.map_state = lx__proto_to_mapstate(rep[26]); if (a.map_state == LX__map_error) { lx__protoerr(op->conn,"GetWindowAttributes returned invalid map-state value %u",rep[26]); break <"ret">; } a.override_redirect = lx__proto_to_boolean(rep[27]); if (a.override_redirect < 0) { lx__protoerr(op->conn,"GetWindowAttributes returned invalid override-redirect value %u",rep[27]); break <"ret">; } a.colormap = r_card32(rep+28); if (a.colormap == 0) a.colormap = LX_COLORMAP_None; a.all_events = r_card32(rep+32); if (a.all_events & EVM_EVENT_MBZ) { lx__protoerr(op->conn,"GetWindowAttributes returned invalid all-events value 0x%08lx",(unsigned long int)a.all_events); break <"ret">; } a.our_events = r_card32(rep+36); if (a.our_events & EVM_EVENT_MBZ) { lx__protoerr(op->conn,"GetWindowAttributes returned invalid our-events value 0x%08lx",(unsigned long int)a.our_events); break <"ret">; } a.dont_propagate = r_card16(rep+40); if (a.dont_propagate & EVM_DEVICEEVENT_MBZ) { lx__protoerr(op->conn,"GetWindowAttributes returned invalid our-events value 0x%08lx",(unsigned long int)a.our_events); break <"ret">; } if (p->attrs) *p->attrs = a; } while (0); op->reqpriv = 0; free(p); } LX_OP *lx_GetWindowAttributes(LX_CONN *xc, LX_XID window, LX_GET_WINDOW_ATTRIBUTES *attrs) { unsigned char req[8]; PRIV_GetWindowAttributes *p; if (xc->flags & XCF_FAIL) { lx__bad_call(xc,"lx_GetWindowAttributes"); return(0); } p = malloc(sizeof(PRIV_GetWindowAttributes)); if (! p) { lx__nomem_fail(xc); return(0); } p->attrs = attrs; req[0] = XP_REQ_GetWindowAttributes; req[1] = 0; w_card16(&req[2],2); w_card32(&req[4],window); return(lx__expect_reply(xc,&req[0],-1,&done_GetWindowAttributes,p)); }