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

Custom cursors don't scale the same as ui elements, when monitors are scaled #97390

Open
tomfull123 opened this issue Sep 24, 2024 · 5 comments

Comments

@tomfull123
Copy link

tomfull123 commented Sep 24, 2024

Tested versions

  • Reproducible in: 4.0.stable, 4.3.stable, 4.4.dev2

System information

Godot v4.3.stable (77dcf97) - Windows 10.0.19045 - Vulkan (Forward+) - dedicated AMD Radeon RX 6650 XT (Advanced Micro Devices, Inc.; 32.0.11021.1011) - AMD Ryzen 5 2600X Six-Core Processor (12 Threads)

Issue description

When using monitors with different scaling, custom mouse cursor images aren't scaled.
UI elements work fine and will correctly update when changing a monitor's scaling percent.

Steps to reproduce

  1. Set a custom cursor, Input.set_custom_mouse_cursor(CUSTOM_CURSOR)
  2. Run project
  3. Move game window between monitors of different scales.
    3b. You can also change the scale of the monitor the game window is currently on.
    image

Minimal reproduction project (MRP)

Custom Cursor Scaling.zip

Cursor size should match the color rect.

Expected (100% scale):
image

Actual (150% scale):
image

@tomfull123 tomfull123 changed the title Custom cursors don't respect content_scale_size, when monitors are scaled Custom cursors don't scale the same as ui elements, when monitors are scaled Sep 24, 2024
@AThousandShips
Copy link
Member

This is likely an OS issue as custom cursors are rendered by the operating system, but there might be some way to configure this but otherwise this is not something that Godot controls

@lostminds
Copy link

Unfortunately this seems to be very cumbersome to implement on windows (see godotengine/godot-proposals#9262 for discussion) as it seems to require setting up specific windows multi-resolution cursor resources to get resolution-based versions. But I agree that the lack of resolution-based custom cursors support is a problem.

@tomfull123
Copy link
Author

tomfull123 commented Sep 25, 2024

Its also worth noting that the default cursor on windows does get scaled when you change the monitor's scaling.

@Calinou
Copy link
Member

Calinou commented Dec 6, 2024

What I would do to address this particular problem is to have Godot do an Image.resize() of the specified custom cursor image according to the OS' scale factor, regardless of the Godot project settings. To get a crisper appearance, nearest-neighbor scaling can be used for integer scale factors like 200%, or bilinear otherwise. (This is the same approach to scaling used by Windows for non-hiDPI compliant apps.)

However, you currently can't get the display scale factor on Windows or Linux (X11) due to godotengine/godot-proposals#2661.

@lostminds
Copy link

What I would do to address this particular problem is to have Godot do an Image.resize() of the specified custom cursor image according to the OS' scale factor, regardless of the Godot project settings.

Considering each cursor type will likely be static in most cases one alternative (previously discussed here) I'd favor is to add cursor setup as a new project settings tab, similar to Input mapping and autoloads. So for each project you could set up what custom images and settings you want to use for your cursors in the editor UI instead of in code. This would then both support adding multiple/high-resolution versions of the cursor images (typically only a 1x and a 2x version) and adding additional custom cursors in addition to the standard set. This would make it easier to set up cursors and have the benefit of the data being available at build time, so the engine could generate the needed resources or versions of the graphics at build time as required by windows, and do all the setup of any custom cursors so you don't need to do it in code. And then we could let the OS scale/pick which cursor resolution to use instead of trying to figure out when/how to scale it ourselves.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants