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
|
|
|
|
|
2021-08-12 09:07:38 +00:00
|
|
|
#include "kwineffects.h"
|
2022-03-23 10:13:38 +00:00
|
|
|
#include "kwinglobals.h"
|
2021-08-12 09:07:38 +00:00
|
|
|
|
|
|
|
#include <QMatrix4x4>
|
|
|
|
#include <QObject>
|
2021-02-04 09:07:20 +00:00
|
|
|
|
2021-06-19 17:50:19 +00:00
|
|
|
#include <optional>
|
|
|
|
|
2021-02-04 09:07:20 +00:00
|
|
|
namespace KWin
|
|
|
|
{
|
|
|
|
|
2022-04-14 12:33:28 +00:00
|
|
|
class Output;
|
2021-08-24 20:55:42 +00:00
|
|
|
|
2021-02-04 09:07:20 +00:00
|
|
|
/**
|
|
|
|
* The Item class is the base class for items in the scene.
|
|
|
|
*/
|
|
|
|
class KWIN_EXPORT Item : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2021-08-12 09:07:38 +00:00
|
|
|
explicit Item(Item *parent = nullptr);
|
2021-02-04 09:07:20 +00:00
|
|
|
~Item() override;
|
|
|
|
|
2022-05-05 12:56:36 +00:00
|
|
|
qreal opacity() const;
|
|
|
|
void setOpacity(qreal opacity);
|
|
|
|
|
2021-02-04 09:07:20 +00:00
|
|
|
QPoint position() const;
|
|
|
|
void setPosition(const QPoint &point);
|
|
|
|
|
|
|
|
QSize size() const;
|
|
|
|
void setSize(const QSize &size);
|
|
|
|
|
2021-06-19 14:00:19 +00:00
|
|
|
int z() const;
|
|
|
|
void setZ(int z);
|
|
|
|
|
2021-02-04 09:07:20 +00:00
|
|
|
/**
|
|
|
|
* Returns the enclosing rectangle of the item. The rect equals QRect(0, 0, width(), height()).
|
|
|
|
*/
|
|
|
|
QRect rect() const;
|
|
|
|
/**
|
|
|
|
* Returns the enclosing rectangle of the item and all of its descendants.
|
|
|
|
*/
|
|
|
|
QRect boundingRect() const;
|
|
|
|
|
2022-05-07 10:20:11 +00:00
|
|
|
virtual QRegion shape() const;
|
|
|
|
virtual QRegion opaque() const;
|
|
|
|
|
2021-02-04 09:07:20 +00:00
|
|
|
/**
|
|
|
|
* Returns the visual parent of the item. Note that the visual parent differs from
|
|
|
|
* the QObject parent.
|
|
|
|
*/
|
|
|
|
Item *parentItem() const;
|
|
|
|
void setParentItem(Item *parent);
|
|
|
|
QList<Item *> childItems() const;
|
2021-06-19 14:00:19 +00:00
|
|
|
QList<Item *> sortedChildItems() const;
|
2021-02-04 09:07:20 +00:00
|
|
|
|
|
|
|
QPoint rootPosition() const;
|
|
|
|
|
2021-08-11 15:03:06 +00:00
|
|
|
QMatrix4x4 transform() const;
|
|
|
|
void setTransform(const QMatrix4x4 &transform);
|
|
|
|
|
2021-02-04 09:07:20 +00:00
|
|
|
/**
|
|
|
|
* Maps the given @a region from the item's coordinate system to the scene's coordinate
|
|
|
|
* system.
|
|
|
|
*/
|
|
|
|
QRegion mapToGlobal(const QRegion ®ion) const;
|
|
|
|
/**
|
|
|
|
* Maps the given @a rect from the item's coordinate system to the scene's coordinate
|
|
|
|
* system.
|
|
|
|
*/
|
|
|
|
QRect mapToGlobal(const QRect &rect) const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Moves this item right before the specified @a sibling in the parent's children list.
|
|
|
|
*/
|
|
|
|
void stackBefore(Item *sibling);
|
|
|
|
/**
|
|
|
|
* Moves this item right after the specified @a sibling in the parent's children list.
|
|
|
|
*/
|
|
|
|
void stackAfter(Item *sibling);
|
|
|
|
|
2022-04-27 11:07:21 +00:00
|
|
|
bool explicitVisible() const;
|
2021-05-26 09:27:27 +00:00
|
|
|
bool isVisible() const;
|
|
|
|
void setVisible(bool visible);
|
|
|
|
|
2021-02-04 09:07:20 +00:00
|
|
|
void scheduleRepaint(const QRegion ®ion);
|
2021-05-19 06:35:42 +00:00
|
|
|
void scheduleFrame();
|
2022-04-14 12:33:28 +00:00
|
|
|
QRegion repaints(Output *output) const;
|
|
|
|
void resetRepaints(Output *output);
|
2021-02-04 09:07:20 +00:00
|
|
|
|
2021-05-21 10:51:23 +00:00
|
|
|
WindowQuadList quads() const;
|
2021-06-10 11:18:42 +00:00
|
|
|
virtual void preprocess();
|
2021-05-21 10:51:23 +00:00
|
|
|
|
2021-02-04 09:07:20 +00:00
|
|
|
Q_SIGNALS:
|
|
|
|
/**
|
2021-07-05 17:40:47 +00:00
|
|
|
* This signal is emitted when the position of this item has changed.
|
2021-02-04 09:07:20 +00:00
|
|
|
*/
|
2021-07-05 17:40:47 +00:00
|
|
|
void positionChanged();
|
2021-02-04 09:07:20 +00:00
|
|
|
/**
|
2021-07-05 17:40:47 +00:00
|
|
|
* This signal is emitted when the size of this item has changed.
|
2021-02-04 09:07:20 +00:00
|
|
|
*/
|
2021-07-05 17:40:47 +00:00
|
|
|
void sizeChanged();
|
2021-02-04 09:07:20 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* This signal is emitted when the rectangle that encloses this item and all of its children
|
|
|
|
* has changed.
|
|
|
|
*/
|
|
|
|
void boundingRectChanged();
|
|
|
|
|
|
|
|
protected:
|
2021-05-21 10:51:23 +00:00
|
|
|
virtual WindowQuadList buildQuads() const;
|
2021-02-04 09:07:20 +00:00
|
|
|
void discardQuads();
|
|
|
|
|
|
|
|
private:
|
|
|
|
void addChild(Item *item);
|
|
|
|
void removeChild(Item *item);
|
|
|
|
void updateBoundingRect();
|
2021-05-26 09:27:27 +00:00
|
|
|
void scheduleRepaintInternal(const QRegion ®ion);
|
2021-06-19 14:00:19 +00:00
|
|
|
void markSortedChildItemsDirty();
|
2021-02-04 09:07:20 +00:00
|
|
|
|
2021-05-26 09:27:27 +00:00
|
|
|
bool computeEffectiveVisibility() const;
|
|
|
|
void updateEffectiveVisibility();
|
2022-04-14 12:33:28 +00:00
|
|
|
void removeRepaints(Output *output);
|
2021-05-26 09:27:27 +00:00
|
|
|
|
2021-02-04 09:07:20 +00:00
|
|
|
QPointer<Item> m_parentItem;
|
|
|
|
QList<Item *> m_childItems;
|
2021-08-11 15:03:06 +00:00
|
|
|
QMatrix4x4 m_transform;
|
2021-02-04 09:07:20 +00:00
|
|
|
QRect m_boundingRect;
|
2021-07-05 17:40:47 +00:00
|
|
|
QPoint m_position;
|
|
|
|
QSize m_size = QSize(0, 0);
|
2022-05-05 12:56:36 +00:00
|
|
|
qreal m_opacity = 1;
|
2021-06-19 14:00:19 +00:00
|
|
|
int m_z = 0;
|
2022-04-27 11:07:21 +00:00
|
|
|
bool m_explicitVisible = true;
|
2021-05-26 09:27:27 +00:00
|
|
|
bool m_effectiveVisible = true;
|
2022-04-14 12:33:28 +00:00
|
|
|
QMap<Output *, QRegion> m_repaints;
|
2021-06-19 17:50:19 +00:00
|
|
|
mutable std::optional<WindowQuadList> m_quads;
|
2021-06-19 14:00:19 +00:00
|
|
|
mutable std::optional<QList<Item *>> m_sortedChildItems;
|
2021-02-04 09:07:20 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace KWin
|