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.
icc-effect-5.14.5
Martin Gräßlin 2013-06-25 10:39:13 +02:00
parent 1be3a7a9f0
commit b65d54f4d2
4 changed files with 32 additions and 2 deletions

View File

@ -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 {

View File

@ -218,6 +218,11 @@ bool Application::shouldUseWaylandForCompositing() const
return m_operationMode == OperationModeWaylandAndX11;
}
bool Application::requiresCompositing() const
{
return shouldUseWaylandForCompositing();
}
void Application::start()
{
setQuitOnLastWindowClosed(false);

1
main.h
View File

@ -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();

View File

@ -25,6 +25,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <kdecoration.h>
#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,