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

Some small cursor code cleanups #940

Merged
merged 2 commits into from
Aug 17, 2024
Merged

Some small cursor code cleanups #940

merged 2 commits into from
Aug 17, 2024

Conversation

psychon
Copy link
Owner

@psychon psychon commented Aug 17, 2024

Two commits here. The later is just a small refactoring that does not really do anything, but might be nice anyway.

The first one fixes a resource leak where a font was not getting closed again. I think my fix actually simplifies the code a bit.

I tested this by hardcoding a "core" cursor and changing simple_window to use the boat cursor. No idea what I am looking at, but it's definitely not my default cursor. This also looks fine in xtrace, so this still seems to work.

The struct x11rb::cursor::Handle contained a cursor_font resource. This
resource was never freed, so basically leaked. It's "just a font" and it
is unlikely to cause a problem, but I want to deal with it anyway.

One option would be to add a Drop implementation, but that would make
everything more complicated since the Drop implementation would need
access to the X11 connection. So, this basically requires an API break.

In this commit, I go with the other option: Instead of keeping the core
font open all the time, it is now only opened when needed and then
immediately closed again.

Since this is dealing with a font leak already, I am also changing the
code from using a plain "Font" to the "FontWrapper" struct that cleans
up the font in its Drop implementation.

Signed-off-by: Uli Schlachter <[email protected]>
This should not have any externally visible effect, but I change some
manual resource management for a picture to use a PictureWrapper
instead, which frees things up in its Drop implementation.

Signed-off-by: Uli Schlachter <[email protected]>
@mergify mergify bot merged commit 5558a7f into master Aug 17, 2024
21 checks passed
@mergify mergify bot deleted the cursor-cleanup branch August 17, 2024 14:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants