aboutsummaryrefslogtreecommitdiff
path: root/libxcb/src
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2012-06-08 09:33:13 +0200
committermarha <marha@users.sourceforge.net>2012-06-08 09:33:13 +0200
commit990bc3f015a4f8fce2eb918375defcd44980a845 (patch)
tree8e8301f19482b52cc00bd95b4593522cc93267af /libxcb/src
parent1af6fc1b5d93e54d6674de8b5870448b29f139a7 (diff)
downloadvcxsrv-990bc3f015a4f8fce2eb918375defcd44980a845.tar.gz
vcxsrv-990bc3f015a4f8fce2eb918375defcd44980a845.tar.bz2
vcxsrv-990bc3f015a4f8fce2eb918375defcd44980a845.zip
Used synchronise script to update files
Diffstat (limited to 'libxcb/src')
-rw-r--r--libxcb/src/.gitignore29
-rw-r--r--libxcb/src/xcb_ext.c254
-rw-r--r--libxcb/src/xcb_list.c202
-rw-r--r--libxcb/src/xcb_xid.c194
-rw-r--r--libxcb/src/xcbext.h204
5 files changed, 456 insertions, 427 deletions
diff --git a/libxcb/src/.gitignore b/libxcb/src/.gitignore
new file mode 100644
index 000000000..a402afe57
--- /dev/null
+++ b/libxcb/src/.gitignore
@@ -0,0 +1,29 @@
+bigreq.*
+composite.*
+damage.*
+dpms.*
+dri2.*
+glx.*
+randr.*
+record.*
+render.*
+res.*
+screensaver.*
+shape.*
+shm.*
+sync.*
+xc_misc.*
+xevie.*
+xf86dri.*
+xfixes.*
+xinerama.*
+xinput.*
+xkb.*
+xprint.*
+xselinux.*
+xtest.*
+xv.*
+xvmc.*
+xproto.*
+xcb_des.c
+X11
diff --git a/libxcb/src/xcb_ext.c b/libxcb/src/xcb_ext.c
index 68bb29bdf..edad18da3 100644
--- a/libxcb/src/xcb_ext.c
+++ b/libxcb/src/xcb_ext.c
@@ -1,127 +1,127 @@
-/* Copyright (C) 2001-2004 Bart Massey and Jamey Sharp.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- * Except as contained in this notice, the names of the authors or their
- * institutions shall not be used in advertising or otherwise to promote the
- * sale, use or other dealings in this Software without prior written
- * authorization from the authors.
- */
-
-/* A cache for QueryExtension results. */
-
-#include <stdlib.h>
-#include <string.h>
-
-#include "xcb.h"
-#include "xcbext.h"
-#include "xcbint.h"
-
-typedef struct lazyreply {
- enum lazy_reply_tag tag;
- union {
- xcb_query_extension_cookie_t cookie;
- xcb_query_extension_reply_t *reply;
- } value;
-} lazyreply;
-
-static lazyreply *get_index(xcb_connection_t *c, int idx)
-{
- if(idx > c->ext.extensions_size)
- {
- int new_size = idx << 1;
- lazyreply *new_extensions = realloc(c->ext.extensions, sizeof(lazyreply) * new_size);
- if(!new_extensions)
- return 0;
- memset(new_extensions + c->ext.extensions_size, 0, sizeof(lazyreply) * (new_size - c->ext.extensions_size));
- c->ext.extensions = new_extensions;
- c->ext.extensions_size = new_size;
- }
- return c->ext.extensions + idx - 1;
-}
-
-static lazyreply *get_lazyreply(xcb_connection_t *c, xcb_extension_t *ext)
-{
- static pthread_mutex_t global_lock = PTHREAD_MUTEX_INITIALIZER;
- static int next_global_id;
-
- lazyreply *data;
-
- pthread_mutex_lock(&global_lock);
- if(!ext->global_id)
- ext->global_id = ++next_global_id;
- pthread_mutex_unlock(&global_lock);
-
- data = get_index(c, ext->global_id);
- if(data && data->tag == LAZY_NONE)
- {
- /* cache miss: query the server */
- data->tag = LAZY_COOKIE;
- data->value.cookie = xcb_query_extension(c, strlen(ext->name), ext->name);
- }
- return data;
-}
-
-/* Public interface */
-
-/* Do not free the returned xcb_query_extension_reply_t - on return, it's aliased
- * from the cache. */
-const xcb_query_extension_reply_t *xcb_get_extension_data(xcb_connection_t *c, xcb_extension_t *ext)
-{
- lazyreply *data;
- if(c->has_error)
- return 0;
-
- pthread_mutex_lock(&c->ext.lock);
- data = get_lazyreply(c, ext);
- if(data && data->tag == LAZY_COOKIE)
- {
- data->tag = LAZY_FORCED;
- data->value.reply = xcb_query_extension_reply(c, data->value.cookie, 0);
- }
- pthread_mutex_unlock(&c->ext.lock);
-
- return data ? data->value.reply : 0;
-}
-
-void xcb_prefetch_extension_data(xcb_connection_t *c, xcb_extension_t *ext)
-{
- if(c->has_error)
- return;
- pthread_mutex_lock(&c->ext.lock);
- get_lazyreply(c, ext);
- pthread_mutex_unlock(&c->ext.lock);
-}
-
-/* Private interface */
-
-int _xcb_ext_init(xcb_connection_t *c)
-{
- if(pthread_mutex_init(&c->ext.lock, 0))
- return 0;
- return 1;
-}
-
-void _xcb_ext_destroy(xcb_connection_t *c)
-{
- pthread_mutex_destroy(&c->ext.lock);
- while(c->ext.extensions_size-- > 0)
- if(c->ext.extensions[c->ext.extensions_size].tag == LAZY_FORCED)
- free(c->ext.extensions[c->ext.extensions_size].value.reply);
- free(c->ext.extensions);
-}
+/* Copyright (C) 2001-2004 Bart Massey and Jamey Sharp.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the names of the authors or their
+ * institutions shall not be used in advertising or otherwise to promote the
+ * sale, use or other dealings in this Software without prior written
+ * authorization from the authors.
+ */
+
+/* A cache for QueryExtension results. */
+
+#include <stdlib.h>
+#include <string.h>
+
+#include "xcb.h"
+#include "xcbext.h"
+#include "xcbint.h"
+
+typedef struct lazyreply {
+ enum lazy_reply_tag tag;
+ union {
+ xcb_query_extension_cookie_t cookie;
+ xcb_query_extension_reply_t *reply;
+ } value;
+} lazyreply;
+
+static lazyreply *get_index(xcb_connection_t *c, int idx)
+{
+ if(idx > c->ext.extensions_size)
+ {
+ int new_size = idx << 1;
+ lazyreply *new_extensions = realloc(c->ext.extensions, sizeof(lazyreply) * new_size);
+ if(!new_extensions)
+ return 0;
+ memset(new_extensions + c->ext.extensions_size, 0, sizeof(lazyreply) * (new_size - c->ext.extensions_size));
+ c->ext.extensions = new_extensions;
+ c->ext.extensions_size = new_size;
+ }
+ return c->ext.extensions + idx - 1;
+}
+
+static lazyreply *get_lazyreply(xcb_connection_t *c, xcb_extension_t *ext)
+{
+ static pthread_mutex_t global_lock = PTHREAD_MUTEX_INITIALIZER;
+ static int next_global_id;
+
+ lazyreply *data;
+
+ pthread_mutex_lock(&global_lock);
+ if(!ext->global_id)
+ ext->global_id = ++next_global_id;
+ pthread_mutex_unlock(&global_lock);
+
+ data = get_index(c, ext->global_id);
+ if(data && data->tag == LAZY_NONE)
+ {
+ /* cache miss: query the server */
+ data->tag = LAZY_COOKIE;
+ data->value.cookie = xcb_query_extension(c, strlen(ext->name), ext->name);
+ }
+ return data;
+}
+
+/* Public interface */
+
+/* Do not free the returned xcb_query_extension_reply_t - on return, it's aliased
+ * from the cache. */
+const xcb_query_extension_reply_t *xcb_get_extension_data(xcb_connection_t *c, xcb_extension_t *ext)
+{
+ lazyreply *data;
+ if(c->has_error)
+ return 0;
+
+ pthread_mutex_lock(&c->ext.lock);
+ data = get_lazyreply(c, ext);
+ if(data && data->tag == LAZY_COOKIE)
+ {
+ data->tag = LAZY_FORCED;
+ data->value.reply = xcb_query_extension_reply(c, data->value.cookie, 0);
+ }
+ pthread_mutex_unlock(&c->ext.lock);
+
+ return data ? data->value.reply : 0;
+}
+
+void xcb_prefetch_extension_data(xcb_connection_t *c, xcb_extension_t *ext)
+{
+ if(c->has_error)
+ return;
+ pthread_mutex_lock(&c->ext.lock);
+ get_lazyreply(c, ext);
+ pthread_mutex_unlock(&c->ext.lock);
+}
+
+/* Private interface */
+
+int _xcb_ext_init(xcb_connection_t *c)
+{
+ if(pthread_mutex_init(&c->ext.lock, 0))
+ return 0;
+ return 1;
+}
+
+void _xcb_ext_destroy(xcb_connection_t *c)
+{
+ pthread_mutex_destroy(&c->ext.lock);
+ while(c->ext.extensions_size-- > 0)
+ if(c->ext.extensions[c->ext.extensions_size].tag == LAZY_FORCED)
+ free(c->ext.extensions[c->ext.extensions_size].value.reply);
+ free(c->ext.extensions);
+}
diff --git a/libxcb/src/xcb_list.c b/libxcb/src/xcb_list.c
index 3a18d9086..fc00588b4 100644
--- a/libxcb/src/xcb_list.c
+++ b/libxcb/src/xcb_list.c
@@ -1,101 +1,101 @@
-/* Copyright (C) 2001-2004 Bart Massey and Jamey Sharp.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- * Except as contained in this notice, the names of the authors or their
- * institutions shall not be used in advertising or otherwise to promote the
- * sale, use or other dealings in this Software without prior written
- * authorization from the authors.
- */
-
-/* A generic implementation of a list of void-pointers. */
-
-#include <stdlib.h>
-
-#include "xcb.h"
-#include "xcbint.h"
-
-typedef struct node {
- struct node *next;
- unsigned int key;
- void *data;
-} node;
-
-struct _xcb_map {
- node *head;
- node **tail;
-};
-
-/* Private interface */
-
-_xcb_map *_xcb_map_new()
-{
- _xcb_map *list;
- list = malloc(sizeof(_xcb_map));
- if(!list)
- return 0;
- list->head = 0;
- list->tail = &list->head;
- return list;
-}
-
-void _xcb_map_delete(_xcb_map *list, xcb_list_free_func_t do_free)
-{
- if(!list)
- return;
- while(list->head)
- {
- node *cur = list->head;
- if(do_free)
- do_free(cur->data);
- list->head = cur->next;
- free(cur);
- }
- free(list);
-}
-
-int _xcb_map_put(_xcb_map *list, unsigned int key, void *data)
-{
- node *cur = malloc(sizeof(node));
- if(!cur)
- return 0;
- cur->key = key;
- cur->data = data;
- cur->next = 0;
- *list->tail = cur;
- list->tail = &cur->next;
- return 1;
-}
-
-void *_xcb_map_remove(_xcb_map *list, unsigned int key)
-{
- node **cur;
- for(cur = &list->head; *cur; cur = &(*cur)->next)
- if((*cur)->key == key)
- {
- node *tmp = *cur;
- void *ret = (*cur)->data;
- *cur = (*cur)->next;
- if(!*cur)
- list->tail = cur;
-
- free(tmp);
- return ret;
- }
- return 0;
-}
+/* Copyright (C) 2001-2004 Bart Massey and Jamey Sharp.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the names of the authors or their
+ * institutions shall not be used in advertising or otherwise to promote the
+ * sale, use or other dealings in this Software without prior written
+ * authorization from the authors.
+ */
+
+/* A generic implementation of a list of void-pointers. */
+
+#include <stdlib.h>
+
+#include "xcb.h"
+#include "xcbint.h"
+
+typedef struct node {
+ struct node *next;
+ unsigned int key;
+ void *data;
+} node;
+
+struct _xcb_map {
+ node *head;
+ node **tail;
+};
+
+/* Private interface */
+
+_xcb_map *_xcb_map_new()
+{
+ _xcb_map *list;
+ list = malloc(sizeof(_xcb_map));
+ if(!list)
+ return 0;
+ list->head = 0;
+ list->tail = &list->head;
+ return list;
+}
+
+void _xcb_map_delete(_xcb_map *list, xcb_list_free_func_t do_free)
+{
+ if(!list)
+ return;
+ while(list->head)
+ {
+ node *cur = list->head;
+ if(do_free)
+ do_free(cur->data);
+ list->head = cur->next;
+ free(cur);
+ }
+ free(list);
+}
+
+int _xcb_map_put(_xcb_map *list, unsigned int key, void *data)
+{
+ node *cur = malloc(sizeof(node));
+ if(!cur)
+ return 0;
+ cur->key = key;
+ cur->data = data;
+ cur->next = 0;
+ *list->tail = cur;
+ list->tail = &cur->next;
+ return 1;
+}
+
+void *_xcb_map_remove(_xcb_map *list, unsigned int key)
+{
+ node **cur;
+ for(cur = &list->head; *cur; cur = &(*cur)->next)
+ if((*cur)->key == key)
+ {
+ node *tmp = *cur;
+ void *ret = (*cur)->data;
+ *cur = (*cur)->next;
+ if(!*cur)
+ list->tail = cur;
+
+ free(tmp);
+ return ret;
+ }
+ return 0;
+}
diff --git a/libxcb/src/xcb_xid.c b/libxcb/src/xcb_xid.c
index 3df5dbec6..364662bc1 100644
--- a/libxcb/src/xcb_xid.c
+++ b/libxcb/src/xcb_xid.c
@@ -1,97 +1,97 @@
-/* Copyright (C) 2001-2008 Bart Massey and Jamey Sharp.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- * Except as contained in this notice, the names of the authors or their
- * institutions shall not be used in advertising or otherwise to promote the
- * sale, use or other dealings in this Software without prior written
- * authorization from the authors.
- */
-
-/* XID allocators. */
-
-#include <assert.h>
-#include <stdlib.h>
-#include "xcb.h"
-#include "xcbext.h"
-#include "xcbint.h"
-#include "xc_misc.h"
-
-/* Public interface */
-
-uint32_t xcb_generate_id(xcb_connection_t *c)
-{
- uint32_t ret;
- if(c->has_error)
- return -1;
- pthread_mutex_lock(&c->xid.lock);
- if(c->xid.last >= c->xid.max - c->xid.inc + 1)
- {
- xcb_xc_misc_get_xid_range_reply_t *range;
- assert(c->xid.last == c->xid.max);
- if (c->xid.last == 0) {
- /* finish setting up initial range */
- c->xid.max = c->setup->resource_id_mask;
- } else {
- /* check for extension */
- const xcb_query_extension_reply_t *xc_misc_reply =
- xcb_get_extension_data(c, &xcb_xc_misc_id);
- if (!xc_misc_reply) {
- pthread_mutex_unlock(&c->xid.lock);
- return -1;
- }
- /* get new range */
- range = xcb_xc_misc_get_xid_range_reply(c,
- xcb_xc_misc_get_xid_range(c), 0);
- /* XXX The latter disjunct is what the server returns
- when it is out of XIDs. Sweet. */
- if(!range || (range->start_id == 0 && range->count == 1))
- {
- pthread_mutex_unlock(&c->xid.lock);
- return -1;
- }
- assert(range->count > 0 && range->start_id > 0);
- c->xid.last = range->start_id;
- c->xid.max = range->start_id + (range->count - 1) * c->xid.inc;
- free(range);
- }
- } else {
- c->xid.last += c->xid.inc;
- }
- ret = c->xid.last | c->xid.base;
- pthread_mutex_unlock(&c->xid.lock);
- return ret;
-}
-
-/* Private interface */
-
-int _xcb_xid_init(xcb_connection_t *c)
-{
- if(pthread_mutex_init(&c->xid.lock, 0))
- return 0;
- c->xid.last = 0;
- c->xid.max = 0;
- c->xid.base = c->setup->resource_id_base;
- c->xid.inc = c->setup->resource_id_mask & -(c->setup->resource_id_mask);
- return 1;
-}
-
-void _xcb_xid_destroy(xcb_connection_t *c)
-{
- pthread_mutex_destroy(&c->xid.lock);
-}
+/* Copyright (C) 2001-2008 Bart Massey and Jamey Sharp.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the names of the authors or their
+ * institutions shall not be used in advertising or otherwise to promote the
+ * sale, use or other dealings in this Software without prior written
+ * authorization from the authors.
+ */
+
+/* XID allocators. */
+
+#include <assert.h>
+#include <stdlib.h>
+#include "xcb.h"
+#include "xcbext.h"
+#include "xcbint.h"
+#include "xc_misc.h"
+
+/* Public interface */
+
+uint32_t xcb_generate_id(xcb_connection_t *c)
+{
+ uint32_t ret;
+ if(c->has_error)
+ return -1;
+ pthread_mutex_lock(&c->xid.lock);
+ if(c->xid.last >= c->xid.max - c->xid.inc + 1)
+ {
+ xcb_xc_misc_get_xid_range_reply_t *range;
+ assert(c->xid.last == c->xid.max);
+ if (c->xid.last == 0) {
+ /* finish setting up initial range */
+ c->xid.max = c->setup->resource_id_mask;
+ } else {
+ /* check for extension */
+ const xcb_query_extension_reply_t *xc_misc_reply =
+ xcb_get_extension_data(c, &xcb_xc_misc_id);
+ if (!xc_misc_reply) {
+ pthread_mutex_unlock(&c->xid.lock);
+ return -1;
+ }
+ /* get new range */
+ range = xcb_xc_misc_get_xid_range_reply(c,
+ xcb_xc_misc_get_xid_range(c), 0);
+ /* XXX The latter disjunct is what the server returns
+ when it is out of XIDs. Sweet. */
+ if(!range || (range->start_id == 0 && range->count == 1))
+ {
+ pthread_mutex_unlock(&c->xid.lock);
+ return -1;
+ }
+ assert(range->count > 0 && range->start_id > 0);
+ c->xid.last = range->start_id;
+ c->xid.max = range->start_id + (range->count - 1) * c->xid.inc;
+ free(range);
+ }
+ } else {
+ c->xid.last += c->xid.inc;
+ }
+ ret = c->xid.last | c->xid.base;
+ pthread_mutex_unlock(&c->xid.lock);
+ return ret;
+}
+
+/* Private interface */
+
+int _xcb_xid_init(xcb_connection_t *c)
+{
+ if(pthread_mutex_init(&c->xid.lock, 0))
+ return 0;
+ c->xid.last = 0;
+ c->xid.max = 0;
+ c->xid.base = c->setup->resource_id_base;
+ c->xid.inc = c->setup->resource_id_mask & -(c->setup->resource_id_mask);
+ return 1;
+}
+
+void _xcb_xid_destroy(xcb_connection_t *c)
+{
+ pthread_mutex_destroy(&c->xid.lock);
+}
diff --git a/libxcb/src/xcbext.h b/libxcb/src/xcbext.h
index 1c2ab2236..98b3c93c1 100644
--- a/libxcb/src/xcbext.h
+++ b/libxcb/src/xcbext.h
@@ -1,102 +1,102 @@
-/*
- * Copyright (C) 2001-2004 Bart Massey and Jamey Sharp.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- * Except as contained in this notice, the names of the authors or their
- * institutions shall not be used in advertising or otherwise to promote the
- * sale, use or other dealings in this Software without prior written
- * authorization from the authors.
- */
-
-#ifndef __XCBEXT_H
-#define __XCBEXT_H
-
-#include "xcb.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* xcb_ext.c */
-
-struct xcb_extension_t {
- const char *name;
- int global_id;
-};
-
-
-/* xcb_out.c */
-
-typedef struct {
- size_t count;
- xcb_extension_t *ext;
- uint8_t opcode;
- uint8_t isvoid;
-} xcb_protocol_request_t;
-
-enum xcb_send_request_flags_t {
- XCB_REQUEST_CHECKED = 1 << 0,
- XCB_REQUEST_RAW = 1 << 1,
- XCB_REQUEST_DISCARD_REPLY = 1 << 2
-};
-
-unsigned int xcb_send_request(xcb_connection_t *c, int flags, struct iovec *vector, const xcb_protocol_request_t *request);
-
-/* xcb_take_socket allows external code to ask XCB for permission to
- * take over the write side of the socket and send raw data with
- * xcb_writev. xcb_take_socket provides the sequence number of the last
- * request XCB sent. The caller of xcb_take_socket must supply a
- * callback which XCB can call when it wants the write side of the
- * socket back to make a request. This callback synchronizes with the
- * external socket owner and flushes any output queues if appropriate.
- * If you are sending requests which won't cause a reply, please note the
- * comment for xcb_writev which explains some sequence number wrap issues.
- * */
-int xcb_take_socket(xcb_connection_t *c, void (*return_socket)(void *closure), void *closure, int flags, uint64_t *sent);
-
-/* You must own the write-side of the socket (you've called
- * xcb_take_socket, and haven't returned from return_socket yet) to call
- * xcb_writev. Also, the iovec must have at least 1 byte of data in it.
- * You have to make sure that xcb can detect sequence number wraps correctly.
- * This means that the first request you send after xcb_take_socket must cause a
- * reply (e.g. just insert a GetInputFocus request). After every (1 << 16) - 1
- * requests without a reply, you have to insert a request which will cause a
- * reply. You can again use GetInputFocus for this. You do not have to wait for
- * any of the GetInputFocus replies, but can instead handle them via
- * xcb_discard_reply(). */
-int xcb_writev(xcb_connection_t *c, struct iovec *vector, int count, uint64_t requests);
-
-
-/* xcb_in.c */
-
-void *xcb_wait_for_reply(xcb_connection_t *c, unsigned int request, xcb_generic_error_t **e);
-int xcb_poll_for_reply(xcb_connection_t *c, unsigned int request, void **reply, xcb_generic_error_t **error);
-
-
-/* xcb_util.c */
-
-int xcb_popcount(uint32_t mask);
-int xcb_sumof(uint8_t *list, int len);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
+/*
+ * Copyright (C) 2001-2004 Bart Massey and Jamey Sharp.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the names of the authors or their
+ * institutions shall not be used in advertising or otherwise to promote the
+ * sale, use or other dealings in this Software without prior written
+ * authorization from the authors.
+ */
+
+#ifndef __XCBEXT_H
+#define __XCBEXT_H
+
+#include "xcb.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* xcb_ext.c */
+
+struct xcb_extension_t {
+ const char *name;
+ int global_id;
+};
+
+
+/* xcb_out.c */
+
+typedef struct {
+ size_t count;
+ xcb_extension_t *ext;
+ uint8_t opcode;
+ uint8_t isvoid;
+} xcb_protocol_request_t;
+
+enum xcb_send_request_flags_t {
+ XCB_REQUEST_CHECKED = 1 << 0,
+ XCB_REQUEST_RAW = 1 << 1,
+ XCB_REQUEST_DISCARD_REPLY = 1 << 2
+};
+
+unsigned int xcb_send_request(xcb_connection_t *c, int flags, struct iovec *vector, const xcb_protocol_request_t *request);
+
+/* xcb_take_socket allows external code to ask XCB for permission to
+ * take over the write side of the socket and send raw data with
+ * xcb_writev. xcb_take_socket provides the sequence number of the last
+ * request XCB sent. The caller of xcb_take_socket must supply a
+ * callback which XCB can call when it wants the write side of the
+ * socket back to make a request. This callback synchronizes with the
+ * external socket owner and flushes any output queues if appropriate.
+ * If you are sending requests which won't cause a reply, please note the
+ * comment for xcb_writev which explains some sequence number wrap issues.
+ * */
+int xcb_take_socket(xcb_connection_t *c, void (*return_socket)(void *closure), void *closure, int flags, uint64_t *sent);
+
+/* You must own the write-side of the socket (you've called
+ * xcb_take_socket, and haven't returned from return_socket yet) to call
+ * xcb_writev. Also, the iovec must have at least 1 byte of data in it.
+ * You have to make sure that xcb can detect sequence number wraps correctly.
+ * This means that the first request you send after xcb_take_socket must cause a
+ * reply (e.g. just insert a GetInputFocus request). After every (1 << 16) - 1
+ * requests without a reply, you have to insert a request which will cause a
+ * reply. You can again use GetInputFocus for this. You do not have to wait for
+ * any of the GetInputFocus replies, but can instead handle them via
+ * xcb_discard_reply(). */
+int xcb_writev(xcb_connection_t *c, struct iovec *vector, int count, uint64_t requests);
+
+
+/* xcb_in.c */
+
+void *xcb_wait_for_reply(xcb_connection_t *c, unsigned int request, xcb_generic_error_t **e);
+int xcb_poll_for_reply(xcb_connection_t *c, unsigned int request, void **reply, xcb_generic_error_t **error);
+
+
+/* xcb_util.c */
+
+int xcb_popcount(uint32_t mask);
+int xcb_sumof(uint8_t *list, int len);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif