-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Implement HiDPI cursors on Wayland #2709
Conversation
Also fixed a minor formatting issue.
I'll review when I have some of the fickle free time :) But right off the bat, what happens currently if loading a theme fails? To me the ideal behavior would be to fallback to the "hidpi" theme which IIRC is supposed to be always present, and if that also fails either to use a deault image or to abort with an error message. The last ight be problematic given that theme loading no longer happens at init time. Might be best to just store a default cursor image as a C header and use that as final fallback. |
So in regards to actual theme loading, that's handled by Sadly, the fallback for xcursor theme loading (EDIT: which would get used if the
|
I have merged, but I have a couple of questions.
|
Not to mention that the result of glfwloadcursor leaks in (2) above |
Also in setCursorImage cursorWayland never has its scale set to be window->wl.scale |
On further reading, it seems the result of wl_cursor_theme_get_cursor() does not need to be destroyed, so no leak there. |
Closing the PR as the commits have been merged outside of it, but will still watch for discussion. Thank you! As you've noted, With respect to scale changes, there is a brief period where the cursor pointers might dangle after the scale gets changed. However, With respect to the behavior of
I know I had that line at one point in the |
I have committed code to fix both the stack cursor animation issue and to change the cursor image immediately on scale change. Please test. |
The changed code appears to work! Cursors animate properly (including the arrow cursor in grabbed contexts), and scale changes work as before. ASAN builds don't report any new leaks related to the cursor code either. |
NOTE FOR PEOPLE FROM THE FUTURE: The commits for this PR have been merged outside of Github.
Free time is a fickle thing, isn't it?
These commits implement properly-scaled cursors on Wayland compositors with HiDPI support, addressing #2647/#2669. It implements a reference-counting manager for cursor themes, and changes some of the Wayland-specific platform code to use the new manager to acquire themes with the required pixel sizes.
I tried to be as surgical as possible in my implementation, which lead to a couple of questionable design choices that I'd prefer to be upfront about:
cursor
variable in_GLFWcursorWayland
have changed.NULL
no longer means thatbuffer
and its associated variables should be used instead. Instead, thescale
variable stores the relevant information (see the attached comment). I've tried to find the spots where this would be an issue, but won't claim it's impossible that I've overlooked something.setCursorImage
gets called. Loading can fail, andsetCursorImage
handles this quietly, which in the worst case may result in a null pointer dereference. If you folks have a preference on what way this failure should be handled instead, please let me know. As a tangent, settingXCURSOR_THEME
to an invalid value doesn't produce this issue for me (on sway).