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
Geometry classes should support floating-point types #1829
Comments
1830: Send sub-pixel input events to Wayland clients r=AlanGriffiths a=wmww Fixes #1814, fixes #1828. This area of code will be a little nicer when #1829 is done, but I don't think we should block on that. As you can see we use the ugly and rather unsafe `std::pair<float, float>` types to represent sub-pixel positions, but the amount of code that has to handle this is not large. Another option would be to send the event all the way through until we hit the Wayland wrapper call. This would be a good idea, but it seems pointer events aren't mutable and generic events aren't queryable, so we'd have to do a bunch of messy casting and IMO it's not worth it. In the long run all this code will disappear once we address #1732 and make subsurfaces real input surfaces. Co-authored-by: William Wold <wm@wmww.sh> Co-authored-by: Alan Griffiths <alan@octopull.co.uk>
1830: Send sub-pixel input events to Wayland clients r=AlanGriffiths a=wmww Fixes #1814, fixes #1828. This area of code will be a little nicer when #1829 is done, but I don't think we should block on that. As you can see we use the ugly and rather unsafe `std::pair<float, float>` types to represent sub-pixel positions, but the amount of code that has to handle this is not large. Another option would be to send the event all the way through until we hit the Wayland wrapper call. This would be a good idea, but it seems pointer events aren't mutable and generic events aren't queryable, so we'd have to do a bunch of messy casting and IMO it's not worth it. In the long run all this code will disappear once we address #1732 and make subsurfaces real input surfaces. Co-authored-by: William Wold <wm@wmww.sh> Co-authored-by: Alan Griffiths <alan@octopull.co.uk> Co-authored-by: Michał Sawicz <michal.sawicz@canonical.com>
I have an idea for the right way to do this. I started working on it but it's a lot of work so I don't want to continue until I've gotten a green-light for the idea.
Compared to making entirely new classes for floating points, this would:
Unknowns:
|
No. For one thing type names are encoded in function signatures |
After discussion, we decided we might be able to make generic types work if we change our existing types to inherit from them. I will attempt this and put up a draft PR |
1858: Floating point geometry r=AlanGriffiths a=wmww Will address #1829 when complete. Adds a new `geometry::generic::Wrapper` class and changes the ABI-stable `IntWrapper` to inherit from it. Only minor issue is that to be generic, operations need to return `generic::Wrapper<Tag, int>` instead of `IntWrapper<Tag>`. The two can be implicitly converted between, but this can cause a problem in some cases. For example, if `std::max()` is called on an `IntWrapper` and a `generic::Wrapper`, it needs an explicit type to cast to. When we break ABI, I would like to drop `IntWrapper` and make `Width`, `Height`, `X`, etc typedefs of the `generic::Type<int>`. This would fix those problems. Co-authored-by: William Wold <wm@wmww.sh>
I think this was addressed by #1858 |
Rather than re-writing floating-point variants of everything, I propose we change the current types to templates and make specializations of them.
PointI
would be an alias forPoint<int>
and an equivalent of the currentPoint
,DisplacementF
would be an alias ofDisplacement<float>
, etc. This would give our input handling code the same level of type safety as the rest of Mir.The text was updated successfully, but these errors were encountered: