-
Notifications
You must be signed in to change notification settings - Fork 216
Add support for ext-foreign-toplevel-list-v1 #2833
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
Add support for ext-foreign-toplevel-list-v1 #2833
Conversation
ammen99
left a comment
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.
A few things I noticed
|
I am marking this as draft because I seem to encounter a crash when both plugins are active. Just closing a toplevel is sufficient to trigger this crash. I think there is some memory corruption that's taking place. I'll mark this as ready once I can fix the crash. @ammen99 Here is the ASAN output if it helps: |
|
@marcusbritanicus I think you are trying to reuse too much between the plugins, I meant simply the app-id generation function. If you truly want to reuse the rest as well, I think you will need to use something like the strategy pattern:
What you have currently definitely is not a good idea if you have both plugins enabled: they implement the same class in two different ways, that is generally not allowed and will lead to crashes. Considering that there is also ext-toplevel-management, I think it is worth thinking how it will play with these abstractions ... Maybe we need to split the big shared class into two parts, each responsible for either the listing or for the management. The wlr protocol implementation then would simply instantiate both shared classes, and the ext protocols will instantiate one of each. |
|
@ammen99 Thanks!! I was under the (incorrect) impression that since they're different plugins it will not matter. Anyways, I decided to make subclasses for wlr and ext plugins. All the junk values I was getting in the previous tests are now gone. I have tested for both ext-foreign-toplevel-list and wlr-foreign-toplevel-management protocols. Both work seamlessly and no crashes. Please have a look and tell me if is what you meant. |
|
@ammen99 Incorporated all your suggestions. They were all murmurs from the old code. I have also rebased - I think I have done it properly. Please do check and tell me if everything is proper. |
|
Something seems to have gone wrong in the rebase, github reports many more changes in this PR than actually intended .. |
0091baf to
4835cfb
Compare
|
@ammen99 I force-pushed the changes on top the latest master. I think now everything should be proper. |
| toplevel_send_state(); | ||
| }; | ||
|
|
||
| wf::wl_listener_wrapper toplevel_handle_v1_maximize_request; |
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 think that just like the void *handle field, these belong in the concrete implementations, as they are not used in the base class at all. I suppose we could also drop the function for initializing them from the interface.
Rationale: I get what you like with the current implementation, it seems that we share some code and code structure. But in reality I feel that by adding these abstractions here, we are simply removing 'duplicate' code by adding complex abstractions which are not 'natural' and make the code hard to read (to understand what is going on you have to go back and forth between the base and the derived classes).
A bit late, but if you are really keen on perfecting this, I would even suggest using the strategy design pattern. As people say, 'prefer composition over inheritance'. Have the base class which connects to signals, then pass a pointer to an interface implementation in the constructor. The interface would contain just the methods that are to be overridden (send_initial_state, toplevel_send_state, etc.). That would be best from a design perspective, but as we have been going back and forth I would also be ok with the current state, just move the listener_wrappers and their initialization functions to the derived classes.
@ammen99 I did an initial test of this plugin. I am able to list the toplevels, and get their titles and app-ids, which is what this is supposed to do. Please let me know if there are any changes required.