1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2026-04-14 09:42:10 -04:00

wallpaper: fix per-monitor view modes

fixes #1582
This commit is contained in:
bbedward
2026-02-11 17:58:44 -05:00
parent 0133c19276
commit 1a9d7684b9
7 changed files with 143 additions and 107 deletions

View File

@@ -58,6 +58,7 @@ Singleton {
property string wallpaperPathDark: "" property string wallpaperPathDark: ""
property var monitorWallpapersLight: ({}) property var monitorWallpapersLight: ({})
property var monitorWallpapersDark: ({}) property var monitorWallpapersDark: ({})
property var monitorWallpaperFillModes: ({})
property string wallpaperTransition: "fade" property string wallpaperTransition: "fade"
readonly property var availableWallpaperTransitions: ["none", "fade", "wipe", "disc", "stripes", "iris bloom", "pixelate", "portal"] readonly property var availableWallpaperTransitions: ["none", "fade", "wipe", "disc", "stripes", "iris bloom", "pixelate", "portal"]
property var includedTransitions: availableWallpaperTransitions.filter(t => t !== "none") property var includedTransitions: availableWallpaperTransitions.filter(t => t !== "none")
@@ -1094,11 +1095,7 @@ Singleton {
wallpaperPath = isLightMode ? wallpaperPathLight : wallpaperPathDark; wallpaperPath = isLightMode ? wallpaperPathLight : wallpaperPathDark;
} }
function getMonitorWallpaper(screenName) { function _findMonitorValue(map, screenName) {
if (!perMonitorWallpaper) {
return wallpaperPath;
}
var screen = null; var screen = null;
var screens = Quickshell.screens; var screens = Quickshell.screens;
for (var i = 0; i < screens.length; i++) { for (var i = 0; i < screens.length; i++) {
@@ -1108,52 +1105,72 @@ Singleton {
} }
} }
if (!screen) { if (!screen)
return monitorWallpapers[screenName] || wallpaperPath; return map[screenName];
if (map[screen.name] !== undefined)
return map[screen.name];
if (screen.model && map[screen.model] !== undefined)
return map[screen.model];
if (typeof SettingsData !== "undefined") {
var displayName = SettingsData.getScreenDisplayName(screen);
if (displayName && map[displayName] !== undefined)
return map[displayName];
}
return undefined;
}
function getMonitorWallpaper(screenName) {
if (!perMonitorWallpaper)
return wallpaperPath;
var value = _findMonitorValue(monitorWallpapers, screenName);
return value !== undefined ? value : wallpaperPath;
}
function getMonitorWallpaperFillMode(screenName) {
var globalFillMode = (typeof SettingsData !== "undefined") ? SettingsData.wallpaperFillMode : "Fill";
if (!perMonitorWallpaper)
return globalFillMode;
var value = _findMonitorValue(monitorWallpaperFillModes, screenName);
return value !== undefined ? value : globalFillMode;
}
function setMonitorWallpaperFillMode(screenName, mode) {
var screen = null;
var screens = Quickshell.screens;
for (var i = 0; i < screens.length; i++) {
if (screens[i].name === screenName) {
screen = screens[i];
break;
}
} }
if (monitorWallpapers[screen.name]) { if (!screen)
return monitorWallpapers[screen.name]; return;
}
if (screen.model && monitorWallpapers[screen.model]) { var identifier = typeof SettingsData !== "undefined" ? SettingsData.getScreenDisplayName(screen) : screen.name;
return monitorWallpapers[screen.model];
var newModes = {};
for (var key in monitorWallpaperFillModes) {
var isThisScreen = key === screen.name || (screen.model && key === screen.model);
if (!isThisScreen)
newModes[key] = monitorWallpaperFillModes[key];
} }
return wallpaperPath; newModes[identifier] = mode;
monitorWallpaperFillModes = newModes;
saveSettings();
} }
function getMonitorCyclingSettings(screenName) { function getMonitorCyclingSettings(screenName) {
var screen = null; var defaults = {
var screens = Quickshell.screens;
for (var i = 0; i < screens.length; i++) {
if (screens[i].name === screenName) {
screen = screens[i];
break;
}
}
if (!screen) {
return monitorCyclingSettings[screenName] || {
"enabled": false,
"mode": "interval",
"interval": 300,
"time": "06:00"
};
}
if (monitorCyclingSettings[screen.name]) {
return monitorCyclingSettings[screen.name];
}
if (screen.model && monitorCyclingSettings[screen.model]) {
return monitorCyclingSettings[screen.model];
}
return {
"enabled": false, "enabled": false,
"mode": "interval", "mode": "interval",
"interval": 300, "interval": 300,
"time": "06:00" "time": "06:00"
}; };
var value = _findMonitorValue(monitorCyclingSettings, screenName);
return value !== undefined ? value : defaults;
} }
FileView { FileView {

View File

@@ -45,11 +45,12 @@ Singleton {
if (typeof SessionData === "undefined") if (typeof SessionData === "undefined")
return ""; return "";
var monitors = SessionData.monitorWallpapers;
if (SessionData.perMonitorWallpaper) { if (SessionData.perMonitorWallpaper) {
var screens = Quickshell.screens; var screens = Quickshell.screens;
if (screens.length > 0) { if (screens.length > 0) {
var firstMonitorWallpaper = SessionData.getMonitorWallpaper(screens[0].name); var s = screens[0];
return firstMonitorWallpaper || SessionData.wallpaperPath; return monitors[s.name] || (s.model ? monitors[s.model] : "") || SessionData.wallpaperPath;
} }
} }
@@ -59,6 +60,7 @@ Singleton {
if (typeof SessionData === "undefined") if (typeof SessionData === "undefined")
return ""; return "";
var monitors = SessionData.monitorWallpapers;
if (SessionData.perMonitorWallpaper) { if (SessionData.perMonitorWallpaper) {
var screens = Quickshell.screens; var screens = Quickshell.screens;
if (screens.length > 0) { if (screens.length > 0) {
@@ -72,12 +74,20 @@ Singleton {
} }
} }
if (!targetMonitorExists) { if (!targetMonitorExists)
targetMonitor = screens[0].name; targetMonitor = screens[0].name;
var s = null;
for (var j = 0; j < screens.length; j++) {
if (screens[j].name === targetMonitor) {
s = screens[j];
break;
}
} }
var targetMonitorWallpaper = SessionData.getMonitorWallpaper(targetMonitor); if (s)
return targetMonitorWallpaper || SessionData.wallpaperPath; return monitors[s.name] || (s.model ? monitors[s.model] : "") || SessionData.wallpaperPath;
return monitors[targetMonitor] || SessionData.wallpaperPath;
} }
} }

View File

@@ -12,6 +12,7 @@ var SPEC = {
wallpaperPathDark: { def: "" }, wallpaperPathDark: { def: "" },
monitorWallpapersLight: { def: {} }, monitorWallpapersLight: { def: {} },
monitorWallpapersDark: { def: {} }, monitorWallpapersDark: { def: {} },
monitorWallpaperFillModes: { def: {} },
wallpaperTransition: { def: "fade" }, wallpaperTransition: { def: "fade" },
includedTransitions: { def: ["fade", "wipe", "disc", "stripes", "iris bloom", "pixelate", "portal"] }, includedTransitions: { def: ["fade", "wipe", "disc", "stripes", "iris bloom", "pixelate", "portal"] },

View File

@@ -189,7 +189,7 @@ Variants {
smooth: true smooth: true
cache: true cache: true
sourceSize: Qt.size(root.textureWidth, root.textureHeight) sourceSize: Qt.size(root.textureWidth, root.textureHeight)
fillMode: root.getFillMode(SessionData.isGreeterMode ? GreetdSettings.wallpaperFillMode : SettingsData.wallpaperFillMode) fillMode: root.getFillMode(SessionData.isGreeterMode ? GreetdSettings.wallpaperFillMode : SessionData.getMonitorWallpaperFillMode(modelData.name))
} }
Image { Image {
@@ -201,7 +201,7 @@ Variants {
smooth: true smooth: true
cache: true cache: true
sourceSize: Qt.size(root.textureWidth, root.textureHeight) sourceSize: Qt.size(root.textureWidth, root.textureHeight)
fillMode: root.getFillMode(SessionData.isGreeterMode ? GreetdSettings.wallpaperFillMode : SettingsData.wallpaperFillMode) fillMode: root.getFillMode(SessionData.isGreeterMode ? GreetdSettings.wallpaperFillMode : SessionData.getMonitorWallpaperFillMode(modelData.name))
onStatusChanged: { onStatusChanged: {
if (status !== Image.Ready) if (status !== Image.Ready)

View File

@@ -166,7 +166,7 @@ Item {
var currentWallpaper = SessionData.getMonitorWallpaper(screenName); var currentWallpaper = SessionData.getMonitorWallpaper(screenName);
return (currentWallpaper && !currentWallpaper.startsWith("#")) ? encodeFileUrl(currentWallpaper) : ""; return (currentWallpaper && !currentWallpaper.startsWith("#")) ? encodeFileUrl(currentWallpaper) : "";
} }
fillMode: Theme.getFillMode(SettingsData.wallpaperFillMode) fillMode: Theme.getFillMode(SessionData.getMonitorWallpaperFillMode(screenName))
smooth: true smooth: true
asynchronous: false asynchronous: false
cache: true cache: true

View File

@@ -18,6 +18,26 @@ Item {
var screens = Quickshell.screens; var screens = Quickshell.screens;
return screens.length > 0 ? screens[0].name : ""; return screens.length > 0 ? screens[0].name : "";
} }
property string currentWallpaper: {
if (!SessionData.perMonitorWallpaper)
return SessionData.wallpaperPath;
var map = SessionData.monitorWallpapers;
var screens = Quickshell.screens;
for (var i = 0; i < screens.length; i++) {
if (screens[i].name !== selectedMonitorName)
continue;
var screen = screens[i];
if (map[screen.name] !== undefined)
return map[screen.name];
if (screen.model && map[screen.model] !== undefined)
return map[screen.model];
var displayName = SettingsData.getScreenDisplayName(screen);
if (displayName && map[displayName] !== undefined)
return map[displayName];
break;
}
return SessionData.wallpaperPath;
}
Component.onCompleted: { Component.onCompleted: {
WallpaperCyclingService.cyclingActive; WallpaperCyclingService.cyclingActive;
@@ -55,19 +75,22 @@ Item {
radius: Theme.cornerRadius radius: Theme.cornerRadius
color: Theme.surfaceVariant color: Theme.surfaceVariant
CachingImage { Image {
anchors.fill: parent anchors.fill: parent
anchors.margins: 1 anchors.margins: 1
imagePath: { source: {
var currentWallpaper = SessionData.perMonitorWallpaper ? SessionData.getMonitorWallpaper(selectedMonitorName) : SessionData.wallpaperPath; var wp = root.currentWallpaper;
return (currentWallpaper !== "" && !currentWallpaper.startsWith("#")) ? currentWallpaper : ""; if (wp === "" || wp.startsWith("#"))
return "";
if (wp.startsWith("file://"))
wp = wp.substring(7);
return "file://" + wp.split('/').map(s => encodeURIComponent(s)).join('/');
} }
fillMode: Image.PreserveAspectCrop fillMode: Image.PreserveAspectCrop
visible: { visible: root.currentWallpaper !== "" && !root.currentWallpaper.startsWith("#")
var currentWallpaper = SessionData.perMonitorWallpaper ? SessionData.getMonitorWallpaper(selectedMonitorName) : SessionData.wallpaperPath; sourceSize.width: 160
return currentWallpaper !== "" && !currentWallpaper.startsWith("#"); sourceSize.height: 160
} asynchronous: true
maxCacheSize: 160
layer.enabled: true layer.enabled: true
layer.effect: MultiEffect { layer.effect: MultiEffect {
maskEnabled: true maskEnabled: true
@@ -81,14 +104,8 @@ Item {
anchors.fill: parent anchors.fill: parent
anchors.margins: 1 anchors.margins: 1
radius: Theme.cornerRadius - 1 radius: Theme.cornerRadius - 1
color: { color: root.currentWallpaper.startsWith("#") ? root.currentWallpaper : "transparent"
var currentWallpaper = SessionData.perMonitorWallpaper ? SessionData.getMonitorWallpaper(selectedMonitorName) : SessionData.wallpaperPath; visible: root.currentWallpaper !== "" && root.currentWallpaper.startsWith("#")
return currentWallpaper.startsWith("#") ? currentWallpaper : "transparent";
}
visible: {
var currentWallpaper = SessionData.perMonitorWallpaper ? SessionData.getMonitorWallpaper(selectedMonitorName) : SessionData.wallpaperPath;
return currentWallpaper !== "" && currentWallpaper.startsWith("#");
}
} }
Rectangle { Rectangle {
@@ -106,10 +123,7 @@ Item {
name: "image" name: "image"
size: Theme.iconSizeLarge + 8 size: Theme.iconSizeLarge + 8
color: Theme.surfaceVariantText color: Theme.surfaceVariantText
visible: { visible: root.currentWallpaper === ""
var currentWallpaper = SessionData.perMonitorWallpaper ? SessionData.getMonitorWallpaper(selectedMonitorName) : SessionData.wallpaperPath;
return currentWallpaper === "";
}
} }
Rectangle { Rectangle {
@@ -162,8 +176,7 @@ Item {
onClicked: { onClicked: {
if (!PopoutService.colorPickerModal) if (!PopoutService.colorPickerModal)
return; return;
var currentWallpaper = SessionData.perMonitorWallpaper ? SessionData.getMonitorWallpaper(selectedMonitorName) : SessionData.wallpaperPath; PopoutService.colorPickerModal.selectedColor = root.currentWallpaper.startsWith("#") ? root.currentWallpaper : Theme.primary;
PopoutService.colorPickerModal.selectedColor = currentWallpaper.startsWith("#") ? currentWallpaper : Theme.primary;
PopoutService.colorPickerModal.pickerTitle = "Choose Wallpaper Color"; PopoutService.colorPickerModal.pickerTitle = "Choose Wallpaper Color";
PopoutService.colorPickerModal.onColorSelectedCallback = function (selectedColor) { PopoutService.colorPickerModal.onColorSelectedCallback = function (selectedColor) {
if (SessionData.perMonitorWallpaper) { if (SessionData.perMonitorWallpaper) {
@@ -182,10 +195,7 @@ Item {
height: 32 height: 32
radius: 16 radius: 16
color: Qt.rgba(255, 255, 255, 0.9) color: Qt.rgba(255, 255, 255, 0.9)
visible: { visible: root.currentWallpaper !== ""
var currentWallpaper = SessionData.perMonitorWallpaper ? SessionData.getMonitorWallpaper(selectedMonitorName) : SessionData.wallpaperPath;
return currentWallpaper !== "";
}
DankIcon { DankIcon {
anchors.centerIn: parent anchors.centerIn: parent
@@ -227,10 +237,7 @@ Item {
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
StyledText { StyledText {
text: { text: root.currentWallpaper ? root.currentWallpaper.split('/').pop() : "No wallpaper selected"
var currentWallpaper = SessionData.perMonitorWallpaper ? SessionData.getMonitorWallpaper(selectedMonitorName) : SessionData.wallpaperPath;
return currentWallpaper ? currentWallpaper.split('/').pop() : "No wallpaper selected";
}
font.pixelSize: Theme.fontSizeLarge font.pixelSize: Theme.fontSizeLarge
color: Theme.surfaceText color: Theme.surfaceText
elide: Text.ElideMiddle elide: Text.ElideMiddle
@@ -240,39 +247,27 @@ Item {
} }
StyledText { StyledText {
text: { text: root.currentWallpaper
var currentWallpaper = SessionData.perMonitorWallpaper ? SessionData.getMonitorWallpaper(selectedMonitorName) : SessionData.wallpaperPath;
return currentWallpaper ? currentWallpaper : "";
}
font.pixelSize: Theme.fontSizeSmall font.pixelSize: Theme.fontSizeSmall
color: Theme.surfaceVariantText color: Theme.surfaceVariantText
elide: Text.ElideMiddle elide: Text.ElideMiddle
maximumLineCount: 1 maximumLineCount: 1
width: parent.width width: parent.width
horizontalAlignment: Text.AlignLeft horizontalAlignment: Text.AlignLeft
visible: { visible: root.currentWallpaper !== ""
var currentWallpaper = SessionData.perMonitorWallpaper ? SessionData.getMonitorWallpaper(selectedMonitorName) : SessionData.wallpaperPath;
return currentWallpaper !== "";
}
} }
Row { Row {
anchors.left: parent.left anchors.left: parent.left
spacing: Theme.spacingS spacing: Theme.spacingS
layoutDirection: I18n.isRtl ? Qt.RightToLeft : Qt.LeftToRight layoutDirection: I18n.isRtl ? Qt.RightToLeft : Qt.LeftToRight
visible: { visible: root.currentWallpaper !== ""
var currentWallpaper = SessionData.perMonitorWallpaper ? SessionData.getMonitorWallpaper(selectedMonitorName) : SessionData.wallpaperPath;
return currentWallpaper !== "";
}
DankActionButton { DankActionButton {
buttonSize: 32 buttonSize: 32
iconName: "skip_previous" iconName: "skip_previous"
iconSize: Theme.iconSizeSmall iconSize: Theme.iconSizeSmall
enabled: { enabled: root.currentWallpaper && !root.currentWallpaper.startsWith("#") && !root.currentWallpaper.startsWith("we")
var currentWallpaper = SessionData.perMonitorWallpaper ? SessionData.getMonitorWallpaper(selectedMonitorName) : SessionData.wallpaperPath;
return currentWallpaper && !currentWallpaper.startsWith("#") && !currentWallpaper.startsWith("we");
}
opacity: enabled ? 1 : 0.5 opacity: enabled ? 1 : 0.5
backgroundColor: Theme.surfaceContainerHigh backgroundColor: Theme.surfaceContainerHigh
iconColor: Theme.surfaceText iconColor: Theme.surfaceText
@@ -289,10 +284,7 @@ Item {
buttonSize: 32 buttonSize: 32
iconName: "skip_next" iconName: "skip_next"
iconSize: Theme.iconSizeSmall iconSize: Theme.iconSizeSmall
enabled: { enabled: root.currentWallpaper && !root.currentWallpaper.startsWith("#") && !root.currentWallpaper.startsWith("we")
var currentWallpaper = SessionData.perMonitorWallpaper ? SessionData.getMonitorWallpaper(selectedMonitorName) : SessionData.wallpaperPath;
return currentWallpaper && !currentWallpaper.startsWith("#") && !currentWallpaper.startsWith("we");
}
opacity: enabled ? 1 : 0.5 opacity: enabled ? 1 : 0.5
backgroundColor: Theme.surfaceContainerHigh backgroundColor: Theme.surfaceContainerHigh
iconColor: Theme.surfaceText iconColor: Theme.surfaceText
@@ -311,10 +303,7 @@ Item {
Item { Item {
width: parent.width width: parent.width
height: fillModeGroup.height height: fillModeGroup.height
visible: { visible: root.currentWallpaper !== "" && !root.currentWallpaper.startsWith("#")
var currentWallpaper = SessionData.perMonitorWallpaper ? SessionData.getMonitorWallpaper(selectedMonitorName) : SessionData.wallpaperPath;
return currentWallpaper !== "" && !currentWallpaper.startsWith("#");
}
DankButtonGroup { DankButtonGroup {
id: fillModeGroup id: fillModeGroup
@@ -329,20 +318,39 @@ Item {
textSize: Theme.fontSizeSmall textSize: Theme.fontSizeSmall
checkEnabled: false checkEnabled: false
currentIndex: { currentIndex: {
return internalModes.indexOf(SettingsData.wallpaperFillMode); var mode = SessionData.perMonitorWallpaper ? SessionData.getMonitorWallpaperFillMode(selectedMonitorName) : SettingsData.wallpaperFillMode;
return internalModes.indexOf(mode);
} }
onSelectionChanged: (index, selected) => { onSelectionChanged: (index, selected) => {
if (!selected) if (!selected)
return; return;
SettingsData.set("wallpaperFillMode", internalModes[index]); if (SessionData.perMonitorWallpaper) {
SessionData.setMonitorWallpaperFillMode(selectedMonitorName, internalModes[index]);
} else {
SettingsData.set("wallpaperFillMode", internalModes[index]);
}
} }
Connections { Connections {
target: SettingsData target: SettingsData
function onWallpaperFillModeChanged() { function onWallpaperFillModeChanged() {
if (SessionData.perMonitorWallpaper)
return;
fillModeGroup.currentIndex = fillModeGroup.internalModes.indexOf(SettingsData.wallpaperFillMode); fillModeGroup.currentIndex = fillModeGroup.internalModes.indexOf(SettingsData.wallpaperFillMode);
} }
} }
Connections {
target: root
function onSelectedMonitorNameChanged() {
if (!SessionData.perMonitorWallpaper)
return;
fillModeGroup.currentIndex = Qt.binding(() => {
var mode = SessionData.perMonitorWallpaper ? SessionData.getMonitorWallpaperFillMode(selectedMonitorName) : SettingsData.wallpaperFillMode;
return fillModeGroup.internalModes.indexOf(mode);
});
}
}
} }
} }

View File

@@ -71,7 +71,7 @@ Variants {
} }
property real transitionProgress: 0 property real transitionProgress: 0
property real shaderFillMode: getFillMode(SettingsData.wallpaperFillMode) property real shaderFillMode: getFillMode(SessionData.getMonitorWallpaperFillMode(modelData.name))
property vector4d fillColor: Qt.vector4d(0, 0, 0, 1) property vector4d fillColor: Qt.vector4d(0, 0, 0, 1)
property real edgeSmoothness: 0.1 property real edgeSmoothness: 0.1
@@ -236,7 +236,7 @@ Variants {
smooth: true smooth: true
cache: true cache: true
sourceSize: Qt.size(root.textureWidth, root.textureHeight) sourceSize: Qt.size(root.textureWidth, root.textureHeight)
fillMode: root.getFillMode(SettingsData.wallpaperFillMode) fillMode: root.getFillMode(SessionData.getMonitorWallpaperFillMode(modelData.name))
} }
Image { Image {
@@ -249,7 +249,7 @@ Variants {
smooth: true smooth: true
cache: true cache: true
sourceSize: Qt.size(root.textureWidth, root.textureHeight) sourceSize: Qt.size(root.textureWidth, root.textureHeight)
fillMode: root.getFillMode(SettingsData.wallpaperFillMode) fillMode: root.getFillMode(SessionData.getMonitorWallpaperFillMode(modelData.name))
onStatusChanged: { onStatusChanged: {
if (status !== Image.Ready) if (status !== Image.Ready)