diff --git a/src/core/renderloop.cpp b/src/core/renderloop.cpp index 75ce3096b8..1b3e98c909 100644 --- a/src/core/renderloop.cpp +++ b/src/core/renderloop.cpp @@ -263,7 +263,7 @@ void RenderLoop::setFullscreenSurface(Item *surfaceItem) { d->fullscreenItem = surfaceItem; if (SurfaceItemWayland *wayland = qobject_cast(surfaceItem)) { - d->allowTearing = d->canDoTearing && wayland->surface()->presentationHint() == KWaylandServer::PresentationHint::Async; + d->allowTearing = d->canDoTearing && options->allowTearing() && wayland->surface()->presentationHint() == KWaylandServer::PresentationHint::Async; } else { d->allowTearing = false; } diff --git a/src/kcmkwin/kwincompositing/compositing.ui b/src/kcmkwin/kwincompositing/compositing.ui index 2810f6676d..286c21c7ef 100644 --- a/src/kcmkwin/kwincompositing/compositing.ui +++ b/src/kcmkwin/kwincompositing/compositing.ui @@ -207,6 +207,16 @@ you can reset this protection but be aware that this might result in an immediat + + + + Allows applications to cause screen tearing in fullscreen. + + + Allow tearing in fullscreen + + + diff --git a/src/kcmkwin/kwincompositing/kwincompositing_setting.kcfg b/src/kcmkwin/kwincompositing/kwincompositing_setting.kcfg index e024582fa0..0488de1fbd 100644 --- a/src/kcmkwin/kwincompositing/kwincompositing_setting.kcfg +++ b/src/kcmkwin/kwincompositing/kwincompositing_setting.kcfg @@ -45,6 +45,10 @@ LatencyMedium + + true + + diff --git a/src/kcmkwin/kwincompositing/main.cpp b/src/kcmkwin/kwincompositing/main.cpp index 80c03c0225..df37e2dff9 100644 --- a/src/kcmkwin/kwincompositing/main.cpp +++ b/src/kcmkwin/kwincompositing/main.cpp @@ -85,6 +85,7 @@ KWinCompositingKCM::KWinCompositingKCM(QWidget *parent, const QVariantList &args m_form.kcfg_Enabled->setVisible(!compositingRequired()); m_form.kcfg_WindowsBlockCompositing->setVisible(!compositingRequired()); m_form.compositingLabel->setVisible(!compositingRequired()); + m_form.kcfg_AllowTearing->setVisible(compositingRequired()); connect(this, &KWinCompositingKCM::defaultsIndicatorsVisibleChanged, this, &KWinCompositingKCM::updateUnmanagedItemStatus); diff --git a/src/kwin.kcfg b/src/kwin.kcfg index d30ce1f9d5..17d0c8486c 100644 --- a/src/kwin.kcfg +++ b/src/kwin.kcfg @@ -278,6 +278,9 @@ RenderTimeEstimatorMaximum + + true + diff --git a/src/options.cpp b/src/options.cpp index a069013588..e74d46cb58 100644 --- a/src/options.cpp +++ b/src/options.cpp @@ -653,6 +653,19 @@ void Options::setRenderTimeEstimator(RenderTimeEstimator estimator) Q_EMIT renderTimeEstimatorChanged(); } +bool Options::allowTearing() const +{ + return m_allowTearing; +} + +void Options::setAllowTearing(bool allow) +{ + if (allow != m_allowTearing) { + m_allowTearing = allow; + Q_EMIT allowTearingChanged(); + } +} + void Options::setGlPlatformInterface(OpenGLPlatformInterface interface) { // check environment variable @@ -793,6 +806,7 @@ void Options::syncFromKcfgc() setMoveMinimizedWindowsToEndOfTabBoxFocusChain(m_settings->moveMinimizedWindowsToEndOfTabBoxFocusChain()); setLatencyPolicy(m_settings->latencyPolicy()); setRenderTimeEstimator(m_settings->renderTimeEstimator()); + setAllowTearing(m_settings->allowTearing()); } bool Options::loadCompositingConfig(bool force) diff --git a/src/options.h b/src/options.h index 46922566e6..a8f4a7c804 100644 --- a/src/options.h +++ b/src/options.h @@ -214,6 +214,7 @@ class KWIN_EXPORT Options : public QObject Q_PROPERTY(bool windowsBlockCompositing READ windowsBlockCompositing WRITE setWindowsBlockCompositing NOTIFY windowsBlockCompositingChanged) Q_PROPERTY(LatencyPolicy latencyPolicy READ latencyPolicy WRITE setLatencyPolicy NOTIFY latencyPolicyChanged) Q_PROPERTY(RenderTimeEstimator renderTimeEstimator READ renderTimeEstimator WRITE setRenderTimeEstimator NOTIFY renderTimeEstimatorChanged) + Q_PROPERTY(bool allowTearing READ allowTearing WRITE setAllowTearing NOTIFY allowTearingChanged) public: explicit Options(QObject *parent = nullptr); ~Options() override; @@ -704,6 +705,7 @@ public: QStringList modifierOnlyDBusShortcut(Qt::KeyboardModifier mod) const; LatencyPolicy latencyPolicy() const; RenderTimeEstimator renderTimeEstimator() const; + bool allowTearing() const; // setters void setFocusPolicy(FocusPolicy focusPolicy); @@ -763,6 +765,7 @@ public: void setMoveMinimizedWindowsToEndOfTabBoxFocusChain(bool set); void setLatencyPolicy(LatencyPolicy policy); void setRenderTimeEstimator(RenderTimeEstimator estimator); + void setAllowTearing(bool allow); // default values static WindowOperation defaultOperationTitlebarDblClick() @@ -969,6 +972,7 @@ Q_SIGNALS: void latencyPolicyChanged(); void configChanged(); void renderTimeEstimatorChanged(); + void allowTearingChanged(); private: void setElectricBorders(int borders); @@ -1042,6 +1046,8 @@ private: bool borderless_maximized_windows; bool condensed_title; + bool m_allowTearing = true; + QHash m_modifierOnlyShortcuts; MouseCommand wheelToMouseCommand(MouseWheelCommand com, int delta) const;