pragma ComponentBehavior: Bound

import Quickshell
import Quickshell.Hyprland
import QtQuick
import qs.Components
import qs.Helpers
import ZShell.Internal

Item {
	id: root

	readonly property var displayData: Wallpapers.getCrop(screen.name)
	required property ShellScreen screen
	property size screenResolution: Qt.size(screen.width * screenScale, screen.height * screenScale)
	property real screenScale: Hyprland.monitorFor(screen).scale

	anchors.fill: parent

	Component.onCompleted: Hyprland.refreshMonitors()

	WallpaperImage {
		id: img

		anchors.fill: parent
		cropHeight: root.displayData?.height ?? 1.0
		cropWidth: root.displayData?.width ?? 1.0
		cropX: root.displayData?.x ?? 0.0
		cropY: root.displayData?.y ?? 0.0
		fadeDuration: 150
		screenResolution: root.screenResolution
		source: Wallpapers.current

		Behavior on cropHeight {
			Anim {
			}
		}
		Behavior on cropWidth {
			Anim {
			}
		}
		Behavior on cropX {
			Anim {
			}
		}
		Behavior on cropY {
			Anim {
			}
		}
	}
}
