Skip to content

Commit edef78c

Browse files
committed
fix: after setting the cursor theme, it will not update in real-time.
Monitor the Gtk/CursorThemeName property and manually call changeCursor() to refresh the cursor when it changes pms: BUG-296269
1 parent ee7a8e3 commit edef78c

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

xcb/dplatformintegration.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1011,6 +1011,22 @@ static void startDrag(QXcbDrag *drag)
10111011
xcb_flush(drag->xcb_connection());
10121012
}
10131013

1014+
static void cursorThemePropertyChanged(xcb_connection_t *connection, const QByteArray &name, const QVariant &property, void *handle)
1015+
{
1016+
Q_UNUSED(connection);
1017+
Q_UNUSED(name);
1018+
Q_UNUSED(property);
1019+
Q_UNUSED(handle)
1020+
1021+
QMetaObject::invokeMethod(qApp, [](){
1022+
for (const auto window : qApp->allWindows()) {
1023+
auto cursor = window->cursor();
1024+
if (window->screen() && window->screen()->handle() && window->screen()->handle()->cursor())
1025+
overrideChangeCursor(window->screen()->handle()->cursor(), &cursor, window);
1026+
}
1027+
}, Qt::QueuedConnection);
1028+
}
1029+
10141030
void DPlatformIntegration::initialize()
10151031
{
10161032
// 由于Qt很多代码中写死了是xcb,所以只能伪装成是xcb
@@ -1131,6 +1147,9 @@ void DPlatformIntegration::initialize()
11311147
});
11321148
}
11331149
}
1150+
1151+
// Qt中同样监听了这个属性的变化,但是只刷新了光标上下文却没有更新当前窗口的光标,无法做到光标的实时变化,所以加了该逻辑额外处理
1152+
xSettings()->registerCallbackForProperty("Gtk/CursorThemeName", cursorThemePropertyChanged, nullptr);
11341153
}
11351154

11361155
#ifdef Q_OS_LINUX

0 commit comments

Comments
 (0)