-
Notifications
You must be signed in to change notification settings - Fork 171
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
Improve geometry APIs, to be closer to euclid
#1621
base: master
Are you sure you want to change the base?
Conversation
ef1a272
to
771ba0b
Compare
I am not sure I agree with this, when we are just adding |
Matches definitions in `euclid`. This seems useful and is a pattern widely used in Smithay.
A couple patterns are used for this already. This method makes it consistent and a bit more concise. This seems to cover a lot of the uses of `Rectangle::from_loc_and_size`.
This new function is the same as `from_loc_and_size`, except it takes concrete types as arguments instead of `impl Into`. This matches `euclid::Rect`'s API, but it also seems a little better to have strong typing without implicit conversion like this. In a few cases it's not obvious that the argument is variable of tuple type, so there is an implied assertion that the coordinate space is right. The use of `#[deprecated]` makes this not entirely urgent for compositors, but uses of this should be updated to `::new`, or other functions like `from_size`.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1621 +/- ##
==========================================
+ Coverage 19.33% 19.34% +0.01%
==========================================
Files 171 171
Lines 28365 28363 -2
==========================================
+ Hits 5485 5488 +3
+ Misses 22880 22875 -5
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
I've added a Where possible it seems best to use high-level operations like that on these strongly-typed geometry types instead of calls to things like
Where we really want to get type safety is by using more coordinate spaces, distinguishing between points and vectors (it shouldn't be possible to add two "points" in the same space to get an element of that space.) And things like euclid::Translation2D. #1620 happens to be a good example of something we'd want to make statically impossible. If we want to move to If we don't move to Though if that change is too controversial I can drop 5471a59 from this PR. The other small additions here seem useful. |
I want to update #1136, make any needed improvements upstream to
euclid
, and get that merged. But it requires a lot of changes both in Smithay and compositors using it. Perhaps adding some APIs and uses of the#[deprecated]
attribute first could make that a little less painful to deal with.Even if Smithay didn't move to
euclid
, it would be worth borrowing some ideas to make geometry handling more strongly typed, as well as a couple API conveniences.