[PATCH 3/3] A small test app for ewmh_get_wm_icon_*

Uli Schlachter psychon at znc.in
Fri Mar 11 02:27:44 PST 2011


This is not intended to be merged anywhere! I just wanted to make sure this
stuff works.

NOT-Signed-off-by: Uli Schlachter <psychon at znc.in>
---
 ewmh/Makefile.am |    4 +++
 ewmh/foo.c       |   56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 60 insertions(+), 0 deletions(-)
 create mode 100644 ewmh/foo.c

diff --git a/ewmh/Makefile.am b/ewmh/Makefile.am
index 42b3a40..78fe295 100644
--- a/ewmh/Makefile.am
+++ b/ewmh/Makefile.am
@@ -23,3 +23,7 @@ ewmh.c: ewmh.c.m4 atomlist.m4
 
 xcb_ewmh.h: xcb_ewmh.h.m4 atomlist.m4
 	$(M4) -I$(srcdir) $< >$@
+
+bin_PROGRAMS = foo
+foo_LDADD = libxcb-ewmh.la -lxcb
+foo_SOURCES = foo.c
diff --git a/ewmh/foo.c b/ewmh/foo.c
new file mode 100644
index 0000000..8d80e8c
--- /dev/null
+++ b/ewmh/foo.c
@@ -0,0 +1,56 @@
+#include <xcb_ewmh.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+int main(int argc, char *argv[])
+{
+	xcb_connection_t *c;
+	xcb_window_t w;
+	xcb_intern_atom_cookie_t *atom_cookie;
+	xcb_get_property_cookie_t prop_cookie;
+	xcb_ewmh_connection_t ewmh;
+	xcb_ewmh_get_wm_icon_reply_t wm_icon;
+	unsigned int i;
+
+	if (argc < 2) {
+		printf("Usage: %s <win-id>\n", argv[0]);
+		return 1;
+	}
+
+	w = strtol(argv[1], NULL, 0);
+	if (w == XCB_NONE) {
+		fprintf(stderr, "Invalid argument!\n");
+		return 1;
+	}
+	c = xcb_connect(NULL, NULL);
+	atom_cookie = xcb_ewmh_init_atoms(c, &ewmh);
+	if (atom_cookie == NULL) {
+		fprintf(stderr, "Can not request atoms\n");
+		xcb_disconnect(c);
+		return 1;
+	}
+	if (!xcb_ewmh_init_atoms_replies(&ewmh, atom_cookie, NULL)) {
+		fprintf(stderr, "Can not get atom replies\n");
+		xcb_disconnect(c);
+		return 1;
+	}
+	prop_cookie = xcb_ewmh_get_wm_icon(&ewmh, w);
+	if (!xcb_ewmh_get_wm_icon_reply(&ewmh, prop_cookie, &wm_icon, NULL)) {
+		fprintf(stderr, "Can not get icon (window got no icon?)\n");
+		xcb_ewmh_connection_wipe(&ewmh);
+		xcb_disconnect(c);
+		return 1;
+	}
+
+	for (i = 0; i < EWMH_WM_ICON_MAX; i++) {
+		printf("Icon %2d%s: Width %u, Height %u, Data %p\n",
+				i, (i < wm_icon.num_icons) ? "" : " (invalid)",
+				wm_icon.icons[i].width,
+				wm_icon.icons[i].height,
+				wm_icon.icons[i].data);
+	}
+	xcb_ewmh_get_wm_icon_reply_wipe(&wm_icon);
+	xcb_ewmh_connection_wipe(&ewmh);
+	xcb_disconnect(c);
+	return 0;
+}
-- 
1.7.2.3


--------------090907060109020503090309
Content-Type: application/octet-stream;
 name="0001-_NET_WM_ICON-Fix-the-length-check.patch.sig"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
 filename="0001-_NET_WM_ICON-Fix-the-length-check.patch.sig"

iQEcBAABCAAGBQJNegSBAAoJECLkKOvLj8sGw6sIAJ0FHKXps3kEkVGSBIuub6s3Rz/kZOry
FsneTl7DVWgDF8WcGckolgxjQydAzWqg6p5uOlrkwYtuhtYSfC4tICQC3XlnB9Niu1P5/lcH
xTu/Xpw1cCytOhshrwM92ZCdt2b63Q9w3kQxvpdc7K+O3V3rDVgimMlFVikBNsPYoU7uMlxp
hZptC2UaO7KiviIXdfmhjvCJZ6OiOAie6qDfB+SgKzUFz6qAPtl1IQeROaFHUY4kndhs38Xg
I8mQreN8OPIOIR57bTQlxWLGNBV9l7uvjYvxgJVT4474Rl5MDh8TW9UmfghAKZ4oqQfuD5Gj
MLNRYfIhyfKoS9D18FJycoQ=
--------------090907060109020503090309
Content-Type: application/octet-stream;
 name="0002-Return-more-icons-from-_NET_WM_ICON.patch.sig"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
 filename="0002-Return-more-icons-from-_NET_WM_ICON.patch.sig"

iQEcBAABCAAGBQJNegSBAAoJECLkKOvLj8sG41oIAI1a1Udnj8rzApyYO46uo/nz7Zl1JBBf
6GE6XrgS4BcUCtDlsoR5W+O3whC8ex07gD1DVtpPtqJs8puIxfRueU4osC4LGoYokHrJ3V6j
hkG8rD6xNKfJuO1RleCY+1BMez90tKdMZP8XA4Zj8VOuMJnvBaTm84QZTVV1JdDEh2X9n5rn
pP1dkgHDcevxBPC3epjb8S7Y5Vaec+zhHvHAYsvNsdHKjxY9Tf7HZAZ9489fKD+z3ged0H9q
Kx0imCQdZqX3th5chvlNfDQU8dwoVEkpJmV5eH6jQw4JXMAjMkju02pJDty7ZPsP23FxfFqy
kuwBlSrrYrOkxps9BN5hK8o=
--------------090907060109020503090309
Content-Type: application/octet-stream;
 name="0003-A-small-test-app-for-ewmh_get_wm_icon_.patch.sig"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
 filename="0003-A-small-test-app-for-ewmh_get_wm_icon_.patch.sig"

iQEcBAABCAAGBQJNegSBAAoJECLkKOvLj8sGyEUIAK/fb+T09cDhIHkJ0LAg9N4KB6DxfE9+
JhLDM4JNPv66tvOBnGr8mbNnmqD8IcQosr+33dUQQfWup8QK9HDZ+jxFSskQ1MG3q2eVTuwe
PcXmtVYoqaYwflnqvmBY/uhkH3jwNBLii171vjedL6paN8EVjjLQIFAtd3RQ84VP/2lHfocW
d6DkcrB9DLqPwfDFRiRMEoUEK1DomM/H9fQtKYIPxNr1YjWEikTi35Bi4JrbwsE+Gs5bP9EB
lBtlK5Cv4fx4ua+eRWsCgCr8PrLDZiSSw5wm3ueSeqO/iZ/Bxx5vm26flS34UbWisoQehV4S
oS5tQ2oFVgWdhGEO7kOTHUg=
--------------090907060109020503090309--


More information about the Xcb mailing list