diff --git a/kcm/package/contents/ui/Output.qml b/kcm/package/contents/ui/Output.qml --- a/kcm/package/contents/ui/Output.qml +++ b/kcm/package/contents/ui/Output.qml @@ -23,6 +23,8 @@ Rectangle { id: output + property rect visibleBounds + property bool isSelected: root.selectedOutput === model.index onIsSelectedChanged: { @@ -263,6 +265,14 @@ var newY = dragStartPosition.y + translation.y; model.position = getAbsolutePosition(Qt.point(newX, newY)); } + onActiveChanged: { + if (!active && visibleBounds.width > 0 && visibleBounds.height > 0) { + // When dragging stops, ensure screens are within bounds + var newX = Math.max(visibleBounds.left - width, Math.min(visibleBounds.right, dragStartPosition.x + translation.x)); + var newY = Math.max(visibleBounds.top - height, Math.min(visibleBounds.bottom, dragStartPosition.y + translation.y)); + model.position = getAbsolutePosition(Qt.point(newX, newY)); + } + } } } diff --git a/kcm/package/contents/ui/Screen.qml b/kcm/package/contents/ui/Screen.qml --- a/kcm/package/contents/ui/Screen.qml +++ b/kcm/package/contents/ui/Screen.qml @@ -20,6 +20,8 @@ import org.kde.kirigami 2.5 as Kirigami Controls.ScrollView { + id: screenView + property var outputs property size totalSize @@ -76,8 +78,10 @@ Repeater { model: kcm.outputModel - delegate: Output {} - + delegate: Output { + // Ensure a corner of a screen always stays visible + visibleBounds: Qt.rect(20, 20, screenView.width - 40, screenView.height - 40) + } onCountChanged: resetTotalSize() } }