mirror of
https://gitlab.freedesktop.org/xorg/lib/libx11.git
synced 2026-05-09 04:58:06 +02:00
XCL is dead; long live Xlib/XCB
Rename all instances of "XCL" to Xlib/XCB-derived names. The only user-visible change: rename the include file <X11/xcl.h> to <X11/Xlib-xcb.h>; programs will need to change their #include lines to match. Remove the XCL cast inlines from Xlib-xcb.h.
This commit is contained in:
parent
5b73093203
commit
ab728ca372
13 changed files with 136 additions and 173 deletions
|
|
@ -20,7 +20,7 @@ AC_PROG_CC
|
|||
|
||||
XORG_PROG_RAWCPP
|
||||
|
||||
# Build XCL? or traditional Xlib?
|
||||
# Build with XCB support?
|
||||
AC_ARG_WITH(xcb,
|
||||
AC_HELP_STRING([--with-xcb], [use XCB for low-level protocol implementation]),
|
||||
[ac_cv_use_xcb=$withval], [ac_cv_use_xcb=yes])
|
||||
|
|
|
|||
|
|
@ -16,5 +16,5 @@ EXTRA_DIST=\
|
|||
X11/XlibConf.h.in
|
||||
|
||||
if XCB
|
||||
x11include_HEADERS += X11/xcl.h
|
||||
x11include_HEADERS += X11/Xlib-xcb.h
|
||||
endif
|
||||
|
|
|
|||
15
include/X11/Xlib-xcb.h
Normal file
15
include/X11/Xlib-xcb.h
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
/* Copyright (C) 2003-2006 Jamey Sharp, Josh Triplett
|
||||
* This file is licensed under the MIT license. See the file COPYING. */
|
||||
|
||||
#ifndef XLIB_XCB_H
|
||||
#define XLIB_XCB_H
|
||||
|
||||
#include <xcb/xcb.h>
|
||||
#include <X11/Xlib.h>
|
||||
|
||||
xcb_connection_t *XGetXCBConnection(Display *dpy);
|
||||
|
||||
enum XEventQueueOwner { XlibOwnsEventQueue = 0, XCBOwnsEventQueue };
|
||||
void XSetEventQueueOwner(Display *dpy, enum XEventQueueOwner owner);
|
||||
|
||||
#endif /* XLIB_XCB_H */
|
||||
|
|
@ -184,7 +184,7 @@ struct _XDisplay
|
|||
int xcmisc_opcode; /* major opcode for XC-MISC */
|
||||
struct _XkbInfoRec *xkb_info; /* XKB info */
|
||||
struct _XtransConnInfo *trans_conn; /* transport connection object */
|
||||
struct XCLPrivate *xcl; /* XCB glue private data */
|
||||
struct _X11XCBPrivate *xcb; /* XCB glue private data */
|
||||
};
|
||||
|
||||
#define XAllocIDs(dpy,ids,n) (*(dpy)->idlist_alloc)(dpy,ids,n)
|
||||
|
|
|
|||
|
|
@ -1,52 +0,0 @@
|
|||
/* Copyright (C) 2003 Jamey Sharp.
|
||||
* This file is licensed under the MIT license. See the file COPYING. */
|
||||
|
||||
#ifndef XCL_H
|
||||
#define XCL_H
|
||||
|
||||
#include <xcb/xcb.h>
|
||||
#include <X11/Xlib.h>
|
||||
|
||||
/* Coercions from Xlib XID types to XCB XID types.
|
||||
* On GCC/x86 with optimizations turned on, these compile to zero
|
||||
* instructions. */
|
||||
|
||||
#define XCLCASTDECL(src_t, dst_t, field) \
|
||||
static inline xcb_##dst_t xcl_##dst_t(src_t src) \
|
||||
{ \
|
||||
xcb_##dst_t dst; \
|
||||
dst.field = src; \
|
||||
return dst; \
|
||||
}
|
||||
#define XCLXIDCASTDECL(src_t, dst_t) XCLCASTDECL(src_t, dst_t, xid)
|
||||
#define XCLIDCASTDECL(src_t, dst_t) XCLCASTDECL(src_t, dst_t, id)
|
||||
|
||||
XCLXIDCASTDECL(Window, window_t)
|
||||
XCLXIDCASTDECL(Pixmap, pixmap_t)
|
||||
XCLXIDCASTDECL(Cursor, cursor_t)
|
||||
XCLXIDCASTDECL(Font, font_t)
|
||||
XCLXIDCASTDECL(GContext, gcontext_t)
|
||||
XCLXIDCASTDECL(Colormap, colormap_t)
|
||||
XCLXIDCASTDECL(Atom, atom_t)
|
||||
|
||||
/* For the union types, pick an arbitrary field of the union to hold the
|
||||
* Xlib XID. Assumes the bit pattern is the same regardless of the field. */
|
||||
XCLCASTDECL(Drawable, drawable_t, window.xid)
|
||||
XCLCASTDECL(Font, fontable_t, font.xid)
|
||||
|
||||
XCLIDCASTDECL(VisualID, visualid_t)
|
||||
XCLIDCASTDECL(Time, timestamp_t)
|
||||
XCLIDCASTDECL(KeySym, keysym_t)
|
||||
XCLIDCASTDECL(KeyCode, keycode_t)
|
||||
XCLIDCASTDECL(CARD8, button_t)
|
||||
|
||||
/* xcl/display.c */
|
||||
|
||||
xcb_connection_t *XGetXCBConnection(Display *dpy);
|
||||
|
||||
/* xcl/io.c */
|
||||
|
||||
enum XEventQueueOwner { XlibOwnsEventQueue = 0, XCBOwnsEventQueue };
|
||||
void XSetEventQueueOwner(Display *dpy, enum XEventQueueOwner owner);
|
||||
|
||||
#endif /* XCL_H */
|
||||
|
|
@ -33,7 +33,7 @@ from The Open Group.
|
|||
#include <config.h>
|
||||
#endif
|
||||
#if USE_XCB
|
||||
#include "xclint.h"
|
||||
#include "Xxcbint.h"
|
||||
#else /* !USE_XCB */
|
||||
#include <X11/Xtrans/Xtrans.h>
|
||||
#endif /* USE_XCB */
|
||||
|
|
@ -75,7 +75,7 @@ XCloseDisplay (
|
|||
XSync(dpy, 1);
|
||||
}
|
||||
#if USE_XCB
|
||||
xcb_disconnect(dpy->xcl->connection);
|
||||
xcb_disconnect(dpy->xcb->connection);
|
||||
#else /* !USE_XCB */
|
||||
_XDisconnectDisplay(dpy->trans_conn);
|
||||
#endif /* USE_XCB */
|
||||
|
|
|
|||
|
|
@ -342,12 +342,12 @@ EXTRA_DIST = \
|
|||
|
||||
if XCB
|
||||
libX11_la_SOURCES += \
|
||||
xcl/xcblock.c \
|
||||
xcl/display.c \
|
||||
xcl/io.c
|
||||
xcb_lock.c \
|
||||
xcb_disp.c \
|
||||
xcb_io.c
|
||||
|
||||
lib_LTLIBRARIES += libX11-xcb.la
|
||||
libX11_xcb_la_SOURCES = xcl/x11-xcb.c
|
||||
libX11_xcb_la_SOURCES = x11_xcb.c
|
||||
libX11_xcb_la_LDFLAGS = -version-info 1:0:0 -no-undefined
|
||||
libX11_xcb_la_LIBADD = libX11.la
|
||||
else
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ in this Software without prior written authorization from The Open Group.
|
|||
#endif
|
||||
#include "Xlibint.h"
|
||||
#if USE_XCB
|
||||
#include "xclint.h"
|
||||
#include "Xxcbint.h"
|
||||
#else /* !USE_XCB */
|
||||
#include <X11/Xtrans/Xtrans.h>
|
||||
#include <X11/extensions/bigreqstr.h>
|
||||
|
|
@ -363,7 +363,7 @@ XOpenDisplay (
|
|||
|
||||
#if USE_XCB
|
||||
{
|
||||
const xcb_setup_t *xcbsetup = xcb_get_setup(dpy->xcl->connection);
|
||||
const xcb_setup_t *xcbsetup = xcb_get_setup(dpy->xcb->connection);
|
||||
setuplength = xcbsetup->length << 2;
|
||||
memcpy(&prefix, xcbsetup, sizeof(prefix));
|
||||
setup = (char *) xcbsetup;
|
||||
|
|
@ -673,7 +673,7 @@ XOpenDisplay (
|
|||
(void) XSynchronize(dpy, _Xdebug);
|
||||
|
||||
#if USE_XCB
|
||||
dpy->bigreq_size = xcb_get_maximum_request_length(dpy->xcl->connection);
|
||||
dpy->bigreq_size = xcb_get_maximum_request_length(dpy->xcb->connection);
|
||||
if(dpy->bigreq_size <= dpy->max_request_size)
|
||||
dpy->bigreq_size = 0;
|
||||
#endif /* USE_XCB */
|
||||
|
|
@ -907,7 +907,7 @@ void _XFreeDisplayStructure(dpy)
|
|||
Xfree (dpy->filedes);
|
||||
|
||||
#if USE_XCB
|
||||
_XFreeXCLStructure(dpy);
|
||||
_XFreeX11XCBStructure(dpy);
|
||||
#endif /* USE_XCB */
|
||||
|
||||
Xfree ((char *)dpy);
|
||||
|
|
@ -921,8 +921,8 @@ static void OutOfMemory (dpy, setup)
|
|||
char *setup;
|
||||
{
|
||||
#if USE_XCB
|
||||
if(dpy->xcl->connection)
|
||||
xcb_disconnect(dpy->xcl->connection);
|
||||
if(dpy->xcb->connection)
|
||||
xcb_disconnect(dpy->xcb->connection);
|
||||
#else /* !USE_XCB */
|
||||
_XDisconnectDisplay (dpy->trans_conn);
|
||||
#endif /* USE_XCB */
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
/* Copyright (C) 2003-2005 Jamey Sharp.
|
||||
/* Copyright (C) 2003-2006 Jamey Sharp, Josh Triplett
|
||||
* This file is licensed under the MIT license. See the file COPYING. */
|
||||
|
||||
#ifndef XCLINT_H
|
||||
#define XCLINT_H
|
||||
#ifndef XXCBINT_H
|
||||
#define XXCBINT_H
|
||||
|
||||
#include <assert.h>
|
||||
#include <X11/Xlibint.h>
|
||||
#include <X11/xcl.h>
|
||||
#include <X11/Xlib-xcb.h>
|
||||
|
||||
#define XCB_SEQUENCE_COMPARE(a,op,b) ((int) ((a) - (b)) op 0)
|
||||
#define assert_sequence_less(a,b) assert(XCB_SEQUENCE_COMPARE((a), <=, (b)))
|
||||
|
|
@ -17,7 +17,7 @@ struct PendingRequest {
|
|||
unsigned int sequence;
|
||||
};
|
||||
|
||||
typedef struct XCLPrivate {
|
||||
typedef struct _X11XCBPrivate {
|
||||
struct _XLockPtrs lock_fns;
|
||||
xcb_connection_t *connection;
|
||||
PendingRequest *pending_requests;
|
||||
|
|
@ -32,14 +32,14 @@ typedef struct XCLPrivate {
|
|||
int reply_consumed;
|
||||
enum XEventQueueOwner event_owner;
|
||||
XID next_xid;
|
||||
} XCLPrivate;
|
||||
} _X11XCBPrivate;
|
||||
|
||||
/* xcl/display.c */
|
||||
/* xcb_disp.c */
|
||||
|
||||
int _XConnectXCB(Display *dpy, _Xconst char *display, char **fullnamep, int *screenp);
|
||||
void _XFreeXCLStructure(Display *dpy);
|
||||
void _XFreeX11XCBStructure(Display *dpy);
|
||||
|
||||
/* xcl/xcblock.c */
|
||||
/* xcb_lock.c */
|
||||
|
||||
int _XCBInitDisplayLock(Display *dpy);
|
||||
|
||||
|
|
@ -49,4 +49,4 @@ int _XCBInitDisplayLock(Display *dpy);
|
|||
void _XGetXCBBuffer(Display *dpy);
|
||||
void _XPutXCBBuffer(Display *dpy);
|
||||
|
||||
#endif /* XCLINT_H */
|
||||
#endif /* XXCBINT_H */
|
||||
|
|
@ -2,14 +2,14 @@
|
|||
* This file is licensed under the MIT license. See the file COPYING. */
|
||||
|
||||
#include "Xlibint.h"
|
||||
#include "xclint.h"
|
||||
#include "Xxcbint.h"
|
||||
|
||||
xcb_connection_t *XGetXCBConnection(Display *dpy)
|
||||
{
|
||||
return dpy->xcl->connection;
|
||||
return dpy->xcb->connection;
|
||||
}
|
||||
|
||||
void XSetEventQueueOwner(Display *dpy, enum XEventQueueOwner owner)
|
||||
{
|
||||
dpy->xcl->event_owner = owner;
|
||||
dpy->xcb->event_owner = owner;
|
||||
}
|
||||
|
|
@ -1,8 +1,8 @@
|
|||
/* Copyright (C) 2003 Jamey Sharp.
|
||||
/* Copyright (C) 2003-2006 Jamey Sharp, Josh Triplett
|
||||
* This file is licensed under the MIT license. See the file COPYING. */
|
||||
|
||||
#include "Xlibint.h"
|
||||
#include "xclint.h"
|
||||
#include "Xxcbint.h"
|
||||
#include <xcb/xcbext.h>
|
||||
#include <X11/Xatom.h>
|
||||
#include <X11/Xresource.h>
|
||||
|
|
@ -61,8 +61,8 @@ int _XConnectXCB(Display *dpy, _Xconst char *display, char **fullnamep, int *scr
|
|||
|
||||
dpy->fd = -1;
|
||||
|
||||
dpy->xcl = Xcalloc(1, sizeof(XCLPrivate));
|
||||
if(!dpy->xcl)
|
||||
dpy->xcb = Xcalloc(1, sizeof(_X11XCBPrivate));
|
||||
if(!dpy->xcb)
|
||||
return 0;
|
||||
|
||||
if(!xcb_parse_display(display, &host, &n, screenp))
|
||||
|
|
@ -82,22 +82,22 @@ int _XConnectXCB(Display *dpy, _Xconst char *display, char **fullnamep, int *scr
|
|||
|
||||
dpy->fd = xcb_get_file_descriptor(c);
|
||||
|
||||
dpy->xcl->connection = c;
|
||||
dpy->xcl->pending_requests_tail = &dpy->xcl->pending_requests;
|
||||
dpy->xcl->next_xid = xcb_generate_id(dpy->xcl->connection);
|
||||
dpy->xcb->connection = c;
|
||||
dpy->xcb->pending_requests_tail = &dpy->xcb->pending_requests;
|
||||
dpy->xcb->next_xid = xcb_generate_id(dpy->xcb->connection);
|
||||
|
||||
return !xcb_connection_has_error(c);
|
||||
}
|
||||
|
||||
void _XFreeXCLStructure(Display *dpy)
|
||||
void _XFreeX11XCBStructure(Display *dpy)
|
||||
{
|
||||
/* reply_data was allocated by system malloc, not Xmalloc */
|
||||
free(dpy->xcl->reply_data);
|
||||
while(dpy->xcl->pending_requests)
|
||||
free(dpy->xcb->reply_data);
|
||||
while(dpy->xcb->pending_requests)
|
||||
{
|
||||
PendingRequest *tmp = dpy->xcl->pending_requests;
|
||||
dpy->xcl->pending_requests = tmp->next;
|
||||
PendingRequest *tmp = dpy->xcb->pending_requests;
|
||||
dpy->xcb->pending_requests = tmp->next;
|
||||
free(tmp);
|
||||
}
|
||||
Xfree(dpy->xcl);
|
||||
Xfree(dpy->xcb);
|
||||
}
|
||||
|
|
@ -1,8 +1,8 @@
|
|||
/* Copyright (C) 2003-2004 Jamey Sharp.
|
||||
/* Copyright (C) 2003-2006 Jamey Sharp, Josh Triplett
|
||||
* This file is licensed under the MIT license. See the file COPYING. */
|
||||
|
||||
#include "Xlibint.h"
|
||||
#include "xclint.h"
|
||||
#include "Xxcbint.h"
|
||||
#include <xcb/xcbext.h>
|
||||
#include <xcb/xcbxlib.h>
|
||||
|
||||
|
|
@ -95,12 +95,12 @@ static void call_handlers(Display *dpy, xcb_generic_reply_t *buf)
|
|||
static void process_responses(Display *dpy, int wait_for_first_event, xcb_generic_error_t **current_error, unsigned long current_request)
|
||||
{
|
||||
void *reply;
|
||||
xcb_generic_event_t *event = dpy->xcl->next_event;
|
||||
xcb_generic_event_t *event = dpy->xcb->next_event;
|
||||
xcb_generic_error_t *error;
|
||||
PendingRequest *req;
|
||||
int ret;
|
||||
xcb_connection_t *c = dpy->xcl->connection;
|
||||
if(!event && dpy->xcl->event_owner == XlibOwnsEventQueue)
|
||||
xcb_connection_t *c = dpy->xcb->connection;
|
||||
if(!event && dpy->xcb->event_owner == XlibOwnsEventQueue)
|
||||
{
|
||||
if(wait_for_first_event)
|
||||
{
|
||||
|
|
@ -114,7 +114,7 @@ static void process_responses(Display *dpy, int wait_for_first_event, xcb_generi
|
|||
|
||||
while(1)
|
||||
{
|
||||
req = dpy->xcl->pending_requests;
|
||||
req = dpy->xcb->pending_requests;
|
||||
if(event && XCB_SEQUENCE_COMPARE(event->full_sequence, <=, current_request)
|
||||
&& (!req || XCB_SEQUENCE_COMPARE(event->full_sequence, <=, req->sequence)))
|
||||
{
|
||||
|
|
@ -128,9 +128,9 @@ static void process_responses(Display *dpy, int wait_for_first_event, xcb_generi
|
|||
event = xcb_poll_for_event(c, &ret);
|
||||
}
|
||||
else if(req && XCB_SEQUENCE_COMPARE(req->sequence, <, current_request)
|
||||
&& xcb_poll_for_reply(dpy->xcl->connection, req->sequence, &reply, &error))
|
||||
&& xcb_poll_for_reply(dpy->xcb->connection, req->sequence, &reply, &error))
|
||||
{
|
||||
dpy->xcl->pending_requests = req->next;
|
||||
dpy->xcb->pending_requests = req->next;
|
||||
if(!reply)
|
||||
reply = error;
|
||||
if(reply)
|
||||
|
|
@ -144,10 +144,10 @@ static void process_responses(Display *dpy, int wait_for_first_event, xcb_generi
|
|||
else
|
||||
break;
|
||||
}
|
||||
if(!dpy->xcl->pending_requests)
|
||||
dpy->xcl->pending_requests_tail = &dpy->xcl->pending_requests;
|
||||
if(!dpy->xcb->pending_requests)
|
||||
dpy->xcb->pending_requests_tail = &dpy->xcb->pending_requests;
|
||||
|
||||
dpy->xcl->next_event = event;
|
||||
dpy->xcb->next_event = event;
|
||||
|
||||
if(xcb_connection_has_error(c))
|
||||
_XIOError(dpy);
|
||||
|
|
@ -157,7 +157,7 @@ static void process_responses(Display *dpy, int wait_for_first_event, xcb_generi
|
|||
|
||||
int _XEventsQueued(Display *dpy, int mode)
|
||||
{
|
||||
if(dpy->xcl->event_owner != XlibOwnsEventQueue)
|
||||
if(dpy->xcb->event_owner != XlibOwnsEventQueue)
|
||||
return 0;
|
||||
|
||||
if(mode == QueuedAfterFlush)
|
||||
|
|
@ -174,7 +174,7 @@ int _XEventsQueued(Display *dpy, int mode)
|
|||
void _XReadEvents(Display *dpy)
|
||||
{
|
||||
_XSend(dpy, 0, 0);
|
||||
if(dpy->xcl->event_owner != XlibOwnsEventQueue)
|
||||
if(dpy->xcb->event_owner != XlibOwnsEventQueue)
|
||||
return;
|
||||
check_internal_connections(dpy);
|
||||
process_responses(dpy, 1, 0, dpy->request);
|
||||
|
|
@ -189,11 +189,11 @@ void _XReadEvents(Display *dpy)
|
|||
*/
|
||||
void _XSend(Display *dpy, const char *data, long size)
|
||||
{
|
||||
xcb_connection_t *c = dpy->xcl->connection;
|
||||
xcb_connection_t *c = dpy->xcb->connection;
|
||||
|
||||
assert(!dpy->xcl->request_extra);
|
||||
dpy->xcl->request_extra = data;
|
||||
dpy->xcl->request_extra_size = size;
|
||||
assert(!dpy->xcb->request_extra);
|
||||
dpy->xcb->request_extra = data;
|
||||
dpy->xcb->request_extra_size = size;
|
||||
|
||||
/* give dpy->buffer to XCB */
|
||||
_XPutXCBBuffer(dpy);
|
||||
|
|
@ -229,9 +229,9 @@ void _XFlush(Display *dpy)
|
|||
static int
|
||||
_XIDHandler(Display *dpy)
|
||||
{
|
||||
XID next = xcb_generate_id(dpy->xcl->connection);
|
||||
XID next = xcb_generate_id(dpy->xcb->connection);
|
||||
LockDisplay(dpy);
|
||||
dpy->xcl->next_xid = next;
|
||||
dpy->xcb->next_xid = next;
|
||||
if(dpy->flags & XlibDisplayPrivSync)
|
||||
{
|
||||
dpy->synchandler = dpy->savedsynchandler;
|
||||
|
|
@ -245,8 +245,8 @@ _XIDHandler(Display *dpy)
|
|||
/* _XAllocID - resource ID allocation routine. */
|
||||
XID _XAllocID(Display *dpy)
|
||||
{
|
||||
XID ret = dpy->xcl->next_xid;
|
||||
dpy->xcl->next_xid = 0;
|
||||
XID ret = dpy->xcb->next_xid;
|
||||
dpy->xcb->next_xid = 0;
|
||||
|
||||
assert(!(dpy->flags & XlibDisplayPrivSync));
|
||||
dpy->savedsynchandler = dpy->synchandler;
|
||||
|
|
@ -261,16 +261,16 @@ void _XAllocIDs(Display *dpy, XID *ids, int count)
|
|||
int i;
|
||||
_XPutXCBBuffer(dpy);
|
||||
for (i = 0; i < count; i++)
|
||||
ids[i] = xcb_generate_id(dpy->xcl->connection);
|
||||
ids[i] = xcb_generate_id(dpy->xcb->connection);
|
||||
_XGetXCBBuffer(dpy);
|
||||
}
|
||||
|
||||
static void _XFreeReplyData(Display *dpy, Bool force)
|
||||
{
|
||||
if(!force && dpy->xcl->reply_consumed < dpy->xcl->reply_length)
|
||||
if(!force && dpy->xcb->reply_consumed < dpy->xcb->reply_length)
|
||||
return;
|
||||
free(dpy->xcl->reply_data);
|
||||
dpy->xcl->reply_data = 0;
|
||||
free(dpy->xcb->reply_data);
|
||||
dpy->xcb->reply_data = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -282,11 +282,11 @@ static void _XFreeReplyData(Display *dpy, Bool force)
|
|||
Status _XReply(Display *dpy, xReply *rep, int extra, Bool discard)
|
||||
{
|
||||
xcb_generic_error_t *error;
|
||||
xcb_connection_t *c = dpy->xcl->connection;
|
||||
xcb_connection_t *c = dpy->xcb->connection;
|
||||
unsigned long request = dpy->request;
|
||||
char *reply;
|
||||
|
||||
assert(!dpy->xcl->reply_data);
|
||||
assert(!dpy->xcb->reply_data);
|
||||
|
||||
UnlockDisplay(dpy);
|
||||
reply = xcb_wait_for_reply(c, request, &error);
|
||||
|
|
@ -351,17 +351,17 @@ Status _XReply(Display *dpy, xReply *rep, int extra, Bool discard)
|
|||
dpy->last_request_read = request;
|
||||
|
||||
/* there's no error and we have a reply. */
|
||||
dpy->xcl->reply_data = reply;
|
||||
dpy->xcl->reply_consumed = sizeof(xReply) + (extra * 4);
|
||||
dpy->xcl->reply_length = sizeof(xReply);
|
||||
if(dpy->xcl->reply_data[0] == 1)
|
||||
dpy->xcl->reply_length += (((xcb_generic_reply_t *) dpy->xcl->reply_data)->length * 4);
|
||||
dpy->xcb->reply_data = reply;
|
||||
dpy->xcb->reply_consumed = sizeof(xReply) + (extra * 4);
|
||||
dpy->xcb->reply_length = sizeof(xReply);
|
||||
if(dpy->xcb->reply_data[0] == 1)
|
||||
dpy->xcb->reply_length += (((xcb_generic_reply_t *) dpy->xcb->reply_data)->length * 4);
|
||||
|
||||
/* error: Xlib asks too much. give them what we can anyway. */
|
||||
if(dpy->xcl->reply_length < dpy->xcl->reply_consumed)
|
||||
dpy->xcl->reply_consumed = dpy->xcl->reply_length;
|
||||
if(dpy->xcb->reply_length < dpy->xcb->reply_consumed)
|
||||
dpy->xcb->reply_consumed = dpy->xcb->reply_length;
|
||||
|
||||
memcpy(rep, dpy->xcl->reply_data, dpy->xcl->reply_consumed);
|
||||
memcpy(rep, dpy->xcb->reply_data, dpy->xcb->reply_consumed);
|
||||
_XFreeReplyData(dpy, discard);
|
||||
return 1;
|
||||
}
|
||||
|
|
@ -371,10 +371,10 @@ int _XRead(Display *dpy, char *data, long size)
|
|||
assert(size >= 0);
|
||||
if(size == 0)
|
||||
return 0;
|
||||
assert(dpy->xcl->reply_data != 0);
|
||||
assert(dpy->xcl->reply_consumed + size <= dpy->xcl->reply_length);
|
||||
memcpy(data, dpy->xcl->reply_data + dpy->xcl->reply_consumed, size);
|
||||
dpy->xcl->reply_consumed += size;
|
||||
assert(dpy->xcb->reply_data != 0);
|
||||
assert(dpy->xcb->reply_consumed + size <= dpy->xcb->reply_length);
|
||||
memcpy(data, dpy->xcb->reply_data + dpy->xcb->reply_consumed, size);
|
||||
dpy->xcb->reply_consumed += size;
|
||||
_XFreeReplyData(dpy, False);
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -387,13 +387,13 @@ int _XRead(Display *dpy, char *data, long size)
|
|||
void _XReadPad(Display *dpy, char *data, long size)
|
||||
{
|
||||
_XRead(dpy, data, size);
|
||||
dpy->xcl->reply_consumed += -size & 3;
|
||||
dpy->xcb->reply_consumed += -size & 3;
|
||||
_XFreeReplyData(dpy, False);
|
||||
}
|
||||
|
||||
/* Read and discard "n" 8-bit bytes of data */
|
||||
void _XEatData(Display *dpy, unsigned long n)
|
||||
{
|
||||
dpy->xcl->reply_consumed += n;
|
||||
dpy->xcb->reply_consumed += n;
|
||||
_XFreeReplyData(dpy, False);
|
||||
}
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
/* Copyright (C) 2003-2004 Jamey Sharp.
|
||||
/* Copyright (C) 2003-2006 Jamey Sharp, Josh Triplett
|
||||
* This file is licensed under the MIT license. See the file COPYING. */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
#include "Xlibint.h"
|
||||
#include "locking.h"
|
||||
#include "xclint.h"
|
||||
#include "Xxcbint.h"
|
||||
#include <xcb/xcbext.h>
|
||||
#include <xcb/xcbxlib.h>
|
||||
|
||||
|
|
@ -15,34 +15,34 @@
|
|||
|
||||
static void _XCBLockDisplay(Display *dpy)
|
||||
{
|
||||
if(dpy->xcl->lock_fns.lock_display)
|
||||
dpy->xcl->lock_fns.lock_display(dpy);
|
||||
xcb_xlib_lock(dpy->xcl->connection);
|
||||
if(dpy->xcb->lock_fns.lock_display)
|
||||
dpy->xcb->lock_fns.lock_display(dpy);
|
||||
xcb_xlib_lock(dpy->xcb->connection);
|
||||
_XGetXCBBuffer(dpy);
|
||||
}
|
||||
|
||||
static void _XCBUnlockDisplay(Display *dpy)
|
||||
{
|
||||
_XPutXCBBuffer(dpy);
|
||||
assert(dpy->xcl->partial_request == 0);
|
||||
assert(xcb_get_request_sent(dpy->xcl->connection) == dpy->request);
|
||||
assert(dpy->xcb->partial_request == 0);
|
||||
assert(xcb_get_request_sent(dpy->xcb->connection) == dpy->request);
|
||||
|
||||
/* Traditional Xlib does this in _XSend; see the Xlib/XCB version
|
||||
* of that function for why we do it here instead. */
|
||||
_XSetSeqSyncFunction(dpy);
|
||||
|
||||
xcb_xlib_unlock(dpy->xcl->connection);
|
||||
if(dpy->xcl->lock_fns.unlock_display)
|
||||
dpy->xcl->lock_fns.unlock_display(dpy);
|
||||
xcb_xlib_unlock(dpy->xcb->connection);
|
||||
if(dpy->xcb->lock_fns.unlock_display)
|
||||
dpy->xcb->lock_fns.unlock_display(dpy);
|
||||
}
|
||||
|
||||
int _XCBInitDisplayLock(Display *dpy)
|
||||
{
|
||||
if(!dpy->lock_fns && !(dpy->lock_fns = Xcalloc(1, sizeof(dpy->lock_fns))))
|
||||
return 0;
|
||||
dpy->xcl->lock_fns.lock_display = dpy->lock_fns->lock_display;
|
||||
dpy->xcb->lock_fns.lock_display = dpy->lock_fns->lock_display;
|
||||
dpy->lock_fns->lock_display = _XCBLockDisplay;
|
||||
dpy->xcl->lock_fns.unlock_display = dpy->lock_fns->unlock_display;
|
||||
dpy->xcb->lock_fns.unlock_display = dpy->lock_fns->unlock_display;
|
||||
dpy->lock_fns->unlock_display = _XCBUnlockDisplay;
|
||||
return 1;
|
||||
}
|
||||
|
|
@ -50,10 +50,10 @@ int _XCBInitDisplayLock(Display *dpy)
|
|||
void _XGetXCBBuffer(Display *dpy)
|
||||
{
|
||||
static const xReq dummy_request;
|
||||
unsigned int xcb_req = xcb_get_request_sent(dpy->xcl->connection);
|
||||
unsigned int xcb_req = xcb_get_request_sent(dpy->xcb->connection);
|
||||
/* if Xlib has a partial request pending then XCB doesn't know about
|
||||
* the current request yet */
|
||||
if(dpy->xcl->partial_request)
|
||||
if(dpy->xcb->partial_request)
|
||||
++xcb_req;
|
||||
|
||||
assert(XCB_SEQUENCE_COMPARE(xcb_req, >=, dpy->request));
|
||||
|
|
@ -120,14 +120,14 @@ static inline int issue_complete_request(Display *dpy, int veclen, struct iovec
|
|||
|
||||
/* if we don't own the event queue, we have to ask XCB to set our
|
||||
* errors aside for us. */
|
||||
if(dpy->xcl->event_owner != XlibOwnsEventQueue)
|
||||
if(dpy->xcb->event_owner != XlibOwnsEventQueue)
|
||||
flags |= XCB_REQUEST_CHECKED;
|
||||
|
||||
/* XCB will always skip request 0; account for that in the Xlib count */
|
||||
if (xcb_get_request_sent(dpy->xcl->connection) == 0xffffffff)
|
||||
if (xcb_get_request_sent(dpy->xcb->connection) == 0xffffffff)
|
||||
dpy->request++;
|
||||
/* send the accumulated request. */
|
||||
sequence = xcb_send_request(dpy->xcl->connection, flags, vec, &xcb_req);
|
||||
sequence = xcb_send_request(dpy->xcb->connection, flags, vec, &xcb_req);
|
||||
if(!sequence)
|
||||
_XIOError(dpy);
|
||||
|
||||
|
|
@ -144,8 +144,8 @@ static inline int issue_complete_request(Display *dpy, int veclen, struct iovec
|
|||
assert(req);
|
||||
req->next = 0;
|
||||
req->sequence = sequence;
|
||||
*dpy->xcl->pending_requests_tail = req;
|
||||
dpy->xcl->pending_requests_tail = &req->next;
|
||||
*dpy->xcb->pending_requests_tail = req;
|
||||
dpy->xcb->pending_requests_tail = &req->next;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
|
@ -153,8 +153,8 @@ static inline int issue_complete_request(Display *dpy, int veclen, struct iovec
|
|||
void _XPutXCBBuffer(Display *dpy)
|
||||
{
|
||||
static char const pad[3];
|
||||
const int padsize = -dpy->xcl->request_extra_size & 3;
|
||||
xcb_connection_t *c = dpy->xcl->connection;
|
||||
const int padsize = -dpy->xcb->request_extra_size & 3;
|
||||
xcb_connection_t *c = dpy->xcb->connection;
|
||||
_XExtension *ext;
|
||||
struct iovec iov[6];
|
||||
|
||||
|
|
@ -164,20 +164,20 @@ void _XPutXCBBuffer(Display *dpy)
|
|||
for(ext = dpy->flushes; ext; ext = ext->next_flush)
|
||||
{
|
||||
ext->before_flush(dpy, &ext->codes, dpy->buffer, dpy->bufptr - dpy->buffer);
|
||||
if(dpy->xcl->request_extra)
|
||||
if(dpy->xcb->request_extra)
|
||||
{
|
||||
ext->before_flush(dpy, &ext->codes, dpy->xcl->request_extra, dpy->xcl->request_extra_size);
|
||||
ext->before_flush(dpy, &ext->codes, dpy->xcb->request_extra, dpy->xcb->request_extra_size);
|
||||
if(padsize)
|
||||
ext->before_flush(dpy, &ext->codes, pad, padsize);
|
||||
}
|
||||
}
|
||||
|
||||
iov[2].iov_base = dpy->xcl->partial_request;
|
||||
iov[2].iov_len = dpy->xcl->partial_request_offset;
|
||||
iov[2].iov_base = dpy->xcb->partial_request;
|
||||
iov[2].iov_len = dpy->xcb->partial_request_offset;
|
||||
iov[3].iov_base = dpy->buffer;
|
||||
iov[3].iov_len = dpy->bufptr - dpy->buffer;
|
||||
iov[4].iov_base = (caddr_t) dpy->xcl->request_extra;
|
||||
iov[4].iov_len = dpy->xcl->request_extra_size;
|
||||
iov[4].iov_base = (caddr_t) dpy->xcb->request_extra;
|
||||
iov[4].iov_len = dpy->xcb->request_extra_size;
|
||||
iov[5].iov_base = (caddr_t) pad;
|
||||
iov[5].iov_len = padsize;
|
||||
|
||||
|
|
@ -185,32 +185,32 @@ void _XPutXCBBuffer(Display *dpy)
|
|||
/* empty */;
|
||||
|
||||
/* first discard any completed partial_request. */
|
||||
if(iov[2].iov_len == 0 && dpy->xcl->partial_request)
|
||||
if(iov[2].iov_len == 0 && dpy->xcb->partial_request)
|
||||
{
|
||||
free(dpy->xcl->partial_request);
|
||||
dpy->xcl->partial_request = 0;
|
||||
dpy->xcl->partial_request_offset = 0;
|
||||
free(dpy->xcb->partial_request);
|
||||
dpy->xcb->partial_request = 0;
|
||||
dpy->xcb->partial_request_offset = 0;
|
||||
}
|
||||
|
||||
/* is there anything to copy into partial_request? */
|
||||
if(iov[3].iov_len != 0 || iov[4].iov_len != 0 || iov[5].iov_len != 0)
|
||||
{
|
||||
int i;
|
||||
if(!dpy->xcl->partial_request)
|
||||
if(!dpy->xcb->partial_request)
|
||||
{
|
||||
size_t len = request_length(iov + 3);
|
||||
assert(!dpy->xcl->partial_request_offset);
|
||||
dpy->xcl->partial_request = malloc(len);
|
||||
assert(dpy->xcl->partial_request);
|
||||
assert(!dpy->xcb->partial_request_offset);
|
||||
dpy->xcb->partial_request = malloc(len);
|
||||
assert(dpy->xcb->partial_request);
|
||||
}
|
||||
for(i = 3; i < sizeof(iov) / sizeof(*iov); ++i)
|
||||
{
|
||||
memcpy(dpy->xcl->partial_request + dpy->xcl->partial_request_offset, iov[i].iov_base, iov[i].iov_len);
|
||||
dpy->xcl->partial_request_offset += iov[i].iov_len;
|
||||
memcpy(dpy->xcb->partial_request + dpy->xcb->partial_request_offset, iov[i].iov_base, iov[i].iov_len);
|
||||
dpy->xcb->partial_request_offset += iov[i].iov_len;
|
||||
}
|
||||
}
|
||||
|
||||
dpy->xcl->request_extra = 0;
|
||||
dpy->xcl->request_extra_size = 0;
|
||||
dpy->xcb->request_extra = 0;
|
||||
dpy->xcb->request_extra_size = 0;
|
||||
dpy->bufptr = dpy->buffer;
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue