Skip to content

Commit

Permalink
fix: after setting the cursor theme, it will not update in real-time.
Browse files Browse the repository at this point in the history
Monitor the Gtk/CursorThemeName property and manually call changeCursor() to refresh the cursor when it changes

pms: BUG-296269
  • Loading branch information
mhduiy committed Jan 7, 2025
1 parent ee7a8e3 commit f02e6f9
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions xcb/dplatformintegration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -1131,6 +1147,8 @@ void DPlatformIntegration::initialize()
});
}
}

xSettings()->registerCallbackForProperty("Gtk/CursorThemeName", cursorThemePropertyChanged, nullptr);
}

#ifdef Q_OS_LINUX
Expand Down

0 comments on commit f02e6f9

Please sign in to comment.