mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-06-08 04:09:15 -04:00
Fix Hyprland scrolling overview geometry (#2442)
This commit is contained in:
@@ -107,6 +107,24 @@ Item {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getWorkspaceViewportBounds(workspaceId) {
|
||||||
|
const workspace = allWorkspaces?.find(ws => ws?.id === workspaceId);
|
||||||
|
const mon = workspace?.monitor?.lastIpcObject || monitor?.lastIpcObject || {};
|
||||||
|
const reserved = mon.reserved || [0, 0, 0, 0];
|
||||||
|
|
||||||
|
const x = (mon.x ?? 0) + (reserved[0] ?? 0);
|
||||||
|
const y = (mon.y ?? 0) + (reserved[1] ?? 0);
|
||||||
|
const width = Math.max((mon.width ?? monitorPhysicalWidth) - (reserved[0] ?? 0) - (reserved[2] ?? 0), 1);
|
||||||
|
const height = Math.max((mon.height ?? monitorPhysicalHeight) - (reserved[1] ?? 0) - (reserved[3] ?? 0), 1);
|
||||||
|
const scale = Math.min(root.workspaceImplicitWidth / width, root.workspaceImplicitHeight / height);
|
||||||
|
|
||||||
|
return {
|
||||||
|
"x": x,
|
||||||
|
"y": y,
|
||||||
|
"scale": scale
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
property bool monitorIsFocused: monitor?.focused ?? false
|
property bool monitorIsFocused: monitor?.focused ?? false
|
||||||
property real scale: SettingsData.overviewScale
|
property real scale: SettingsData.overviewScale
|
||||||
property color activeBorderColor: Theme.primary
|
property color activeBorderColor: Theme.primary
|
||||||
@@ -223,7 +241,7 @@ Item {
|
|||||||
onClicked: {
|
onClicked: {
|
||||||
if (root.draggingTargetWorkspace === -1) {
|
if (root.draggingTargetWorkspace === -1) {
|
||||||
root.overviewOpen = false;
|
root.overviewOpen = false;
|
||||||
HyplandService.focusWorkspace(workspaceValue);
|
HyprlandService.focusWorkspace(workspaceValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -309,12 +327,16 @@ Item {
|
|||||||
readonly property int workspaceIndex: getWorkspaceIndex()
|
readonly property int workspaceIndex: getWorkspaceIndex()
|
||||||
readonly property int workspaceColIndex: workspaceIndex % root.effectiveColumns
|
readonly property int workspaceColIndex: workspaceIndex % root.effectiveColumns
|
||||||
readonly property int workspaceRowIndex: Math.floor(workspaceIndex / root.effectiveColumns)
|
readonly property int workspaceRowIndex: Math.floor(workspaceIndex / root.effectiveColumns)
|
||||||
|
readonly property var workspaceBounds: root.getWorkspaceViewportBounds(windowWorkspaceId)
|
||||||
|
|
||||||
toplevel: modelData
|
toplevel: modelData
|
||||||
scale: root.scale
|
scale: root.scale
|
||||||
monitorDpr: root.dpr
|
monitorDpr: root.dpr
|
||||||
availableWorkspaceWidth: root.workspaceImplicitWidth
|
availableWorkspaceWidth: root.workspaceImplicitWidth
|
||||||
availableWorkspaceHeight: root.workspaceImplicitHeight
|
availableWorkspaceHeight: root.workspaceImplicitHeight
|
||||||
|
contentOriginX: workspaceBounds.x
|
||||||
|
contentOriginY: workspaceBounds.y
|
||||||
|
contentScale: workspaceBounds.scale
|
||||||
widgetMonitorId: root.monitor.id
|
widgetMonitorId: root.monitor.id
|
||||||
|
|
||||||
xOffset: (root.workspaceImplicitWidth + workspaceSpacing) * workspaceColIndex
|
xOffset: (root.workspaceImplicitWidth + workspaceSpacing) * workspaceColIndex
|
||||||
|
|||||||
@@ -14,20 +14,34 @@ Item {
|
|||||||
property var availableWorkspaceHeight
|
property var availableWorkspaceHeight
|
||||||
property bool restrictToWorkspace: true
|
property bool restrictToWorkspace: true
|
||||||
property real monitorDpr: 1
|
property real monitorDpr: 1
|
||||||
|
property real contentOriginX: 0
|
||||||
|
property real contentOriginY: 0
|
||||||
|
property real contentScale: 0
|
||||||
|
|
||||||
readonly property var windowData: toplevel?.lastIpcObject || null
|
readonly property var windowData: toplevel?.lastIpcObject || null
|
||||||
readonly property var monitorObj: toplevel?.monitor
|
readonly property var monitorObj: toplevel?.monitor
|
||||||
readonly property var monitorData: monitorObj?.lastIpcObject || null
|
readonly property var monitorData: monitorObj?.lastIpcObject || null
|
||||||
readonly property real effectiveScale: root.scale / root.monitorDpr
|
readonly property real effectiveScale: root.scale / root.monitorDpr
|
||||||
|
readonly property real overviewScale: root.contentScale > 0 ? root.contentScale : root.effectiveScale
|
||||||
|
|
||||||
property real initX: Math.max(((windowData?.at?.[0] ?? 0) - (monitorData?.x ?? 0) - (monitorData?.reserved?.[0] ?? 0)) * effectiveScale, 0) + xOffset
|
readonly property real rawX: ((windowData?.at?.[0] ?? 0) - contentOriginX) * overviewScale
|
||||||
property real initY: Math.max(((windowData?.at?.[1] ?? 0) - (monitorData?.y ?? 0) - (monitorData?.reserved?.[1] ?? 0)) * effectiveScale, 0) + yOffset
|
readonly property real rawY: ((windowData?.at?.[1] ?? 0) - contentOriginY) * overviewScale
|
||||||
|
readonly property real rawWidth: (windowData?.size?.[0] ?? 100) * overviewScale
|
||||||
|
readonly property real rawHeight: (windowData?.size?.[1] ?? 100) * overviewScale
|
||||||
|
readonly property real clipLeft: Math.max(0, rawX)
|
||||||
|
readonly property real clipTop: Math.max(0, rawY)
|
||||||
|
readonly property real clipRight: Math.min(availableWorkspaceWidth, rawX + rawWidth)
|
||||||
|
readonly property real clipBottom: Math.min(availableWorkspaceHeight, rawY + rawHeight)
|
||||||
|
readonly property bool intersectsViewport: clipRight > clipLeft && clipBottom > clipTop
|
||||||
|
|
||||||
|
property real initX: clipLeft + xOffset
|
||||||
|
property real initY: clipTop + yOffset
|
||||||
property real xOffset: 0
|
property real xOffset: 0
|
||||||
property real yOffset: 0
|
property real yOffset: 0
|
||||||
property int widgetMonitorId: 0
|
property int widgetMonitorId: 0
|
||||||
|
|
||||||
property var targetWindowWidth: (windowData?.size?.[0] ?? 100) * effectiveScale
|
property var targetWindowWidth: Math.max(clipRight - clipLeft, 0)
|
||||||
property var targetWindowHeight: (windowData?.size?.[1] ?? 100) * effectiveScale
|
property var targetWindowHeight: Math.max(clipBottom - clipTop, 0)
|
||||||
property bool hovered: false
|
property bool hovered: false
|
||||||
property bool pressed: false
|
property bool pressed: false
|
||||||
|
|
||||||
@@ -39,8 +53,9 @@ Item {
|
|||||||
|
|
||||||
x: initX
|
x: initX
|
||||||
y: initY
|
y: initY
|
||||||
width: Math.min((windowData?.size?.[0] ?? 100) * effectiveScale, availableWorkspaceWidth)
|
width: targetWindowWidth
|
||||||
height: Math.min((windowData?.size?.[1] ?? 100) * effectiveScale, availableWorkspaceHeight)
|
height: targetWindowHeight
|
||||||
|
visible: intersectsViewport
|
||||||
opacity: (monitorObj?.id ?? -1) == widgetMonitorId ? 1 : 0.4
|
opacity: (monitorObj?.id ?? -1) == widgetMonitorId ? 1 : 0.4
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
|
|||||||
Reference in New Issue
Block a user