diff --git a/client.cpp b/client.cpp
index 2d7d45dd07..ac806847d9 100644
--- a/client.cpp
+++ b/client.cpp
@@ -47,6 +47,7 @@ along with this program. If not, see .
#include "client_machine.h"
#include "composite.h"
#include "cursor.h"
+#include "decorations.h"
#include "group.h"
#include "focuschain.h"
#include "workspace.h"
@@ -442,7 +443,11 @@ void Client::updateDecoration(bool check_workspace_pos, bool force)
destroyDecoration();
if (!noBorder()) {
setMask(QRegion()); // Reset shape mask
- decoration = workspace()->createDecoration(bridge);
+ if (decorationPlugin()->hasNoDecoration()) {
+ decoration = NULL;
+ } else {
+ decoration = decorationPlugin()->createDecoration(bridge);
+ }
#ifdef KWIN_BUILD_KAPPMENU
connect(this, SIGNAL(showRequest()), decoration, SIGNAL(showRequest()));
connect(this, SIGNAL(appMenuAvailable()), decoration, SIGNAL(appMenuAvailable()));
@@ -551,7 +556,7 @@ void Client::layoutDecorationRects(QRect &left, QRect &top, QRect &right, QRect
NETStrut strut = info->frameOverlap();
// Ignore the overlap strut when compositing is disabled
- if (!compositing() || !Workspace::self()->decorationSupportsFrameOverlap())
+ if (!compositing() || !decorationPlugin()->supportsFrameOverlap())
strut.left = strut.top = strut.right = strut.bottom = 0;
else if (strut.left == -1 && strut.top == -1 && strut.right == -1 && strut.bottom == -1) {
top = QRect(r.x(), r.y(), r.width(), r.height() / 3);
@@ -584,7 +589,7 @@ QRect Client::transparentRect() const
NETStrut strut = info->frameOverlap();
// Ignore the strut when compositing is disabled or the decoration doesn't support it
- if (!compositing() || !Workspace::self()->decorationSupportsFrameOverlap())
+ if (!compositing() || !decorationPlugin()->supportsFrameOverlap())
strut.left = strut.top = strut.right = strut.bottom = 0;
else if (strut.left == -1 && strut.top == -1 && strut.right == -1 && strut.bottom == -1)
return QRect();
@@ -669,7 +674,7 @@ void Client::resizeDecoration(const QSize& s)
bool Client::noBorder() const
{
- return !workspace()->hasDecorationPlugin() || noborder || isFullScreen();
+ return decorationPlugin()->hasNoDecoration() || noborder || isFullScreen();
}
bool Client::userCanSetNoBorder() const
@@ -2527,11 +2532,11 @@ NET::WindowType Client::windowType(bool direct, int supportedTypes) const
bool Client::decorationHasAlpha() const
{
- if (!decoration || !workspace()->decorationHasAlpha()) {
+ if (!decoration || !decorationPlugin()->hasAlpha()) {
// either no decoration or decoration has alpha disabled
return false;
}
- if (workspace()->decorationSupportsAnnounceAlpha()) {
+ if (decorationPlugin()->supportsAnnounceAlpha()) {
return decoration->isAlphaEnabled();
} else {
// decoration has alpha enabled and does not support alpha announcement
diff --git a/dbusinterface.cpp b/dbusinterface.cpp
index 8cebebf3c4..b2a2c369a6 100644
--- a/dbusinterface.cpp
+++ b/dbusinterface.cpp
@@ -25,6 +25,7 @@ along with this program. If not, see .
// TODO: remove together with deprecated methods
#include "client.h"
#include "composite.h"
+#include "decorations.h"
#include "effects.h"
#include "kwinadaptor.h"
#include "workspace.h"
@@ -119,7 +120,6 @@ rettype DBusInterface::name( ) \
return Workspace::self()->name(); \
}
-WRAP(QList, decorationSupportedColors)
WRAP(QString, supportInformation)
WRAP(bool, waitForCompositingSetup)
@@ -245,4 +245,9 @@ void DBusInterface::previousDesktop()
VirtualDesktopManager::self()->moveTo();
}
+QList< int > DBusInterface::decorationSupportedColors()
+{
+ return decorationPlugin()->supportedColors();
+}
+
} // namespace
diff --git a/decorations.cpp b/decorations.cpp
index 227de7ec85..49bf8c284b 100644
--- a/decorations.cpp
+++ b/decorations.cpp
@@ -21,6 +21,7 @@ along with this program. If not, see .
#include "decorations.h"
#include "config-kwin.h"
+#include
#include
#include
@@ -74,4 +75,74 @@ bool DecorationPlugin::hasNoDecoration() const
return m_noDecoration;
}
+bool DecorationPlugin::hasShadows() const
+{
+ if (hasNoDecoration()) {
+ return false;
+ }
+ return factory()->supports(AbilityProvidesShadow);
+}
+
+bool DecorationPlugin::hasAlpha() const
+{
+ if (hasNoDecoration()) {
+ return false;
+ }
+ return factory()->supports(AbilityUsesAlphaChannel);
+}
+
+bool DecorationPlugin::supportsAnnounceAlpha() const
+{
+ if (hasNoDecoration()) {
+ return false;
+ }
+ return factory()->supports(AbilityAnnounceAlphaChannel);
+}
+
+bool DecorationPlugin::supportsTabbing() const
+{
+ if (hasNoDecoration()) {
+ return false;
+ }
+ return factory()->supports(AbilityTabbing);
+}
+
+bool DecorationPlugin::supportsFrameOverlap() const
+{
+ if (hasNoDecoration()) {
+ return false;
+ }
+ return factory()->supports(AbilityExtendIntoClientArea);
+}
+
+bool DecorationPlugin::supportsBlurBehind() const
+{
+ if (hasNoDecoration()) {
+ return false;
+ }
+ return factory()->supports(AbilityUsesBlurBehind);
+}
+
+Qt::Corner DecorationPlugin::closeButtonCorner()
+{
+ if (hasNoDecoration()) {
+ return Qt::TopRightCorner;
+ }
+ return factory()->closeButtonCorner();
+}
+
+QList< int > DecorationPlugin::supportedColors() const
+{
+ QList ret;
+ if (hasNoDecoration()) {
+ return ret;
+ }
+ for (Ability ab = ABILITYCOLOR_FIRST;
+ ab < ABILITYCOLOR_END;
+ ab = static_cast(ab + 1))
+ if (factory()->supports(ab))
+ ret << ab;
+ return ret;
+}
+
} // namespace
diff --git a/decorations.h b/decorations.h
index 69e248099c..31180b3be6 100644
--- a/decorations.h
+++ b/decorations.h
@@ -38,6 +38,21 @@ public:
* @returns @c true if there is no decoration plugin.
**/
bool hasNoDecoration() const;
+
+ bool hasShadows() const;
+ bool hasAlpha() const;
+ bool supportsAnnounceAlpha() const;
+ bool supportsTabbing() const;
+ bool supportsFrameOverlap() const;
+ bool supportsBlurBehind() const;
+ Qt::Corner closeButtonCorner();
+
+ // D-Bus interface
+ /**
+ * @deprecated
+ * @todo: remove KDE5
+ **/
+ QList supportedColors() const;
protected:
virtual void error(const QString& error_msg);
private:
@@ -46,6 +61,10 @@ private:
KWIN_SINGLETON(DecorationPlugin)
};
+inline DecorationPlugin *decorationPlugin() {
+ return DecorationPlugin::self();
+}
+
} // namespace
#endif
diff --git a/effects.cpp b/effects.cpp
index ed93363814..341ea68dab 100644
--- a/effects.cpp
+++ b/effects.cpp
@@ -25,6 +25,7 @@ along with this program. If not, see .
#ifdef KWIN_BUILD_ACTIVITIES
#include "activities.h"
#endif
+#include "decorations.h"
#include "deleted.h"
#include "client.h"
#include "cursor.h"
@@ -452,17 +453,17 @@ void EffectsHandlerImpl::buildQuads(EffectWindow* w, WindowQuadList& quadList)
bool EffectsHandlerImpl::hasDecorationShadows() const
{
- return Workspace::self()->hasDecorationShadows();
+ return decorationPlugin()->hasShadows();
}
bool EffectsHandlerImpl::decorationsHaveAlpha() const
{
- return Workspace::self()->decorationHasAlpha();
+ return decorationPlugin()->hasAlpha();
}
bool EffectsHandlerImpl::decorationSupportsBlurBehind() const
{
- return Workspace::self()->decorationSupportsBlurBehind();
+ return decorationPlugin()->supportsBlurBehind();
}
// start another painting pass
@@ -1584,7 +1585,7 @@ QVariant EffectsHandlerImpl::kwinOption(KWinOption kwopt)
{
switch (kwopt) {
case CloseButtonCorner:
- return Workspace::self()->decorationCloseButtonCorner();
+ return decorationPlugin()->closeButtonCorner();
#ifdef KWIN_BUILD_SCREENEDGES
case SwitchDesktopOnScreenEdge:
return ScreenEdges::self()->isDesktopSwitching();
diff --git a/events.cpp b/events.cpp
index 13adf4faa9..e62d571b8d 100644
--- a/events.cpp
+++ b/events.cpp
@@ -29,6 +29,7 @@ along with this program. If not, see .
#include "client.h"
#include "cursor.h"
+#include "decorations.h"
#include "focuschain.h"
#include "workspace.h"
#include "atoms.h"
@@ -1302,7 +1303,7 @@ bool Client::buttonReleaseEvent(Window w, int /*button*/, int state, int x, int
// mouse position is still relative to old Client position, adjust it
QPoint mousepos(x_root - x + padding_left, y_root - y + padding_top);
mode = mousePosition(mousepos);
- } else if (workspace()->decorationSupportsTabbing())
+ } else if (decorationPlugin()->supportsTabbing())
return false;
updateCursor();
}
diff --git a/libkdecorations/kdecoration_plugins_p.cpp b/libkdecorations/kdecoration_plugins_p.cpp
index b9454a577f..952baa3e92 100644
--- a/libkdecorations/kdecoration_plugins_p.cpp
+++ b/libkdecorations/kdecoration_plugins_p.cpp
@@ -92,6 +92,11 @@ KDecorationFactory* KDecorationPlugins::factory()
return fact;
}
+const KDecorationFactory *KDecorationPlugins::factory() const
+{
+ return fact;
+}
+
// convenience
KDecoration* KDecorationPlugins::createDecoration(KDecorationBridge* bridge)
{
diff --git a/libkdecorations/kdecoration_plugins_p.h b/libkdecorations/kdecoration_plugins_p.h
index 2c1740a03c..1a96a01853 100644
--- a/libkdecorations/kdecoration_plugins_p.h
+++ b/libkdecorations/kdecoration_plugins_p.h
@@ -55,6 +55,7 @@ public:
bool loadPlugin(QString name);
void destroyPreviousPlugin();
KDecorationFactory* factory();
+ const KDecorationFactory* factory() const;
KDecoration* createDecoration(KDecorationBridge*);
QString currentPlugin();
bool reset(unsigned long changed); // returns true if decorations need to be recreated
diff --git a/scene.cpp b/scene.cpp
index 6a3aaeb26a..91e9e8d477 100644
--- a/scene.cpp
+++ b/scene.cpp
@@ -74,6 +74,7 @@ along with this program. If not, see .
#include
#include "client.h"
+#include "decorations.h"
#include "deleted.h"
#include "effects.h"
#include "overlaywindow.h"
@@ -624,7 +625,7 @@ WindowQuadList Scene::Window::buildQuads(bool force) const
Client *client = dynamic_cast(toplevel);
QRegion contents = clientShape();
QRegion center = toplevel->transparentRect();
- QRegion decoration = (client && Workspace::self()->decorationHasAlpha() ?
+ QRegion decoration = (client && decorationPlugin()->hasAlpha() ?
QRegion(client->decorationRect()) : shape()) - center;
ret = makeQuads(WindowQuadContents, contents);
if (!client || !(center.isEmpty() || client->isShade()))
diff --git a/scene_xrender.cpp b/scene_xrender.cpp
index ab908150b0..04ad958437 100644
--- a/scene_xrender.cpp
+++ b/scene_xrender.cpp
@@ -25,6 +25,7 @@ along with this program. If not, see .
#include "toplevel.h"
#include "client.h"
+#include "decorations.h"
#include "deleted.h"
#include "effects.h"
#include "overlaywindow.h"
@@ -469,7 +470,7 @@ void SceneXrender::Window::performPaint(int mask, QRegion region, WindowPaintDat
Deleted *deleted = dynamic_cast(toplevel);
const QRect decorationRect = toplevel->decorationRect();
if (((client && !client->noBorder()) || (deleted && !deleted->noBorder())) &&
- Workspace::self()->decorationHasAlpha()) {
+ decorationPlugin()->hasAlpha()) {
// decorated client
transformed_shape = decorationRect;
if (toplevel->shape()) {
diff --git a/tabgroup.cpp b/tabgroup.cpp
index 7fbde4d16a..3cdc10365e 100644
--- a/tabgroup.cpp
+++ b/tabgroup.cpp
@@ -21,6 +21,7 @@ along with this program. If not, see .
#include "tabgroup.h"
#include "client.h"
+#include "decorations.h"
#include "effects.h"
namespace KWin
@@ -62,7 +63,7 @@ bool TabGroup::add(Client* c, Client *other, bool after, bool becomeVisible)
{
Q_ASSERT(!c->tabGroup());
- if (!c->workspace()->decorationSupportsTabbing() || contains(c) || !contains(other))
+ if (!decorationPlugin()->supportsTabbing() || contains(c) || !contains(other))
return false;
// Tabbed windows MUST have a decoration
diff --git a/useractions.cpp b/useractions.cpp
index 4ff236ec1f..cb9b6aae21 100755
--- a/useractions.cpp
+++ b/useractions.cpp
@@ -34,6 +34,7 @@ along with this program. If not, see .
#include "useractions.h"
#include "cursor.h"
#include "client.h"
+#include "decorations.h"
#include "workspace.h"
#include "effects.h"
#include "virtualdesktops.h"
@@ -357,7 +358,7 @@ void UserActionsMenu::init()
m_menu->addSeparator();
// Actions for window tabbing
- if (Workspace::self()->decorationSupportsTabbing()) {
+ if (decorationPlugin()->supportsTabbing()) {
m_removeFromTabGroup = m_menu->addAction(i18n("&Untab"));
kaction = qobject_cast(keys->action("Untab"));
if (kaction != 0)
@@ -440,7 +441,7 @@ void UserActionsMenu::menuAboutToShow()
m_minimizeOperation->setEnabled(m_client.data()->isMinimizable());
m_closeOperation->setEnabled(m_client.data()->isCloseable());
- if (ws->decorationSupportsTabbing()) {
+ if (decorationPlugin()->supportsTabbing()) {
initTabbingPopups();
} else {
delete m_addTabsMenu;
diff --git a/workspace.cpp b/workspace.cpp
index 64484b7159..2d7d55e06b 100644
--- a/workspace.cpp
+++ b/workspace.cpp
@@ -47,6 +47,7 @@ along with this program. If not, see .
#include "client.h"
#include "composite.h"
+#include "decorations.h"
#include "focuschain.h"
#ifdef KWIN_BUILD_TABBOX
#include "tabbox.h"
@@ -66,6 +67,7 @@ along with this program. If not, see .
#include "useractions.h"
#include "virtualdesktops.h"
#include "xcbutils.h"
+#include
#include
#include
#ifdef KWIN_BUILD_SCREENEDGES
@@ -159,7 +161,7 @@ Workspace::Workspace(bool restore)
reparseConfigFuture.waitForFinished();
options->loadConfig();
options->loadCompositingConfig(false);
- mgr = DecorationPlugin::create(this);
+ DecorationPlugin::create(this);
default_colormap = DefaultColormap(display(), screen_number);
installed_colormap = default_colormap;
@@ -354,7 +356,8 @@ void Workspace::init()
,
};
- if (hasDecorationPlugin() && mgr->factory()->supports(AbilityExtendIntoClientArea))
+ DecorationPlugin *deco = DecorationPlugin::self();
+ if (!deco->hasNoDecoration() && deco->factory()->supports(AbilityExtendIntoClientArea))
protocols[ NETRootInfo::PROTOCOLS2 ] |= NET::WM2FrameOverlap;
rootInfo = new RootInfo(this, display(), supportWindow->winId(), "KWin", protocols, 5, screen_number);
@@ -534,7 +537,7 @@ Workspace::~Workspace()
delete rootInfo;
delete supportWindow;
- delete DecorationManager::self();
+ delete decorationPlugin();
delete startup;
delete Placement::self();
delete client_keys_dialog;
@@ -913,7 +916,8 @@ void Workspace::slotReconfigure()
m_userActionsMenu->discard();
updateToolWindows(true);
- if (hasDecorationPlugin() && mgr->reset(changed)) {
+ DecorationPlugin *deco = DecorationPlugin::self();
+ if (!deco->hasNoDecoration() && deco->reset(changed)) {
// Decorations need to be recreated
// This actually seems to make things worse now
@@ -925,11 +929,11 @@ void Workspace::slotReconfigure()
for (ClientList::ConstIterator it = clients.constBegin(); it != clients.constEnd(); ++it)
(*it)->updateDecoration(true, true);
// If the new decoration doesn't supports tabs then ungroup clients
- if (!decorationSupportsTabbing()) {
+ if (!decorationPlugin()->supportsTabbing()) {
foreach (Client * c, clients)
c->untab();
}
- mgr->destroyPreviousPlugin();
+ deco->destroyPreviousPlugin();
} else {
forEachClient(CheckBorderSizesProcedure());
foreach (Client * c, clients)
@@ -957,8 +961,8 @@ void Workspace::slotReconfigure()
}
}
- if (hasDecorationPlugin()) {
- rootInfo->setSupported(NET::WM2FrameOverlap, mgr->factory()->supports(AbilityExtendIntoClientArea));
+ if (!deco->hasNoDecoration()) {
+ rootInfo->setSupported(NET::WM2FrameOverlap, deco->factory()->supports(AbilityExtendIntoClientArea));
} else {
rootInfo->setSupported(NET::WM2FrameOverlap, false);
}
@@ -1476,33 +1480,6 @@ void Workspace::cancelDelayFocus()
delayFocusTimer = 0;
}
-KDecoration* Workspace::createDecoration(KDecorationBridge* bridge)
-{
- if (!hasDecorationPlugin()) {
- return NULL;
- }
- return mgr->createDecoration(bridge);
-}
-
-/**
- * Returns a list of all colors (KDecorationDefines::ColorType) the current
- * decoration supports
- */
-QList Workspace::decorationSupportedColors() const
-{
- QList ret;
- if (!hasDecorationPlugin()) {
- return ret;
- }
- KDecorationFactory* factory = mgr->factory();
- for (Ability ab = ABILITYCOLOR_FIRST;
- ab < ABILITYCOLOR_END;
- ab = static_cast(ab + 1))
- if (factory->supports(ab))
- ret << ab;
- return ret;
-}
-
bool Workspace::checkStartupNotification(Window w, KStartupInfoId& id, KStartupInfoData& data)
{
return startup->checkStartup(w, id, data) == KStartupInfo::Match;
@@ -1837,9 +1814,9 @@ QString Workspace::supportInformation() const
void Workspace::slotCompositingToggled()
{
// notify decorations that composition state has changed
- if (hasDecorationPlugin()) {
- KDecorationFactory* factory = mgr->factory();
- factory->reset(SettingCompositing);
+ DecorationPlugin *deco = DecorationPlugin::self();
+ if (!deco->hasNoDecoration()) {
+ deco->factory()->reset(SettingCompositing);
}
}
diff --git a/workspace.h b/workspace.h
index 38f3b30cde..2fd18ed404 100644
--- a/workspace.h
+++ b/workspace.h
@@ -35,9 +35,7 @@ along with this program. If not, see .
// need to include utils.h before we use the ifdefs
#include "utils.h"
-#include "decorations.h"
#include "kdecoration.h"
-#include "kdecorationfactory.h"
#include "sm.h"
#include "killwindow.h"
@@ -60,7 +58,6 @@ namespace KWin
class Client;
class Outline;
class RootInfo;
-class DecorationPlugin;
class Rules;
class UserActionsMenu;
class WindowRules;
@@ -80,9 +77,6 @@ public:
bool workspaceEvent(XEvent*);
bool workspaceEvent(QEvent*);
- KDecoration* createDecoration(KDecorationBridge* bridge);
- bool hasDecorationPlugin() const;
-
bool hasClient(const Client*);
template Client* findClient(T predicate) const;
@@ -281,20 +275,7 @@ public:
void disableRulesUpdates(bool disable);
bool rulesUpdatesDisabled() const;
- bool hasDecorationShadows() const;
- Qt::Corner decorationCloseButtonCorner();
- bool decorationHasAlpha() const;
- bool decorationSupportsAnnounceAlpha() const;
- bool decorationSupportsTabbing() const; // Returns true if the decoration supports tabs.
- bool decorationSupportsFrameOverlap() const;
- bool decorationSupportsBlurBehind() const;
-
// D-Bus interface
- /**
- * @deprecated
- * @todo: remove KDE5
- **/
- QList decorationSupportedColors() const;
bool waitForCompositingSetup();
QString supportInformation() const;
@@ -592,8 +573,6 @@ private:
bool global_shortcuts_disabled;
bool global_shortcuts_disabled_for_client;
- DecorationPlugin* mgr;
-
RootInfo* rootInfo;
QWidget* supportWindow;
@@ -835,71 +814,6 @@ inline bool Workspace::hasClient(const Client* c)
return findClient(ClientMatchPredicate(c));
}
-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 Qt::Corner Workspace::decorationCloseButtonCorner()
-{
- if (!hasDecorationPlugin()) {
- return Qt::TopRightCorner;
- }
- return mgr->factory()->closeButtonCorner();
-}
-
-inline bool Workspace::decorationHasAlpha() const
-{
- if (!hasDecorationPlugin()) {
- return false;
- }
- return mgr->factory()->supports(AbilityUsesAlphaChannel);
-}
-
-inline bool Workspace::decorationSupportsAnnounceAlpha() const
-{
- if (!hasDecorationPlugin()) {
- return false;
- }
- return mgr->factory()->supports(AbilityAnnounceAlphaChannel);
-}
-
-inline bool Workspace::decorationSupportsTabbing() const
-{
- if (!hasDecorationPlugin()) {
- return false;
- }
- return mgr->factory()->supports(AbilityTabbing);
-}
-
-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);
-}
-
-
} // namespace
#endif