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
Allow setting cursors with colors on Linux #1693
Comments
FYI I'm keen to look into providing an implementation for this, if no one is already working on it. |
Would be awesome if you could write an implementation. I'm not aware of anyone working on one right now. Keep in mind that the linked code is licensed under GPL and as such incompatible with zlib, but it's a good way to see an example of the API usage. 😉 |
@eXpl0it3r Ok great! I see the original implementation is from @binary1248 and @fundies. Asking them: is there any particular reason why Linux only got the monochrome implementation? Or was it just a practical decision to get the feature merged in quickly? |
That was way easier than I expected. I've opened a PR: #1694 |
To be honest, I wasn't even aware of this limitation. When I initially wrote the XCB implementation many years ago it supported BGRA images from the start. During the refactor in f65459d and 34ea68b, the implementation was moved to where it lives now, however the new implementation only supported monochrome cursors. Since @mantognini wrote the new implementation, only he will be able to answer the question. |
That wasn't yesterday, so my memory is a bit fuzzy... It was one of the first and rare time I had to implement something for Linux and the documentation I had mentioned that only monochrome was supported (ref). I guess for a first implementation it was agreed to be fine and peer review failed to show the loss of functionality. Glad to see this being addressed! :) |
Ok, glad to hear there weren't major problems that were blocking this :) While testing, I also realized the monochrome implementation is broken if the input image has non-power-of-two dimensions (I assume power-of-two images were used for testing, as these indeed worked fine). I've added the fix to the PR linked above. |
Implemented with #1694 |
Subject of the issue
SFML 2.5 added the Cursor class to allow changing the system cursor to an arbitrary bitmap using
sf::Cursor::loadFromPixels()
. On Linux, the implementation with X11 only supports "monochrome" cursors (black, white, or transparent pixels). This should be improved to support full ARGB, which is possible with X11. See reference implementation in GDK which supports both methods: http://web.mit.edu/ghudson/dev/nokrb/third/gtk2/gdk/x11/gdkcursor-x11.cThe monochrome implementation seems available on all/most platforms, but the ARGB implementation is not. I suspect, however, that most desktop distributions do support it.
Your environment
Steps to reproduce
Use
sf::Cursor::loadFromPixels()
on a Linux platform, with an input image that contains color.Expected behavior
Color is displayed correctly.
Actual behavior
Only monochrome output.
The text was updated successfully, but these errors were encountered: