bd52b6791e
Summary: If a client has been resized, it doesn't necessarily mean that the decoration theme will schedule full repaint of the window frame. In OpenGL and Xrender scene, we have a little hack that forces a full repaint of window borders. However, we don't have one in QPainter scene which causes all sorts of weird looking artifacts when resizing a server-side decorated client. We could add yet another hack in the QPainter scene, but a better approach to tackle this problem would be to make DecoratedClient schedule a full repaint of the decoration. It makes code in scene plugins more straightforward and prevents us from repeating the same mistake again. Test Plan: No longer able to see invisible decoration borders when using QPainter render backend. Reviewers: #kwin, davidedmundson Reviewed By: #kwin, davidedmundson Subscribers: davidedmundson, kwin Tags: #kwin Differential Revision: https://phabricator.kde.org/D26927
93 lines
2.7 KiB
C++
93 lines
2.7 KiB
C++
/********************************************************************
|
|
KWin - the KDE window manager
|
|
This file is part of the KDE project.
|
|
|
|
Copyright (C) 2014 Martin Gräßlin <mgraesslin@kde.org>
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
(at your option) any later version.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
*********************************************************************/
|
|
#include "decorationrenderer.h"
|
|
#include "decoratedclient.h"
|
|
#include "deleted.h"
|
|
#include "abstract_client.h"
|
|
#include "screens.h"
|
|
|
|
#include <KDecoration2/Decoration>
|
|
#include <KDecoration2/DecoratedClient>
|
|
|
|
#include <QDebug>
|
|
#include <QPainter>
|
|
|
|
namespace KWin
|
|
{
|
|
namespace Decoration
|
|
{
|
|
|
|
Renderer::Renderer(DecoratedClientImpl *client)
|
|
: QObject(client)
|
|
, m_client(client)
|
|
, m_imageSizesDirty(true)
|
|
{
|
|
auto markImageSizesDirty = [this]{
|
|
schedule(m_client->client()->rect());
|
|
m_imageSizesDirty = true;
|
|
};
|
|
connect(client->client(), &AbstractClient::screenScaleChanged, this, markImageSizesDirty);
|
|
connect(client->decoration(), &KDecoration2::Decoration::bordersChanged, this, markImageSizesDirty);
|
|
connect(client->decoratedClient(), &KDecoration2::DecoratedClient::sizeChanged, this, markImageSizesDirty);
|
|
}
|
|
|
|
Renderer::~Renderer() = default;
|
|
|
|
void Renderer::schedule(const QRect &rect)
|
|
{
|
|
m_scheduled = m_scheduled.united(rect);
|
|
emit renderScheduled(rect);
|
|
}
|
|
|
|
QRegion Renderer::getScheduled()
|
|
{
|
|
QRegion region = m_scheduled;
|
|
m_scheduled = QRegion();
|
|
return region;
|
|
}
|
|
|
|
QImage Renderer::renderToImage(const QRect &geo)
|
|
{
|
|
Q_ASSERT(m_client);
|
|
auto dpr = client()->client()->screenScale();
|
|
QImage image(geo.width() * dpr, geo.height() * dpr, QImage::Format_ARGB32_Premultiplied);
|
|
image.setDevicePixelRatio(dpr);
|
|
image.fill(Qt::transparent);
|
|
QPainter p(&image);
|
|
p.setRenderHint(QPainter::Antialiasing);
|
|
p.setWindow(QRect(geo.topLeft(), geo.size() * dpr));
|
|
p.setClipRect(geo);
|
|
renderToPainter(&p, geo);
|
|
return image;
|
|
}
|
|
|
|
void Renderer::renderToPainter(QPainter *painter, const QRect &rect)
|
|
{
|
|
client()->decoration()->paint(painter, rect);
|
|
}
|
|
|
|
void Renderer::reparent(Deleted *deleted)
|
|
{
|
|
setParent(deleted);
|
|
m_client = nullptr;
|
|
}
|
|
|
|
}
|
|
}
|