adjusting display positions on display config changes
Current status
After !4431 (merged), kwin has taken over the responsibility of storing and restoring output configs. The current config system stores "outputs" (physical displays identified by connector name and edid and such), and "setups" (positions and priorities of outputs when multiple outputs are present).
The problem
Users may change the configs of display A (e.g., scale and orientation) when display B is unplugged. When display B is plugged in again, the stored "setup" of display A + display B is blindly applied, which can lead to non-nonsensical output configurations involving gaps or overlaps.
Currently, Output::adjustPositions
in kscreen/kded
deals with these issues.
(https://invent.kde.org/plasma/kscreen/-/blob/master/kded/output.cpp?ref_type=heads#L185)
Possible solutions
Save "setups" for each different output configuration
Make the setup depend on the scale and the orientation of the displays.
We already removed "Save settings for only this specific display arrangement" feature in KScreen
, since it was too buggy and nearly impossible to fix.
So bringing something similar back probably is not a good idea.
Output::adjustPositions
inside kwin
Duplicate the functionality of Having duplicate code that performs the same functionality is probably a bad idea.
Output::adjustPositions
in kscreen/kded
and call it within kwin
Export Right now this is the solution I am leaning towards. However, I would still need to figure out what is the best way to expose that method. If people are happy with this general approach I will go ahead and submit some MRs.