diff --git a/platformsupport/scenes/opengl/backend.h b/platformsupport/scenes/opengl/backend.h --- a/platformsupport/scenes/opengl/backend.h +++ b/platformsupport/scenes/opengl/backend.h @@ -85,6 +85,7 @@ virtual bool makeCurrent() = 0; virtual void doneCurrent() = 0; virtual bool usesOverlayWindow() const = 0; + virtual bool hasSwapEvent() const { return true; } /** * Whether the rendering needs to be split per screen. * Default implementation returns @c false. diff --git a/plugins/platforms/x11/standalone/glxbackend.h b/plugins/platforms/x11/standalone/glxbackend.h --- a/plugins/platforms/x11/standalone/glxbackend.h +++ b/plugins/platforms/x11/standalone/glxbackend.h @@ -77,6 +77,7 @@ void doneCurrent() override; OverlayWindow* overlayWindow() const override; bool usesOverlayWindow() const override; + bool hasSwapEvent() const override; void init() override; protected: @@ -111,7 +112,6 @@ bool m_haveMESACopySubBuffer = false; bool m_haveMESASwapControl = false; bool m_haveEXTSwapControl = false; - bool m_haveINTELSwapEvent = false; Display *m_x11Display; friend class GlxTexture; }; diff --git a/plugins/platforms/x11/standalone/glxbackend.cpp b/plugins/platforms/x11/standalone/glxbackend.cpp --- a/plugins/platforms/x11/standalone/glxbackend.cpp +++ b/plugins/platforms/x11/standalone/glxbackend.cpp @@ -206,11 +206,10 @@ m_haveMESACopySubBuffer = hasExtension(QByteArrayLiteral("GLX_MESA_copy_sub_buffer")); m_haveMESASwapControl = hasExtension(QByteArrayLiteral("GLX_MESA_swap_control")); m_haveEXTSwapControl = hasExtension(QByteArrayLiteral("GLX_EXT_swap_control")); - // only enable Intel swap event if env variable is set, see BUG 342582 - m_haveINTELSwapEvent = hasExtension(QByteArrayLiteral("GLX_INTEL_swap_event")) - && qgetenv("KWIN_USE_INTEL_SWAP_EVENT") == QByteArrayLiteral("1"); - if (m_haveINTELSwapEvent) { + // only enable Intel swap event if env variable is set, see BUG 342582 + if (hasExtension(QByteArrayLiteral("GLX_INTEL_swap_event")) && + qgetenv("KWIN_USE_INTEL_SWAP_EVENT") == QByteArrayLiteral("1")) { m_swapEventFilter = std::make_unique(window, glxWindow); glXSelectEvent(display(), glxWindow, GLX_BUFFER_SWAP_COMPLETE_INTEL_MASK); } @@ -668,8 +667,9 @@ const bool fullRepaint = supportsBufferAge() || (lastDamage() == displayRegion); if (fullRepaint) { - if (m_haveINTELSwapEvent) + if (hasSwapEvent()) { Compositor::self()->aboutToSwapBuffers(); + } glXSwapBuffers(display(), glxWindow); @@ -782,6 +782,11 @@ return true; } +bool GlxBackend::hasSwapEvent() const +{ + return m_swapEventFilter != nullptr; +} + /******************************************************** * GlxTexture *******************************************************/ diff --git a/plugins/scenes/opengl/scene_opengl.h b/plugins/scenes/opengl/scene_opengl.h --- a/plugins/scenes/opengl/scene_opengl.h +++ b/plugins/scenes/opengl/scene_opengl.h @@ -53,6 +53,7 @@ void screenGeometryChanged(const QSize &size) override; OverlayWindow *overlayWindow() const override; bool usesOverlayWindow() const override; + bool hasSwapEvent() const override; bool makeOpenGLContextCurrent() override; void doneOpenGLContextCurrent() override; Decoration::Renderer *createDecorationRenderer(Decoration::DecoratedClientImpl *impl) override; diff --git a/plugins/scenes/opengl/scene_opengl.cpp b/plugins/scenes/opengl/scene_opengl.cpp --- a/plugins/scenes/opengl/scene_opengl.cpp +++ b/plugins/scenes/opengl/scene_opengl.cpp @@ -522,6 +522,11 @@ return m_backend->overlayWindow(); } +bool SceneOpenGL::hasSwapEvent() const +{ + return m_backend->hasSwapEvent(); +} + void SceneOpenGL::idle() { m_backend->idle(); diff --git a/scene.h b/scene.h --- a/scene.h +++ b/scene.h @@ -146,6 +146,7 @@ // there's nothing to paint (adjust time_diff later) virtual void idle(); virtual OverlayWindow* overlayWindow() const = 0; + virtual bool hasSwapEvent() const; virtual bool makeOpenGLContextCurrent(); virtual void doneOpenGLContextCurrent(); diff --git a/scene.cpp b/scene.cpp --- a/scene.cpp +++ b/scene.cpp @@ -629,6 +629,11 @@ overlayWindow()->resize(size); } +bool Scene::hasSwapEvent() const +{ + return false; +} + bool Scene::makeOpenGLContextCurrent() { return false;