diff --git a/quickshell/Widgets/KeybindItem.qml b/quickshell/Widgets/KeybindItem.qml index eda483ef..a65b5037 100644 --- a/quickshell/Widgets/KeybindItem.qml +++ b/quickshell/Widgets/KeybindItem.qml @@ -26,6 +26,15 @@ Item { property string _actionType: "" property bool addingNewKey: false property bool useCustomCompositor: false + property var _shortcutInhibitor: null + + readonly property bool _shortcutInhibitorAvailable: { + try { + return typeof ShortcutInhibitor !== "undefined"; + } catch (e) { + return false; + } + } readonly property var keys: bindData.keys || [] readonly property bool hasOverride: { @@ -47,6 +56,8 @@ Item { implicitHeight: contentColumn.implicitHeight height: implicitHeight + Component.onDestruction: _destroyShortcutInhibitor() + onIsExpandedChanged: { if (isExpanded) resetEdits(); @@ -118,7 +129,34 @@ Item { addingNewKey = false; } + function _createShortcutInhibitor() { + if (!_shortcutInhibitorAvailable || _shortcutInhibitor) + return; + + const qmlString = ` + import QtQuick + import Quickshell.Wayland + + ShortcutInhibitor { + enabled: false + window: null + } + `; + + _shortcutInhibitor = Qt.createQmlObject(qmlString, root, "KeybindItem.ShortcutInhibitor"); + _shortcutInhibitor.enabled = Qt.binding(() => root.recording); + _shortcutInhibitor.window = Qt.binding(() => root.panelWindow); + } + + function _destroyShortcutInhibitor() { + if (_shortcutInhibitor) { + _shortcutInhibitor.destroy(); + _shortcutInhibitor = null; + } + } + function startRecording() { + _createShortcutInhibitor(); recording = true; } @@ -288,12 +326,6 @@ Item { property alias currentTitle: titleField.text - ShortcutInhibitor { - id: shortcutInhibitor - enabled: root.recording - window: root.panelWindow - } - ColumnLayout { id: expandedContent anchors.left: parent.left