[PATCH] fix XSync Initialize call
Rob Taylor
rob.taylor at codethink.co.uk
Mon Aug 27 06:56:45 PDT 2007
Initialize takes two CARD8 fields for desired Xsync version.
---
src/sync.xml | 4 ++++
1 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/src/sync.xml b/src/sync.xml
index 74281f1..fc3c78c 100644
--- a/src/sync.xml
+++ b/src/sync.xml
@@ -78,10 +78,14 @@ for licensing information.
</error>
<request name="Initialize" opcode="0">
+ <field type="CARD8" name="desired_major_version" />
+ <field type="CARD8" name="desired_minor_version" />
+ <pad bytes="2" />
<reply>
<pad bytes="1" />
<field type="CARD8" name="major_version" />
<field type="CARD8" name="minor_version" />
+ <pad bytes="22" />
</reply>
</request>
--
1.5.3.GIT
--------------060700080701010202050909
Content-Type: text/x-csrc;
name="test-xsync.c"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="test-xsync.c"
#include <stdlib.h>
#include <stdio.h>
#include <xcb/xcb.h>
#include <xcb/sync.h>
#include "xcb_sync_aux.h"
int main()
{
xcb_connection_t *connection;
const xcb_query_extension_reply_t *xsync_ext;
xcb_generic_error_t *err;
xcb_sync_initialize_reply_t *init_reply;
xcb_sync_list_system_counters_reply_t *xsync_list_r;
xcb_sync_systemcounter_iterator_t i;
xcb_sync_counter_t counter_id;
connection = xcb_connect (NULL, NULL);
/* bugger */
if (xcb_connection_has_error(connection)) {
printf ("no X connection!\n");
return 1;
}
printf("connected\n");
xsync_ext = xcb_get_extension_data (connection, &xcb_sync_id);
if (!xsync_ext) {
printf("no Xsync extension!\n");
return 1;
}
printf ("first_event=%d, first_error=%d\n", xsync_ext->first_event, xsync_ext->first_error);
init_reply = xcb_sync_initialize_reply (connection, xcb_sync_initialize (connection, 0, 0), &err);
if (!init_reply) {
printf ("XSync initialize failed: %d %d\n", err->response_type, err->error_code);
return 1;
}
/* Test system counters */
xsync_list_r = xcb_sync_list_system_counters_reply(connection, xcb_sync_list_system_counters(connection), NULL);
i = xcb_sync_list_system_counters_counters_iterator (xsync_list_r);
for (; i.rem ; xcb_sync_systemcounter_next (&i)) {
printf ("SystemCounter %s found.\n", xcb_sync_systemcounter_name(i.data));
}
/* create a counter */
counter_id = xcb_generate_id (connection);
xcb_sync_create_counter (connection, counter_id, int64_to_xcb_sync_int64(0x2000000400000ll));
{
xcb_sync_query_counter_reply_t *qcr;
qcr = xcb_sync_query_counter_reply (connection, xcb_sync_query_counter (connection, counter_id), &err);
if (!qcr) {
printf ("xcb_sync_query_counter failed: %d %d\n", err->response_type, err->error_code);
return 1;
}
printf ("counter value = 0x%016llx\n", xcb_sync_int64_to_int64(qcr->counter_value));
if (xcb_sync_int64_to_int64 (qcr->counter_value) !=0x2000000400000ll) {
printf ("Counter value incorrect!\n");
return 1;
}
}
return 0;
}
--------------060700080701010202050909
Content-Type: text/x-chdr;
name="xcb_sync_aux.h"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="xcb_sync_aux.h"
#ifndef __XCB_SYNC_AUX_H__
#define __XCB_SYNC_AUX_H__
#ifdef __cplusplus
extern "C" {
#endif
inline xcb_sync_int64_t
int64_to_xcb_sync_int64 (int64_t i)
{
xcb_sync_int64_t n;
n.lo = i;
n.hi = (uint32_t) (((uint64_t) i) >> 32);
return n;
}
inline int64_t
xcb_sync_int64_to_int64 (xcb_sync_int64_t n)
{
return (int64_t)((((uint64_t)n.hi) << 32) | ((uint64_t)n.lo));
}
#ifdef __cplusplus
}
#endif
#endif /* __XCB_SYNC_AUX_H__ */
--------------060700080701010202050909--
More information about the Xcb
mailing list