Remember input selections before an app gains focus

This commit is contained in:
David Heinemeier Hansson committed 2026-10-07 17:17:02 +02:00
1 parent cd73dc6cfd
commit 2841563e6c
5 files changed
+148 -40

No files matched your search

+36
View File
@@ -0,0 +1,36 @@
pragma Singleton
import QtQuick
import Quickshell
import Quickshell.Io
Singleton {
id: root
property var state: ({})
function cycle() {
if (watcher.running) watcher.write("cycle\n")
}
// One reader and pending selection for every monitor's keyboard widget.
Process {
id: watcher
command: ["/usr/bin/python", Quickshell.env("OMARCHY_PATH") + "/default/input-methods/indicator.py"]
running: true
stdinEnabled: true
stdout: SplitParser {
onRead: data => {
try { root.state = JSON.parse(data) } catch (e) {}
}
}
onExited: {
root.state = ({})
restart.restart()
}
}
Timer {
id: restart
interval: 5000
onTriggered: watcher.running = true
}
}
+1
View File
@@ -2,6 +2,7 @@ module qs.Commons
singleton Border 1.0 Border.qml
singleton Color 1.0 Color.qml
singleton IpcRegistry 1.0 IpcRegistry.qml
singleton InputMethodState 1.0 InputMethodState.qml
singleton Style 1.0 Style.qml
singleton Util 1.0 Util.qml
ShellIpc 1.0 ShellIpc.qml
+2 -36
View File
@@ -36,7 +36,7 @@ BarWidget {
// xkb's own table rather than maintained by hand.
property var layoutBriefs: ({})
readonly property string layoutLabel: KeyboardLayoutModel.shortLabel(layoutFull, layoutBriefs)
property var inputState: ({})
readonly property var inputState: InputMethodState.state
readonly property bool multipleInputs: (inputState.methods || []).length > 1
readonly property string inputLabel: KeyboardLayoutModel.inputLabel(inputState, layoutLabel)
@@ -231,39 +231,6 @@ BarWidget {
onTriggered: root.refresh()
}
Process {
id: inputWatcher
command: ["/usr/bin/python", Quickshell.env("OMARCHY_PATH") + "/default/input-methods/indicator.py"]
running: true
stdout: SplitParser {
onRead: data => {
try { root.inputState = JSON.parse(data) } catch (e) {}
}
}
onExited: {
root.inputState = ({})
inputRestart.restart()
}
}
Timer {
id: inputRestart
interval: 5000
onTriggered: inputWatcher.running = true
}
Process {
id: inputCycle
property int pending: 0
command: ["/usr/bin/python", Quickshell.env("OMARCHY_PATH") + "/default/input-methods/indicator.py", "cycle"]
onExited: {
if (pending > 0) {
pending--
running = true
}
}
}
visible: inputLabel !== "" && KeyboardLayoutModel.showIndicator(layoutLabel, multipleLayouts, multipleInputs)
implicitWidth: button.implicitWidth
implicitHeight: button.implicitHeight
@@ -278,8 +245,7 @@ BarWidget {
tooltipText: KeyboardLayoutModel.inputTooltip(root.inputState, root.layoutFull, root.multipleLayouts)
onPressed: function(button) {
if (root.multipleInputs && button === Qt.LeftButton) {
if (inputCycle.running) inputCycle.pending++
else inputCycle.running = true
InputMethodState.cycle()
} else if (root.multipleLayouts) {
root.cycleLayout()
} else if (!root.multipleInputs && root.bar) {