mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-01-28 15:32:50 -05:00
compositor service & use toplevels instead of niri data
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import Quickshell
|
||||
import Quickshell.Wayland
|
||||
import QtQuick
|
||||
import qs.Common
|
||||
import qs.Services
|
||||
@@ -12,6 +13,7 @@ Rectangle {
|
||||
readonly property int baseWidth: contentRow.implicitWidth + Theme.spacingS * 2
|
||||
readonly property int maxNormalWidth: 456
|
||||
readonly property int maxCompactWidth: 288
|
||||
readonly property Toplevel activeWindow: ToplevelManager.activeToplevel
|
||||
|
||||
width: compactMode ? Math.min(baseWidth,
|
||||
maxCompactWidth) : Math.min(baseWidth,
|
||||
@@ -19,7 +21,7 @@ Rectangle {
|
||||
height: 30
|
||||
radius: Theme.cornerRadius
|
||||
color: {
|
||||
if (!NiriService.focusedWindowTitle)
|
||||
if (!activeWindow || !activeWindow.title)
|
||||
return "transparent"
|
||||
|
||||
const baseColor = mouseArea.containsMouse ? Theme.primaryHover : Theme.surfaceTextHover
|
||||
@@ -27,7 +29,7 @@ Rectangle {
|
||||
baseColor.a * Theme.widgetTransparency)
|
||||
}
|
||||
clip: true
|
||||
visible: NiriService.niriAvailable && NiriService.focusedWindowTitle
|
||||
visible: activeWindow && activeWindow.title
|
||||
|
||||
Row {
|
||||
id: contentRow
|
||||
@@ -39,18 +41,12 @@ Rectangle {
|
||||
id: appText
|
||||
|
||||
text: {
|
||||
if (!NiriService.focusedWindowId)
|
||||
if (!activeWindow || !activeWindow.appId)
|
||||
return ""
|
||||
|
||||
var window = NiriService.windows.find(w => {
|
||||
return w.id == NiriService.focusedWindowId
|
||||
})
|
||||
if (!window || !window.app_id)
|
||||
return ""
|
||||
|
||||
var desktopEntry = DesktopEntries.byId(window.app_id)
|
||||
var desktopEntry = DesktopEntries.byId(activeWindow.appId)
|
||||
return desktopEntry
|
||||
&& desktopEntry.name ? desktopEntry.name : window.app_id
|
||||
&& desktopEntry.name ? desktopEntry.name : activeWindow.appId
|
||||
}
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
font.weight: Font.Medium
|
||||
@@ -74,7 +70,7 @@ Rectangle {
|
||||
id: titleText
|
||||
|
||||
text: {
|
||||
var title = NiriService.focusedWindowTitle || ""
|
||||
var title = activeWindow && activeWindow.title ? activeWindow.title : ""
|
||||
var appName = appText.text
|
||||
|
||||
if (!title || !appName)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import QtQuick
|
||||
import QtQuick.Controls
|
||||
import Quickshell
|
||||
import Quickshell.Wayland
|
||||
import Quickshell.Widgets
|
||||
import qs.Common
|
||||
import qs.Services
|
||||
@@ -15,7 +16,8 @@ Rectangle {
|
||||
property var topBar: null
|
||||
// The visual root for this window
|
||||
property Item windowRoot: (Window.window ? Window.window.contentItem : null)
|
||||
readonly property int windowCount: NiriService.windows.length
|
||||
readonly property var sortedToplevels: CompositorService.sortedToplevels
|
||||
readonly property int windowCount: sortedToplevels.length
|
||||
readonly property int calculatedWidth: {
|
||||
if (windowCount === 0)
|
||||
return 0
|
||||
@@ -50,16 +52,15 @@ Rectangle {
|
||||
Repeater {
|
||||
id: windowRepeater
|
||||
|
||||
model: NiriService.windows
|
||||
model: sortedToplevels
|
||||
|
||||
delegate: Item {
|
||||
id: delegateItem
|
||||
|
||||
property bool isFocused: String(modelData.id) === String(
|
||||
NiriService.focusedWindowId)
|
||||
property string appId: modelData.app_id || ""
|
||||
property bool isFocused: modelData.activated
|
||||
property string appId: modelData.appId || ""
|
||||
property string windowTitle: modelData.title || "(Unnamed)"
|
||||
property int windowId: modelData.id
|
||||
property var toplevelObject: modelData
|
||||
property string tooltipText: {
|
||||
var appName = "Unknown"
|
||||
if (appId) {
|
||||
@@ -176,7 +177,9 @@ Rectangle {
|
||||
hoverEnabled: true
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
onClicked: {
|
||||
NiriService.focusWindow(windowId)
|
||||
if (toplevelObject) {
|
||||
toplevelObject.activate()
|
||||
}
|
||||
}
|
||||
onEntered: {
|
||||
root.hoveredItem = delegateItem
|
||||
|
||||
@@ -24,7 +24,7 @@ Rectangle {
|
||||
}
|
||||
|
||||
function getDisplayWorkspaces() {
|
||||
if (!NiriService.niriAvailable
|
||||
if (!CompositorService.isNiri
|
||||
|| NiriService.allWorkspaces.length === 0)
|
||||
return [1, 2]
|
||||
|
||||
@@ -41,7 +41,7 @@ Rectangle {
|
||||
}
|
||||
|
||||
function getDisplayActiveWorkspace() {
|
||||
if (!NiriService.niriAvailable
|
||||
if (!CompositorService.isNiri
|
||||
|| NiriService.allWorkspaces.length === 0)
|
||||
return 1
|
||||
|
||||
@@ -68,7 +68,7 @@ Rectangle {
|
||||
return Qt.rgba(baseColor.r, baseColor.g, baseColor.b,
|
||||
baseColor.a * Theme.widgetTransparency)
|
||||
}
|
||||
visible: NiriService.niriAvailable
|
||||
visible: CompositorService.isNiri
|
||||
|
||||
Connections {
|
||||
function onAllWorkspacesChanged() {
|
||||
@@ -83,16 +83,10 @@ Rectangle {
|
||||
root.currentWorkspace = root.getDisplayActiveWorkspace()
|
||||
}
|
||||
|
||||
function onNiriAvailableChanged() {
|
||||
if (NiriService.niriAvailable) {
|
||||
root.workspaceList = SettingsData.showWorkspacePadding ? root.padWorkspaces(root.getDisplayWorkspaces()) : root.getDisplayWorkspaces()
|
||||
root.currentWorkspace = root.getDisplayActiveWorkspace()
|
||||
}
|
||||
}
|
||||
|
||||
target: NiriService
|
||||
}
|
||||
|
||||
|
||||
Connections {
|
||||
function onShowWorkspacePaddingChanged() {
|
||||
var baseList = root.getDisplayWorkspaces()
|
||||
@@ -118,7 +112,7 @@ Rectangle {
|
||||
property bool isHovered: mouseArea.containsMouse
|
||||
property int sequentialNumber: index + 1
|
||||
property var workspaceData: {
|
||||
if (isPlaceholder || !NiriService.niriAvailable)
|
||||
if (isPlaceholder || !CompositorService.isNiri)
|
||||
return null
|
||||
for (var i = 0; i < NiriService.allWorkspaces.length; i++) {
|
||||
var ws = NiriService.allWorkspaces[i]
|
||||
|
||||
Reference in New Issue
Block a user