Skip to content

Commit f820b34

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 f820b34

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

Diff for: xcb/dplatformintegration.cpp

+17
Original file line numberDiff line numberDiff line change
@@ -1011,6 +1011,21 @@ 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+
VtableHook::callOriginalFun( window->screen()->handle()->cursor(), &QPlatformCursor::changeCursor, &cursor, window);
1025+
}
1026+
}, Qt::QueuedConnection);
1027+
}
1028+
10141029
void DPlatformIntegration::initialize()
10151030
{
10161031
// 由于Qt很多代码中写死了是xcb,所以只能伪装成是xcb
@@ -1131,6 +1146,8 @@ void DPlatformIntegration::initialize()
11311146
});
11321147
}
11331148
}
1149+
1150+
xSettings()->registerCallbackForProperty("Gtk/CursorThemeName", cursorThemePropertyChanged, nullptr);
11341151
}
11351152

11361153
#ifdef Q_OS_LINUX

0 commit comments

Comments
 (0)