Commit e2889c86 authored by Aleix Pol Gonzalez's avatar Aleix Pol Gonzalez 🐧
Browse files

inputmethod: Allow forcing the display of the input method

Adds support to the new information offered by KWin. Now it can tell us
that the current client doesn't support Wayland input methods.

Therefore, it sets the plasmoid in a new "unsupported" state that will
offer to force an activation when triggered. KWin will then be able to
emulate a keyboard and it all should work to some extent.

Depends on kwin!2907

BUG: 439911
parent 25baeed7
Pipeline #229396 passed with stage
in 6 minutes and 9 seconds
......@@ -19,12 +19,16 @@ Item {
id: root
property var overlays: []
Plasmoid.onActivated: if (!Keyboards.KWinVirtualKeyboard.available) {
root.action_settings()
} else if (Keyboards.KWinVirtualKeyboard.visible) {
Keyboards.KWinVirtualKeyboard.active = false
} else {
Keyboards.KWinVirtualKeyboard.enabled = !Keyboards.KWinVirtualKeyboard.enabled
Plasmoid.onActivated: {
if (!Keyboards.KWinVirtualKeyboard.available) {
root.action_settings()
} else if (unsupportedState.when) {
Keyboards.KWinVirtualKeyboard.forceActivate()
} else if (Keyboards.KWinVirtualKeyboard.visible) {
Keyboards.KWinVirtualKeyboard.active = false
} else {
Keyboards.KWinVirtualKeyboard.enabled = !Keyboards.KWinVirtualKeyboard.enabled
}
}
Plasmoid.preferredRepresentation: Plasmoid.compactRepresentation
Plasmoid.fullRepresentation: Plasmoid.compactRepresentation
......@@ -67,7 +71,7 @@ Item {
states: [
State {
name: "available"
name: "unavailable"
when: !Keyboards.KWinVirtualKeyboard.available
PropertyChanges {
target: Plasmoid.self
......@@ -88,6 +92,20 @@ Item {
}
PropertyChanges { target: root; overlays: [] }
},
State {
id: unsupportedState
name: "unsupported"
when: Keyboards.KWinVirtualKeyboard.available && !Keyboards.KWinVirtualKeyboard.activeClientSupportsTextInput
// When the current client doesn't support input methods, we can force
// the display of the virtual keyboard so it emulates a hardware keyboard instead
PropertyChanges {
target: Plasmoid.self
icon: "arrow-up"
toolTipSubText: i18n("Show Virtual Keyboard")
status: Kirigami.Settings.tabletMode ? PlasmaCore.Types.ActiveStatus : PlasmaCore.Types.PassiveStatus
}
PropertyChanges { target: root; overlays: [] }
},
State {
name: "visible"
when: Keyboards.KWinVirtualKeyboard.available && Keyboards.KWinVirtualKeyboard.visible
......
......@@ -15,6 +15,7 @@ class KwinVirtualKeyboardInterface : public OrgKdeKwinVirtualKeyboardInterface
Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged)
Q_PROPERTY(bool visible READ visible NOTIFY visibleChanged)
Q_PROPERTY(bool available READ available NOTIFY availableChanged)
Q_PROPERTY(bool activeClientSupportsTextInput READ activeClientSupportsTextInput NOTIFY activeClientSupportsTextInputChanged)
public:
KwinVirtualKeyboardInterface();
};
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment