Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wayland Cursor custom image doesn't update when using Image instead of Texture2D #101929

Closed
wakeofluna opened this issue Jan 22, 2025 · 3 comments · Fixed by #101987
Closed

Wayland Cursor custom image doesn't update when using Image instead of Texture2D #101929

wakeofluna opened this issue Jan 22, 2025 · 3 comments · Fixed by #101987

Comments

@wakeofluna
Copy link

wakeofluna commented Jan 22, 2025

Tested versions

System information

Linux Gentoo using Wayland

Issue description

When using the Wayland DisplayServer you can only update the custom mouse cursor once if you are using Image instead of Texture2D resources and the images have the same hotspot.

The function Input.set_custom_mouse_cursor claims that it is okay to use either an Image or a Texture2D as a custom cursor image. The caching code in DisplayServerWayland::cursor_set_custom_image checks for cursor reuse using "get_rid()" on the provided resource. Since an Image does not have a RID, any image will always enter the branch // We have a cached cursor. Nice..

Bug is visible since #96647 was fixed, although the underlying bug was already older than that.

Workarounds

  • Use Texture2D instead of image resources - may cause undesired overhead to convert back to image
  • Reset the cursor in between - may cause cursor flickering
  • Move the hotspot locations to force a cache miss - unwanted extra work to make images suitable with different hotspots

Steps to reproduce

  • Force editor and game to use the Wayland display server
  • Make sure the referenced img1 and img2 are imported as Image and not as Texture.
Input.set_custom_mouse_cursor(img1, Input.CURSOR_ARROW)
# Correctly shows img1 as the cursor
Input.set_custom_mouse_cursor(img2, Input.CURSOR_ARROW)
# Still shows img1 as the cursor

Minimal reproduction project (MRP)

wayland-cursor-reproducer.zip

@Riteo
Copy link
Contributor

Riteo commented Jan 24, 2025

Hi, thank you for you report and for the thorough analysis!

Since an Image does not have a RID

Shoot, I really had no idea. You just saved me from a lot of debugging :D

You see, this Image thing is actually relatively new. For a long time the custom cursor method only supported Texture2D but then #88970 allowed images and this quirk slipped right through.

I'll fix this ASAP!

@Riteo Riteo moved this from For team assessment to In progress / Assigned in Platforms Issue Triage Jan 24, 2025
@Riteo Riteo self-assigned this Jan 24, 2025
@Riteo
Copy link
Contributor

Riteo commented Jan 24, 2025

PR #101987 is up! Could you please test it and confirm me that it fixes the issue?

@Riteo Riteo moved this from In progress / Assigned to Fix pending review in Platforms Issue Triage Jan 24, 2025
@wakeofluna
Copy link
Author

@Riteo Thank you for your swift response! Can confirm, while testing with build v4.4.beta.custom_build [c808756] from your PR that it solves my problem in both the reproducer and in my main project. I can now switch mouse cursors to my hearts content without converting them to texture2d first.

@akien-mga akien-mga added this to the 4.4 milestone Jan 30, 2025
@github-project-automation github-project-automation bot moved this from Fix pending review to Done in Platforms Issue Triage Jan 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

4 participants