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.
This commit is contained in:
parent
1be3a7a9f0
commit
b65d54f4d2
4 changed files with 32 additions and 2 deletions
|
@ -221,6 +221,11 @@ void Compositor::slotCompositingOptionsInitialized()
|
||||||
m_starting = false;
|
m_starting = false;
|
||||||
cm_selection->owning = false;
|
cm_selection->owning = false;
|
||||||
cm_selection->release();
|
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;
|
return;
|
||||||
}
|
}
|
||||||
if (m_scene == NULL || m_scene->initFailed()) {
|
if (m_scene == NULL || m_scene->initFailed()) {
|
||||||
|
@ -231,6 +236,11 @@ void Compositor::slotCompositingOptionsInitialized()
|
||||||
m_starting = false;
|
m_starting = false;
|
||||||
cm_selection->owning = false;
|
cm_selection->owning = false;
|
||||||
cm_selection->release();
|
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;
|
return;
|
||||||
}
|
}
|
||||||
m_xrrRefreshRate = KWin::currentRefreshRate();
|
m_xrrRefreshRate = KWin::currentRefreshRate();
|
||||||
|
@ -412,6 +422,10 @@ void Compositor::slotReinitialize()
|
||||||
// for the shortcut
|
// for the shortcut
|
||||||
void Compositor::slotToggleCompositing()
|
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
|
if (m_suspended) { // direct user call; clear all bits
|
||||||
resume(AllReasonSuspend);
|
resume(AllReasonSuspend);
|
||||||
} else { // but only set the user one (sufficient to suspend)
|
} else { // but only set the user one (sufficient to suspend)
|
||||||
|
@ -442,6 +456,9 @@ void Compositor::updateCompositeBlocking()
|
||||||
|
|
||||||
void Compositor::updateCompositeBlocking(Client *c)
|
void Compositor::updateCompositeBlocking(Client *c)
|
||||||
{
|
{
|
||||||
|
if (kwinApp()->requiresCompositing()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (c) { // if c == 0 we just check if we can resume
|
if (c) { // if c == 0 we just check if we can resume
|
||||||
if (c->isBlockingCompositing()) {
|
if (c->isBlockingCompositing()) {
|
||||||
if (!(m_suspended & BlockRuleSuspend)) // do NOT attempt to call suspend(true); from within the eventchain!
|
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)
|
void Compositor::suspend(Compositor::SuspendReason reason)
|
||||||
{
|
{
|
||||||
|
if (kwinApp()->requiresCompositing()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
Q_ASSERT(reason != NoReasonSuspend);
|
Q_ASSERT(reason != NoReasonSuspend);
|
||||||
m_suspended |= reason;
|
m_suspended |= reason;
|
||||||
finish();
|
finish();
|
||||||
|
@ -478,6 +498,9 @@ void Compositor::resume(Compositor::SuspendReason reason)
|
||||||
|
|
||||||
void Compositor::setCompositing(bool active)
|
void Compositor::setCompositing(bool active)
|
||||||
{
|
{
|
||||||
|
if (kwinApp()->requiresCompositing()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (active) {
|
if (active) {
|
||||||
resume(ScriptSuspend);
|
resume(ScriptSuspend);
|
||||||
} else {
|
} else {
|
||||||
|
|
5
main.cpp
5
main.cpp
|
@ -218,6 +218,11 @@ bool Application::shouldUseWaylandForCompositing() const
|
||||||
return m_operationMode == OperationModeWaylandAndX11;
|
return m_operationMode == OperationModeWaylandAndX11;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Application::requiresCompositing() const
|
||||||
|
{
|
||||||
|
return shouldUseWaylandForCompositing();
|
||||||
|
}
|
||||||
|
|
||||||
void Application::start()
|
void Application::start()
|
||||||
{
|
{
|
||||||
setQuitOnLastWindowClosed(false);
|
setQuitOnLastWindowClosed(false);
|
||||||
|
|
1
main.h
1
main.h
|
@ -87,6 +87,7 @@ public:
|
||||||
OperationMode operationMode() const;
|
OperationMode operationMode() const;
|
||||||
void setOperationMode(OperationMode mode);
|
void setOperationMode(OperationMode mode);
|
||||||
bool shouldUseWaylandForCompositing() const;
|
bool shouldUseWaylandForCompositing() const;
|
||||||
|
bool requiresCompositing() const;
|
||||||
|
|
||||||
static void setCrashCount(int count);
|
static void setCrashCount(int count);
|
||||||
static bool wasCrash();
|
static bool wasCrash();
|
||||||
|
|
|
@ -25,6 +25,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
#include <kdecoration.h>
|
#include <kdecoration.h>
|
||||||
|
|
||||||
|
#include "main.h"
|
||||||
#include "placement.h"
|
#include "placement.h"
|
||||||
|
|
||||||
namespace KWin
|
namespace KWin
|
||||||
|
@ -496,7 +497,7 @@ public:
|
||||||
}
|
}
|
||||||
// Separate to mode so the user can toggle
|
// Separate to mode so the user can toggle
|
||||||
bool isUseCompositing() const {
|
bool isUseCompositing() const {
|
||||||
return m_useCompositing;
|
return m_useCompositing || kwinApp()->requiresCompositing();
|
||||||
}
|
}
|
||||||
bool isCompositingInitialized() const {
|
bool isCompositingInitialized() const {
|
||||||
return m_compositingInitialized;
|
return m_compositingInitialized;
|
||||||
|
@ -507,7 +508,7 @@ public:
|
||||||
return m_hiddenPreviews;
|
return m_hiddenPreviews;
|
||||||
}
|
}
|
||||||
bool isUnredirectFullscreen() const {
|
bool isUnredirectFullscreen() const {
|
||||||
return m_unredirectFullscreen;
|
return m_unredirectFullscreen && !kwinApp()->requiresCompositing();
|
||||||
}
|
}
|
||||||
// OpenGL
|
// OpenGL
|
||||||
// 0 = no, 1 = yes when transformed,
|
// 0 = no, 1 = yes when transformed,
|
||||||
|
|
Loading…
Reference in a new issue