feat(kded): add a dbus method to lock current rotation
ClosedPublic

Authored by bshah on Mar 18 2020, 6:45 AM.

Details

Summary

This allows to lock the current rotation or temporary inhibit auto
rotation behavior on mobile

Test Plan

tested on mobile

Diff Detail

Repository
R104 KScreen
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
bshah created this revision.Mar 18 2020, 6:45 AM
Restricted Application added a project: Plasma. · View Herald TranscriptMar 18 2020, 6:45 AM
Restricted Application added a subscriber: plasma-devel. · View Herald Transcript
bshah requested review of this revision.Mar 18 2020, 6:45 AM
bshah updated this revision to Diff 77879.Mar 18 2020, 6:47 AM

update branch

bshah added a comment.Mar 18 2020, 6:48 AM

Maybe it would be sensible idea to instead connect/disconnect orientation sensor, and replace method name with "inhibitAutoRotation"?

So I think of two things to consider:

  • How is the overall interaction? Do we want something in line with other systems? Then we should have a lock/unlock rotation workflow where the current rotation orientation is made permanent until the icon is tapped again. Android and GNOME do it like this.
  • To make this consistent with the KScreen KCM the values should be written to the control file. I.e. your KScreenDaemon::setAutoRotation method should call into ControlConfig::setAutoRotate. Then it would just change for example when you lock the rotation from auto to manual and the current rotation value is set anyway.
bshah updated this revision to Diff 77896.Mar 18 2020, 11:00 AM
  • rename method to lock rotation
  • disconnect/connect orientation sensor when we want to lock/unlock rotation
bshah retitled this revision from [RFC] feat(kded): add a dbus method to toggle auto-rotation to feat(kded): add a dbus method to lock current rotation.Mar 18 2020, 11:01 AM
bshah edited the summary of this revision. (Show Details)
bshah edited the test plan for this revision. (Show Details)

This works as expected API wise and functionality wise, but internally control config is not written at all. :/

romangg requested changes to this revision.Mar 22 2020, 2:55 PM

Please call the functions AutoRotate. I failed to name it consistently in the code until now but let's go with AutoRotate from now on (and I will try to rename it where I accidentally said AutoRotation in some form). Reasons are that it's shorter and when I googled it I found only one technical document. Was for Android and called the feature that way.

kded/config.cpp
104

Do it like this:

void Config::setAutoRotation(bool value)
{
    for (KScreen::OutputPtr &output : m_data->outputs()) {
        if (output->type() != KScreen::Output::Type::Panel) {
            continue;
        }
        if(m_control->getAutoRotate(output) != value) {
            m_control->setAutoRotate(output, value);
        }
    }
    m_control->writeFile();
}
This revision now requires changes to proceed.Mar 22 2020, 2:55 PM
bshah updated this revision to Diff 78232.Mar 22 2020, 3:25 PM
  • rename methods to AutoRotate
  • write control file after change, thanks @romangg for suggestion
bshah marked an inline comment as done.Mar 22 2020, 3:26 PM
romangg accepted this revision.Mar 22 2020, 3:29 PM
romangg added inline comments.
kded/config.cpp
103

On push change to: if ( (whitespace)

This revision is now accepted and ready to land.Mar 22 2020, 3:29 PM
bshah updated this revision to Diff 78233.Mar 22 2020, 3:34 PM

whitespace

This revision was automatically updated to reflect the committed changes.

How does mobile retrieve the current lockAutoRotate value?

romangg added a comment.EditedMar 22 2020, 5:49 PM

How does mobile retrieve the current lockAutoRotate value?

It could read it from the config control file (in case of multi-screen which output though?). But it would be better to add another dbus method for that.