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

Prepare for multithreading #413

Merged
merged 2 commits into from
Apr 16, 2024
Merged

Prepare for multithreading #413

merged 2 commits into from
Apr 16, 2024

Conversation

Drakulix
Copy link
Member

As part of refactoring the KMS code to allow for mirroring outputs (and generally not matching a single output per surface), I wanted to introduce proper per-thread rendering per surface.

This obviously leads to complications regarding access of the necessary window management code from various threads. This is an attempt of solving this mess, by moving the Shell behind an RwLock. (The idea being that rendering and parts of the logic will only need to read the state and can do so in parallel, while modifications require an exclusive lock.)

This has had a couple of consequences, one being, that the seats are now part of the state, which makes access inside the window management code easier. (And earlier attempt trying to introduce the lock without this ran into some ugly issues.)

Additionally all wayland event-loop related structs had to be moved out of the Shell, which is especially annoying for the WorkspaceState and the XdgActivationState, which are frequently needed (and now passed into) the window management code.

One attempt at solving this (long-term) within wayland-rs and smithay is here: Smithay/smithay#1384

This would also allow to limit the access of grabs (or the SeatHandler in general) to Shell, which would mean we could move all the ptr.set_grab-code inside Shell and simply the logic quite a bit.

Anyway this is good enough for now and seems to be working just the same as before. As per usual I will drive this a couple of days to make sure everything is sound, but given the large diff this shouldn't sit around for long.

@Drakulix Drakulix force-pushed the shell-rwlock branch 2 times, most recently from ea32c40 to 2243ab9 Compare April 11, 2024 16:35
@Drakulix
Copy link
Member Author

Drakulix commented Apr 15, 2024

@ids1024 I did a last big rebase before merge and had to move some parts of the new touch code around. Could you give this a quick check to see if anything related to touch has regressed?

Copy link
Member

@ids1024 ids1024 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Touch grabs still seem to work.

Everything looks fine. Adding RwLocks and more clones is annoying, but I guess not avoidable if we want to have multiple threads. At least so far, it isn't too bad.

@Drakulix Drakulix merged commit 5d5a510 into master Apr 16, 2024
5 checks passed
@jackpot51 jackpot51 deleted the shell-rwlock branch April 26, 2024 19:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants