From f97c92fde94aa8b6ab0688b456afb4d46a1289a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Thu, 28 Apr 2011 15:56:50 +0200 Subject: [PATCH] KWin does not require a decoration plugin any more With config option "NoPlugin" in group "Style" it is possible to no request that KWin should be run without a decoration plugin. This is a change for Plasma Active to properly support no decorations. As well if a decoration plugin cannot be loaded, KWin will no longer exit, but continue to run just without a decoration. As a nice side-effect changes in Oxygen no longer destroy my kwin build ;-) BUG: 224440 FIXED-IN: 4.7.0 CCMAIL: sebas@kde.org --- client.cpp | 2 +- composite.cpp | 6 ++++-- libkdecorations/kdecoration_plugins_p.cpp | 6 +++++- plugins.cpp | 17 +++++++++++++--- plugins.h | 7 +++++++ workspace.cpp | 24 +++++++++++++++++------ workspace.h | 24 +++++++++++++++++++++++ 7 files changed, 73 insertions(+), 13 deletions(-) diff --git a/client.cpp b/client.cpp index ee2fef0674..247d35b761 100644 --- a/client.cpp +++ b/client.cpp @@ -695,7 +695,7 @@ void Client::resizeDecoration(const QSize& s) bool Client::noBorder() const { - return noborder || isFullScreen(); + return !workspace()->hasDecorationPlugin() || noborder || isFullScreen(); } bool Client::userCanSetNoBorder() const diff --git a/composite.cpp b/composite.cpp index 66638b11de..598db03636 100644 --- a/composite.cpp +++ b/composite.cpp @@ -319,8 +319,10 @@ void Workspace::suspendCompositing(bool suspend) finishCompositing(); setupCompositing(); // will do nothing if suspended // notify decorations that composition state has changed - KDecorationFactory* factory = mgr->factory(); - factory->reset(SettingCompositing); + if (hasDecorationPlugin()) { + KDecorationFactory* factory = mgr->factory(); + factory->reset(SettingCompositing); + } emit compositingToggled(!compositingSuspended); } diff --git a/libkdecorations/kdecoration_plugins_p.cpp b/libkdecorations/kdecoration_plugins_p.cpp index d5957e81ed..26e01bfadc 100644 --- a/libkdecorations/kdecoration_plugins_p.cpp +++ b/libkdecorations/kdecoration_plugins_p.cpp @@ -101,10 +101,14 @@ KDecoration* KDecorationPlugins::createDecoration(KDecorationBridge* bridge) // returns true if plugin was loaded successfully bool KDecorationPlugins::loadPlugin(QString nameStr) { + KConfigGroup group(config, QString("Style")); if (nameStr.isEmpty()) { - KConfigGroup group(config, QString("Style")); nameStr = group.readEntry("PluginLib", defaultPlugin); } + if (group.readEntry("NoPlugin", false)) { + error(i18n("Loading of window decoration plugin library disabled in configuration.")); + return false; + } KLibrary *oldLibrary = library; KDecorationFactory* oldFactory = fact; diff --git a/plugins.cpp b/plugins.cpp index e31ace91fe..d31548af1a 100644 --- a/plugins.cpp +++ b/plugins.cpp @@ -31,6 +31,7 @@ namespace KWin PluginMgr::PluginMgr() : KDecorationPlugins(KGlobal::config()) + , m_noDecoration(false) { defaultPlugin = (QPixmap::defaultDepth() > 8) ? "kwin3_oxygen" : "kwin3_plastik"; @@ -39,9 +40,9 @@ PluginMgr::PluginMgr() void PluginMgr::error(const QString &error_msg) { - qWarning("%s", (i18n("KWin: ") + error_msg + - i18n("\nKWin will now exit...")).toLocal8Bit().data()); - exit(1); + qWarning("%s", (i18n("KWin: ") + error_msg).toLocal8Bit().data()); + + setNoDecoration(true); } bool PluginMgr::provides(Requirement) @@ -49,4 +50,14 @@ bool PluginMgr::provides(Requirement) return false; } +void PluginMgr::setNoDecoration(bool noDecoration) +{ + m_noDecoration = noDecoration; +} + +bool PluginMgr::hasNoDecoration() const +{ + return m_noDecoration; +} + } // namespace diff --git a/plugins.h b/plugins.h index 5773d9d5d4..627a713e54 100644 --- a/plugins.h +++ b/plugins.h @@ -33,8 +33,15 @@ class PluginMgr public: PluginMgr(); virtual bool provides(Requirement); + /** + * @returns @c true if there is no decoration plugin. + **/ + bool hasNoDecoration() const; protected: virtual void error(const QString& error_msg); +private: + void setNoDecoration(bool noDecoration); + bool m_noDecoration; }; } // namespace diff --git a/workspace.cpp b/workspace.cpp index 053ca6074a..251561d597 100644 --- a/workspace.cpp +++ b/workspace.cpp @@ -355,7 +355,7 @@ void Workspace::init() , }; - if (mgr->factory()->supports(AbilityExtendIntoClientArea)) + if (hasDecorationPlugin() && mgr->factory()->supports(AbilityExtendIntoClientArea)) protocols[ NETRootInfo::PROTOCOLS2 ] |= NET::WM2FrameOverlap; QX11Info info; @@ -1058,7 +1058,7 @@ void Workspace::slotReconfigure() forEachClient(CheckIgnoreFocusStealingProcedure()); updateToolWindows(true); - if (mgr->reset(changed)) { + if (hasDecorationPlugin() && mgr->reset(changed)) { // Decorations need to be recreated // This actually seems to make things worse now @@ -1140,7 +1140,11 @@ void Workspace::slotReconfigure() } // just so that we reset windows in the right manner, 'activate' the current active window notifyTilingWindowActivated(activeClient()); - rootInfo->setSupported(NET::WM2FrameOverlap, mgr->factory()->supports(AbilityExtendIntoClientArea)); + if (hasDecorationPlugin()) { + rootInfo->setSupported(NET::WM2FrameOverlap, mgr->factory()->supports(AbilityExtendIntoClientArea)); + } else { + rootInfo->setSupported(NET::WM2FrameOverlap, false); + } } void Workspace::slotReinitCompositing() @@ -1158,8 +1162,10 @@ void Workspace::slotReinitCompositing() compositingSuspended = false; options->compositingInitialized = false; setupCompositing(); - KDecorationFactory* factory = mgr->factory(); - factory->reset(SettingCompositing); + if (hasDecorationPlugin()) { + KDecorationFactory* factory = mgr->factory(); + factory->reset(SettingCompositing); + } if (effects) { // setupCompositing() may fail effects->reconfigure(); @@ -2539,6 +2545,9 @@ int Workspace::topMenuHeight() const KDecoration* Workspace::createDecoration(KDecorationBridge* bridge) { + if (!hasDecorationPlugin()) { + return NULL; + } return mgr->createDecoration(bridge); } @@ -2548,8 +2557,11 @@ KDecoration* Workspace::createDecoration(KDecorationBridge* bridge) */ QList Workspace::decorationSupportedColors() const { - KDecorationFactory* factory = mgr->factory(); QList ret; + if (!hasDecorationPlugin()) { + return ret; + } + KDecorationFactory* factory = mgr->factory(); for (Ability ab = ABILITYCOLOR_FIRST; ab < ABILITYCOLOR_END; ab = static_cast(ab + 1)) diff --git a/workspace.h b/workspace.h index 29960a498a..8e639ff41c 100644 --- a/workspace.h +++ b/workspace.h @@ -90,6 +90,7 @@ public: bool workspaceEvent(QEvent*); KDecoration* createDecoration(KDecorationBridge* bridge); + bool hasDecorationPlugin() const; bool hasClient(const Client*); @@ -1307,28 +1308,51 @@ inline void Workspace::checkCompositeTimer() setCompositeTimer(); } +inline bool Workspace::hasDecorationPlugin() const +{ + if (!mgr) { + return false; + } + return !mgr->hasNoDecoration(); +} + inline bool Workspace::hasDecorationShadows() const { + if (!hasDecorationPlugin()) { + return false; + } return mgr->factory()->supports(AbilityProvidesShadow); } inline bool Workspace::decorationHasAlpha() const { + if (!hasDecorationPlugin()) { + return false; + } return mgr->factory()->supports(AbilityUsesAlphaChannel); } inline bool Workspace::decorationSupportsClientGrouping() const { + if (!hasDecorationPlugin()) { + return false; + } return mgr->factory()->supports(AbilityClientGrouping); } inline bool Workspace::decorationSupportsFrameOverlap() const { + if (!hasDecorationPlugin()) { + return false; + } return mgr->factory()->supports(AbilityExtendIntoClientArea); } inline bool Workspace::decorationSupportsBlurBehind() const { + if (!hasDecorationPlugin()) { + return false; + } return mgr->factory()->supports(AbilityUsesBlurBehind); }