2021-02-04 09:07:20 +00:00
|
|
|
/*
|
|
|
|
SPDX-FileCopyrightText: 2021 Vlad Zahorodnii <vlad.zahorodnii@kde.org>
|
|
|
|
|
|
|
|
SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "item.h"
|
|
|
|
|
|
|
|
namespace KDecoration2
|
|
|
|
{
|
|
|
|
class Decoration;
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace KWin
|
|
|
|
{
|
|
|
|
|
2021-08-12 09:07:38 +00:00
|
|
|
class AbstractClient;
|
|
|
|
class Deleted;
|
|
|
|
class Toplevel;
|
|
|
|
|
2021-04-26 16:38:40 +00:00
|
|
|
namespace Decoration
|
|
|
|
{
|
|
|
|
class DecoratedClientImpl;
|
|
|
|
}
|
|
|
|
|
|
|
|
class KWIN_EXPORT DecorationRenderer : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
virtual void render(const QRegion ®ion) = 0;
|
|
|
|
void invalidate();
|
|
|
|
|
|
|
|
// TODO: Move damage tracking inside DecorationItem.
|
|
|
|
QRegion damage() const;
|
|
|
|
void addDamage(const QRegion ®ion);
|
|
|
|
void resetDamage();
|
|
|
|
|
|
|
|
Q_SIGNALS:
|
|
|
|
void damaged(const QRegion ®ion);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
explicit DecorationRenderer(Decoration::DecoratedClientImpl *client);
|
|
|
|
|
|
|
|
Decoration::DecoratedClientImpl *client() const;
|
|
|
|
|
|
|
|
bool areImageSizesDirty() const {
|
|
|
|
return m_imageSizesDirty;
|
|
|
|
}
|
|
|
|
void resetImageSizesDirty() {
|
|
|
|
m_imageSizesDirty = false;
|
|
|
|
}
|
|
|
|
QImage renderToImage(const QRect &geo);
|
|
|
|
void renderToPainter(QPainter *painter, const QRect &rect);
|
|
|
|
|
|
|
|
private:
|
|
|
|
QPointer<Decoration::DecoratedClientImpl> m_client;
|
|
|
|
QRegion m_damage;
|
|
|
|
bool m_imageSizesDirty;
|
|
|
|
};
|
|
|
|
|
2021-02-04 09:07:20 +00:00
|
|
|
/**
|
|
|
|
* The DecorationItem class represents a server-side decoration.
|
|
|
|
*/
|
|
|
|
class KWIN_EXPORT DecorationItem : public Item
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2021-08-12 09:07:38 +00:00
|
|
|
explicit DecorationItem(KDecoration2::Decoration *decoration, AbstractClient *window, Item *parent = nullptr);
|
2021-02-04 09:07:20 +00:00
|
|
|
|
2021-04-26 16:38:40 +00:00
|
|
|
DecorationRenderer *renderer() const;
|
|
|
|
|
2021-02-04 09:07:20 +00:00
|
|
|
private Q_SLOTS:
|
|
|
|
void handleFrameGeometryChanged();
|
2021-08-12 09:07:38 +00:00
|
|
|
void handleWindowClosed(Toplevel *original, Deleted *deleted);
|
2021-02-04 09:07:20 +00:00
|
|
|
|
2021-04-26 16:38:40 +00:00
|
|
|
protected:
|
|
|
|
void preprocess() override;
|
2021-05-21 10:51:23 +00:00
|
|
|
WindowQuadList buildQuads() const override;
|
2021-04-26 16:38:40 +00:00
|
|
|
|
2021-02-04 09:07:20 +00:00
|
|
|
private:
|
2021-08-12 09:07:38 +00:00
|
|
|
Toplevel *m_window;
|
2021-02-04 09:07:20 +00:00
|
|
|
QPointer<KDecoration2::Decoration> m_decoration;
|
2021-04-26 16:38:40 +00:00
|
|
|
QScopedPointer<DecorationRenderer> m_renderer;
|
2021-02-04 09:07:20 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace KWin
|