Skip to content

Commit fe7b51c

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 a858879 commit fe7b51c

4 files changed

Lines changed: 30 additions & 1 deletion

File tree

src/loader/widgetplugin.cpp

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,17 @@ 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+
// Handle cursor change for Wayland mode
44+
auto widget = qobject_cast<QWidget*>(watched);
45+
if (widget) {
46+
handleCursorChange(widget);
47+
}
4348
}
4449
return false;
4550
}
@@ -67,6 +72,18 @@ class Q_DECL_HIDDEN EventFilter : public QObject
6772
}
6873
}
6974
}
75+
76+
void handleCursorChange(QWidget *widget)
77+
{
78+
if (!widget || !widget->window() || !widget->window()->windowHandle())
79+
return;
80+
81+
auto windowHandle = widget->window()->windowHandle();
82+
if (auto pluginPopup = Plugin::PluginPopup::getWithoutCreating(windowHandle)) {
83+
Qt::CursorShape cursorShape = widget->cursor().shape();
84+
Q_EMIT pluginPopup->requestSetCursor(static_cast<int>(cursorShape));
85+
}
86+
}
7087
};
7188
}
7289

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)