RFC: Try getting the X keyboard grab multiple times
ClosedPublic

Authored by davidedmundson on Apr 25 2019, 10:29 AM.

Details

Summary

Right now when the screen locker starts it tries to grab the keyboard on
X. This fails if any other application has grabbed the keyboard.

In these situations the screen simply doesn't lock which is a pretty
rubbish state.

This can't be realistically fixed properly on X, on wayland it's a
non-issue.

However, we can minimise the occasions when this occurs.

This patch emits a signal before locking and then tries the lack
multiple times. Clients can listen for this event and release their
keyboard grabs.

Test Plan

Wrote relevant matching kwin patch to close effects
"sleep 5 ; loginctl lock-session" whilst a desktop effect was active still locked the session

Diff Detail

Repository
R133 KScreenLocker
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
Restricted Application added a project: Plasma. · View Herald TranscriptApr 25 2019, 10:29 AM
Restricted Application added a subscriber: plasma-devel. · View Herald Transcript
davidedmundson requested review of this revision.Apr 25 2019, 10:29 AM
shubham added inline comments.
interface.h
116

Shouldn't this and the above function name start with small letter?

Shouldn't this and the above function name start with small letter?

DBus methods and signals tend to start with an upper case. Though interface already consists of a mixture :/
Classes using Qt generated DBus adaptors have to match the interface they're implementing.

shubham removed a subscriber: shubham.Apr 25 2019, 1:58 PM
zzag added a subscriber: zzag.Apr 26 2019, 2:17 PM

Wrote relevant matching kwin patch to close effects

Have you uploaded it? :-)

zzag added a comment.Apr 30 2019, 10:32 AM

Arguably it won't help us with all cases because the clients would have to voluntarily participate in the protocol.

I wonder whether it's worth fixing this bug on X11 at all.

davidedmundson added a comment.EditedApr 30 2019, 12:17 PM

Arguably it won't help us with all cases because the clients would have to voluntarily participate in the protocol.

Yes. I'm not pretending it will.


I wonder whether it's worth fixing this bug on X11 at all.

There is a way to forcefully take a grab inside X internals.

The only way this is exposed publicly is via the shortcut key XF86Ungrab

setxkbmap -option grab:break_actions
xdotool key XF86Ungrab

It was meant as a dev tool so you could switch to a console to debug locks.
Using this is a horrific idea as it introduces a keyboard shortcut to circumvent the screen locker!!

There's no other public API, though I don't see why one couldn't be added.
The bigger problem is that the client side has no indication that it loses it's lock which leaves it in a corrupt state when you log in.
Adding that retroactively is the part I think is pragmatically impossible.


And before someone suggests injecting an escape key into the focused app, it might work, but we'd have to keep trying the lock until whatever kwin animation finishes which becomes a bit weird.

zzag accepted this revision.May 10 2019, 2:42 PM
This revision is now accepted and ready to land.May 10 2019, 2:42 PM
This revision was automatically updated to reflect the committed changes.