Keep a QPointer<DecoratedClientImpl> in Client

This allows to remove the internal access to the DecoratedClientPrivate
in the KDecoration API.
This commit is contained in:
Martin Gräßlin 2014-10-21 07:46:44 +02:00
parent c0c57d7076
commit 21dca7ac14
8 changed files with 28 additions and 19 deletions

View file

@ -2492,12 +2492,14 @@ BORDER(Right)
BORDER(Top) BORDER(Top)
#undef BORDER #undef BORDER
Decoration::DecoratedClientImpl *Client::decoratedClient() QPointer<Decoration::DecoratedClientImpl> Client::decoratedClient() const
{ {
if (!m_decoration) { return m_decoratedClient;
return nullptr; }
}
return static_cast<Decoration::DecoratedClientImpl*>(m_decoration->client()->handle()); void Client::setDecoratedClient(QPointer< Decoration::DecoratedClientImpl > client)
{
m_decoratedClient = client;
} }
} // namespace } // namespace

View file

@ -596,7 +596,11 @@ public:
const KDecoration2::Decoration *decoration() const { const KDecoration2::Decoration *decoration() const {
return m_decoration; return m_decoration;
} }
Decoration::DecoratedClientImpl *decoratedClient(); QPointer<Decoration::DecoratedClientImpl> decoratedClient() const;
bool isDecorated() const {
return m_decoration != nullptr;
}
void setDecoratedClient(QPointer<Decoration::DecoratedClientImpl> client);
QRect decorationRect() const; QRect decorationRect() const;
@ -863,6 +867,7 @@ private:
// wrapper around m_frame to use as a parent for the decoration // wrapper around m_frame to use as a parent for the decoration
QScopedPointer<QWindow> m_frameWrapper; QScopedPointer<QWindow> m_frameWrapper;
KDecoration2::Decoration *m_decoration; KDecoration2::Decoration *m_decoration;
QPointer<Decoration::DecoratedClientImpl> m_decoratedClient;
int desk; int desk;
QStringList activityList; QStringList activityList;
int m_activityUpdatesBlocked; int m_activityUpdatesBlocked;

View file

@ -1128,7 +1128,7 @@ bool Client::setupCompositing()
if (!Toplevel::setupCompositing()){ if (!Toplevel::setupCompositing()){
return false; return false;
} }
if (decoratedClient()) { if (isDecorated()) {
decoratedClient()->destroyRenderer(); decoratedClient()->destroyRenderer();
} }
updateVisibility(); // for internalKeep() updateVisibility(); // for internalKeep()
@ -1140,7 +1140,7 @@ void Client::finishCompositing(ReleaseReason releaseReason)
Toplevel::finishCompositing(releaseReason); Toplevel::finishCompositing(releaseReason);
updateVisibility(); updateVisibility();
if (!deleting) { if (!deleting) {
if (decoratedClient()) { if (isDecorated()) {
decoratedClient()->destroyRenderer(); decoratedClient()->destroyRenderer();
} }
} }

View file

@ -43,6 +43,7 @@ DecoratedClientImpl::DecoratedClientImpl(Client *client, KDecoration2::Decorated
, m_renderer(nullptr) , m_renderer(nullptr)
{ {
createRenderer(); createRenderer();
client->setDecoratedClient(QPointer<DecoratedClientImpl>(this));
connect(client, &Client::activeChanged, this, connect(client, &Client::activeChanged, this,
[decoratedClient, client]() { [decoratedClient, client]() {
emit decoratedClient->activeChanged(client->isActive()); emit decoratedClient->activeChanged(client->isActive());

View file

@ -90,8 +90,8 @@ void Deleted::copyToDeleted(Toplevel* c)
decoration_top, decoration_top,
decoration_right, decoration_right,
decoration_bottom); decoration_bottom);
if (Decoration::DecoratedClientImpl *decoClient = client->decoratedClient()) { if (client->isDecorated()) {
if (Decoration::Renderer *renderer = decoClient->renderer()) { if (Decoration::Renderer *renderer = client->decoratedClient()->renderer()) {
m_decorationRenderer = renderer; m_decorationRenderer = renderer;
m_decorationRenderer->reparent(this); m_decorationRenderer->reparent(this);
} }

View file

@ -1195,11 +1195,12 @@ GLTexture *SceneOpenGL::Window::getDecorationTexture() const
return nullptr; return nullptr;
} }
if (Decoration::DecoratedClientImpl *impl = client->decoratedClient()) { if (!client->isDecorated()) {
if (SceneOpenGLDecorationRenderer *renderer = static_cast<SceneOpenGLDecorationRenderer*>(impl->renderer())) { return nullptr;
renderer->render(); }
return renderer->texture(); if (SceneOpenGLDecorationRenderer *renderer = static_cast<SceneOpenGLDecorationRenderer*>(client->decoratedClient()->renderer())) {
} renderer->render();
return renderer->texture();
} }
} else if (toplevel->isDeleted()) { } else if (toplevel->isDeleted()) {
Deleted *deleted = static_cast<Deleted *>(toplevel); Deleted *deleted = static_cast<Deleted *>(toplevel);

View file

@ -423,8 +423,8 @@ void SceneQPainter::Window::renderWindowDecorations(QPainter *painter)
const SceneQPainterDecorationRenderer *renderer = nullptr; const SceneQPainterDecorationRenderer *renderer = nullptr;
QRect dtr, dlr, drr, dbr; QRect dtr, dlr, drr, dbr;
if (client && !client->noBorder()) { if (client && !client->noBorder()) {
if (Decoration::DecoratedClientImpl *impl = client->decoratedClient()) { if (client->isDecorated()) {
if (SceneQPainterDecorationRenderer *r = static_cast<SceneQPainterDecorationRenderer *>(impl->renderer())) { if (SceneQPainterDecorationRenderer *r = static_cast<SceneQPainterDecorationRenderer *>(client->decoratedClient()->renderer())) {
r->render(); r->render();
renderer = r; renderer = r;
} }

View file

@ -660,8 +660,8 @@ void SceneXrender::Window::performPaint(int mask, QRegion region, WindowPaintDat
const SceneXRenderDecorationRenderer *renderer = nullptr; const SceneXRenderDecorationRenderer *renderer = nullptr;
if (client) { if (client) {
if (client && !client->noBorder()) { if (client && !client->noBorder()) {
if (Decoration::DecoratedClientImpl *impl = client->decoratedClient()) { if (client->isDecorated()) {
SceneXRenderDecorationRenderer *r = static_cast<SceneXRenderDecorationRenderer*>(impl->renderer()); SceneXRenderDecorationRenderer *r = static_cast<SceneXRenderDecorationRenderer*>(client->decoratedClient()->renderer());
if (r) { if (r) {
r->render(); r->render();
renderer = r; renderer = r;