From f049b883c13a8374e294fc55bc7ee6b64d4cbc6f Mon Sep 17 00:00:00 2001 From: David Hill Date: Tue, 3 Jul 2012 16:41:25 -0400 Subject: [PATCH] make get_iconic use xcb --- spectrwm.c | 43 ++++++++++++++++++++++++------------------- 1 file changed, 24 insertions(+), 19 deletions(-) diff --git a/spectrwm.c b/spectrwm.c index 63e925a..bad65b5 100644 --- a/spectrwm.c +++ b/spectrwm.c @@ -675,28 +675,33 @@ update_iconic(struct ws_win *win, int newv) int get_iconic(struct ws_win *win) { - int32_t v = 0; - int retfmt, status; - Atom iprop, rettype; - unsigned long nitems, extra; - unsigned char *prop = NULL; - - iprop = XInternAtom(display, "_SWM_ICONIC", False); - if (!iprop) - goto out; - status = XGetWindowProperty(display, win->id, iprop, 0L, 1L, - False, XA_INTEGER, &rettype, &retfmt, &nitems, &extra, &prop); - if (status != Success) - goto out; - if (rettype != XA_INTEGER || retfmt != 32) - goto out; - if (nitems != 1) + int32_t v = 0, *vtmp; + xcb_atom_t iprop; + xcb_intern_atom_cookie_t c; + xcb_intern_atom_reply_t *r; + xcb_get_property_cookie_t pc; + xcb_get_property_reply_t *pr; + + c = xcb_intern_atom(conn, False, strlen("_SWM_ICONIC"), "_SWM_ICONIC"); + r = xcb_intern_atom_reply(conn, c, NULL); + if (r) { + iprop = r->atom; + free(r); + } else goto out; - v = *((int32_t *)prop); + pc = xcb_get_property(conn, False, win->id, iprop, XCB_ATOM_INTEGER, + 0, 1); + pr = xcb_get_property_reply(conn, pc, NULL); + if (!pr) + goto out; + if (pr->type != XCB_ATOM_INTEGER || pr->format != 32) + goto out; + vtmp = xcb_get_property_value(pr); + v = *vtmp; out: - if (prop != NULL) - XFree(prop); + if (pr != NULL) + free(pr); return (v); } -- 1.7.10.4