mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-04-10 15:52:58 -04:00
running apps: make settings bar-specific
This commit is contained in:
@@ -335,6 +335,33 @@ Singleton {
|
||||
return toplevels;
|
||||
}
|
||||
|
||||
function filterCurrentDisplay(toplevels, screenName) {
|
||||
if (!toplevels || toplevels.length === 0 || !screenName)
|
||||
return toplevels;
|
||||
if (useNiriSorting)
|
||||
return NiriService.filterCurrentDisplay(toplevels, screenName);
|
||||
if (isHyprland)
|
||||
return filterHyprlandCurrentDisplaySafe(toplevels, screenName);
|
||||
return toplevels;
|
||||
}
|
||||
|
||||
function filterHyprlandCurrentDisplaySafe(toplevels, screenName) {
|
||||
if (!toplevels || toplevels.length === 0 || !Hyprland.toplevels)
|
||||
return toplevels;
|
||||
|
||||
let monitorWindows = new Set();
|
||||
try {
|
||||
const hy = Array.from(Hyprland.toplevels.values);
|
||||
for (const t of hy) {
|
||||
const mon = _get(t, ["monitor", "name"], "");
|
||||
if (mon === screenName && t.wayland)
|
||||
monitorWindows.add(t.wayland);
|
||||
}
|
||||
} catch (e) {}
|
||||
|
||||
return toplevels.filter(w => monitorWindows.has(w));
|
||||
}
|
||||
|
||||
function filterHyprlandCurrentWorkspaceSafe(toplevels, screenName) {
|
||||
if (!toplevels || toplevels.length === 0 || !Hyprland.toplevels)
|
||||
return toplevels;
|
||||
|
||||
@@ -1084,6 +1084,87 @@ Singleton {
|
||||
return result;
|
||||
}
|
||||
|
||||
function filterCurrentDisplay(toplevels, screenName) {
|
||||
if (!toplevels || toplevels.length === 0 || !screenName)
|
||||
return toplevels;
|
||||
|
||||
const outputWorkspaceIds = new Set();
|
||||
for (var i = 0; i < allWorkspaces.length; i++) {
|
||||
const ws = allWorkspaces[i];
|
||||
if (ws.output === screenName)
|
||||
outputWorkspaceIds.add(ws.id);
|
||||
}
|
||||
|
||||
if (outputWorkspaceIds.size === 0)
|
||||
return toplevels;
|
||||
|
||||
const displayWindows = windows.filter(niriWindow => outputWorkspaceIds.has(niriWindow.workspace_id));
|
||||
const usedToplevels = new Set();
|
||||
const result = [];
|
||||
|
||||
for (const niriWindow of displayWindows) {
|
||||
let bestMatch = null;
|
||||
let bestScore = -1;
|
||||
|
||||
for (const toplevel of toplevels) {
|
||||
if (usedToplevels.has(toplevel))
|
||||
continue;
|
||||
if (toplevel.appId === niriWindow.app_id) {
|
||||
let score = 1;
|
||||
|
||||
if (niriWindow.title && toplevel.title) {
|
||||
if (toplevel.title === niriWindow.title) {
|
||||
score = 3;
|
||||
} else if (toplevel.title.includes(niriWindow.title) || niriWindow.title.includes(toplevel.title)) {
|
||||
score = 2;
|
||||
}
|
||||
}
|
||||
|
||||
if (score > bestScore) {
|
||||
bestScore = score;
|
||||
bestMatch = toplevel;
|
||||
if (score === 3)
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!bestMatch)
|
||||
continue;
|
||||
usedToplevels.add(bestMatch);
|
||||
|
||||
const workspace = workspaces[niriWindow.workspace_id];
|
||||
const isFocused = niriWindow.is_focused ?? (workspace && workspace.active_window_id === niriWindow.id) ?? false;
|
||||
|
||||
const enrichedToplevel = {
|
||||
"appId": bestMatch.appId,
|
||||
"title": bestMatch.title,
|
||||
"activated": isFocused,
|
||||
"niriWindowId": niriWindow.id,
|
||||
"niriWorkspaceId": niriWindow.workspace_id,
|
||||
"activate": function () {
|
||||
return NiriService.focusWindow(niriWindow.id);
|
||||
},
|
||||
"close": function () {
|
||||
if (bestMatch.close) {
|
||||
return bestMatch.close();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
for (let prop in bestMatch) {
|
||||
if (!(prop in enrichedToplevel)) {
|
||||
enrichedToplevel[prop] = bestMatch[prop];
|
||||
}
|
||||
}
|
||||
|
||||
result.push(enrichedToplevel);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
function generateNiriLayoutConfig() {
|
||||
if (!CompositorService.isNiri || configGenerationPending)
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user