diff --git a/platform.cpp b/platform.cpp
index 257d9ea068..e986fd943b 100644
--- a/platform.cpp
+++ b/platform.cpp
@@ -37,6 +37,8 @@ along with this program. If not, see .
#include
#include
+#include
+
namespace KWin
{
@@ -501,8 +503,32 @@ OverlayWindow *Platform::createOverlayWindow()
return nullptr;
}
+static quint32 monotonicTime()
+{
+ timespec ts;
+
+ const int result = clock_gettime(CLOCK_MONOTONIC, &ts);
+ if (result)
+ qCWarning(KWIN_CORE, "Failed to query monotonic time: %s", strerror(errno));
+
+ return ts.tv_sec * 1000 + ts.tv_nsec / 1000000L;
+}
+
void Platform::updateXTime()
{
+ switch (kwinApp()->operationMode()) {
+ case Application::OperationModeX11:
+ kwinApp()->setX11Time(QX11Info::getTimestamp(), Application::TimestampUpdate::Always);
+ break;
+
+ case Application::OperationModeXwayland:
+ kwinApp()->setX11Time(monotonicTime(), Application::TimestampUpdate::Always);
+ break;
+
+ default:
+ // Do not update the current X11 time stamp if it's the Wayland only session.
+ break;
+ }
}
OutlineVisual *Platform::createOutline(Outline *outline)
diff --git a/platform.h b/platform.h
index d6da5c4e86..35d708fcb4 100644
--- a/platform.h
+++ b/platform.h
@@ -364,13 +364,9 @@ public:
virtual OverlayWindow *createOverlayWindow();
/**
- * Allows a platform to update the X11 timestamp.
- * Mostly for the X11 standalone platform to interact with QX11Info.
- *
- * Default implementation does nothing. This means code relying on the X timestamp being up to date,
- * might not be working. E.g. synced X11 window resizing
+ * Queries the current X11 time stamp of the X server.
*/
- virtual void updateXTime();
+ void updateXTime();
/**
* Creates the OutlineVisual for the given @p outline.
diff --git a/plugins/platforms/x11/standalone/x11_platform.cpp b/plugins/platforms/x11/standalone/x11_platform.cpp
index 92a8337912..7310d8df21 100644
--- a/plugins/platforms/x11/standalone/x11_platform.cpp
+++ b/plugins/platforms/x11/standalone/x11_platform.cpp
@@ -348,22 +348,6 @@ OverlayWindow *X11StandalonePlatform::createOverlayWindow()
return new OverlayWindowX11();
}
-/*
- Updates xTime(). This used to simply fetch current timestamp from the server,
- but that can cause xTime() to be newer than timestamp of events that are
- still in our events queue, thus e.g. making XSetInputFocus() caused by such
- event to be ignored. Therefore events queue is searched for first
- event with timestamp, and extra PropertyNotify is generated in order to make
- sure such event is found.
-*/
-void X11StandalonePlatform::updateXTime()
-{
- // NOTE: QX11Info::getTimestamp does not yet search the event queue as the old
- // solution did. This means there might be regressions currently. See the
- // documentation above on how it should be done properly.
- kwinApp()->setX11Time(QX11Info::getTimestamp(), Application::TimestampUpdate::Always);
-}
-
OutlineVisual *X11StandalonePlatform::createOutline(Outline *outline)
{
// first try composited Outline
diff --git a/plugins/platforms/x11/standalone/x11_platform.h b/plugins/platforms/x11/standalone/x11_platform.h
index ac6fff0ac9..78a12704bf 100644
--- a/plugins/platforms/x11/standalone/x11_platform.h
+++ b/plugins/platforms/x11/standalone/x11_platform.h
@@ -62,8 +62,6 @@ public:
void setupActionForGlobalAccel(QAction *action) override;
OverlayWindow *createOverlayWindow() override;
-
- void updateXTime() override;
OutlineVisual *createOutline(Outline *outline) override;
Decoration::Renderer *createDecorationRenderer(Decoration::DecoratedClientImpl *client) override;