7e6721ece0
Summary: Under wayland we support high DPI putting by putting a separation between the logical co-ordinate system and the resolution of rendered assets. I didn't include window decorations in the previous wayland scaling patchset. They were drawn them at a standard resolution, which is implicitly scaled up. This uses the Qt scaling, meaning oxygen and breeze (and others) get perfect high DPI support with zero client changes. Like the window scaling this handles any combination of a 2x scaled decoration being rendered on a 1x screen or vice versa. CCBUG: 384765 Test Plan: export KWIN_COMPOSE=Q Had two screens of different scales It was the right size on both (as before) Was super-sharp on the fancy screen Reviewers: #plasma, hetzenecker, graesslin Reviewed By: #plasma, graesslin Subscribers: ngraham, graesslin, plasma-devel, kwin, #kwin Tags: #plasma Differential Revision: https://phabricator.kde.org/D8504
85 lines
2.5 KiB
C++
85 lines
2.5 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 <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]{ m_imageSizesDirty = true; };
|
|
if (kwinApp()->operationMode() != Application::OperationModeX11) {
|
|
connect(client->client(), &AbstractClient::screenChanged, this, markImageSizesDirty);
|
|
}
|
|
connect(client->decoration(), &KDecoration2::Decoration::bordersChanged, this, markImageSizesDirty);
|
|
connect(client->decoratedClient(), &KDecoration2::DecoratedClient::widthChanged, this, markImageSizesDirty);
|
|
connect(client->decoratedClient(), &KDecoration2::DecoratedClient::heightChanged, 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);
|
|
QImage image(geo.width(), geo.height(), QImage::Format_ARGB32_Premultiplied);
|
|
image.fill(Qt::transparent);
|
|
QPainter p(&image);
|
|
p.setRenderHint(QPainter::Antialiasing);
|
|
p.setWindow(geo);
|
|
p.setClipRect(geo);
|
|
client()->decoration()->paint(&p, geo);
|
|
return image;
|
|
}
|
|
|
|
void Renderer::reparent(Deleted *deleted)
|
|
{
|
|
setParent(deleted);
|
|
m_client = nullptr;
|
|
}
|
|
|
|
}
|
|
}
|