Skip to content

Commit ceb6fcf

Browse files
committed
feat: Add support for modifying the plugin popup cursor shape via the protocol.
add support in plugin-manager-v1.xml Log: Add support for modifying the plugin popup cursor shape via the protocol.
1 parent 9b025ed commit ceb6fcf

4 files changed

Lines changed: 29 additions & 1 deletion

File tree

src/loader/widgetplugin.cpp

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,16 @@ class Q_DECL_HIDDEN EventFilter : public QObject
3434
public:
3535
bool eventFilter(QObject *watched, QEvent *event)
3636
{
37-
Q_UNUSED(watched)
3837
if (event->type() == QEvent::ToolTip) {
3938
const auto pos = static_cast<QHelpEvent*>(event)->globalPos();
4039
QMetaObject::invokeMethod(this, [this, pos] () {
4140
updateToolTipPosition(pos);
4241
}, Qt::QueuedConnection);
42+
} else if (event->type() == QEvent::CursorChange) {
43+
auto widget = qobject_cast<QWidget*>(watched);
44+
if (widget) {
45+
handleCursorChange(widget);
46+
}
4347
}
4448
return false;
4549
}
@@ -67,6 +71,18 @@ class Q_DECL_HIDDEN EventFilter : public QObject
6771
}
6872
}
6973
}
74+
75+
void handleCursorChange(QWidget *widget)
76+
{
77+
if (!widget || !widget->window() || !widget->window()->windowHandle())
78+
return;
79+
80+
auto windowHandle = widget->window()->windowHandle();
81+
if (auto pluginPopup = Plugin::PluginPopup::getWithoutCreating(windowHandle)) {
82+
Qt::CursorShape cursorShape = widget->cursor().shape();
83+
Q_EMIT pluginPopup->requestSetCursor(static_cast<int>(cursorShape));
84+
}
85+
}
7086
};
7187
}
7288

src/protocol/plugin-manager-v1.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,13 @@
139139
<arg name="width" type="int"/>
140140
<arg name="height" type="int"/>
141141
</request>
142+
<request name="set_cursor">
143+
<description summary="request to change cursor shape">
144+
This requests the compositor to change the cursor shape.
145+
The cursor_shape follows Qt::CursorShape enum values.
146+
</description>
147+
<arg name="cursor_shape" type="int"/>
148+
</request>
142149
</interface>
143150

144151
<interface name="plugin" version="1">

src/tray-wayland-integration/plugin.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ class PluginPopup : public QObject
153153
void xChanged();
154154
void yChanged();
155155
void pluginPosChanged(const QPoint &point);
156+
void requestSetCursor(int cursorShape);
156157

157158
private:
158159
explicit PluginPopup(QWindow* window);

src/tray-wayland-integration/pluginsurface.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,10 @@ PluginPopupSurface::PluginPopupSurface(PluginManagerIntegration *manager, QtWayl
119119
connect(m_dirtyTimer, &QTimer::timeout, this, [this]{
120120
set_position(m_popup->x(), m_popup->y());
121121
});
122+
123+
connect(m_popup, &PluginPopup::requestSetCursor, this, [this](int cursorShape) {
124+
set_cursor(cursorShape);
125+
});
122126
}
123127

124128
PluginPopupSurface::~PluginPopupSurface()

0 commit comments

Comments
 (0)