mirror of
https://github.com/zoriya/noctalia-shell.git
synced 2026-06-05 11:40:00 +00:00
Call compositor backend actions with model reference
This allows the compositor backend to decide what property to use when invoking the action
This commit is contained in:
@@ -105,13 +105,13 @@ Rectangle {
|
||||
|
||||
if (mouse.button === Qt.LeftButton) {
|
||||
try {
|
||||
CompositorService.focusWindow(taskbarItem.modelData.id)
|
||||
CompositorService.focusWindow(taskbarItem.modelData)
|
||||
} catch (error) {
|
||||
Logger.error("Taskbar", "Failed to activate toplevel: " + error)
|
||||
}
|
||||
} else if (mouse.button === Qt.RightButton) {
|
||||
try {
|
||||
CompositorService.closeWindow(taskbarItem.modelData.id)
|
||||
CompositorService.closeWindow(taskbarItem.modelData)
|
||||
} catch (error) {
|
||||
Logger.error("Taskbar", "Failed to close toplevel: " + error)
|
||||
}
|
||||
|
||||
@@ -119,7 +119,7 @@ Item {
|
||||
next = localWorkspaces.count - 1
|
||||
const ws = localWorkspaces.get(next)
|
||||
if (ws && ws.idx !== undefined)
|
||||
CompositorService.switchToWorkspace(ws.idx)
|
||||
CompositorService.switchToWorkspace(ws)
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
@@ -323,7 +323,7 @@ Item {
|
||||
anchors.fill: parent
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
onClicked: {
|
||||
CompositorService.switchToWorkspace(model.idx)
|
||||
CompositorService.switchToWorkspace(model)
|
||||
}
|
||||
hoverEnabled: true
|
||||
}
|
||||
@@ -467,7 +467,7 @@ Item {
|
||||
anchors.fill: parent
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
onClicked: {
|
||||
CompositorService.switchToWorkspace(model.idx)
|
||||
CompositorService.switchToWorkspace(model)
|
||||
}
|
||||
hoverEnabled: true
|
||||
}
|
||||
|
||||
@@ -145,9 +145,9 @@ Singleton {
|
||||
}
|
||||
|
||||
// Generic workspace switching
|
||||
function switchToWorkspace(workspaceId) {
|
||||
function switchToWorkspace(workspace) {
|
||||
if (backend && backend.switchToWorkspace) {
|
||||
backend.switchToWorkspace(workspaceId)
|
||||
backend.switchToWorkspace(workspace)
|
||||
} else {
|
||||
Logger.warn("Compositor", "No backend available for workspace switching")
|
||||
}
|
||||
@@ -177,18 +177,18 @@ Singleton {
|
||||
}
|
||||
|
||||
// Set focused window
|
||||
function focusWindow(windowId) {
|
||||
function focusWindow(window) {
|
||||
if (backend && backend.focusWindow) {
|
||||
backend.focusWindow(windowId)
|
||||
backend.focusWindow(window)
|
||||
} else {
|
||||
Logger.warn("Compositor", "No backend available for window focus")
|
||||
}
|
||||
}
|
||||
|
||||
// Close window
|
||||
function closeWindow(windowId) {
|
||||
function closeWindow(window) {
|
||||
if (backend && backend.closeWindow) {
|
||||
backend.closeWindow(windowId)
|
||||
backend.closeWindow(window)
|
||||
} else {
|
||||
Logger.warn("Compositor", "No backend available for window closing")
|
||||
}
|
||||
|
||||
@@ -272,25 +272,25 @@ Item {
|
||||
}
|
||||
|
||||
// Public functions
|
||||
function switchToWorkspace(workspaceId) {
|
||||
function switchToWorkspace(workspace) {
|
||||
try {
|
||||
Hyprland.dispatch(`workspace ${workspaceId}`)
|
||||
Hyprland.dispatch(`workspace ${workspace.idx}`)
|
||||
} catch (e) {
|
||||
Logger.error("HyprlandService", "Failed to switch workspace:", e)
|
||||
}
|
||||
}
|
||||
|
||||
function focusWindow(windowId) {
|
||||
function focusWindow(window) {
|
||||
try {
|
||||
Hyprland.dispatch(`focuswindow address:0x${windowId.toString()}`)
|
||||
Hyprland.dispatch(`focuswindow address:0x${window.id.toString()}`)
|
||||
} catch (e) {
|
||||
Logger.error("HyprlandService", "Failed to switch window:", e)
|
||||
}
|
||||
}
|
||||
|
||||
function closeWindow(windowId) {
|
||||
function closeWindow(window) {
|
||||
try {
|
||||
Hyprland.dispatch(`killwindow address:0x${windowId}`)
|
||||
Hyprland.dispatch(`killwindow address:0x${window.id}`)
|
||||
} catch (e) {
|
||||
Logger.error("HyprlandService", "Failed to close window:", e)
|
||||
}
|
||||
|
||||
@@ -332,25 +332,25 @@ Item {
|
||||
}
|
||||
|
||||
// Public functions
|
||||
function switchToWorkspace(workspaceId) {
|
||||
function switchToWorkspace(workspace) {
|
||||
try {
|
||||
Quickshell.execDetached(["niri", "msg", "action", "focus-workspace", workspaceId.toString()])
|
||||
Quickshell.execDetached(["niri", "msg", "action", "focus-workspace", workspace.idx.toString()])
|
||||
} catch (e) {
|
||||
Logger.error("NiriService", "Failed to switch workspace:", e)
|
||||
}
|
||||
}
|
||||
|
||||
function focusWindow(windowId) {
|
||||
function focusWindow(window) {
|
||||
try {
|
||||
Quickshell.execDetached(["niri", "msg", "action", "focus-window", "--id", windowId.toString()])
|
||||
Quickshell.execDetached(["niri", "msg", "action", "focus-window", "--id", window.id.toString()])
|
||||
} catch (e) {
|
||||
Logger.error("NiriService", "Failed to switch window:", e)
|
||||
}
|
||||
}
|
||||
|
||||
function closeWindow(windowId) {
|
||||
function closeWindow(window) {
|
||||
try {
|
||||
Quickshell.execDetached(["niri", "msg", "action", "close-window", "--id", windowId.toString()])
|
||||
Quickshell.execDetached(["niri", "msg", "action", "close-window", "--id", window.id.toString()])
|
||||
} catch (e) {
|
||||
Logger.error("NiriService", "Failed to close window:", e)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user