mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-10-26 13:07:49 -04:00
niri: drive touchpad OSD from native compositor events
This commit is contained in:
1 parent
87ce92703c
commit
c4aea85296
5 files changed
+50
-30
No files matched your search
@@ -92,7 +92,13 @@ binds {
|
||||
|
||||
// === Input ===
|
||||
XF86TouchpadToggle allow-when-locked=true repeat=false {
|
||||
spawn "dms" "ipc" "call" "niri" "toggleTouchpad";
|
||||
spawn "niri" "msg" "action" "toggle-touchpad";
|
||||
}
|
||||
XF86TouchpadOn allow-when-locked=true repeat=false {
|
||||
spawn "dms" "ipc" "call" "niri" "showTouchpadOsd" "true";
|
||||
}
|
||||
XF86TouchpadOff allow-when-locked=true repeat=false {
|
||||
spawn "dms" "ipc" "call" "niri" "showTouchpadOsd" "false";
|
||||
}
|
||||
|
||||
// === Window Management ===
|
||||
|
||||
+11
-1
@@ -158,7 +158,17 @@ in {
|
||||
"XF86TouchpadToggle" = {
|
||||
allow-when-locked = true;
|
||||
repeat = false;
|
||||
action = dms-ipc "niri" "toggleTouchpad";
|
||||
action = spawn "niri" "msg" "action" "toggle-touchpad";
|
||||
};
|
||||
"XF86TouchpadOn" = {
|
||||
allow-when-locked = true;
|
||||
repeat = false;
|
||||
action = dms-ipc "niri" "showTouchpadOsd" "true";
|
||||
};
|
||||
"XF86TouchpadOff" = {
|
||||
allow-when-locked = true;
|
||||
repeat = false;
|
||||
action = dms-ipc "niri" "showTouchpadOsd" "false";
|
||||
};
|
||||
"Mod+Alt+N" = {
|
||||
allow-when-locked = true;
|
||||
|
||||
@@ -40,6 +40,8 @@ const KEY_MAP = {
|
||||
16777329: "XF86AudioMute",
|
||||
16842808: "XF86AudioMicMute",
|
||||
16777488: "XF86TouchpadToggle",
|
||||
16777489: "XF86TouchpadOn",
|
||||
16777490: "XF86TouchpadOff",
|
||||
16777344: "XF86AudioPlay",
|
||||
16777345: "XF86AudioStop",
|
||||
16777346: "XF86AudioPrev",
|
||||
|
||||
@@ -13,13 +13,16 @@ DOSD {
|
||||
autoHideInterval: 2000
|
||||
enableMouseInteraction: false
|
||||
|
||||
property bool touchpadEnabled: true
|
||||
|
||||
Connections {
|
||||
target: NiriService
|
||||
|
||||
function onTouchpadToggled() {
|
||||
if (SettingsData.osdTouchpadEnabled) {
|
||||
root.show();
|
||||
}
|
||||
function onTouchpadOsdRequested(enabled: bool) {
|
||||
if (!SettingsData.osdTouchpadEnabled)
|
||||
return;
|
||||
root.touchpadEnabled = enabled;
|
||||
root.show();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,8 +30,8 @@ DOSD {
|
||||
OsdIcon {
|
||||
tonal: false
|
||||
anchors.centerIn: parent
|
||||
iconName: NiriService.touchpadDisabled ? "touchpad_mouse_off" : "touchpad_mouse"
|
||||
iconColor: NiriService.touchpadDisabled ? Theme.outline : Theme.primary
|
||||
iconName: root.touchpadEnabled ? "touchpad_mouse" : "touchpad_mouse_off"
|
||||
iconColor: root.touchpadEnabled ? Theme.primary : Theme.outline
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -41,9 +41,9 @@ Singleton {
|
||||
property int currentKeyboardLayoutIndex: 0
|
||||
property var keyboardLayoutNames: []
|
||||
|
||||
// niri never reports toggle-touchpad state, so this only tracks toggles issued through DMS.
|
||||
property bool touchpadDisabled: false
|
||||
signal touchpadToggled
|
||||
property bool touchpadEnabled: true
|
||||
property bool _touchpadStateInitialized: false
|
||||
signal touchpadOsdRequested(bool enabled)
|
||||
|
||||
property string configValidationOutput: ""
|
||||
property bool hasInitialConnection: false
|
||||
@@ -259,7 +259,8 @@ Singleton {
|
||||
connected: CompositorService.isNiri
|
||||
|
||||
onConnectionStateChanged: {
|
||||
if (connected) {
|
||||
root._touchpadStateInitialized = false;
|
||||
if (linkUp) {
|
||||
send('"EventStream"');
|
||||
fetchOutputs();
|
||||
}
|
||||
@@ -428,6 +429,9 @@ Singleton {
|
||||
case 'KeyboardLayoutSwitched':
|
||||
handleKeyboardLayoutSwitched(event.KeyboardLayoutSwitched);
|
||||
break;
|
||||
case 'TouchpadToggled':
|
||||
handleTouchpadToggled(event.TouchpadToggled);
|
||||
break;
|
||||
case 'WorkspaceUrgencyChanged':
|
||||
handleWorkspaceUrgencyChanged(event.WorkspaceUrgencyChanged);
|
||||
break;
|
||||
@@ -449,6 +453,15 @@ Singleton {
|
||||
}
|
||||
}
|
||||
|
||||
function handleTouchpadToggled(data) {
|
||||
// Each subscription starts with a snapshot; only later changes show the OSD.
|
||||
const showOsd = _touchpadStateInitialized && touchpadEnabled !== data.on;
|
||||
touchpadEnabled = data.on;
|
||||
_touchpadStateInitialized = true;
|
||||
if (showOsd)
|
||||
touchpadOsdRequested(touchpadEnabled);
|
||||
}
|
||||
|
||||
function handleWorkspacesChanged(data) {
|
||||
const newWorkspaces = {};
|
||||
|
||||
@@ -814,19 +827,6 @@ Singleton {
|
||||
});
|
||||
}
|
||||
|
||||
function toggleTouchpad() {
|
||||
if (!CompositorService.isNiri)
|
||||
return;
|
||||
Proc.runCommand("niri-toggle-touchpad", ["niri", "msg", "action", "toggle-touchpad"], (output, exitCode) => {
|
||||
if (exitCode !== 0) {
|
||||
log.warn("toggle-touchpad failed, exit code:", exitCode);
|
||||
return;
|
||||
}
|
||||
touchpadDisabled = !touchpadDisabled;
|
||||
touchpadToggled();
|
||||
});
|
||||
}
|
||||
|
||||
function toggleOverview() {
|
||||
return send({
|
||||
"Action": {
|
||||
@@ -1940,12 +1940,11 @@ window-rule {
|
||||
return "SCREENSHOT_WINDOW_FAILED";
|
||||
}
|
||||
|
||||
function toggleTouchpad(): string {
|
||||
if (!CompositorService.isNiri) {
|
||||
function showTouchpadOsd(enabled: bool): string {
|
||||
if (!CompositorService.isNiri)
|
||||
return "NIRI_NOT_AVAILABLE";
|
||||
}
|
||||
NiriService.toggleTouchpad();
|
||||
return "TOUCHPAD_TOGGLED";
|
||||
NiriService.touchpadOsdRequested(enabled);
|
||||
return "TOUCHPAD_OSD_SHOWN";
|
||||
}
|
||||
|
||||
target: "niri"
|
||||
|
||||
Reference in new issue
Block a user