From 301a9965638376a7edfb052ed8640a2f88290b81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20H=C3=B6glund?= Date: Thu, 8 Jan 2015 07:12:20 +0100 Subject: [PATCH] glx: Fix the swap event filter for DRI3 drivers The drawable field is set to the X drawable ID when the swap event is synthesized by DRI2WireToEvent(), and the GLX drawable ID when the event is received over the wire. The latter being the case with DRI3. __glXWireToEvent() fixes this for Xlib clients by changing the field to the X drawable ID. This doesn't work for xcb clients however, so we have to expect the field to be set to either the X or the GLX drawable ID. BUG: 342582 --- glxbackend.cpp | 13 ++++++++----- glxbackend.h | 4 +++- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/glxbackend.cpp b/glxbackend.cpp index fc0046d9c3..78efa4ebc3 100644 --- a/glxbackend.cpp +++ b/glxbackend.cpp @@ -41,7 +41,6 @@ along with this program. If not, see . #include // system #include -#include #include #include @@ -79,9 +78,10 @@ namespace std { namespace KWin { -SwapEventFilter::SwapEventFilter(xcb_drawable_t drawable) +SwapEventFilter::SwapEventFilter(xcb_drawable_t drawable, xcb_glx_drawable_t glxDrawable) : X11EventFilter(Xcb::Extensions::self()->glxEventBase() + XCB_GLX_BUFFER_SWAP_COMPLETE), - m_drawable(drawable) + m_drawable(drawable), + m_glxDrawable(glxDrawable) { } @@ -90,7 +90,10 @@ bool SwapEventFilter::event(xcb_generic_event_t *event) xcb_glx_buffer_swap_complete_event_t *ev = reinterpret_cast(event); - if (ev->drawable == m_drawable) { + // The drawable field is the X drawable when the event was synthesized + // by a WireToEvent handler, and the GLX drawable when the event was + // received over the wire + if (ev->drawable == m_drawable || ev->drawable == m_glxDrawable) { Compositor::self()->bufferSwapComplete(); return true; } @@ -192,7 +195,7 @@ void GlxBackend::init() } if (m_haveINTELSwapEvent) { - m_swapEventFilter = std::make_unique(window); + m_swapEventFilter = std::make_unique(window, glxWindow); glXSelectEvent(display(), glxWindow, GLX_BUFFER_SWAP_COMPLETE_INTEL_MASK); } diff --git a/glxbackend.h b/glxbackend.h index fba0a3459c..5fd0b0bd6a 100644 --- a/glxbackend.h +++ b/glxbackend.h @@ -22,6 +22,7 @@ along with this program. If not, see . #include "scene_opengl.h" #include "x11eventfilter.h" +#include #include namespace KWin @@ -44,11 +45,12 @@ public: class SwapEventFilter : public X11EventFilter { public: - SwapEventFilter(xcb_drawable_t drawable); + SwapEventFilter(xcb_drawable_t drawable, xcb_glx_drawable_t glxDrawable); bool event(xcb_generic_event_t *event) override; private: xcb_drawable_t m_drawable; + xcb_glx_drawable_t m_glxDrawable; };