mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-01-27 23:12:49 -05:00
hyprland repairs
This commit is contained in:
@@ -9,6 +9,7 @@ import qs.Widgets
|
||||
Item {
|
||||
id: root
|
||||
|
||||
clip: false
|
||||
property var appData
|
||||
property var contextMenu: null
|
||||
property var dockApps: null
|
||||
@@ -23,6 +24,20 @@ Item {
|
||||
property string windowTitle: ""
|
||||
property bool isHovered: mouseArea.containsMouse && !dragging
|
||||
property bool showTooltip: mouseArea.containsMouse && !dragging
|
||||
property bool isWindowFocused: {
|
||||
if (!appData || appData.type !== "window") {
|
||||
return false
|
||||
}
|
||||
|
||||
var toplevels = CompositorService.sortedToplevels
|
||||
for (var i = 0; i < toplevels.length; i++) {
|
||||
var toplevel = toplevels[i]
|
||||
if (toplevel.appId === appData.appId) {
|
||||
return toplevel.activated
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
property string tooltipText: {
|
||||
if (!appData)
|
||||
return ""
|
||||
@@ -198,13 +213,17 @@ Item {
|
||||
"comment": desktopEntry.comment || ""
|
||||
})
|
||||
|
||||
Quickshell.execDetached(
|
||||
["gtk-launch", appData.appId])
|
||||
desktopEntry.execute()
|
||||
}
|
||||
} else if (appData.type === "window") {
|
||||
// Focus the specific window using toplevel
|
||||
if (appData.toplevelObject) {
|
||||
appData.toplevelObject.activate()
|
||||
// Find the toplevel by matching appId from sorted list
|
||||
var toplevels = CompositorService.sortedToplevels
|
||||
for (var i = 0; i < toplevels.length; i++) {
|
||||
var toplevel = toplevels[i]
|
||||
if (toplevel.appId === appData.appId && toplevel.title === appData.windowTitle) {
|
||||
toplevel.activate()
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (mouse.button === Qt.MiddleButton) {
|
||||
@@ -224,8 +243,7 @@ Item {
|
||||
|| ""
|
||||
})
|
||||
|
||||
Quickshell.execDetached(
|
||||
["gtk-launch", appData.appId])
|
||||
desktopEntry.execute()
|
||||
}
|
||||
} else if (mouse.button === Qt.RightButton) {
|
||||
if (contextMenu)
|
||||
@@ -237,9 +255,8 @@ Item {
|
||||
IconImage {
|
||||
id: iconImg
|
||||
|
||||
width: 40
|
||||
height: 40
|
||||
anchors.centerIn: parent
|
||||
implicitSize: 40
|
||||
source: {
|
||||
if (!appData || !appData.appId)
|
||||
return ""
|
||||
@@ -253,11 +270,9 @@ Item {
|
||||
}
|
||||
return ""
|
||||
}
|
||||
smooth: true
|
||||
mipmap: true
|
||||
smooth: true
|
||||
asynchronous: true
|
||||
visible: status === Image.Ready
|
||||
implicitSize: 40
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
@@ -302,7 +317,7 @@ Item {
|
||||
return "transparent"
|
||||
|
||||
// For window type, check if focused using reactive property
|
||||
if (appData.type === "window" && appData.toplevelObject && appData.toplevelObject.activated)
|
||||
if (isWindowFocused)
|
||||
return Theme.primary
|
||||
|
||||
// For running apps, show dimmer indicator
|
||||
|
||||
@@ -157,6 +157,7 @@ Item {
|
||||
dockModel.updateModel()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Connections {
|
||||
|
||||
@@ -10,62 +10,69 @@ Rectangle {
|
||||
id: root
|
||||
|
||||
property string screenName: ""
|
||||
property int currentWorkspace: getDisplayActiveWorkspace()
|
||||
property int currentWorkspace: {
|
||||
if (CompositorService.isNiri) {
|
||||
return getNiriActiveWorkspace()
|
||||
} else if (CompositorService.isHyprland) {
|
||||
return Hyprland.focusedWorkspace ? Hyprland.focusedWorkspace.id : 1
|
||||
}
|
||||
return 1
|
||||
}
|
||||
property var workspaceList: {
|
||||
var baseList = getDisplayWorkspaces()
|
||||
return SettingsData.showWorkspacePadding ? padWorkspaces(
|
||||
baseList) : baseList
|
||||
if (CompositorService.isNiri) {
|
||||
var baseList = getNiriWorkspaces()
|
||||
return SettingsData.showWorkspacePadding ? padWorkspaces(baseList) : baseList
|
||||
} else if (CompositorService.isHyprland) {
|
||||
var workspaces = Hyprland.workspaces ? Hyprland.workspaces.values : []
|
||||
if (workspaces.length === 0) {
|
||||
return [{id: 1, name: "1"}]
|
||||
}
|
||||
var sorted = workspaces.slice().sort((a, b) => a.id - b.id)
|
||||
return SettingsData.showWorkspacePadding ? padWorkspaces(sorted) : sorted
|
||||
}
|
||||
return [1]
|
||||
}
|
||||
|
||||
function padWorkspaces(list) {
|
||||
var padded = list.slice()
|
||||
while (padded.length < 3)
|
||||
padded.push(-1) // Use -1 as a placeholder
|
||||
while (padded.length < 3) {
|
||||
if (CompositorService.isHyprland) {
|
||||
padded.push({id: -1, name: ""})
|
||||
} else {
|
||||
padded.push(-1)
|
||||
}
|
||||
}
|
||||
return padded
|
||||
}
|
||||
|
||||
function getDisplayWorkspaces() {
|
||||
if (CompositorService.isNiri) {
|
||||
if (NiriService.allWorkspaces.length === 0)
|
||||
return [1, 2]
|
||||
function getNiriWorkspaces() {
|
||||
if (NiriService.allWorkspaces.length === 0)
|
||||
return [1, 2]
|
||||
|
||||
if (!root.screenName)
|
||||
return NiriService.getCurrentOutputWorkspaceNumbers()
|
||||
if (!root.screenName)
|
||||
return NiriService.getCurrentOutputWorkspaceNumbers()
|
||||
|
||||
var displayWorkspaces = []
|
||||
for (var i = 0; i < NiriService.allWorkspaces.length; i++) {
|
||||
var ws = NiriService.allWorkspaces[i]
|
||||
if (ws.output === root.screenName)
|
||||
displayWorkspaces.push(ws.idx + 1)
|
||||
}
|
||||
return displayWorkspaces.length > 0 ? displayWorkspaces : [1, 2]
|
||||
} else if (CompositorService.isHyprland) {
|
||||
var workspaces = HyprlandService.getWorkspaceDisplayNumbers()
|
||||
return workspaces.length > 0 ? workspaces : [1]
|
||||
var displayWorkspaces = []
|
||||
for (var i = 0; i < NiriService.allWorkspaces.length; i++) {
|
||||
var ws = NiriService.allWorkspaces[i]
|
||||
if (ws.output === root.screenName)
|
||||
displayWorkspaces.push(ws.idx + 1)
|
||||
}
|
||||
|
||||
return [1, 2]
|
||||
return displayWorkspaces.length > 0 ? displayWorkspaces : [1, 2]
|
||||
}
|
||||
|
||||
function getDisplayActiveWorkspace() {
|
||||
if (CompositorService.isNiri) {
|
||||
if (NiriService.allWorkspaces.length === 0)
|
||||
return 1
|
||||
|
||||
if (!root.screenName)
|
||||
return NiriService.getCurrentWorkspaceNumber()
|
||||
|
||||
for (var i = 0; i < NiriService.allWorkspaces.length; i++) {
|
||||
var ws = NiriService.allWorkspaces[i]
|
||||
if (ws.output === root.screenName && ws.is_active)
|
||||
return ws.idx + 1
|
||||
}
|
||||
function getNiriActiveWorkspace() {
|
||||
if (NiriService.allWorkspaces.length === 0)
|
||||
return 1
|
||||
} else if (CompositorService.isHyprland) {
|
||||
var activeWs = HyprlandService.getCurrentWorkspaceNumber()
|
||||
return activeWs
|
||||
|
||||
if (!root.screenName)
|
||||
return NiriService.getCurrentWorkspaceNumber()
|
||||
|
||||
for (var i = 0; i < NiriService.allWorkspaces.length; i++) {
|
||||
var ws = NiriService.allWorkspaces[i]
|
||||
if (ws.output === root.screenName && ws.is_active)
|
||||
return ws.idx + 1
|
||||
}
|
||||
|
||||
return 1
|
||||
}
|
||||
|
||||
@@ -85,15 +92,14 @@ Rectangle {
|
||||
|
||||
Connections {
|
||||
function onAllWorkspacesChanged() {
|
||||
root.workspaceList
|
||||
= SettingsData.showWorkspacePadding ? root.padWorkspaces(
|
||||
root.getDisplayWorkspaces(
|
||||
)) : root.getDisplayWorkspaces()
|
||||
root.currentWorkspace = root.getDisplayActiveWorkspace()
|
||||
if (CompositorService.isNiri) {
|
||||
root.workspaceList = SettingsData.showWorkspacePadding ? root.padWorkspaces(
|
||||
root.getNiriWorkspaces()) : root.getNiriWorkspaces()
|
||||
}
|
||||
}
|
||||
|
||||
function onFocusedWorkspaceIndexChanged() {
|
||||
root.currentWorkspace = root.getDisplayActiveWorkspace()
|
||||
// Niri workspace changes handled automatically by currentWorkspace binding
|
||||
}
|
||||
|
||||
target: NiriService
|
||||
@@ -101,32 +107,47 @@ Rectangle {
|
||||
}
|
||||
|
||||
Connections {
|
||||
function onWorkspacesUpdated() {
|
||||
root.workspaceList
|
||||
= SettingsData.showWorkspacePadding ? root.padWorkspaces(
|
||||
root.getDisplayWorkspaces(
|
||||
)) : root.getDisplayWorkspaces()
|
||||
root.currentWorkspace = root.getDisplayActiveWorkspace()
|
||||
function onValuesChanged() {
|
||||
if (CompositorService.isHyprland) {
|
||||
var workspaces = Hyprland.workspaces ? Hyprland.workspaces.values : []
|
||||
if (workspaces.length === 0) {
|
||||
workspaces = [{id: 1, name: "1"}]
|
||||
}
|
||||
var sorted = workspaces.slice().sort((a, b) => a.id - b.id)
|
||||
root.workspaceList = SettingsData.showWorkspacePadding ? root.padWorkspaces(sorted) : sorted
|
||||
}
|
||||
}
|
||||
|
||||
function onFocusedWorkspaceUpdated() {
|
||||
root.currentWorkspace = root.getDisplayActiveWorkspace()
|
||||
}
|
||||
|
||||
function onFocusedMonitorUpdated() {
|
||||
root.currentWorkspace = root.getDisplayActiveWorkspace()
|
||||
}
|
||||
|
||||
target: HyprlandService
|
||||
target: Hyprland.workspaces
|
||||
enabled: CompositorService.isHyprland
|
||||
}
|
||||
|
||||
Connections {
|
||||
function onFocusedWorkspaceChanged() {
|
||||
// Hyprland workspace changes handled automatically by currentWorkspace binding
|
||||
}
|
||||
|
||||
function onFocusedMonitorChanged() {
|
||||
// Hyprland monitor changes handled automatically by currentWorkspace binding
|
||||
}
|
||||
|
||||
target: Hyprland
|
||||
enabled: CompositorService.isHyprland
|
||||
}
|
||||
|
||||
Connections {
|
||||
function onShowWorkspacePaddingChanged() {
|
||||
var baseList = root.getDisplayWorkspaces()
|
||||
root.workspaceList = SettingsData.showWorkspacePadding ? root.padWorkspaces(
|
||||
baseList) : baseList
|
||||
if (CompositorService.isHyprland) {
|
||||
var workspaces = Hyprland.workspaces ? Hyprland.workspaces.values : []
|
||||
if (workspaces.length === 0) {
|
||||
workspaces = [{id: 1, name: "1"}]
|
||||
}
|
||||
var sorted = workspaces.slice().sort((a, b) => a.id - b.id)
|
||||
root.workspaceList = SettingsData.showWorkspacePadding ? root.padWorkspaces(sorted) : sorted
|
||||
} else {
|
||||
var baseList = root.getNiriWorkspaces()
|
||||
root.workspaceList = SettingsData.showWorkspacePadding ? root.padWorkspaces(baseList) : baseList
|
||||
}
|
||||
}
|
||||
|
||||
target: SettingsData
|
||||
@@ -142,10 +163,19 @@ Rectangle {
|
||||
model: root.workspaceList
|
||||
|
||||
Rectangle {
|
||||
property bool isActive: modelData === root.currentWorkspace
|
||||
property bool isPlaceholder: modelData === -1
|
||||
property bool isActive: {
|
||||
if (CompositorService.isHyprland) {
|
||||
return modelData && modelData.id === root.currentWorkspace
|
||||
}
|
||||
return modelData === root.currentWorkspace
|
||||
}
|
||||
property bool isPlaceholder: {
|
||||
if (CompositorService.isHyprland) {
|
||||
return modelData && modelData.id === -1
|
||||
}
|
||||
return modelData === -1
|
||||
}
|
||||
property bool isHovered: mouseArea.containsMouse
|
||||
property int sequentialNumber: index + 1
|
||||
property var workspaceData: {
|
||||
if (isPlaceholder)
|
||||
return null
|
||||
@@ -157,12 +187,7 @@ Rectangle {
|
||||
return ws
|
||||
}
|
||||
} else if (CompositorService.isHyprland) {
|
||||
var hyprWorkspaces = HyprlandService.getWorkspacesForMonitor(root.screenName)
|
||||
for (var j = 0; j < hyprWorkspaces.length; j++) {
|
||||
var hws = hyprWorkspaces[j]
|
||||
if (hws.id === modelData)
|
||||
return hws
|
||||
}
|
||||
return modelData
|
||||
}
|
||||
return null
|
||||
}
|
||||
@@ -189,13 +214,14 @@ Rectangle {
|
||||
if (CompositorService.isNiri) {
|
||||
NiriService.switchToWorkspace(modelData - 1)
|
||||
} else if (CompositorService.isHyprland) {
|
||||
Hyprland.dispatch(`workspace ${modelData}`)
|
||||
if (modelData && modelData.id) {
|
||||
Hyprland.dispatch(`workspace ${modelData.id}`)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Icon display (priority over numbers)
|
||||
DankIcon {
|
||||
visible: hasIcon && iconData.type === "icon"
|
||||
anchors.centerIn: parent
|
||||
@@ -209,7 +235,6 @@ Rectangle {
|
||||
weight: isActive && !isPlaceholder ? 500 : 400
|
||||
}
|
||||
|
||||
// Custom text display (priority over numbers)
|
||||
StyledText {
|
||||
visible: hasIcon && iconData.type === "text"
|
||||
anchors.centerIn: parent
|
||||
@@ -224,11 +249,15 @@ Rectangle {
|
||||
&& !isPlaceholder ? Font.DemiBold : Font.Normal
|
||||
}
|
||||
|
||||
// Number display (secondary priority, only when no icon)
|
||||
StyledText {
|
||||
visible: SettingsData.showWorkspaceIndex && !hasIcon
|
||||
anchors.centerIn: parent
|
||||
text: isPlaceholder ? sequentialNumber : sequentialNumber
|
||||
text: {
|
||||
if (CompositorService.isHyprland) {
|
||||
return modelData && modelData.id ? modelData.id : ""
|
||||
}
|
||||
return modelData
|
||||
}
|
||||
color: isActive ? Qt.rgba(
|
||||
Theme.surfaceContainer.r,
|
||||
Theme.surfaceContainer.g,
|
||||
@@ -255,4 +284,4 @@ Rectangle {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user