tray:unix: Rework the tray structures to have an 'internal' member (Follow-up for #15364)#15368
Open
sulix wants to merge 1 commit intolibsdl-org:mainfrom
Open
tray:unix: Rework the tray structures to have an 'internal' member (Follow-up for #15364)#15368sulix wants to merge 1 commit intolibsdl-org:mainfrom
sulix wants to merge 1 commit intolibsdl-org:mainfrom
Conversation
Currently, the SDL_Tray* structs in the unix backend are subclassed for each implementation (only dbus so far). This means that the DBus-specific members are in their own structs (SDL_Tray*DBus), which all are required to have the corresponding 'parent' struct as their first member, so that they can be cast easily and used in the more generic code. However, other SDL systems which have pluggable backends work the other way around: the 'generic' struct has an 'internal' member, which individual drivers can use to store a pointer to any internal state. This is a bit simpler to wrap one's head around -- particularly because it's consistent -- but does typically involve more memory allocations. Change the unix/DBus tray implementations to use an 'internal' pointer to match other subsystems.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Okay, this is the follow-up to #15364 which makes the various generic structures have an
internalpointer, rather than the DBus-specific ones having aclass_parentstructure and being cast to their generic equivalents all the time. I'm not completely convinced this is actually an improvement — or even 100% convinced it's correct, as there were a lot of subtle casts througout the original — but it passes a few tests withtesttray, as well as with my own projects. Most annoyingly, it does double the number of allocations needed, as the generic and backend-specific structs are now allocated separately. (We could try to combine the allocations, but the extra ugliness is probably not worth the gain.Thoughts?
Currently, the
SDL_Tray* structs in the unix backend are subclassed for each implementation (only dbus so far). This means that the DBus-specific members are in their own structs (SDL_Tray*DBus), which all are required to have the corresponding 'parent' struct as their first member, so that they can be cast easily and used in the more generic code.However, other SDL systems which have pluggable backends work the other way around: the 'generic' struct has an 'internal' member, which individual drivers can use to store a pointer to any internal state. This is a bit simpler to wrap one's head around -- particularly because it's consistent -- but does typically involve more memory allocations.
Change the unix/DBus tray implementations to use an 'internal' pointer to match other subsystems.