First approach to a plasmoid that can display the state of caps lock
ClosedPublic

Authored by apol on Feb 6 2018, 11:00 AM.

Diff Detail

Repository
R114 Plasma Addons
Branch
master
Lint
No Linters Available
Unit
No Unit Test Coverage
apol created this revision.Feb 6 2018, 11:00 AM
Restricted Application added a project: Plasma. · View Herald TranscriptFeb 6 2018, 11:00 AM
Restricted Application added a subscriber: plasma-devel. · View Herald Transcript
apol requested review of this revision.Feb 6 2018, 11:00 AM
broulik added a subscriber: broulik.Feb 6 2018, 1:36 PM
broulik added inline comments.
applets/keyboardindicator/contents/ui/main.qml
29

I don't see a toggle() function

34

I know QML does this magically but I'd prefer explicit array

connectedSources: ["Caps Lock"]
61

You change the icon *and* let it glow when caps lock is enabled?

applets/keyboardindicator/metadata.desktop
3

Is this supposed to be augmented to show Num Lock etc otherwise this is oddly unspecific

abetts added a subscriber: abetts.Feb 6 2018, 3:53 PM

Does this have a look yet?

Please be aware that this will not work on Wayland. The modifier state is only available to the window which currently has keyboard focus. We either need a dedicated Wayland protocol to send all modifier changes to Plasma or some other way to have KWin feed in the state.

Anyway: I would recommend to make it only available for platform xcb right now.

apol added a comment.Feb 6 2018, 4:02 PM

Please be aware that this will not work on Wayland. The modifier state is only available to the window which currently has keyboard focus. We either need a dedicated Wayland protocol to send all modifier changes to Plasma or some other way to have KWin feed in the state.

Anyway: I would recommend to make it only available for platform xcb right now.

Note this is using a Plasma Data Engine that is used by several plasmoids and components throughout plasma. In turn, we should make sure that if the data engine doesn't have any data, it doesn't work.
Or have the data engine work on Wayland.

In D10337#202007, @apol wrote:

Please be aware that this will not work on Wayland. The modifier state is only available to the window which currently has keyboard focus. We either need a dedicated Wayland protocol to send all modifier changes to Plasma or some other way to have KWin feed in the state.

Anyway: I would recommend to make it only available for platform xcb right now.

Note this is using a Plasma Data Engine that is used by several plasmoids and components throughout plasma. In turn, we should make sure that if the data engine doesn't have any data, it doesn't work.
Or have the data engine work on Wayland.

The data engine can partially work. If you are interested only in the data engine while you have keyboard focus, it actually does work [1]. An example would be the lockscreen which uses the data engine and has keyboard focus.

The concept of this data engine just doesn't match the Wayland world: there are no global keyloggers. KWayland::Server could send the modifier changes to all applications, but this would on the one side trigger wakeups whenever a modifier changes for all applications (bad) or in the worst case even trigger crashes in applications as they don't expect modifier changes when not having keyboard focus.

So in summary: it depends a lot on what the use case for the engine is. This plasmoid unfortunately is an example for a usage pattern which does not work in a Wayland world. The only possibility I see is exposing a DBus service in KWin and have the data engine talk to it, but this would mean it's kwin dependent and still doesn't work on Wayland in general.

[1] KModifierKeyInfo doesn't support Wayland yet, so in practice it doesn't work

apol updated this revision to Diff 26665.Feb 6 2018, 7:01 PM

Also expose numlock, somewhat

apol added a comment.Feb 6 2018, 7:03 PM

this is a very clunky video of what it looks like. Hope this helps.
Design input very welcome.

This revision was not accepted when it landed; it landed in state Needs Review.Feb 20 2018, 2:36 AM
This revision was automatically updated to reflect the committed changes.

Quick note before I forget again: doesn't this need some Messages.sh? There are some i18n calls in the QML.