Bug 488764

Summary: Auto-rotate settings don't appear in KCM until leaving KCM and returning to it once
Product: [Applications] systemsettings Reporter: Nate Graham <nate>
Component: kcm_kscreenAssignee: kscreen-bugs-null <kscreen-bugs-null>
Status: RESOLVED FIXED    
Severity: normal CC: kde, notmart, plasma-bugs, qydwhotmail, sitter
Priority: NOR Keywords: regression
Version: 5.93.0   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed In: 6.1.4
Sentry Crash Report:
Attachments: Blind patch

Description Nate Graham 2024-06-19 23:30:17 UTC
Git master everything, Qt 6.7.1, Kernel 6.8.9.


When I open the KCM for the first time after a reboot, the auto-rotate controls are all missing. When I flip my laptop's screen around to enter tablet mode, the controls appear.

This is governed by the following visibility condition in https://invent.kde.org/plasma/kscreen/-/blob/master/kcm/ui/Orientation.qml?ref_type=heads#L23:

visible: kcm.autoRotationSupported && kcm.orientationSensorAvailable

I did a bit of testing, and what happens is that the value of kcm.orientationSensorAvailable doesn't become true until I flip around my laptop's lid to enter Tablet Mode.

Maybe entering tablet mode for the first time initializes the orientation sensor or something?
Comment 1 Fushan Wen 2024-06-20 01:07:11 UTC
Can reproduce. No wonder I don't see the option.
Comment 2 Harald Sitter 2024-06-21 14:35:42 UTC
what I'm seeing in busctl on the first run is that we `Get` the `AccelerometerOrientation` property. that returns `undefined`. after it returns, the service issues a `PropertiesChanged`  on that property with `normal` (we probably fail to act on that correctly).

on subsequent runs the property is already in the service-side cache and the `Get` returns `normal` instead of `undefined` 

i.e. the reason it works on subsequent runs is because the service already has the property cached and returns its value immediately instead of via a changed signal
Comment 3 David Redondo 2024-06-28 11:26:06 UTC
Created attachment 171126 [details]
Blind patch

Attached a blind patch, as I dont have the hardware to test this.
Comment 4 Marco Martin 2024-06-28 11:59:25 UTC
(In reply to David Redondo from comment #3)
> Created attachment 171126 [details]
> Blind patch
> 
> Attached a blind patch, as I dont have the hardware to test this.

Can you do a MR? I can test it
Comment 5 Bug Janitor Service 2024-08-05 14:42:42 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/kscreen/-/merge_requests/320
Comment 6 Marco Martin 2024-08-05 14:48:43 UTC
Git commit 7723a604662c83f10e3db90c4130b2fd3b461c82 by Marco Martin.
Committed on 05/08/2024 at 14:48.
Pushed by mart into branch 'master'.

Emit OrientationSensor::availableChanged() when needed

when we get the signal from QtSensors that the rotation sensor
became available, forward the signal so that the QML part can show the
autorotation checkbox

M  +1    -0    common/orientation_sensor.cpp

https://invent.kde.org/plasma/kscreen/-/commit/7723a604662c83f10e3db90c4130b2fd3b461c82
Comment 7 Marco Martin 2024-08-05 14:51:26 UTC
Git commit 779c1f56d363f5f8afe7d71def5cd2d5699f8347 by Marco Martin.
Committed on 05/08/2024 at 14:49.
Pushed by mart into branch 'Plasma/6.1'.

Emit OrientationSensor::availableChanged() when needed

when we get the signal from QtSensors that the rotation sensor
became available, forward the signal so that the QML part can show the
autorotation checkbox


(cherry picked from commit 7723a604662c83f10e3db90c4130b2fd3b461c82)

bddbbfc6 Emit availableChanged() when needed

Co-authored-by: Marco Martin <notmart@gmail.com>

M  +1    -0    common/orientation_sensor.cpp

https://invent.kde.org/plasma/kscreen/-/commit/779c1f56d363f5f8afe7d71def5cd2d5699f8347