Remove unused geometry setters in Item

Originally, only x, y, width, and height property setters were used. A
bit later "position" and "size" helper setters were added to simplify
code in SurfaceItem sub-classes. It seems like setX(), setY(), setWidth(),
and setHeight() are unused now, so remove them.
This commit is contained in:
Vlad Zahorodnii 2021-07-05 20:40:47 +03:00
parent db6b4c9c2e
commit 1e1ad82f3b
5 changed files with 17 additions and 137 deletions

View file

@ -39,76 +39,6 @@ Item::~Item()
}
}
int Item::x() const
{
return m_x;
}
void Item::setX(int x)
{
if (m_x == x) {
return;
}
scheduleRepaint(boundingRect());
m_x = x;
updateBoundingRect();
scheduleRepaint(boundingRect());
Q_EMIT xChanged();
}
int Item::y() const
{
return m_y;
}
void Item::setY(int y)
{
if (m_y == y) {
return;
}
scheduleRepaint(boundingRect());
m_y = y;
updateBoundingRect();
scheduleRepaint(boundingRect());
Q_EMIT yChanged();
}
int Item::width() const
{
return m_width;
}
void Item::setWidth(int width)
{
if (m_width == width) {
return;
}
scheduleRepaint(rect());
m_width = width;
updateBoundingRect();
scheduleRepaint(rect());
discardQuads();
Q_EMIT widthChanged();
}
int Item::height() const
{
return m_height;
}
void Item::setHeight(int height)
{
if (m_height == height) {
return;
}
scheduleRepaint(rect());
m_height = height;
updateBoundingRect();
scheduleRepaint(rect());
discardQuads();
Q_EMIT heightChanged();
}
Item *Item::parentItem() const
{
return m_parentItem;
@ -160,55 +90,34 @@ Scene::Window *Item::window() const
QPoint Item::position() const
{
return QPoint(x(), y());
return m_position;
}
void Item::setPosition(const QPoint &point)
{
const bool xDirty = (x() != point.x());
const bool yDirty = (y() != point.y());
if (xDirty || yDirty) {
if (m_position != point) {
scheduleRepaint(boundingRect());
m_x = point.x();
m_y = point.y();
m_position = point;
updateBoundingRect();
scheduleRepaint(boundingRect());
if (xDirty) {
Q_EMIT xChanged();
}
if (yDirty) {
Q_EMIT yChanged();
}
Q_EMIT positionChanged();
}
}
QSize Item::size() const
{
return QSize(width(), height());
return m_size;
}
void Item::setSize(const QSize &size)
{
const bool widthDirty = (width() != size.width());
const bool heightDirty = (height() != size.height());
if (widthDirty || heightDirty) {
if (m_size != size) {
scheduleRepaint(rect());
m_width = size.width();
m_height = size.height();
m_size = size;
updateBoundingRect();
scheduleRepaint(rect());
discardQuads();
if (widthDirty) {
Q_EMIT widthChanged();
}
if (heightDirty) {
Q_EMIT heightChanged();
}
Q_EMIT sizeChanged();
}
}

View file

@ -24,24 +24,6 @@ public:
explicit Item(Scene::Window *window, Item *parent = nullptr);
~Item() override;
/**
* Returns the x coordinate relative to the top left corner of the parent item.
*/
int x() const;
void setX(int x);
/**
* Returns the y coordinate relative to the top left corner of the parent item.
*/
int y() const;
void setY(int y);
int width() const;
void setWidth(int width);
int height() const;
void setHeight(int height);
QPoint position() const;
void setPosition(const QPoint &point);
@ -106,21 +88,13 @@ public:
Q_SIGNALS:
/**
* This signal is emitted when the x coordinate of this item has changed.
* This signal is emitted when the position of this item has changed.
*/
void xChanged();
void positionChanged();
/**
* This signal is emitted when the y coordinate of this item has changed.
* This signal is emitted when the size of this item has changed.
*/
void yChanged();
/**
* This signal is emitted when the width of this item has changed.
*/
void widthChanged();
/**
* This signal is emitted when the height of this item has changed.
*/
void heightChanged();
void sizeChanged();
/**
* This signal is emitted when the rectangle that encloses this item and all of its children
@ -146,10 +120,8 @@ private:
QPointer<Item> m_parentItem;
QList<Item *> m_childItems;
QRect m_boundingRect;
int m_x = 0;
int m_y = 0;
int m_width = 0;
int m_height = 0;
QPoint m_position;
QSize m_size = QSize(0, 0);
bool m_visible = true;
bool m_effectiveVisible = true;
QVector<QRegion> m_repaints;

View file

@ -29,7 +29,7 @@ QPointF SurfaceItemInternal::mapToBuffer(const QPointF &point) const
QRegion SurfaceItemInternal::shape() const
{
return QRegion(0, 0, width(), height());
return QRegion(rect());
}
SurfacePixmap *SurfaceItemInternal::createPixmap()

View file

@ -66,7 +66,7 @@ QPointF SurfaceItemWayland::mapToBuffer(const QPointF &point) const
QRegion SurfaceItemWayland::shape() const
{
return QRegion(0, 0, width(), height());
return QRegion(rect());
}
QRegion SurfaceItemWayland::opaque() const

View file

@ -270,8 +270,7 @@ bool Toplevel::setupCompositing()
effect_window = new EffectWindowImpl(this);
Compositor::self()->scene()->addToplevel(this);
connect(windowItem(), &WindowItem::xChanged, this, &Toplevel::visibleGeometryChanged);
connect(windowItem(), &WindowItem::yChanged, this, &Toplevel::visibleGeometryChanged);
connect(windowItem(), &WindowItem::positionChanged, this, &Toplevel::visibleGeometryChanged);
connect(windowItem(), &WindowItem::boundingRectChanged, this, &Toplevel::visibleGeometryChanged);
return true;