Bug 454542

Summary: KDE-specific tablet mode features not being automatically activated on Lenovo ideapad anymore
Product: [Plasma] kwin Reporter: Etaash Mathamsetty <etaash.mathamsetty>
Component: wayland-genericAssignee: KWin default assignee <kwin-bugs-null>
Status: RESOLVED UPSTREAM    
Severity: normal CC: kde, nate, notmart
Priority: NOR Keywords: regression
Version First Reported In: 5.24.90   
Target Milestone: ---   
Platform: Arch Linux   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description Etaash Mathamsetty 2022-05-28 20:47:22 UTC
latest packages on kde-unstable 
this is a regression from plasma 5.24.5
basically, in 5.24.5, KDE would detect I am in tablet mode by allowing auto rotate and other tablet mode features.
plasma 5.24.90 does not do this. 5.24.90 also doesn't increase spacing between items when tablet mode is activated. It does disable and renable the touchpad which is strange.
Comment 1 Nate Graham 2022-06-01 17:46:05 UTC
> It does disable and renable the touchpad which is strange.
That means that tablet mode is in fact being automatically detected properly by Libinput. Perhaps some signal isn't getting passed onto KWin anymore.

FWIW it's working properly with my Lenovo X1 Yoga G4.
Comment 2 Etaash Mathamsetty 2022-06-07 20:29:57 UTC
I have a feeling that is caused by lenovo's interesting method of sending the F22 and F23 keys for leaving and entering tablet mode. Could you check if you lenovo computer does this as well?
Comment 3 Etaash Mathamsetty 2022-07-17 23:25:32 UTC
any updates on this?
Comment 4 Nate Graham 2022-07-19 15:37:30 UTC
If you go to System Settings > Workspace Behavior > Touch Mode, can you make sure it's set to "Automatically enable as needed"?

If it's already set to that, do you see that Touch Mode works properly if you manually set it to "Always enabled" for testing purposes?
Comment 5 Etaash Mathamsetty 2022-07-19 18:08:50 UTC
(In reply to Nate Graham from comment #4)
> If you go to System Settings > Workspace Behavior > Touch Mode, can you make
> sure it's set to "Automatically enable as needed"?
> 
> If it's already set to that, do you see that Touch Mode works properly if
> you manually set it to "Always enabled" for testing purposes?

always enabled works fine
automatically enabled as needed is set
Comment 6 Etaash Mathamsetty 2022-07-19 18:10:01 UTC
(In reply to Etaash Mathamsetty from comment #5)
> (In reply to Nate Graham from comment #4)
> > If you go to System Settings > Workspace Behavior > Touch Mode, can you make
> > sure it's set to "Automatically enable as needed"?
> > 
> > If it's already set to that, do you see that Touch Mode works properly if
> > you manually set it to "Always enabled" for testing purposes?
> 
> always enabled works fine
> automatically enabled as needed is set

am using plasma 5.25.3 now, along with beta frameworks and it's not working still
Comment 7 Nate Graham 2022-07-19 18:15:30 UTC
OK, then I think a KWin or Kirigami person just needs to investigate it.
Comment 8 Etaash Mathamsetty 2022-07-19 18:23:03 UTC
I conveniently have the kwin source code on my machine, (I patched it for zoom screensharing, but don't worry the tablet mode was broken even before I patched it), so if you could point me to the general area to look in the code, I could see where the error is
Comment 9 Nate Graham 2022-07-19 18:46:06 UTC
Check out:
- src/input.cpp
- src/tabletmodemanager.cpp

If you're handy with source code and compiling things, you could also to a `git bisect` to find out which exact commit regressed it for you.
Comment 10 Etaash Mathamsetty 2022-07-19 18:57:47 UTC
(In reply to Nate Graham from comment #9)
> Check out:
> - src/input.cpp
> - src/tabletmodemanager.cpp
> 
> If you're handy with source code and compiling things, you could also to a
> `git bisect` to find out which exact commit regressed it for you.

won't I have to test it for basically every commit to kwin if I go with the git bisect
Comment 11 Etaash Mathamsetty 2022-07-19 19:11:21 UTC
kwin debug console shows the buttons touchpad on and touchpad off being pressed and released
but nothing else
Comment 12 Etaash Mathamsetty 2022-07-19 19:25:31 UTC
my suspicions that I stated earlier are correct, my laptop doesn't have a tablet mode switch, instead it has ideapad extra buttons, where it sends a keycode for enabling the touchpad and disabling it
Comment 13 Etaash Mathamsetty 2022-07-19 19:25:46 UTC
(In reply to Etaash Mathamsetty from comment #12)
> my suspicions that I stated earlier are correct, my laptop doesn't have a
> tablet mode switch, instead it has ideapad extra buttons, where it sends a
> keycode for enabling the touchpad and disabling it

the code only appears to be checking for the tablet mode switch
Comment 14 Nate Graham 2022-07-19 19:29:27 UTC
Were any other packages updated when you upgraded to Plasma 5.25? I ask because it's also possible this is a Libinput regression, that it used may that event to "tablet switch changed" but that broke.
Comment 15 Etaash Mathamsetty 2022-07-19 19:35:24 UTC
this kernel module does the trick!!!!!!
https://github.com/lukas-w/yoga-usage-mode
Comment 16 Nate Graham 2022-07-19 19:45:04 UTC
Aha, so the issue was in the kernel.

Ideally that code would be upstreamed so you don't need a 3rd-party kernel module for this.