plugins/screencast: Fix hidden cursors

The screencast plugin doesn't take into account the hidden status of
the cursor, which results in the cursor being visible when screencasting
even though it's hidden.
This commit is contained in:
Vlad Zahorodnii 2024-01-30 23:46:23 +02:00
parent 120e36da2a
commit 3a1b9414ed
2 changed files with 13 additions and 4 deletions

View file

@ -535,7 +535,7 @@ void ScreenCastStream::recordFrame(const QRegion &_damagedRegion)
m_source->render(spa_data, m_videoFormat.format);
auto cursor = Cursors::self()->currentCursor();
if (m_cursor.mode == ScreencastV1Interface::Embedded && exclusiveContains(m_cursor.viewport, cursor->pos())) {
if (m_cursor.mode == ScreencastV1Interface::Embedded && includesCursor(cursor)) {
QImage dest(data, size.width(), size.height(), stride, hasAlpha ? QImage::Format_RGBA8888_Premultiplied : QImage::Format_RGB888);
QPainter painter(&dest);
const auto position = (cursor->pos() - m_cursor.viewport.topLeft() - cursor->hotspot()) * m_cursor.scale;
@ -557,7 +557,7 @@ void ScreenCastStream::recordFrame(const QRegion &_damagedRegion)
m_source->render(buf->framebuffer());
auto cursor = Cursors::self()->currentCursor();
if (m_cursor.mode == ScreencastV1Interface::Embedded && exclusiveContains(m_cursor.viewport, cursor->pos())) {
if (m_cursor.mode == ScreencastV1Interface::Embedded && includesCursor(cursor)) {
if (m_cursor.invalid) {
m_cursor.invalid = false;
const PlatformCursorImage cursorImage = kwinApp()->cursorImage();
@ -669,7 +669,7 @@ void ScreenCastStream::recordCursor()
return;
}
if (!exclusiveContains(m_cursor.viewport, Cursors::self()->currentCursor()->pos()) && !m_cursor.visible) {
if (!includesCursor(Cursors::self()->currentCursor()) && !m_cursor.visible) {
return;
}
@ -802,13 +802,21 @@ spa_pod *ScreenCastStream::buildFormat(struct spa_pod_builder *b, enum spa_video
return (spa_pod *)spa_pod_builder_pop(b, &f[0]);
}
bool ScreenCastStream::includesCursor(Cursor *cursor) const
{
if (Cursors::self()->isCursorHidden()) {
return false;
}
return m_cursor.viewport.intersects(cursor->geometry());
}
void ScreenCastStream::sendCursorData(Cursor *cursor, spa_meta_cursor *spa_meta_cursor)
{
if (!cursor || !spa_meta_cursor) {
return;
}
if (!exclusiveContains(m_cursor.viewport, cursor->pos())) {
if (!includesCursor(cursor)) {
spa_meta_cursor->id = 0;
spa_meta_cursor->position.x = -1;
spa_meta_cursor->position.y = -1;

View file

@ -74,6 +74,7 @@ public:
public Q_SLOTS:
void invalidateCursor();
void recordCursor();
bool includesCursor(Cursor *cursor) const;
Q_SIGNALS:
void streamReady(quint32 nodeId);