// SPDX-License-Identifier: MIT .pragma library // Task Manager fills unused panel space. Only delegates are task buttons. function hasTaskAt(item, x, y) { if (!item.visible) return false; const point = item.mapFromItem(null, x, y); if (!item.contains(point)) return false; if (item.tasksRoot !== undefined && item.isWindow !== undefined && item.index !== undefined) return true; for (const child of item.children) { if (hasTaskAt(child, x, y)) return true; } return false; } function appletArea(child, x, y) { const applet = child.applet; const name = applet?.plasmoid?.pluginName; if (!name) return "other"; if (name === "org.kde.plasma.taskmanager" || name === "org.kde.plasma.icontasks") { return hasTaskAt(applet, x, y) ? "tasks" : "empty"; } if (name === "se.ajpanton.panelactions" || name === "org.kde.plasma.panelspacer" || name === "org.kde.plasma.marginsseparator") return "empty"; if (name === "org.kde.plasma.systemtray") return "tray"; if (name === "org.kde.plasma.digitalclock" || name === "org.kde.plasma.analogclock") return "clock"; if (name === "org.kde.plasma.kickoff" || name === "org.kde.plasma.kicker" || name === "org.kde.plasma.kickerdash") return "launcher"; return "other"; } function panelViewFor(item) { for (let parent = item.parent; parent; parent = parent.parent) { if (parent.containment && parent.leftPadding !== undefined && parent.rightPadding !== undefined && parent.topPadding !== undefined && parent.bottomPadding !== undefined) return parent; } return null; } function areaAt(panelLayout, x, y, panelView) { if (!panelLayout || !panelView?.containment) return ""; // Match Plasma PanelView's containmentContainsPosition / positionAdjustedForContainment. // Read the same live theme padding and containment origin, including floating offsets. const containment = panelView.containment; const origin = containment.mapToItem(null, 0, 0); const left = origin.x + panelView.leftPadding; const top = origin.y + panelView.topPadding; const right = origin.x + containment.width - panelView.rightPadding; const bottom = origin.y + containment.height - panelView.bottomPadding; if (right <= left || bottom <= top) return ""; if (x < left || x >= right || y < top || y >= bottom) { // The trailing boundary itself is outside Qt Quick's input area. x = Math.max(left, Math.min(x, right - 1)); y = Math.max(top, Math.min(y, bottom - 1)); } for (const child of panelLayout.children) { if (child.visible && child.contains(child.mapFromItem(null, x, y))) { return appletArea(child, x, y); } } return "empty"; }