Move decoration related methods from Workspace to DecorationPlugin

They were all just delegating to the DecorationPlugin.
icc-effect-5.14.5
Martin Gräßlin 2013-04-08 12:31:16 +02:00
parent d8e1b1c00e
commit 265b5523e2
14 changed files with 144 additions and 141 deletions

View File

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

View File

@ -25,6 +25,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
// 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<int>, decorationSupportedColors)
WRAP(QString, supportInformation)
WRAP(bool, waitForCompositingSetup)
@ -245,4 +245,9 @@ void DBusInterface::previousDesktop()
VirtualDesktopManager::self()->moveTo<DesktopPrevious>();
}
QList< int > DBusInterface::decorationSupportedColors()
{
return decorationPlugin()->supportedColors();
}
} // namespace

View File

@ -21,6 +21,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "decorations.h"
#include "config-kwin.h"
#include <kdecorationfactory.h>
#include <kglobal.h>
#include <KDE/KLocalizedString>
@ -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<int> ret;
if (hasNoDecoration()) {
return ret;
}
for (Ability ab = ABILITYCOLOR_FIRST;
ab < ABILITYCOLOR_END;
ab = static_cast<Ability>(ab + 1))
if (factory()->supports(ab))
ret << ab;
return ret;
}
} // namespace

View File

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

View File

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

View File

@ -29,6 +29,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#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();
}

View File

@ -92,6 +92,11 @@ KDecorationFactory* KDecorationPlugins::factory()
return fact;
}
const KDecorationFactory *KDecorationPlugins::factory() const
{
return fact;
}
// convenience
KDecoration* KDecorationPlugins::createDecoration(KDecorationBridge* bridge)
{

View File

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

View File

@ -74,6 +74,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <QGraphicsView>
#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<Client*>(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()))

View File

@ -25,6 +25,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#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<Deleted*>(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()) {

View File

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

View File

@ -34,6 +34,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#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<KAction*>(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;

View File

@ -47,6 +47,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#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 <http://www.gnu.org/licenses/>.
#include "useractions.h"
#include "virtualdesktops.h"
#include "xcbutils.h"
#include <kdecorationfactory.h>
#include <kwinglplatform.h>
#include <kwinglutils.h>
#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<int> Workspace::decorationSupportedColors() const
{
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))
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);
}
}

View File

@ -35,9 +35,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
// 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<typename T> 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<int> 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