-
Notifications
You must be signed in to change notification settings - Fork 21
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
libinput 1.23, Add accel config for pointer acceleration #72
base: master
Are you sure you want to change the base?
Conversation
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.
Thanks for working on this!
Unfortunately there are some issues with this implementation mostly regarding the lifetime of the AccelConfig
and the 1:1 copied implementation. But I would very much like to merge this, if you could take the time to tackle these issues!
Cargo.toml
Outdated
use_bindgen = ["input-sys/use_bindgen"] | ||
libinput_1_11 = ["input-sys/libinput_1_11"] | ||
libinput_1_14 = ["input-sys/libinput_1_14", "libinput_1_11"] | ||
libinput_1_15 = ["input-sys/libinput_1_15", "libinput_1_14"] | ||
libinput_1_19 = ["input-sys/libinput_1_19", "libinput_1_15"] | ||
libinput_1_21 = ["input-sys/libinput_1_21", "libinput_1_19"] | ||
libinput_1_26 = ["input-sys/libinput_1_26", "libinput_1_21"] |
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.
If this feature was added in 1.23 already, the feature should be named accordingly and the corresponding header file of it's tar-archive should be used for generating.
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.
Thanks for pointing this out. Are we implying we should have a 1.23 version here instead of the 1.26 version? I'm not 100% sure what this is pointing out as a feature. 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.
In general these features are meant to be activated for the minimum-version of libinput users of these bindings want to support. So if you care to enable 1_21 because you need some methods introduced with that version, 1.21 is the minimum libinput version on any target system your crate needs.
Which is why this should be libinput_1_23
, so that it signifies, that pointer acceleration profiles were added in that version and requiring these options, requires that version of libinput to be available.
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.
Removed libinput_1_26 and added libinput_1_23
src/accel_config.rs
Outdated
} | ||
|
||
/// Get the pointer for the acceleration config | ||
pub fn ptr(&self) -> *mut libinput_config_accel { |
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.
Please implement crate::AsRaw
instead of rolling your own ptr
-method.
src/accel_config.rs
Outdated
/// | ||
/// @warning Unlike other structs pointer acceleration configuration is | ||
/// considered transient and <b>not</b> refcounted. Calling | ||
/// libinput_config_accel_destroy() <b>will</b> destroy the configuration. |
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.
Looking at these copied docs, we need a Drop
implementation for AccelConfig
that calls libinput_config_accel_destroy
.
Also please reword the docs to not mention ref-counting or destroy calls, as this is handled transparently.
src/accel_config.rs
Outdated
/// configure the profile-specific acceleration properties. | ||
/// | ||
/// In this version of libinput, this pointer acceleration configuration | ||
/// only provides configuration for @ref LIBINPUT_CONFIG_ACCEL_PROFILE_CUSTOM. |
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.
Also please replace LIBINPUT_CONFIG_ACCEL_PROFILE_CUSTOM
with AccelProfile::Custom
and generate proper doc-links.
src/accel_config.rs
Outdated
/// @ref libinput_config_accel_set_points. | ||
/// | ||
/// Once set up, apply the configuration to a device using | ||
/// libinput_device_config_accel_apply(). Once applied, |
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.
Similarly please replace this with a link to Device::config_accel_apply
.
src/accel_config.rs
Outdated
/// only provides configuration for @ref LIBINPUT_CONFIG_ACCEL_PROFILE_CUSTOM. | ||
/// | ||
/// For @ref LIBINPUT_CONFIG_ACCEL_PROFILE_CUSTOM use | ||
/// @ref libinput_config_accel_set_points. |
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.
Similarly please replace this with a link to AccelConfig::set_points
.
src/accel_config.rs
Outdated
accel_type, | ||
step, | ||
npoints, | ||
points.clone().as_mut_ptr(), |
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.
We own points
, why do we clone
?
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.
Removed clone and set points as mut.
/// Acceleration types are categories of movement by a device that may have | ||
/// specific acceleration functions applied. A device always supports the | ||
/// @ref LIBINPUT_ACCEL_TYPE_MOTION type (for regular pointer motion). Other | ||
/// types (e.g. scrolling) may be added in the future. |
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.
Please cleanup these docs as well.
src/device.rs
Outdated
/// | ||
/// # Safety | ||
/// | ||
/// The accel config could become dereferenced |
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.
How could it be? During the call it will be valid. Since this method transfers ownership it should be destroyed after this call though. It might be better to accept a reference
here.
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 to a reference and removed the Safety.
Thanks for taking the time to review this code. I will make the marked improvements. I minimally made these changes and wasn't sure if they would be accepted. I can now work to make this acceptable for merging. Thanks. |
Is this ready for review? I'd like to see this merged (and am happy to do what I can to keep it going) |
I was wanting to play with pointer acceleration added in 1.23. I gen'd the latest version 1.26.1.
Add AccelProfile::Custom
Add AccelType
Add AccelConfig
The example I have been testing with:
Willing to make some updates of what may be better.
Thanks
Context