This is a preparatory step to add signals later for watching file changes.
- Group Reviewers
- R104:e5abdd26fd27: refactor: let Control be a QObject
Tested in Wayland session.
It's not for the full output configuration but only certain settings communicated from KScreen KCM to its daemon and which are not communicated through KWayland / XCB. For now I do/plan it for:
- Output retention
- If the refresh rate is automatically chosen or set by user explicitly.
- If the resolution is automatically chosen or set by user explicitly.
- If the rotation value is automatically chosen or set by user explicitly.
Example rotation: Default is "Automatic". That means if KScreen daemon detects orientation change via sensor it will send new configuration with updated rotation value for internal screen to KWin via KWayland. User now selects "Manual", then KScreen daemon ignores future orientation changes and not send new configuration via KWayland.
That being said thinking about it some more having a file watcher can lead to races for example in the following case:
- User changes auto rotation and resolution at the same time while device is held in a position unequal to current rotation
- KWin receives updated configuration (I)
- KScreen daemon receives auto rotation change through file watcher before resolution change through KCM -> KWin -> daemon
- KScreen sends updated configuration (II) with different rotation to KWin
- KWin sends new configuration (i) and afterwards receives configuration (II)
- KWin applies (II) and sends (II)
- KScreen receives first new configuration (I) and then (II)
In this case the resolution would not be set.
I'm unsure how to solve this best. I really don't want to send all auxiliary KScreen data through the KWin connection. Simple solution would be a small delay on control changes waiting for potential KWin changes. A likely better solution might be to introduce this libkscreen dbus out of process service found on RandR backend to the KWayland backend and then send auxiliary data through there but not to the compositor.
Caching it means we don't read in new retention value when it changed. So this patch without a file watcher yet or other system to communicate changes breaks the runtime. Solution without it: do not cache but in writeFile always create new object for now.