[plasma/kwin] src: Simplify move resize geometry tracking in XdgSurfaceWindow
Vlad Zahorodnii <[email protected]>
| Newsgroups | gmane.comp.kde.cvs |
|---|---|
| Message-ID | <[email protected]> |
Git commit 287299af11f2af7d432099f2e898ac56aaa76406 by Vlad Zahorodnii.
Committed on 03/08/2026 at 13:24.
Pushed by vladz into branch 'master'.
Simplify move resize geometry tracking in XdgSurfaceWindow
It's less technically correct but it's also relevant only in a case
where both the compositor and the client actively update the geometry.
In practice, it doesn't happen that often. Even with the
ConfigurePosition flag, it is still possible to encounter geometry
conflicts.
The main goal is to be able to get rid of configure flags and simplify
geometry code.
M +8 -34 src/xdgshellwindow.cpp
M +0 -10 src/xdgshellwindow.h
https://invent.kde.org/plasma/kwin/-/commit/287299af11f2af7d432099f2e898ac56aaa76406
diff --git a/src/xdgshellwindow.cpp b/src/xdgshellwindow.cpp
index a7b86bd6462..3269bf768bb 100644
--- a/src/xdgshellwindow.cpp
+++ b/src/xdgshellwindow.cpp
@@ -93,16 +93,9 @@ void XdgSurfaceWindow::sendConfigure()
{
XdgSurfaceConfigure *configureEvent = sendRoleConfigure();
- // The configure event inherits configure flags from the previous event.
- if (!m_configureEvents.isEmpty()) {
- const XdgSurfaceConfigure *previousEvent = m_configureEvents.constLast();
- configureEvent->flags = previousEvent->flags;
- }
-
configureEvent->gravity = m_nextGravity;
- configureEvent->flags |= m_configureFlags;
configureEvent->scale = m_nextTargetScale;
- m_configureFlags = {};
+
if (!isInteractiveMoveResize()) {
m_nextGravity = Gravity::None;
}
@@ -156,25 +149,6 @@ void XdgSurfaceWindow::handleRoleCommit()
{
}
-void XdgSurfaceWindow::maybeUpdateMoveResizeGeometry(const RectF &rect)
-{
- // We are about to send a configure event, ignore the committed window geometry.
- if (m_configureTimer->isActive()) {
- return;
- }
-
- // If there are unacknowledged configure events that change the geometry, don't sync
- // the move resize geometry in order to avoid rolling back to old state. When the last
- // configure event is acknowledged, the move resize geometry will be synchronized.
- for (int i = m_configureEvents.count() - 1; i >= 0; --i) {
- if (m_configureEvents[i]->flags & XdgSurfaceConfigure::ConfigurePosition) {
- return;
- }
- }
-
- setMoveResizeGeometry(rect);
-}
-
void XdgSurfaceWindow::handleNextWindowGeometry()
{
if (const XdgSurfaceConfigure *configureEvent = lastAcknowledgedConfigure()) {
@@ -185,9 +159,7 @@ void XdgSurfaceWindow::handleNextWindowGeometry()
RectF frameGeometry(pos(), clientSizeToFrameSize(m_windowGeometry.size()));
if (const XdgSurfaceConfigure *configureEvent = lastAcknowledgedConfigure()) {
- if (configureEvent->flags & XdgSurfaceConfigure::ConfigurePosition) {
- frameGeometry = configureEvent->gravity.apply(frameGeometry, configureEvent->bounds);
- }
+ frameGeometry = configureEvent->gravity.apply(frameGeometry, configureEvent->bounds);
}
if (isInteractiveMove()) {
@@ -200,7 +172,10 @@ void XdgSurfaceWindow::handleNextWindowGeometry()
}
}
- maybeUpdateMoveResizeGeometry(frameGeometry);
+ if (!m_configureTimer->isActive() && m_configureEvents.isEmpty()) {
+ setMoveResizeGeometry(frameGeometry);
+ }
+
updateGeometry(frameGeometry);
}
@@ -235,15 +210,14 @@ void XdgSurfaceWindow::moveResizeInternal(const RectF &rect, MoveResizeMode mode
const RectF snappedRect = RectF(rect.topLeft(), nextClientSizeToFrameSize(snapToPixels(roundedClientSize, nextTargetScale())));
updateGeometry(m_nextGravity.apply(snappedRect, rect));
} else {
- m_configureFlags |= XdgSurfaceConfigure::ConfigurePosition;
scheduleConfigure();
}
} else {
// If the window is moved, cancel any queued window position updates.
for (XdgSurfaceConfigure *configureEvent : std::as_const(m_configureEvents)) {
- configureEvent->flags.setFlag(XdgSurfaceConfigure::ConfigurePosition, false);
+ configureEvent->bounds.moveTopLeft(rect.topLeft());
+ configureEvent->gravity = Gravity::BottomRight;
}
- m_configureFlags.setFlag(XdgSurfaceConfigure::ConfigurePosition, false);
updateGeometry(RectF(rect.topLeft(), size()));
}
}
diff --git a/src/xdgshellwindow.h b/src/xdgshellwindow.h
index 598edeadb45..221771a7740 100644
--- a/src/xdgshellwindow.h
+++ b/src/xdgshellwindow.h
@@ -46,15 +46,9 @@ public:
{
}
- enum ConfigureFlag {
- ConfigurePosition = 0x1,
- };
- Q_DECLARE_FLAGS(ConfigureFlags, ConfigureFlag)
-
RectF bounds;
Gravity gravity;
qreal serial;
- ConfigureFlags flags;
double scale;
};
@@ -96,11 +90,9 @@ private:
bool haveNextWindowGeometry() const;
void setHaveNextWindowGeometry();
void resetHaveNextWindowGeometry();
- void maybeUpdateMoveResizeGeometry(const RectF &rect);
XdgSurfaceInterface *m_shellSurface;
QTimer *m_configureTimer;
- XdgSurfaceConfigure::ConfigureFlags m_configureFlags;
QQueue<XdgSurfaceConfigure *> m_configureEvents;
std::unique_ptr<XdgSurfaceConfigure> m_lastAcknowledgedConfigure;
std::optional<quint32> m_lastAcknowledgedConfigureSerial;
@@ -325,5 +317,3 @@ private:
};
} // namespace KWin
-
-Q_DECLARE_OPERATORS_FOR_FLAGS(KWin::XdgSurfaceConfigure::ConfigureFlags)