Skip to content
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

fdo: Factor out switcheroos for the different Wayland shell protocols #336

Open
aperezdc opened this issue Jul 27, 2021 · 0 comments
Open
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@aperezdc
Copy link
Member

Currently in the FDO Wayland platform plug-in we have code that checks which shell protocol is being used, every time that is needed. Like this:

if (wl_data.xdg_shell) {
    // do something when we use the xdg_wm_base protocol
} else if (wl_data.fshell) {
    // do something else when using the zwp_fullscreen_shell_v1 protocol
}  else if (wl_data.shell) {
    // and something different for the wl_shell_protocol
} else {
    g_assert_not_reached();
}

It would be better to avoid duplicating this logic everywhere, and instead:

  • Have a list of functions for each operation used from the different protocols (initialize surface, enter fullscreen, exit fullscreen, deinitialize surface, set title, etc.)
    • This can a struct shell_operations with a function pointer for each operation.
    • For each shell protocol, have a static const instance of the struct with the function pointers set to the corresponding functions.
  • Have the notion of “current shell protocol being used”.
    • This can be a pointer to one of the struct shell_operations, its value determined at runtime depending on which protocol(s) the Wayland compositor supports.
  • Instead of Wayland protocol functions directly, do the calls through the struct with callbacks pointed to as “current shell protocol”.
@aperezdc aperezdc added the enhancement New feature or request label Jul 27, 2021
@Cwiiis Cwiiis added the good first issue Good for newcomers label Aug 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants