Prototype a Dispatch2/GlobalDispatch2 trait to dispatch delegate macros to oblivion#2008
Prototype a Dispatch2/GlobalDispatch2 trait to dispatch delegate macros to oblivion#2008Drakulix merged 2 commits intoSmithay:masterfrom
Dispatch2/GlobalDispatch2 trait to dispatch delegate macros to oblivion#2008Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #2008 +/- ##
==========================================
- Coverage 18.73% 18.45% -0.28%
==========================================
Files 182 183 +1
Lines 28934 29194 +260
==========================================
- Hits 5421 5388 -33
- Misses 23513 23806 +293
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This makes the documentation more consistent with other protocols, and means there's a test for the protocol that doesn't otherwise exists since `anvil` doesn't use it.
8e67f07 to
1dc32a6
Compare
|
CI passes, this works with cosmic-comp, and #2017 shows it also works with an updated So I think this should be good to merge. |
Dispatch2/GlobalDispatch2 trait to dispatch delegate macros to oblivionDispatch2/GlobalDispatch2 trait to dispatch delegate macros to oblivion
Drakulix
left a comment
There was a problem hiding this comment.
Looks great. I'd say we shouldn't let this bit-rot as it is an improvement all around. But this needs a CHANGELOG entry, no? 😅
A single `delegate_dispatch2!` replaces all other delegate macros. When wayland-rs updates the definition of `Dispatch`, this macro will be unnecessary, and `Dispatch` type bounds should become inferable by the type system. `Dispatch` is now implemented for the user-data type, so `smithay` is able to provide blanket implementations as long as the user data is a type owned by `smithay`. Therefore, `GlobalData` replaces `()` as a user data (`smithay-client-toolkit` already did this), and udata that is simply a type like `Weak<WlSurface>` is wrapped.
|
Amended with a line in the changelog. This is pretty easy to adapt to, though when wayland-rs releases that will be more involved. May want to revive https://github.com/Smithay/smithay.github.io with an announcement of the new release. |
Based on Smithay#2008. Beyond what that PR does, this also allows the availablility of `Dispatch` implementations to be inferred usually by just the `*Handler` trait for the protocol. Though it looks like Rust still can't infer bounds like `<D as SeatHandler>::KeyboardFocus: WaylandFocus` from placing them on the trait (*eventually* it should?). Uses Smithay/wayland-rs#902.
Description
See Smithay/client-toolkit#519 for a bit more context.
At present, this replaces
delegate_compositor!with a single genericdelegate_dispatch2!macro. It should be possible to update all the dispatch implementations this way.If there are no issues with this, since
smithayis less strict about API breaks thanwayland-rs, we could merge this insmithay(compositors mostly should just need to adddelegate_dispatch2!and remove the other macro calls). Then the next wayland-rs version (Smithay/wayland-rs#900) can incorporate the updated version of the trait. At which point the macro is no longer necessary, and more type bounds can be remove as implied.Checklist