Merge pull request #52 from yshui/dri2-hack

Workaround the incompatibility between DRI2 and xcb

Fixes #33 #34 #47
This commit is contained in:
yshui 2018-11-11 13:11:33 +00:00 committed by Yuxuan Shui
commit a61b877e22
1 changed files with 26 additions and 0 deletions

View File

@ -11,6 +11,8 @@
#include <ctype.h> #include <ctype.h>
#include <string.h> #include <string.h>
#include <X11/Xlib.h>
#include <X11/Xlibint.h>
#include <xcb/randr.h> #include <xcb/randr.h>
#include <xcb/present.h> #include <xcb/present.h>
#include <xcb/damage.h> #include <xcb/damage.h>
@ -28,6 +30,8 @@
#include "config.h" #include "config.h"
#include "diagnostic.h" #include "diagnostic.h"
#define auto __auto_type
static void static void
finish_destroy_win(session_t *ps, win **_w); finish_destroy_win(session_t *ps, win **_w);
@ -3236,6 +3240,28 @@ ev_handle(session_t *ps, xcb_generic_event_t *ev) {
} }
#endif #endif
// Check if a custom XEvent constructor was registered in xlib for this event
// type, and call it discarding the constructed XEvent if any. XESetWireToEvent
// might be used by libraries to intercept messages from the X server e.g. the
// OpenGL lib waiting for DRI2 events.
// XXX This exists to workaround compton issue #33, #34, #47
// For even more details, see:
// https://bugs.freedesktop.org/show_bug.cgi?id=35945
// https://lists.freedesktop.org/archives/xcb/2011-November/007337.html
auto proc = XESetWireToEvent(ps->dpy, ev->response_type, 0);
if (proc) {
XESetWireToEvent(ps->dpy, ev->response_type, proc);
XEvent dummy;
// Stop Xlib from complaining about lost sequence numbers.
// proc might also just be Xlib internal event processing functions, and
// because they probably won't see all X replies, they will complain about
// missing sequence numbers.
ev->sequence = LastKnownRequestProcessed(ps->dpy);
proc(ps->dpy, &dummy, (xEvent *)ev);
}
// XXX redraw needs to be more fine grained // XXX redraw needs to be more fine grained
queue_redraw(ps); queue_redraw(ps);