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)
#undef BORDER
Decoration::DecoratedClientImpl *Client::decoratedClient()
QPointer<Decoration::DecoratedClientImpl> Client::decoratedClient() const
{
if (!m_decoration) {
return nullptr;
}
return static_cast<Decoration::DecoratedClientImpl*>(m_decoration->client()->handle());
return m_decoratedClient;
}
void Client::setDecoratedClient(QPointer< Decoration::DecoratedClientImpl > client)
{
m_decoratedClient = client;
}
} // namespace

View file

@ -596,7 +596,11 @@ public:
const KDecoration2::Decoration *decoration() const {
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;
@ -863,6 +867,7 @@ private:
// wrapper around m_frame to use as a parent for the decoration
QScopedPointer<QWindow> m_frameWrapper;
KDecoration2::Decoration *m_decoration;
QPointer<Decoration::DecoratedClientImpl> m_decoratedClient;
int desk;
QStringList activityList;
int m_activityUpdatesBlocked;

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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