@@ -1064,13 +1064,35 @@ static void cursorThemePropertyChanged(xcb_connection_t *connection, const QByte
10641064 Q_UNUSED (property);
10651065 Q_UNUSED (handle)
10661066
1067- QMetaObject::invokeMethod (qApp, [](){
1068- for (const auto window : qApp->allWindows ()) {
1069- auto cursor = window->cursor ();
1070- if (window->screen () && window->screen ()->handle () && window->screen ()->handle ()->cursor ())
1071- overrideChangeCursor (window->screen ()->handle ()->cursor (), &cursor, window);
1067+ // TODO: https://qt-project.atlassian.net/browse/QTBUG-142329 这个BUG解决之后可将这里的代码删除
1068+ for (QScreen *screen : qApp->screens ()) {
1069+ if (screen && screen->handle () && screen->handle ()->cursor ()) {
1070+ QXcbCursor *xcb_cursor = static_cast <QXcbCursor *>(screen->handle ()->cursor ());
1071+
1072+ if (xcb_cursor == nullptr ) {
1073+ continue ;
1074+ }
1075+ xcb_cursor->m_cursorHash .clear ();
1076+
1077+ // source from: QXCBCursor::updateCursorContext()
1078+ if (xcb_cursor->m_cursorContext ) {
1079+ xcb_cursor_context_free (xcb_cursor->m_cursorContext );
1080+ }
1081+ xcb_cursor->m_cursorContext = nullptr ;
1082+ xcb_connection_t *conn = xcb_cursor->xcb_connection ();
1083+
1084+ if (xcb_cursor_context_new (conn, xcb_cursor->m_screen ->screen (), &xcb_cursor->m_cursorContext ) < 0 ) {
1085+ xcb_cursor->m_cursorContext = nullptr ;
1086+ }
1087+ }
1088+ }
1089+
1090+ for (const auto window : qApp->allWindows ()) {
1091+ auto cursor = window->cursor ();
1092+ if (window->screen () && window->screen ()->handle () && window->screen ()->handle ()->cursor ()) {
1093+ overrideChangeCursor (window->screen ()->handle ()->cursor (), &cursor, window);
10721094 }
1073- }, Qt::QueuedConnection);
1095+ }
10741096}
10751097
10761098void DPlatformIntegration::initialize ()
@@ -1196,6 +1218,7 @@ void DPlatformIntegration::initialize()
11961218
11971219 // Qt中同样监听了这个属性的变化,但是只刷新了光标上下文却没有更新当前窗口的光标,无法做到光标的实时变化,所以加了该逻辑额外处理
11981220 xSettings ()->registerCallbackForProperty (" Gtk/CursorThemeName" , cursorThemePropertyChanged, nullptr );
1221+ xSettings ()->registerCallbackForProperty (" Gtk/CursorThemeSize" , cursorThemePropertyChanged, nullptr );
11991222}
12001223
12011224#ifdef Q_OS_LINUX
0 commit comments