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

View file

@ -24,24 +24,6 @@ public:
explicit Item(Scene::Window *window, Item *parent = nullptr); explicit Item(Scene::Window *window, Item *parent = nullptr);
~Item() override; ~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; QPoint position() const;
void setPosition(const QPoint &point); void setPosition(const QPoint &point);
@ -106,21 +88,13 @@ public:
Q_SIGNALS: 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(); void sizeChanged();
/**
* 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();
/** /**
* This signal is emitted when the rectangle that encloses this item and all of its children * 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; QPointer<Item> m_parentItem;
QList<Item *> m_childItems; QList<Item *> m_childItems;
QRect m_boundingRect; QRect m_boundingRect;
int m_x = 0; QPoint m_position;
int m_y = 0; QSize m_size = QSize(0, 0);
int m_width = 0;
int m_height = 0;
bool m_visible = true; bool m_visible = true;
bool m_effectiveVisible = true; bool m_effectiveVisible = true;
QVector<QRegion> m_repaints; QVector<QRegion> m_repaints;

View file

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

View file

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

View file

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