Replace Toplevel::clientContentPos() with a better solution

The Toplevel::clientContentPos() function is needed to map the surface
local coordinates to the global coordinates. But its name is highly
confusing as there's already a function with a similar name. This change
introduces a helper with a better name to fix the readability issue.
This commit is contained in:
Vlad Zahorodnii 2021-05-16 17:32:07 +03:00
parent 18793f83d3
commit 5ece6d55d6
9 changed files with 8 additions and 29 deletions

View file

@ -77,7 +77,6 @@ void Deleted::copyToDeleted(Toplevel* c)
m_desktops = c->desktops();
activityList = c->activities();
contentsRect = QRect(c->clientPos(), c->clientSize());
m_contentPos = c->clientContentPos();
transparent_rect = c->transparentRect();
m_layer = c->layer();
m_frame = c->frameId();

View file

@ -38,9 +38,6 @@ public:
QStringList activities() const override;
QVector<VirtualDesktop *> desktops() const override;
QPoint clientPos() const override;
QPoint clientContentPos() const override {
return m_contentPos;
}
QRect transparentRect() const override;
bool isDeleted() const override;
xcb_window_t frameId() const override;
@ -117,7 +114,6 @@ private:
int desk;
QStringList activityList;
QRect contentsRect; // for clientPos()/clientSize()
QPoint m_contentPos;
QRect transparent_rect;
xcb_window_t m_frame;
QVector <VirtualDesktop *> m_desktops;

View file

@ -120,11 +120,6 @@ QString InternalClient::captionSuffix() const
return m_captionSuffix;
}
QPoint InternalClient::clientContentPos() const
{
return -1 * clientPos();
}
QSize InternalClient::minSize() const
{
return m_internalWindow->minimumSize();

View file

@ -27,7 +27,6 @@ public:
qreal bufferScale() const override;
QString captionNormal() const override;
QString captionSuffix() const override;
QPoint clientContentPos() const override;
QSize minSize() const override;
QSize maxSize() const override;
QRect transparentRect() const override;

View file

@ -701,7 +701,7 @@ void PointerInputRedirection::updatePointerConstraints()
m_locked = false;
disconnectLockedPointerAboutToBeUnboundConnection();
if (! (hint.x() < 0 || hint.y() < 0) && focus()) {
processMotion(focus()->pos() - focus()->clientContentPos() + hint, waylandServer()->seat()->timestamp());
processMotion(focus()->mapFromLocal(hint), waylandServer()->seat()->timestamp());
}
}
return;
@ -719,7 +719,7 @@ void PointerInputRedirection::updatePointerConstraints()
if (hint.x() < 0 || hint.y() < 0 || !focus()) {
return;
}
auto globalHint = focus()->pos() - focus()->clientContentPos() + hint;
auto globalHint = focus()->mapFromLocal(hint);
// When the resource finally goes away, reposition the cursor according to the hint
connect(lock, &KWaylandServer::LockedPointerV1Interface::destroyed, this,

View file

@ -686,6 +686,11 @@ QPointF Toplevel::mapToLocal(const QPointF &point) const
return point - bufferGeometry().topLeft();
}
QPointF Toplevel::mapFromLocal(const QPointF &point) const
{
return point + bufferGeometry().topLeft();
}
QRect Toplevel::inputGeometry() const
{
return frameGeometry();

View file

@ -357,11 +357,6 @@ public:
*/
virtual qreal bufferScale() const;
virtual QPoint clientPos() const = 0; // inside of geometry()
/**
* Describes how the client's content maps to the window geometry including the frame.
* The default implementation is a 1:1 mapping meaning the frame is part of the content.
*/
virtual QPoint clientContentPos() const;
QSize clientSize() const;
/**
* Returns a rectangle that the window occupies on the screen, including drop-shadows.
@ -382,6 +377,7 @@ public:
*/
QPoint mapToLocal(const QPoint &point) const;
QPointF mapToLocal(const QPointF &point) const;
QPointF mapFromLocal(const QPointF &point) const;
// prefer isXXX() instead
// 0 for supported types means default for managed/unmanaged types
@ -1006,11 +1002,6 @@ inline QImage Toplevel::internalImageObject() const
return m_internalImage;
}
inline QPoint Toplevel::clientContentPos() const
{
return QPoint(0, 0);
}
template <class T, class U>
inline T *Toplevel::findInList(const QList<T*> &list, std::function<bool (const U*)> func)
{

View file

@ -65,11 +65,6 @@ QString WaylandClient::captionSuffix() const
return m_captionSuffix;
}
QPoint WaylandClient::clientContentPos() const
{
return -clientPos();
}
QRect WaylandClient::transparentRect() const
{
return QRect();

View file

@ -25,7 +25,6 @@ public:
QString captionNormal() const override;
QString captionSuffix() const override;
QPoint clientContentPos() const override;
QRect transparentRect() const override;
pid_t pid() const override;
bool isLockScreen() const override;