summaryrefslogtreecommitdiffstats
path: root/src/3rdparty/xcb/xcb-util/atoms.c
diff options
context:
space:
mode:
authorKai Koehne <kai.koehne@digia.com>2012-10-29 12:59:09 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2012-11-07 16:55:50 +0100
commit21bd66e1ea06e466754ab06ee2c5f8b737bb4bd7 (patch)
tree2680ca806c003ca2b37d3f6c8b5431f51a3695fe /src/3rdparty/xcb/xcb-util/atoms.c
parentf4121624e9067078249f0fad171c1f8c98271877 (diff)
Add configure option to minimize xcb runtime dependencies
Some of the xcb- libraries we depend upon are not (yet) common across distributions. This is problematic for binaries that should be working on different distributions. The patch mitigates this by: Adding the files from libxcb-proto (version 0.1.6), compiled with libxcb-1.5 xcb-util (version 0.3.9) xcb-util-image (version 0.3.9) xcb-util-keysyms (version 0.3.9) xcb-util-renderutil (version 0.3.8) xcb-util-wm (version 0.3.9) from xcb.freedesktop.org/dist to src/3rdparty/xcb. Adding a configure option '-qt-xcb' to use the sources instead of linking to the respective runtime libraries. Task-number: QTBUG-27803 Change-Id: I6ea87daa382871b2b9072a601511523fa0b9f44b Reviewed-by: Samuel Rødal <samuel.rodal@digia.com>
Diffstat (limited to 'src/3rdparty/xcb/xcb-util/atoms.c')
-rw-r--r--src/3rdparty/xcb/xcb-util/atoms.c76
1 files changed, 76 insertions, 0 deletions
diff --git a/src/3rdparty/xcb/xcb-util/atoms.c b/src/3rdparty/xcb/xcb-util/atoms.c
new file mode 100644
index 0000000000..7b3aec6c0e
--- /dev/null
+++ b/src/3rdparty/xcb/xcb-util/atoms.c
@@ -0,0 +1,76 @@
+/* Rely on vasprintf (GNU extension) instead of vsnprintf if
+ possible... */
+#ifdef HAVE_VASPRINTF
+#define _GNU_SOURCE
+#include <stdio.h>
+#endif
+
+#include <xcb/xcb.h>
+#include <stdlib.h>
+#include <stdarg.h>
+#include "xcb_atom.h"
+
+static char *makename(const char *fmt, ...)
+{
+ char *ret;
+ int n;
+ va_list ap;
+
+#ifndef HAVE_VASPRINTF
+ char *np;
+ int size = 64;
+
+ /* First allocate 'size' bytes, should be enough usually */
+ if((ret = malloc(size)) == NULL)
+ return NULL;
+
+ while(1)
+ {
+ va_start(ap, fmt);
+ n = vsnprintf(ret, size, fmt, ap);
+ va_end(ap);
+
+ if(n < 0)
+ return NULL;
+
+ if(n < size)
+ return ret;
+
+ size = n + 1;
+ if((np = realloc(ret, size)) == NULL)
+ {
+ free(ret);
+ return NULL;
+ }
+
+ ret = np;
+ }
+#else
+ va_start(ap, fmt);
+ n = vasprintf(&ret, fmt, ap);
+ va_end(ap);
+
+ if(n < 0)
+ return NULL;
+
+ return ret;
+#endif
+}
+
+char *xcb_atom_name_by_screen(const char *base, uint8_t screen)
+{
+ return makename("%s_S%u", base, screen);
+}
+
+char *xcb_atom_name_by_resource(const char *base, uint32_t resource)
+{
+ return makename("%s_R%08X", base, resource);
+}
+
+char *xcb_atom_name_unique(const char *base, uint32_t id)
+{
+ if(base)
+ return makename("%s_U%lu", base, id);
+ else
+ return makename("U%lu", id);
+}