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
This commit is contained in:
Martin Gräßlin 2011-04-28 15:56:50 +02:00
parent 4fc369bb3f
commit f97c92fde9
7 changed files with 73 additions and 13 deletions

View file

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

View file

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

View file

@ -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<bool>("NoPlugin", false)) {
error(i18n("Loading of window decoration plugin library disabled in configuration."));
return false;
}
KLibrary *oldLibrary = library;
KDecorationFactory* oldFactory = fact;

View file

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

View file

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

View file

@ -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<int> Workspace::decorationSupportedColors() const
{
KDecorationFactory* factory = mgr->factory();
QList<int> ret;
if (!hasDecorationPlugin()) {
return ret;
}
KDecorationFactory* factory = mgr->factory();
for (Ability ab = ABILITYCOLOR_FIRST;
ab < ABILITYCOLOR_END;
ab = static_cast<Ability>(ab + 1))

View file

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