mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-01-31 08:52:49 -05:00
Workspace click fix
This commit is contained in:
@@ -241,18 +241,27 @@ Singleton {
|
|||||||
return switchToWorkspace(workspace.id)
|
return switchToWorkspace(workspace.id)
|
||||||
}
|
}
|
||||||
|
|
||||||
function switchToWorkspaceByNumber(number) {
|
function switchToWorkspaceByNumber(number, output) {
|
||||||
if (!niriAvailable) return false
|
if (!niriAvailable) return false
|
||||||
|
|
||||||
// Find workspace by number (1-based)
|
var targetOutput = output || currentOutput
|
||||||
var workspace = allWorkspaces.find(w => (w.idx + 1) === number)
|
if (!targetOutput) {
|
||||||
if (workspace) {
|
console.warn("NiriWorkspaceService: No output specified for workspace switching")
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get workspaces for the target output, sorted by idx
|
||||||
|
var outputWorkspaces = allWorkspaces.filter(w => w.output === targetOutput).sort((a, b) => a.idx - b.idx)
|
||||||
|
|
||||||
|
// Use sequential index (number is 1-based, array is 0-based)
|
||||||
|
if (number >= 1 && number <= outputWorkspaces.length) {
|
||||||
|
var workspace = outputWorkspaces[number - 1]
|
||||||
|
console.log("DEBUG: Switching to workspace ID", workspace.id, "for sequential number", number, "on", targetOutput)
|
||||||
return switchToWorkspace(workspace.id)
|
return switchToWorkspace(workspace.id)
|
||||||
}
|
}
|
||||||
|
|
||||||
// If not found, try to switch by number directly
|
console.warn("NiriWorkspaceService: No workspace", number, "found on output", targetOutput)
|
||||||
Quickshell.execDetached(["niri", "msg", "action", "focus-workspace", number.toString()])
|
return false
|
||||||
return true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function getWorkspaceByIndex(index) {
|
function getWorkspaceByIndex(index) {
|
||||||
|
|||||||
@@ -300,15 +300,11 @@ EOF`
|
|||||||
Connections {
|
Connections {
|
||||||
target: NiriWorkspaceService
|
target: NiriWorkspaceService
|
||||||
function onAllWorkspacesChanged() {
|
function onAllWorkspacesChanged() {
|
||||||
var oldCurrent = workspaceSwitcher.currentWorkspace
|
|
||||||
workspaceSwitcher.workspaceList = workspaceSwitcher.getDisplayWorkspaces()
|
workspaceSwitcher.workspaceList = workspaceSwitcher.getDisplayWorkspaces()
|
||||||
workspaceSwitcher.currentWorkspace = workspaceSwitcher.getDisplayActiveWorkspace()
|
workspaceSwitcher.currentWorkspace = workspaceSwitcher.getDisplayActiveWorkspace()
|
||||||
console.log("DEBUG: TopBar onAllWorkspacesChanged for", topBar.screenName, "- current workspace:", oldCurrent, "→", workspaceSwitcher.currentWorkspace)
|
|
||||||
}
|
}
|
||||||
function onFocusedWorkspaceIndexChanged() {
|
function onFocusedWorkspaceIndexChanged() {
|
||||||
var oldCurrent = workspaceSwitcher.currentWorkspace
|
|
||||||
workspaceSwitcher.currentWorkspace = workspaceSwitcher.getDisplayActiveWorkspace()
|
workspaceSwitcher.currentWorkspace = workspaceSwitcher.getDisplayActiveWorkspace()
|
||||||
console.log("DEBUG: TopBar onFocusedWorkspaceIndexChanged for", topBar.screenName, "- current workspace:", oldCurrent, "→", workspaceSwitcher.currentWorkspace)
|
|
||||||
}
|
}
|
||||||
function onNiriAvailableChanged() {
|
function onNiriAvailableChanged() {
|
||||||
if (NiriWorkspaceService.niriAvailable) {
|
if (NiriWorkspaceService.niriAvailable) {
|
||||||
@@ -329,6 +325,7 @@ EOF`
|
|||||||
Rectangle {
|
Rectangle {
|
||||||
property bool isActive: modelData === workspaceSwitcher.currentWorkspace
|
property bool isActive: modelData === workspaceSwitcher.currentWorkspace
|
||||||
property bool isHovered: mouseArea.containsMouse
|
property bool isHovered: mouseArea.containsMouse
|
||||||
|
property int sequentialNumber: index + 1 // 1-based sequential number per monitor
|
||||||
|
|
||||||
|
|
||||||
width: isActive ? Theme.spacingXL + Theme.spacingS : Theme.spacingL
|
width: isActive ? Theme.spacingXL + Theme.spacingS : Theme.spacingL
|
||||||
@@ -359,13 +356,8 @@ EOF`
|
|||||||
cursorShape: Qt.PointingHandCursor
|
cursorShape: Qt.PointingHandCursor
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
// Use NiriWorkspaceService for workspace switching
|
// Use sequential workspace number directly - niri focus-workspace uses 1,2,3,etc per monitor
|
||||||
if (NiriWorkspaceService.niriAvailable) {
|
Quickshell.execDetached(["niri", "msg", "action", "focus-workspace", sequentialNumber.toString()])
|
||||||
NiriWorkspaceService.switchToWorkspaceByNumber(modelData)
|
|
||||||
} else {
|
|
||||||
// Fallback for when service isn't ready
|
|
||||||
Quickshell.execDetached(["niri", "msg", "action", "focus-workspace", modelData.toString()])
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user