Skip to content
Merged
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
18 changes: 17 additions & 1 deletion src/loader/widgetplugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,16 @@ class Q_DECL_HIDDEN EventFilter : public QObject
public:
bool eventFilter(QObject *watched, QEvent *event)
{
Q_UNUSED(watched)
if (event->type() == QEvent::ToolTip) {
const auto pos = static_cast<QHelpEvent*>(event)->globalPos();
QMetaObject::invokeMethod(this, [this, pos] () {
updateToolTipPosition(pos);
}, Qt::QueuedConnection);
} else if (event->type() == QEvent::CursorChange) {
auto widget = qobject_cast<QWidget*>(watched);
if (widget) {
handleCursorChange(widget);
}
}
return false;
}
Expand Down Expand Up @@ -67,6 +71,18 @@ class Q_DECL_HIDDEN EventFilter : public QObject
}
}
}

void handleCursorChange(QWidget *widget)
{
if (!widget || !widget->window() || !widget->window()->windowHandle())
return;

auto windowHandle = widget->window()->windowHandle();
if (auto pluginPopup = Plugin::PluginPopup::getWithoutCreating(windowHandle)) {
Qt::CursorShape cursorShape = widget->cursor().shape();
Q_EMIT pluginPopup->requestSetCursor(static_cast<int>(cursorShape));
}
}
};
}

Expand Down
7 changes: 7 additions & 0 deletions src/protocol/plugin-manager-v1.xml
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,13 @@
<arg name="width" type="int"/>
<arg name="height" type="int"/>
</request>
<request name="set_cursor">
<description summary="request to change cursor shape">
This requests the compositor to change the cursor shape.
The cursor_shape follows Qt::CursorShape enum values.
</description>
<arg name="cursor_shape" type="int"/>
</request>
</interface>

<interface name="plugin" version="1">
Expand Down
1 change: 1 addition & 0 deletions src/tray-wayland-integration/plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,8 @@

void xChanged();
void yChanged();
void pluginPosChanged(const QPoint &point);

Check warning on line 155 in src/tray-wayland-integration/plugin.h

View workflow job for this annotation

GitHub Actions / cppcheck

Local variable 'pluginPosChanged' shadows outer function
void requestSetCursor(int cursorShape);

private:
explicit PluginPopup(QWindow* window);
Expand Down
4 changes: 4 additions & 0 deletions src/tray-wayland-integration/pluginsurface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,10 @@ PluginPopupSurface::PluginPopupSurface(PluginManagerIntegration *manager, QtWayl
connect(m_dirtyTimer, &QTimer::timeout, this, [this]{
set_position(m_popup->x(), m_popup->y());
});

connect(m_popup, &PluginPopup::requestSetCursor, this, [this](int cursorShape) {
set_cursor(cursorShape);
});
}

PluginPopupSurface::~PluginPopupSurface()
Expand Down
Loading