diff --git a/xcb/dplatformintegration.cpp b/xcb/dplatformintegration.cpp index c3883f7b..92091120 100644 --- a/xcb/dplatformintegration.cpp +++ b/xcb/dplatformintegration.cpp @@ -1011,6 +1011,22 @@ static void startDrag(QXcbDrag *drag) xcb_flush(drag->xcb_connection()); } +static void cursorThemePropertyChanged(xcb_connection_t *connection, const QByteArray &name, const QVariant &property, void *handle) +{ + Q_UNUSED(connection); + Q_UNUSED(name); + Q_UNUSED(property); + Q_UNUSED(handle) + + QMetaObject::invokeMethod(qApp, [](){ + for (const auto window : qApp->allWindows()) { + auto cursor = window->cursor(); + if (window->screen() && window->screen()->handle() && window->screen()->handle()->cursor()) + overrideChangeCursor(window->screen()->handle()->cursor(), &cursor, window); + } + }, Qt::QueuedConnection); +} + void DPlatformIntegration::initialize() { // 由于Qt很多代码中写死了是xcb,所以只能伪装成是xcb @@ -1131,6 +1147,8 @@ void DPlatformIntegration::initialize() }); } } + + xSettings()->registerCallbackForProperty("Gtk/CursorThemeName", cursorThemePropertyChanged, nullptr); } #ifdef Q_OS_LINUX