Introduce a signal that notifies about new buffer geometry

The new signal can be useful if one wants to watch a toplevel for buffer
geometry updates. This can be especially useful for input related code
because the position of the upper left corner of the main surface is used
to compute the input transformation matrix.
This commit is contained in:
Vlad Zahorodnii 2020-07-14 15:00:29 +03:00 committed by Vlad Zahorodnii
parent fc839d8b29
commit 9c55c01767
5 changed files with 20 additions and 0 deletions

View file

@ -908,6 +908,7 @@ void AbstractClient::move(int x, int y, ForceGeometry_t force)
screens()->setCurrent(this);
workspace()->updateStackingOrder();
// client itself is not damaged
emit bufferGeometryChanged(this, bufferGeometryBeforeUpdateBlocking());
emit frameGeometryChanged(this, frameGeometryBeforeUpdateBlocking());
addRepaintDuringGeometryUpdates();
updateGeometryBeforeUpdateBlocking();

View file

@ -531,6 +531,9 @@ void InternalClient::commitGeometry(const QRect &rect)
addWorkspaceRepaint(visibleRect());
syncGeometryToInternalWindow();
if (bufferGeometryBeforeUpdateBlocking() != bufferGeometry()) {
emit bufferGeometryChanged(this, bufferGeometryBeforeUpdateBlocking());
}
if (clientGeometryBeforeUpdateBlocking() != clientGeometry()) {
emit clientGeometryChanged(this, clientGeometryBeforeUpdateBlocking());
}

View file

@ -657,6 +657,10 @@ Q_SIGNALS:
*/
void shadowChanged();
/**
* This signal is emitted when the Toplevel's buffer geometry changes.
*/
void bufferGeometryChanged(KWin::Toplevel *toplevel, const QRect &oldGeometry);
/**
* This signal is emitted when the Toplevel's frame geometry changes.
*/

View file

@ -2902,6 +2902,9 @@ void X11Client::move(int x, int y, ForceGeometry_t force)
screens()->setCurrent(this);
workspace()->updateStackingOrder();
// client itself is not damaged
if (bufferGeometryBeforeUpdateBlocking() != bufferGeometry()) {
emit bufferGeometryChanged(this, bufferGeometryBeforeUpdateBlocking());
}
if (clientGeometryBeforeUpdateBlocking() != clientGeometry()) {
emit clientGeometryChanged(this, clientGeometryBeforeUpdateBlocking());
}
@ -4197,6 +4200,9 @@ void X11Client::setFrameGeometry(const QRect &rect, ForceGeometry_t force)
if (bufferGeometryBeforeUpdateBlocking().size() != m_bufferGeometry.size()) {
discardWindowPixmap();
}
if (bufferGeometryBeforeUpdateBlocking() != m_bufferGeometry) {
emit bufferGeometryChanged(this, bufferGeometryBeforeUpdateBlocking());
}
if (clientGeometryBeforeUpdateBlocking() != m_clientGeometry) {
emit clientGeometryChanged(this, clientGeometryBeforeUpdateBlocking());
}
@ -4257,6 +4263,9 @@ void X11Client::plainResize(int w, int h, ForceGeometry_t force)
if (bufferGeometryBeforeUpdateBlocking().size() != m_bufferGeometry.size()) {
discardWindowPixmap();
}
if (bufferGeometryBeforeUpdateBlocking() != bufferGeometry()) {
emit bufferGeometryChanged(this, bufferGeometryBeforeUpdateBlocking());
}
if (clientGeometryBeforeUpdateBlocking() != clientGeometry()) {
emit clientGeometryChanged(this, clientGeometryBeforeUpdateBlocking());
}

View file

@ -463,6 +463,9 @@ void XdgSurfaceClient::updateGeometry(const QRect &rect)
updateWindowRules(Rules::Position | Rules::Size);
updateGeometryBeforeUpdateBlocking();
if (changedGeometries & XdgSurfaceGeometryBuffer) {
emit bufferGeometryChanged(this, oldBufferGeometry);
}
if (changedGeometries & XdgSurfaceGeometryClient) {
emit clientGeometryChanged(this, oldClientGeometry);
}