From b65d54f4d22142aa86fee902248bcf2579e09cc8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Tue, 25 Jun 2013 10:39:13 +0200 Subject: [PATCH] Enforce compositing if required In the Wayland world we need to have a compositor. This means we have to enforce that the compositor is running. If the setup fails we have to quit, because it doesn't make any sense any more to be running. A new method requiresCompositing() is added to the Application. If it returns true the useCompositing option will always return true and the unredirect fullscreen option will always return false. That way compositing is enforced at startup and cannot end by unredirecting. In addition this method is checked if actions are performed which would suspend compositing. E.g. the shortcut to toggle compositing. Restarting the compositor is still possible in order to change the selected compositing backend without a restart. But if it fails KWin will quit. --- composite.cpp | 23 +++++++++++++++++++++++ main.cpp | 5 +++++ main.h | 1 + options.h | 5 +++-- 4 files changed, 32 insertions(+), 2 deletions(-) diff --git a/composite.cpp b/composite.cpp index 754e06b119..ecb61bb4c8 100644 --- a/composite.cpp +++ b/composite.cpp @@ -221,6 +221,11 @@ void Compositor::slotCompositingOptionsInitialized() m_starting = false; cm_selection->owning = false; cm_selection->release(); + if (kwinApp()->requiresCompositing()) { + qCritical() << "The used windowing system requires compositing"; + qCritical() << "We are going to quit KWin now as it is broken"; + qApp->quit(); + } return; } if (m_scene == NULL || m_scene->initFailed()) { @@ -231,6 +236,11 @@ void Compositor::slotCompositingOptionsInitialized() m_starting = false; cm_selection->owning = false; cm_selection->release(); + if (kwinApp()->requiresCompositing()) { + qCritical() << "The used windowing system requires compositing"; + qCritical() << "We are going to quit KWin now as it is broken"; + qApp->quit(); + } return; } m_xrrRefreshRate = KWin::currentRefreshRate(); @@ -412,6 +422,10 @@ void Compositor::slotReinitialize() // for the shortcut void Compositor::slotToggleCompositing() { + if (kwinApp()->requiresCompositing()) { + // we are not allowed to turn on/off compositing + return; + } if (m_suspended) { // direct user call; clear all bits resume(AllReasonSuspend); } else { // but only set the user one (sufficient to suspend) @@ -442,6 +456,9 @@ void Compositor::updateCompositeBlocking() void Compositor::updateCompositeBlocking(Client *c) { + if (kwinApp()->requiresCompositing()) { + return; + } if (c) { // if c == 0 we just check if we can resume if (c->isBlockingCompositing()) { if (!(m_suspended & BlockRuleSuspend)) // do NOT attempt to call suspend(true); from within the eventchain! @@ -464,6 +481,9 @@ void Compositor::updateCompositeBlocking(Client *c) void Compositor::suspend(Compositor::SuspendReason reason) { + if (kwinApp()->requiresCompositing()) { + return; + } Q_ASSERT(reason != NoReasonSuspend); m_suspended |= reason; finish(); @@ -478,6 +498,9 @@ void Compositor::resume(Compositor::SuspendReason reason) void Compositor::setCompositing(bool active) { + if (kwinApp()->requiresCompositing()) { + return; + } if (active) { resume(ScriptSuspend); } else { diff --git a/main.cpp b/main.cpp index cc36c13085..c3fc859681 100644 --- a/main.cpp +++ b/main.cpp @@ -218,6 +218,11 @@ bool Application::shouldUseWaylandForCompositing() const return m_operationMode == OperationModeWaylandAndX11; } +bool Application::requiresCompositing() const +{ + return shouldUseWaylandForCompositing(); +} + void Application::start() { setQuitOnLastWindowClosed(false); diff --git a/main.h b/main.h index 4911c18bad..7c32f65ed0 100644 --- a/main.h +++ b/main.h @@ -87,6 +87,7 @@ public: OperationMode operationMode() const; void setOperationMode(OperationMode mode); bool shouldUseWaylandForCompositing() const; + bool requiresCompositing() const; static void setCrashCount(int count); static bool wasCrash(); diff --git a/options.h b/options.h index d0f0fefb46..48ce693681 100644 --- a/options.h +++ b/options.h @@ -25,6 +25,7 @@ along with this program. If not, see . #include +#include "main.h" #include "placement.h" namespace KWin @@ -496,7 +497,7 @@ public: } // Separate to mode so the user can toggle bool isUseCompositing() const { - return m_useCompositing; + return m_useCompositing || kwinApp()->requiresCompositing(); } bool isCompositingInitialized() const { return m_compositingInitialized; @@ -507,7 +508,7 @@ public: return m_hiddenPreviews; } bool isUnredirectFullscreen() const { - return m_unredirectFullscreen; + return m_unredirectFullscreen && !kwinApp()->requiresCompositing(); } // OpenGL // 0 = no, 1 = yes when transformed,