1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2025-12-05 21:15:38 -05:00

dwl: support display scales

This commit is contained in:
bbedward
2025-10-29 13:45:22 -04:00
parent b294e391e7
commit 7b26692c8e
6 changed files with 62 additions and 46 deletions

View File

@@ -17,17 +17,7 @@ PanelWindow {
property real height: 300
readonly property real screenWidth: screen ? screen.width : 1920
readonly property real screenHeight: screen ? screen.height : 1080
readonly property real dpr: {
if (CompositorService.isNiri && screen) {
const niriScale = NiriService.displayScales[screen.name]
if (niriScale !== undefined) return niriScale
}
if (CompositorService.isHyprland && screen) {
const hyprlandMonitor = Hyprland.monitors.values.find(m => m.name === screen.name)
if (hyprlandMonitor?.scale !== undefined) return hyprlandMonitor.scale
}
return (screen?.devicePixelRatio) || 1
}
readonly property real dpr: CompositorService.getScreenScale(screen)
property bool showBackground: true
property real backgroundOpacity: 0.5
property string positioning: "center"

View File

@@ -18,17 +18,7 @@ Item {
anchors.topMargin: -(SettingsData.dankBarGothCornersEnabled && !axis.isVertical && axis.edge === "bottom" ? barWindow._wingR : 0)
anchors.bottomMargin: -(SettingsData.dankBarGothCornersEnabled && !axis.isVertical && axis.edge === "top" ? barWindow._wingR : 0)
readonly property real dpr: {
if (CompositorService.isNiri && barWindow.screen) {
const niriScale = NiriService.displayScales[barWindow.screen.name]
if (niriScale !== undefined) return niriScale
}
if (CompositorService.isHyprland && barWindow.screen) {
const hyprlandMonitor = Hyprland.monitors.values.find(m => m.name === barWindow.screen.name)
if (hyprlandMonitor?.scale !== undefined) return hyprlandMonitor.scale
}
return barWindow.screen?.devicePixelRatio || 1
}
readonly property real dpr: CompositorService.getScreenScale(barWindow.screen)
function requestRepaint() {
debounceTimer.restart()

View File

@@ -173,19 +173,7 @@ Item {
readonly property color _surfaceContainer: Theme.surfaceContainer
readonly property real _backgroundAlpha: topBarCore?.backgroundTransparency ?? SettingsData.dankBarTransparency
readonly property color _bgColor: Theme.withAlpha(_surfaceContainer, _backgroundAlpha)
readonly property real _dpr: {
if (CompositorService.isNiri && barWindow.screen) {
const niriScale = NiriService.displayScales[barWindow.screen.name]
if (niriScale !== undefined)
return niriScale
}
if (CompositorService.isHyprland && barWindow.screen) {
const hyprlandMonitor = Hyprland.monitors.values.find(m => m.name === barWindow.screen.name)
if (hyprlandMonitor?.scale !== undefined)
return hyprlandMonitor.scale
}
return (barWindow.screen?.devicePixelRatio) || 1
}
readonly property real _dpr: CompositorService.getScreenScale(barWindow.screen)
property string screenName: modelData.name
readonly property int notificationCount: NotificationService.notifications.length

View File

@@ -28,6 +28,27 @@ Singleton {
property var _coordCache: ({})
function getScreenScale(screen) {
if (!screen) return 1
if (isNiri && screen) {
const niriScale = NiriService.displayScales[screen.name]
if (niriScale !== undefined) return niriScale
}
if (isHyprland && screen) {
const hyprlandMonitor = Hyprland.monitors.values.find(m => m.name === screen.name)
if (hyprlandMonitor?.scale !== undefined) return hyprlandMonitor.scale
}
if (isDwl && screen) {
const dwlScale = DwlService.getOutputScale(screen.name)
if (dwlScale !== undefined && dwlScale > 0) return dwlScale
}
return screen?.devicePixelRatio || 1
}
Timer {
id: refreshTimer
interval: 40

View File

@@ -12,6 +12,7 @@ Singleton {
property var tagCount: 0
property var layouts: []
property string activeOutput: ""
property var outputScales: ({})
signal stateChanged()
@@ -38,6 +39,15 @@ Singleton {
if (DMSService.dmsAvailable) {
checkCapabilities()
}
refreshOutputScales()
}
Timer {
id: scaleRefreshTimer
interval: 2000
repeat: true
running: dwlAvailable
onTriggered: refreshOutputScales()
}
function checkCapabilities() {
@@ -167,4 +177,31 @@ Singleton {
function quit() {
Quickshell.execDetached(["mmsg", "-d", "quit"])
}
function refreshOutputScales() {
if (!dwlAvailable) return
Proc.runCommand("wlr-randr", ["--json"], (output, exitCode) => {
if (exitCode !== 0) {
console.warn("DwlService: wlr-randr failed with exit code:", exitCode)
return
}
try {
const outputData = JSON.parse(output)
const newScales = {}
for (const outputInfo of outputData) {
if (outputInfo.name && outputInfo.scale !== undefined) {
newScales[outputInfo.name] = outputInfo.scale
}
}
outputScales = newScales
} catch (e) {
console.warn("DwlService: Failed to parse wlr-randr output:", e)
}
}, 0)
}
function getOutputScale(outputName) {
return outputScales[outputName]
}
}

View File

@@ -75,17 +75,7 @@ PanelWindow {
readonly property real screenWidth: root.screen.width
readonly property real screenHeight: root.screen.height
readonly property real dpr: {
if (CompositorService.isNiri && root.screen) {
const niriScale = NiriService.displayScales[root.screen.name]
if (niriScale !== undefined) return niriScale
}
if (CompositorService.isHyprland && root.screen) {
const hyprlandMonitor = Hyprland.monitors.values.find(m => m.name === root.screen.name)
if (hyprlandMonitor?.scale !== undefined) return hyprlandMonitor.scale
}
return root.screen?.devicePixelRatio || 1
}
readonly property real dpr: CompositorService.getScreenScale(root.screen)
readonly property real alignedWidth: Theme.px(popupWidth, dpr)
readonly property real alignedHeight: Theme.px(popupHeight, dpr)