-
Notifications
You must be signed in to change notification settings - Fork 123
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
feat: load cursor from data #680
Conversation
48331ef
to
1bf7660
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #680 +/- ##
==========================================
- Coverage 76.16% 72.68% -3.49%
==========================================
Files 45 48 +3
Lines 8153 7879 -274
==========================================
- Hits 6210 5727 -483
- Misses 1943 2152 +209
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
Thanks, that is interesting, however I'm not sure this design is the whole way we want to go. As I understand, the goal is to allow an app to provide fallback cursor images by itself in case the system theme does not provide all the ones it needs. The method you introduce directly creates a I think a better approach would be to introduce a proper mechanism by which the user of With such a fallback mechanism, later use of the What do you think of this, would that cover your needs? |
1bf7660
to
ce0c66b
Compare
Ok, I have made change. I also think that is bad.. so I am also thinking a better way.. |
bf1e0b9
to
610e93a
Compare
wayland-cursor/src/lib.rs
Outdated
pub fn get_cursor_with_default_data<F>(&mut self, name: &str, fallback: F) -> Option<&Cursor> | ||
where |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was rather thinking of defining the fallback closure one and for all as a standalone method of CursorTheme
, so that the rest of the API does not need to change at all.
Or is having an independent closure for each time you retrieve the cursor, with all that error-processing machinery something that you need for your uses?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Emm, what do you mean , make the function out of CursorTheme? I am a little difficult to understand.. sorry
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My idea was to add to CursorTheme
a method like this:
pub fn set_fallback(&mut self, fb: impl FnMut(&str) -> Cow<'static, [u8]>) { /* ... */ }
that stores a fallback closure inside the CursorTheme
, that would then be used internally by get_cursor()
if the system theme does not provide the requested cursor.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ha, I see
e763992
to
7b16293
Compare
Hi gentle ping: @elinorbgr Can we get a review on this? 😄 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the long time, this kinda slipped outside of my radar...
LGTM overall, but:
- the
Fallback
function should take a size as argument in addition to the cursor name, like theload_cursor
, making it possible to have multiple sizes for the fallback cursor if desired - Could you expand the documentation of
set_fallback()
to make it clearer what that callback is supposed to do, and how it's meant to be used ?
Ok, is that ok? I have pushed another commit |
done @elinorbgr |
I want to add a function to load cursor from data
Co-authored-by: Elinor B. <[email protected]>
2f1cc86
to
828c219
Compare
828c219
to
85585de
Compare
/// # Ok(theme) | ||
/// # } | ||
/// ``` | ||
pub fn set_callback<F>(&mut self, fallback: F) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While patching up the docs, is it intentional that this is called set_callback()
and not set_fallback()
(where the fallback is a callback that provides a fallback value when called)?
This function name and docs exclusively speak of a callback, but the get_cursor()
function "referencing it" exclusively speaks of fallback, which is confusing on the user end.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh.. it is a mistake. can you make a pr for me? thanks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you do it? I don't know what name you want to make this into.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
set_fallback
, it was the author suggested. but then it become a mistake
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Decodetalkers done in #723!
I want to add a way to load cursor from raw data