jbuchermn / newm

Wayland compositor
MIT License
958 stars 31 forks source link

When copying states, copy child {handle: state} dicts #142

Closed cben closed 1 year ago

cben commented 1 year ago

Previous code could create distinct WorkspaceState / LayoutState instances but share the underlying self._view_states / self._workspace_states dicts, which sounds buggy. E.g. a sequence like this:

ws_copy = ws_state.copy()
ws_copy.without_view_state(view)

would result in both ws_copy and ws_state losing same view key.

This PR does deep copying by giving the copies their own dicts.

BARELY TESTED: based on reading the code I believe this will be more correct, but I don't know any concrete scenario where I saw the WM misbehave and is now better.
All I can say is I've run with the new code for several minutes on 2 outputs, moved some windows around, and nothing obvious went wrong :-)

jbuchermn commented 1 year ago

Thanks for the PR, looks very sensible! :)

I want to do some testing as soon as I find time, and then I see no issue in merging this.