Skip to content

Commit

Permalink
fix: wlr output manager get wrong position
Browse files Browse the repository at this point in the history
  • Loading branch information
wineee committed Jan 5, 2024
1 parent 8fa8ded commit fddcf11
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 25 deletions.
52 changes: 39 additions & 13 deletions src/treeland/quick/qml/Main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -141,24 +141,26 @@ Item {
id: outputManagerV1

onRequestTestOrApply: function(config, onlyTest) {
var states = outputManagerV1.stateListPending();
var ok = true;
var states = outputManagerV1.stateListPending()
var ok = true

for (const i in states) {
let output = states[i].output;
output.enable(states[i].enabled);
let output = states[i].output
output.enable(states[i].enabled)
if (states[i].enabled) {
if (states[i].mode)
output.setMode(states[i].mode);
output.setMode(states[i].mode)
else
output.setCustomMode(states[i].custom_mode_size,
states[i].custom_mode_refresh);
states[i].custom_mode_refresh)

output.enableAdaptiveSync(states[i].adaptive_sync_enabled);
output.enableAdaptiveSync(states[i].adaptive_sync_enabled)
if (!onlyTest) {
let outputDelegate = output.OutputItem.item
outputDelegate.setTransform(states[i].transform)
outputDelegate.setScale(states[i].scale)
outputDelegate.setOutputPosition(states[i].x, states[i].y)
outputDelegate.x = states[i].x
outputDelegate.y = states[i].y
}
}

Expand All @@ -167,10 +169,24 @@ Item {
output.rollback()
} else {
ok &= output.commit()
if (ok)
updateRenderWindowSize()
}
}
outputManagerV1.sendResult(config, ok)
}

function updateRenderWindowSize() {
var states = outputManagerV1.stateListPending()
var maxX = 0, maxY = 0
for (const i in states) {
let outputDelegate = states[i].output.OutputItem.item
maxX = Math.max(maxX, outputDelegate.x + outputDelegate.width)
maxY = Math.max(maxY, outputDelegate.y + outputDelegate.height)
}
outputLayout.xRange = maxX
outputLayout.yRange = maxY
}
}

TreelandOutputManager {
Expand Down Expand Up @@ -256,16 +272,18 @@ Item {
id: renderWindow

compositor: compositor
width: outputRowLayout.implicitWidth + outputRowLayout.x
height: outputRowLayout.implicitHeight + outputRowLayout.y
width: outputLayout.xRange + outputLayout.x
height: outputLayout.yRange + outputLayout.y

EventJunkman {
anchors.fill: parent
}

Row {
// TODO: Row may break output position setting of OutputManager
id: outputRowLayout
Item {
id: outputLayout

property int xRange: 0
property int yRange: 0

DynamicCreatorComponent {
id: outputDelegateCreator
Expand All @@ -274,6 +292,14 @@ Item {
OutputDelegate {
property real topMargin: topbar.height
waylandCursor: cursor1

Component.onCompleted: {
x = outputLayout.xRange
y = 0
outputLayout.xRange += width
if (outputLayout.yRange < height)
outputLayout.yRange = height
}
}
}
}
Expand Down
12 changes: 0 additions & 12 deletions src/treeland/quick/qml/OutputDelegate.qml
Original file line number Diff line number Diff line change
Expand Up @@ -222,13 +222,6 @@ OutputItem {
}
}

Button {
text: "2X"
onClicked: {
waylandOutput.scale = 2
}
}

Button {
text: "Normal"
onClicked: {
Expand Down Expand Up @@ -266,9 +259,4 @@ OutputItem {
function setScale(scale) {
onscreenViewport.setOutputScale(scale)
}

function setOutputPosition(x, y) {
rootOutputItem.x = x;
rootOutputItem.y = y;
}
}

0 comments on commit fddcf11

Please sign in to comment.