summaryrefslogtreecommitdiff
path: root/lib/XCL/Pending.c
diff options
context:
space:
mode:
authorJamey Sharp <jamey@minilop.net>2002-04-07 11:48:12 +0000
committerJamey Sharp <jamey@minilop.net>2002-04-07 11:48:12 +0000
commit1c5f633e1fcee58eba38fe3b0942865fe5a3a874 (patch)
tree4adedc996f927154ef21163ca5ce4e55c25a4508 /lib/XCL/Pending.c
parent09e8de5a74d363033f03cbad0d07417eb1522647 (diff)
No more event queue in the Display: events stay in XCB now. Gnome `w'
support begun. (PutImage is broken.)
Diffstat (limited to 'lib/XCL/Pending.c')
-rw-r--r--lib/XCL/Pending.c36
1 files changed, 17 insertions, 19 deletions
diff --git a/lib/XCL/Pending.c b/lib/XCL/Pending.c
index f8da4f2..4e8380f 100644
--- a/lib/XCL/Pending.c
+++ b/lib/XCL/Pending.c
@@ -4,18 +4,15 @@
*
* See the file COPYING for licensing information. */
#include "xclint.h"
+#include <xcb_event.h>
/* Read in pending events if needed and return the number of queued events. */
int XEventsQueued(register Display *dpy, int mode)
{
- int ret_val;
- LockDisplay(dpy);
- if (dpy->qlen || (mode == QueuedAlready))
- ret_val = dpy->qlen;
- else
- ret_val = _XEventsQueued (dpy, mode);
- UnlockDisplay(dpy);
- return ret_val;
+ int ret = XCBEventQueueLength(XCBConnectionOfDisplay(dpy));
+ if(!ret && mode != QueuedAlready)
+ ret = _XEventsQueued(dpy, mode);
+ return ret;
}
int XPending(Display *dpy)
@@ -25,21 +22,22 @@ int XPending(Display *dpy)
int _XEventsQueued(register Display *dpy, int mode)
{
- fd_set fds;
- struct timeval tv = { 0, 0 };
+ XCBConnection *c = XCBConnectionOfDisplay(dpy);
if(mode == QueuedAfterFlush)
+ XCBFlush(c);
+
+ /* wait for handle to be readable, without blocking. */
+ /* FIXME: this select/XCBWait hack breaks encapsulation. */
+ if(XCBEventQueueIsEmpty(c))
{
- _XFlush(dpy);
- if(dpy->qlen)
- return(dpy->qlen);
- }
- if(XCBEventQueueIsEmpty(XCBConnectionOfDisplay(dpy)))
- {
+ fd_set fds;
+ struct timeval tv = { 0, 0 };
FD_ZERO(&fds);
FD_SET(dpy->fd, &fds);
if(select(dpy->fd + 1, &fds, 0, 0, &tv) < 1)
- return(dpy->qlen);
+ return 0;
+ XCBWait(c->handle, /* should_write */ 0);
}
- _XReadEvents(dpy);
- return(dpy->qlen);
+
+ return XCBEventQueueLength(c);
}