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; };