RFC: Try getting the X keyboard grab multiple times
AcceptedPublic

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

Details

Reviewers
zzag
Group Reviewers
Plasma
KWin
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
Branch
master
Lint
No Linters Available
Unit
No Unit Test Coverage
Build Status
Buildable 11207
Build 11225: arc lint + arc unit
Restricted Application added a project: Plasma. · View Herald TranscriptThu, Apr 25, 10:29 AM
Restricted Application added a subscriber: plasma-devel. · View Herald Transcript
davidedmundson requested review of this revision.Thu, Apr 25, 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.Thu, Apr 25, 1:58 PM
zzag added a subscriber: zzag.Fri, Apr 26, 2:17 PM

Wrote relevant matching kwin patch to close effects

Have you uploaded it? :-)

zzag added a comment.Tue, Apr 30, 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.EditedTue, Apr 30, 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.Fri, May 10, 2:42 PM
This revision is now accepted and ready to land.Fri, May 10, 2:42 PM