pragma ComponentBehavior: Bound

import QtQuick
import Quickshell

Variants {
	model: Quickshell.screens

	Scope {
		id: scope

		required property ShellScreen modelData

		function rebuild(): void {
			loader.active = false;
			loader.active = true;
		}

		LazyLoader {
			id: loader

			active: true

			Drawer {
				screen: scope.modelData
			}
		}

		Connections {
			function onConfigPositionChanged(): void {
				Qt.callLater(scope.rebuild);
			}

			target: (loader.item as Drawer)?.geometry ?? null
		}
	}

	component Drawer: Scope {
		id: drawer

		readonly property alias geometry: content.geometry
		required property ShellScreen screen

		Exclusions {
			bar: content.bar
			geometry: content.geometry
			screen: drawer.screen
		}

		Windows {
			id: content

			screen: drawer.screen
		}
	}
}
