1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2026-05-15 08:42:47 -04:00

workspace/ext-ws: drop custom ext-workspace in favor of quickshell

WindowManager implementation
This commit is contained in:
bbedward
2026-05-14 10:34:35 -04:00
parent 71438530a8
commit fb5198fd0b
11 changed files with 48 additions and 3227 deletions
@@ -4,6 +4,7 @@ import Quickshell
import Quickshell.Widgets
import Quickshell.Hyprland
import Quickshell.I3
import Quickshell.WindowManager
import qs.Common
import qs.Services
import qs.Widgets
@@ -86,7 +87,22 @@ Item {
}
}
readonly property bool useExtWorkspace: DMSService.forceExtWorkspace || (!CompositorService.isNiri && !CompositorService.isHyprland && !CompositorService.isDwl && !CompositorService.isSway && !CompositorService.isScroll && !CompositorService.isMiracle && ExtWorkspaceService.extWorkspaceAvailable)
readonly property var extProjection: (useExtWorkspace && parentScreen) ? WindowManager.screenProjection(parentScreen) : null
readonly property bool useExtWorkspace: {
if (Quickshell.env("DMS_FORCE_EXTWS") === "1")
return (WindowManager.windowsets?.length ?? 0) > 0;
switch (CompositorService.compositor) {
case "niri":
case "hyprland":
case "dwl":
case "sway":
case "scroll":
case "miracle":
return false;
default:
return (WindowManager.windowsets?.length ?? 0) > 0;
}
}
Connections {
target: DesktopEntries
@@ -361,7 +377,7 @@ Item {
"id": "",
"name": "",
"active": false,
"hidden": true
"_placeholder": true
};
} else if (CompositorService.isNiri) {
placeholder = {
@@ -493,33 +509,21 @@ Item {
}
function getExtWorkspaceWorkspaces() {
const groups = ExtWorkspaceService.groups;
if (!ExtWorkspaceService.extWorkspaceAvailable || groups.length === 0) {
return [
{
"id": "1",
"name": "1",
"active": false
}
];
}
const fallback = [
{
"id": "1",
"name": "1",
"active": false
}
];
if (!extProjection)
return fallback;
const group = groups.find(g => g.outputs && g.outputs.includes(root.screenName));
if (!group || !group.workspaces) {
return [
{
"id": "1",
"name": "1",
"active": false
}
];
}
let visible = group.workspaces.filter(ws => !ws.hidden);
let visible = extProjection.windowsets.filter(ws => ws.shouldDisplay);
const hasValidCoordinates = visible.some(ws => ws.coordinates && ws.coordinates.length > 0);
if (hasValidCoordinates) {
visible = visible.sort((a, b) => {
visible = visible.slice().sort((a, b) => {
const coordsA = a.coordinates || [0, 0];
const coordsB = b.coordinates || [0, 0];
if (coordsA[0] !== coordsB[0])
@@ -528,33 +532,14 @@ Item {
});
}
visible = visible.map(ws => ({
id: ws.id,
name: ws.name,
coordinates: ws.coordinates,
state: ws.state,
active: ws.active,
urgent: ws.urgent,
hidden: ws.hidden,
groupID: group.id
}));
return visible.length > 0 ? visible : [
{
"id": "1",
"name": "1",
"active": false
}
];
return visible.length > 0 ? visible : fallback;
}
function getExtWorkspaceActiveWorkspace() {
if (!ExtWorkspaceService.extWorkspaceAvailable) {
return 1;
}
const activeWs = ExtWorkspaceService.getActiveWorkspaceForOutput(root.screenName);
return activeWs ? (activeWs.id || activeWs.name || "1") : "1";
if (!extProjection)
return "";
const activeWs = extProjection.windowsets.find(ws => ws.active);
return activeWs ? (activeWs.id || activeWs.name || "") : "";
}
readonly property real dpr: parentScreen ? CompositorService.getScreenScale(parentScreen) : 1
@@ -566,7 +551,7 @@ Item {
function getRealWorkspaces() {
return root.workspaceList.filter(ws => {
if (useExtWorkspace)
return ws && (ws.id !== "" || ws.name !== "") && !ws.hidden;
return ws && !ws._placeholder;
if (CompositorService.isNiri)
return ws && ws.idx !== -1;
if (CompositorService.isHyprland)
@@ -583,8 +568,9 @@ Item {
if (!data)
return;
if (root.useExtWorkspace && (data.id || data.name)) {
ExtWorkspaceService.activateWorkspace(data.id || data.name, data.groupID || "");
if (root.useExtWorkspace) {
if (typeof data.activate === "function")
data.activate();
return;
}
@@ -649,7 +635,8 @@ Item {
}
const nextWorkspace = realWorkspaces[nextIndex];
ExtWorkspaceService.activateWorkspace(nextWorkspace.id || nextWorkspace.name, nextWorkspace.groupID || "");
if (typeof nextWorkspace.activate === "function")
nextWorkspace.activate();
} else if (CompositorService.isNiri) {
const realWorkspaces = getRealWorkspaces();
if (realWorkspaces.length < 2) {
@@ -1013,7 +1000,7 @@ Item {
}
property bool isPlaceholder: {
if (root.useExtWorkspace)
return !!(modelData && modelData.hidden);
return !!(modelData && modelData._placeholder);
if (CompositorService.isNiri)
return !!(modelData && modelData.idx === -1);
if (CompositorService.isHyprland)
@@ -1313,8 +1300,9 @@ Item {
return;
if (mouse.button === Qt.LeftButton) {
if (root.useExtWorkspace && (modelData?.id || modelData?.name)) {
ExtWorkspaceService.activateWorkspace(modelData.id || modelData.name, modelData.groupID || "");
if (root.useExtWorkspace) {
if (typeof modelData?.activate === "function")
modelData.activate();
} else if (CompositorService.isNiri) {
if (modelData && modelData.id !== undefined) {
NiriService.switchToWorkspace(modelData.id);
@@ -1941,9 +1929,9 @@ Item {
}
}
Connections {
target: ExtWorkspaceService
target: WindowManager
enabled: root.useExtWorkspace
function onStateChanged() {
function onWindowsetsChanged() {
delegateRoot.updateAllData();
}
}
@@ -1952,9 +1940,6 @@ Item {
}
Component.onCompleted: {
if (useExtWorkspace && !DMSService.activeSubscriptions.includes("extworkspace")) {
DMSService.addSubscription("extworkspace");
}
_updateBlurRegistration();
}