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

Feature Request: Get Cursor Icon Size #3788

Open
futile opened this issue Jul 10, 2024 · 8 comments
Open

Feature Request: Get Cursor Icon Size #3788

futile opened this issue Jul 10, 2024 · 8 comments
Labels
DS - windows S - enhancement Wouldn't this be the coolest?

Comments

@futile
Copy link

futile commented Jul 10, 2024

Description

Hi,

I have a larger-than-usual cursor size, which causes tooltips to look like this:

image

I.e., the mouse cursor icon covers part of the tooltip.

What I would like is a way to get the dimensions of the current cursor icon, so that I can adjust the tooltip's position.

I looked around a bit, and found #3306, which is about custom cursors, but it doesn't deal with cursor icon size.

For Windows, I found this (old, but might still work) post where someone figured out how to retrieve the cursor icon size:
https://forums.codeguru.com/showthread.php?449040-get-the-system-current-cursor-size&s=6da505d928b0363ffa51abafcdaefd0e&p=1757676#post1757676

I guess this is annoying to implement? 🙈 Thanks for taking a look already! :)

Relevant platforms

Windows, macOS, Wayland, X11, Web

@madsmtm
Copy link
Member

madsmtm commented Jul 11, 2024

Hmm, on macOS / AppKit, I don't think you can change the size of the cursor programmatically, and I also don't know of a way to query the size of it? This may not be information that's available on Wayland either.

There is the concept of a "cursor hotspot" though (see the docs), I think that's available on some of the other platforms too, and will probably influence any calculation you would make here?

(I will note that another solution to this problem would be to make your "attack" button larger).

@daxpedda
Copy link
Member

AFAIK cursor hotspot is available on all platforms.

I'm quite sure this is not possible to implement on Web.

@daxpedda daxpedda removed the DS - web label Jul 11, 2024
@futile
Copy link
Author

futile commented Jul 11, 2024

Thanks for taking a look at this issue!

(I will note that another solution to this problem would be to make your "attack" button larger).

Kind of, in this example I actually created a tooltip at the cursor position, because I wanted it to follow the cursor around. But yeah, if the tooltip was on the button, that would work.

Actually, I solved it by just moving the tooltip to the right of the button, which looks fine in my case (so very similar to what you proposed):

image

However, this is actually an issue in a lot of applications, e.g., in browsers:

image

Which is why I'm kind of happy if it receives some attention :)

Edit: Other people run into this as well, e.g. (sorry for twitter link): https://x.com/jacobmparis/status/1715031810609185249/

@kchibisov
Copy link
Member

You can not use hotspot alone for that because you don't know the shape of the cursor. hotspot also solves literally nothing because it determines the top-left corner of the cursor icon relative to the pointer location, so this information can not solve the issue, because it shows the offset, and offset could be zero regardless of the size/shape of the cursor icon.

However, if you have both size and hotspot you can approximate the area which will be obscured, but you need both of them at the same time.

On Wayland neither are available for example, on macOS it's just hotspot. On X11 I'm pretty sure you can not do that unless somehow figure out what is actually used right now, but I'm pretty sure you can not do that, it's not reliable at all.

What I'd say that systems compositor should figure this stuff out, since they have all the information available in the end of the day.

We could still probably add a best effort API, but it'll be really rare to have both hotspot and cursor icon size at the same time available, so the usefulness of such API is questionably since you need both.

@kchibisov
Copy link
Member

I've kept only windows since it's likely old enough to have some hacks in place or the API generally stable enough for these hacks to work.

Also, if you set a custom cursor you have all the sizes/hotspot informations available, so it's not an issue either.

@daxpedda
Copy link
Member

Just stumbled on this for MacOS:
https://source.chromium.org/chromium/chromium/src/+/25cbdb930951c1b8b7863351c45c340fcc95fcc4:ui/base/cocoa/cursor_utils.mm;l=275-285;bpv=0;bpt=0

Basically there is a way to get the accessibility setting that determines cursor size, that way the native cursor size might be calculated. This is probably not really viable, but just leaving that here.

@notgull
Copy link
Member

notgull commented Jul 21, 2024

As far as I can tell there aren't any APIs in any eminent GUI frameworks that expose this functionality. I'm not even sure what such an API would look like.

@futile
Copy link
Author

futile commented Jul 22, 2024

As far as I can tell there aren't any APIs in any eminent GUI frameworks that expose this functionality. I'm not even sure what such an API would look like.

Yeah, the problem is really prevalent in basically all applications/OSs when increasing the cursor size (i.e., cursor will start noticeably overlapping tooltips). So I'm not really surprised that other GUI frameworks don't support it either 🙈

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
DS - windows S - enhancement Wouldn't this be the coolest?
Development

No branches or pull requests

5 participants