From 398cf8df1b0cd096dda9955f4a7414b315b2ce23 Mon Sep 17 00:00:00 2001 From: Vlad Zahorodnii Date: Tue, 30 Jul 2024 14:44:52 +0300 Subject: [PATCH] Add CursorSource::frame This fixes not sending frame callbacks for tablet cursors. And in general this simplifies the code by removing a level of indirection responsible for communicating the frame timestamps, the Compositor can tell the CursorSource the frame time directly. --- src/compositor_wayland.cpp | 5 ++++- src/cursor.cpp | 5 ----- src/cursor.h | 3 --- src/cursorsource.cpp | 13 +++++++++++++ src/cursorsource.h | 4 ++++ src/pointer_input.cpp | 12 ------------ src/pointer_input.h | 1 - 7 files changed, 21 insertions(+), 22 deletions(-) diff --git a/src/compositor_wayland.cpp b/src/compositor_wayland.cpp index 1e9619c07d..e86b4e5ff9 100644 --- a/src/compositor_wayland.cpp +++ b/src/compositor_wayland.cpp @@ -12,6 +12,7 @@ #include "core/outputbackend.h" #include "core/renderbackend.h" #include "core/renderlayer.h" +#include "cursorsource.h" #include "effect/effecthandler.h" #include "ftrace.h" #include "main.h" @@ -354,7 +355,9 @@ void WaylandCompositor::composite(RenderLoop *renderLoop) if (!Cursors::self()->isCursorHidden()) { Cursor *cursor = Cursors::self()->currentCursor(); if (cursor->geometry().intersects(output->geometry())) { - cursor->markAsRendered(frameTime); + if (CursorSource *source = cursor->source()) { + source->frame(frameTime); + } } } } diff --git a/src/cursor.cpp b/src/cursor.cpp index c2be4cbc2f..b81b8c367f 100644 --- a/src/cursor.cpp +++ b/src/cursor.cpp @@ -218,11 +218,6 @@ void Cursor::setPos(const QPointF &pos) doSetPos(); } -void Cursor::markAsRendered(std::chrono::milliseconds timestamp) -{ - Q_EMIT rendered(timestamp); -} - #if KWIN_BUILD_X11 xcb_cursor_t Cursor::x11Cursor(CursorShape shape) { diff --git a/src/cursor.h b/src/cursor.h index 0f0b73ba5b..90897b5291 100644 --- a/src/cursor.h +++ b/src/cursor.h @@ -161,8 +161,6 @@ public: */ bool isOnOutput(Output *output) const; - void markAsRendered(std::chrono::milliseconds timestamp); - Q_SIGNALS: void posChanged(const QPointF &pos); void mouseChanged(const QPointF &pos, const QPointF &oldpos, @@ -178,7 +176,6 @@ Q_SIGNALS: */ void cursorChanged(); void themeChanged(); - void rendered(std::chrono::milliseconds timestamp); protected: /** diff --git a/src/cursorsource.cpp b/src/cursorsource.cpp index 74ef4626fe..6108872510 100644 --- a/src/cursorsource.cpp +++ b/src/cursorsource.cpp @@ -31,6 +31,10 @@ QPointF CursorSource::hotspot() const return m_hotspot; } +void CursorSource::frame(std::chrono::milliseconds timestamp) +{ +} + ShapeCursorSource::ShapeCursorSource(QObject *parent) : CursorSource(parent) { @@ -126,6 +130,15 @@ SurfaceInterface *SurfaceCursorSource::surface() const return m_surface; } +void SurfaceCursorSource::frame(std::chrono::milliseconds timestamp) +{ + if (m_surface) { + m_surface->traverseTree([×tamp](SurfaceInterface *surface) { + surface->frameRendered(timestamp.count()); + }); + } +} + void SurfaceCursorSource::refresh() { m_size = m_surface->size(); diff --git a/src/cursorsource.h b/src/cursorsource.h index 2311f8ea8f..8263105f94 100644 --- a/src/cursorsource.h +++ b/src/cursorsource.h @@ -32,6 +32,8 @@ public: QSizeF size() const; QPointF hotspot() const; + virtual void frame(std::chrono::milliseconds timestamp); + Q_SIGNALS: void changed(); @@ -84,6 +86,8 @@ public: SurfaceInterface *surface() const; + void frame(std::chrono::milliseconds timestamp) override; + public Q_SLOTS: void update(SurfaceInterface *surface, const QPointF &hotspot); diff --git a/src/pointer_input.cpp b/src/pointer_input.cpp index df1168aad5..3cc9775744 100644 --- a/src/pointer_input.cpp +++ b/src/pointer_input.cpp @@ -106,7 +106,6 @@ void PointerInputRedirection::init() } }); - connect(Cursors::self()->mouse(), &Cursor::rendered, m_cursor, &CursorImage::markAsRendered); connect(m_cursor, &CursorImage::changed, Cursors::self()->mouse(), [this] { Cursors::self()->mouse()->setSource(m_cursor->source()); m_cursor->updateCursorOutputs(m_pos); @@ -1021,17 +1020,6 @@ void CursorImage::updateCursorOutputs(const QPointF &pos) } } -void CursorImage::markAsRendered(std::chrono::milliseconds timestamp) -{ - if (m_currentSource == m_serverCursor.surface.get()) { - if (auto cursorSurface = m_serverCursor.surface->surface()) { - cursorSurface->traverseTree([×tamp](SurfaceInterface *surface) { - surface->frameRendered(timestamp.count()); - }); - } - } -} - void CursorImage::handleFocusedSurfaceChanged() { PointerInterface *pointer = waylandServer()->seat()->pointer(); diff --git a/src/pointer_input.h b/src/pointer_input.h index 414cd160cd..e07c0820f1 100644 --- a/src/pointer_input.h +++ b/src/pointer_input.h @@ -234,7 +234,6 @@ public: void setSource(CursorSource *source); void updateCursorOutputs(const QPointF &pos); - void markAsRendered(std::chrono::milliseconds timestamp); Q_SIGNALS: void changed();