Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 48 additions & 6 deletions panels/dock/pluginmanagerextension.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,20 @@
#include <cstdint>

#include <QtWaylandCompositor/QWaylandSurface>
#include <QtWaylandCompositor/QWaylandResource>

Check warning on line 15 in panels/dock/pluginmanagerextension.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QtWaylandCompositor/QWaylandResource> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QtWaylandCompositor/QWaylandCompositor>

Check warning on line 16 in panels/dock/pluginmanagerextension.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QtWaylandCompositor/QWaylandCompositor> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QtWaylandCompositor/QWaylandView>

Check warning on line 17 in panels/dock/pluginmanagerextension.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QtWaylandCompositor/QWaylandView> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QtWaylandCompositor/QWaylandBufferRef>

Check warning on line 18 in panels/dock/pluginmanagerextension.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QtWaylandCompositor/QWaylandBufferRef> not found. Please note: Cppcheck does not need standard library headers to get proper results.

#include <QJsonObject>

Check warning on line 20 in panels/dock/pluginmanagerextension.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QJsonObject> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QJsonParseError>

Check warning on line 21 in panels/dock/pluginmanagerextension.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QJsonParseError> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QGuiApplication>

Check warning on line 22 in panels/dock/pluginmanagerextension.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QGuiApplication> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QCursor>

Check warning on line 23 in panels/dock/pluginmanagerextension.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QCursor> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QPixmap>

Check warning on line 24 in panels/dock/pluginmanagerextension.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QPixmap> not found. Please note: Cppcheck does not need standard library headers to get proper results.

#define protected public
#include <private/qwaylandcompositor_p.h>

Check warning on line 27 in panels/dock/pluginmanagerextension.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <private/qwaylandcompositor_p.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <private/qwaylandsurface_p.h>
#undef protected
#include <qpa/qwindowsysteminterface_p.h>

Expand Down Expand Up @@ -709,13 +714,50 @@

QObject::connect(seat, &QWaylandSeat::mouseFocusChanged, this,
[seat](QWaylandView *newFocus, QWaylandView *oldFocus) {
Q_UNUSED(oldFocus);
if(!newFocus)
return;
// Restore default cursor when mouse leaves all plugin areas
if (!newFocus && oldFocus) {
qApp->restoreOverrideCursor();
}

if (newFocus) {
if (auto surface = newFocus->surface()) {
seat->setKeyboardFocus(surface);
}
}
});

if (auto surface = newFocus->surface()) {
qDebug()<<"setKeyboardFocus";
seat->setKeyboardFocus(surface);
// Handle client cursor requests and apply cursor changes to the host window
QObject::connect(seat, &QWaylandSeat::cursorSurfaceRequested, this,
[this](QWaylandSurface *surface, int hotspotX, int hotspotY) {
// Disconnect previous connection
if (m_cursorSurfaceConn) {
QObject::disconnect(m_cursorSurfaceConn);
m_cursorSurfaceConn = {};
}

if (!surface) {
qApp->restoreOverrideCursor();
return;
}

auto updateCursor = [surface, hotspotX, hotspotY]() {
QWaylandSurfacePrivate *surf = QWaylandSurfacePrivate::get(surface);
QWaylandBufferRef buf = surf->bufferRef;
if (!buf.hasBuffer()) {
return;
}
QImage image = buf.image();
if (!image.isNull() && image.width() > 0 && image.height() > 0) {
QPixmap pixmap = QPixmap::fromImage(image);
QCursor cursor(QPixmap::fromImage(image), hotspotX, hotspotY);
if (qApp->overrideCursor()) {
qApp->changeOverrideCursor(cursor);
} else {
qApp->setOverrideCursor(cursor);
}
}
};
// Listen to surface redraw signal to grab cursor after buffer is updated
m_cursorSurfaceConn = QObject::connect(surface, &QWaylandSurface::redraw, updateCursor);
});
}
1 change: 1 addition & 0 deletions panels/dock/pluginmanagerextension_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ private Q_SLOTS:
uint32_t m_dockColorTheme = 0;
QSize m_dockSize;
int m_popupMinHeight = 0;
QMetaObject::Connection m_cursorSurfaceConn = {};
};

class PluginSurface : public QWaylandShellSurfaceTemplate<PluginSurface>, public QtWaylandServer::plugin
Expand Down