fix(osd): handle touchpad hardware keys (#4045)

Port 2.0

(cherry picked from commit 0a84c14a19)
This commit is contained in:
Huỳnh Thiện Lộc authored and dux-ci[bot] committed 2026-10-31 00:51:26 +00:00
1 parent 597b84febc
commit 78183cdb27
2 files changed
+22 -4

No files matched your search

@@ -94,6 +94,12 @@ binds {
XF86TouchpadToggle allow-when-locked=true repeat=false {
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 ===
Mod+Q repeat=false { close-window; }
+16 -4
View File
@@ -462,15 +462,19 @@ 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;
function updateTouchpadState(enabled, forceOsd) {
const showOsd = forceOsd || (_touchpadStateInitialized && touchpadEnabled !== enabled);
touchpadEnabled = enabled;
_touchpadStateInitialized = true;
if (showOsd)
touchpadToggled();
}
function handleTouchpadToggled(data) {
// Each subscription starts with a snapshot; only later changes show the OSD.
updateTouchpadState(data.on, false);
}
function handleWorkspacesChanged(data) {
const newWorkspaces = {};
@@ -1923,6 +1927,14 @@ window-rule {
}
IpcHandler {
function showTouchpadOsd(enabled: bool): string {
if (!CompositorService.isNiri)
return "NIRI_NOT_AVAILABLE";
root.updateTouchpadState(enabled, true);
return "TOUCHPAD_OSD_SHOWN";
}
function screenshot(): string {
if (!CompositorService.isNiri) {
return "NIRI_NOT_AVAILABLE";