diff --git a/platformsupport/scenes/opengl/backend.h b/platformsupport/scenes/opengl/backend.h index 51a5e7da53..bd8b3bc1df 100644 --- a/platformsupport/scenes/opengl/backend.h +++ b/platformsupport/scenes/opengl/backend.h @@ -85,6 +85,7 @@ public: 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.cpp b/plugins/platforms/x11/standalone/glxbackend.cpp index 3897525554..ce6281afc0 100644 --- a/plugins/platforms/x11/standalone/glxbackend.cpp +++ b/plugins/platforms/x11/standalone/glxbackend.cpp @@ -206,11 +206,10 @@ void GlxBackend::init() 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 @@ void GlxBackend::present() const bool fullRepaint = supportsBufferAge() || (lastDamage() == displayRegion); if (fullRepaint) { - if (m_haveINTELSwapEvent) + if (hasSwapEvent()) { Compositor::self()->aboutToSwapBuffers(); + } glXSwapBuffers(display(), glxWindow); @@ -782,6 +782,11 @@ bool GlxBackend::usesOverlayWindow() const return true; } +bool GlxBackend::hasSwapEvent() const +{ + return m_swapEventFilter != nullptr; +} + /******************************************************** * GlxTexture *******************************************************/ diff --git a/plugins/platforms/x11/standalone/glxbackend.h b/plugins/platforms/x11/standalone/glxbackend.h index d72dda8658..71c9c3e256 100644 --- a/plugins/platforms/x11/standalone/glxbackend.h +++ b/plugins/platforms/x11/standalone/glxbackend.h @@ -77,6 +77,7 @@ public: void doneCurrent() override; OverlayWindow* overlayWindow() const override; bool usesOverlayWindow() const override; + bool hasSwapEvent() const override; void init() override; protected: @@ -111,7 +112,6 @@ private: 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/scenes/opengl/scene_opengl.cpp b/plugins/scenes/opengl/scene_opengl.cpp index 5c61a4ae2e..77ae13d0c7 100644 --- a/plugins/scenes/opengl/scene_opengl.cpp +++ b/plugins/scenes/opengl/scene_opengl.cpp @@ -522,6 +522,11 @@ OverlayWindow *SceneOpenGL::overlayWindow() const return m_backend->overlayWindow(); } +bool SceneOpenGL::hasSwapEvent() const +{ + return m_backend->hasSwapEvent(); +} + void SceneOpenGL::idle() { m_backend->idle(); diff --git a/plugins/scenes/opengl/scene_opengl.h b/plugins/scenes/opengl/scene_opengl.h index 094bfe6d4e..e8fdbe6aea 100644 --- a/plugins/scenes/opengl/scene_opengl.h +++ b/plugins/scenes/opengl/scene_opengl.h @@ -53,6 +53,7 @@ public: 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/scene.cpp b/scene.cpp index b466046b54..bf95159922 100644 --- a/scene.cpp +++ b/scene.cpp @@ -629,6 +629,11 @@ void Scene::screenGeometryChanged(const QSize &size) overlayWindow()->resize(size); } +bool Scene::hasSwapEvent() const +{ + return false; +} + bool Scene::makeOpenGLContextCurrent() { return false; diff --git a/scene.h b/scene.h index 7e7aee5847..66c8f705be 100644 --- a/scene.h +++ b/scene.h @@ -146,6 +146,7 @@ public: // 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();