Shrinking cursor leaves artifacts on KDE plasma because of wrong buffer surface.
This affects both GTK3 and GTK4. You can see this in Firefox following the steps to reproduce in https://bugs.kde.org/show_bug.cgi?id=477675 (I've worked around it in https://bugzilla.mozilla.org/show_bug.cgi?id=1867043).
This code, and the equivalent GTK3 code only damages the surface by the new width / height of the cursor, which means that if the compositor decides to reuse the previous buffer it'd leave artifacts. We'd need to invalidate using the max of the new and old sizes.