Files
dotfiles/quickshell/services/WindowPolicy.js
T
2026-11-17 18:15:16 +07:00

16 lines
734 B
JavaScript

.pragma library
// Pure window ordering helpers; no compositor operations in this module.
function ordered(windows) {
return (windows || []).filter(w => w && typeof w.activate === "function");
}
function cycle(windows, currentIndex, direction) {
const list = ordered(windows);
if (!list.length) return null;
if (direction !== 1 && direction !== -1) return null;
const index = Number.isInteger(currentIndex) && currentIndex >= 0 && currentIndex < list.length ? currentIndex : (direction === 1 ? -1 : 0);
return list[(index + direction + list.length) % list.length];
}
function shouldDismissSwipe(dx, dy, width) {
return dy < -Math.max(64, Math.min(130, width * 0.2)) && Math.abs(dy) > Math.abs(dx) * 1.2;
}