wlr-output-management: leverage new wlroots APIs
These new functions allow testing commits without messing up the pending state of the output and needing to rollback. The new apply() function also makes the code considerably more concise.
This commit is contained in:
2
deps/zig-wlroots
vendored
2
deps/zig-wlroots
vendored
Submodule deps/zig-wlroots updated: 04bcd67d52...0c3165f483
@ -19,6 +19,7 @@ const Self = @This();
|
|||||||
const build_options = @import("build_options");
|
const build_options = @import("build_options");
|
||||||
const std = @import("std");
|
const std = @import("std");
|
||||||
const assert = std.debug.assert;
|
const assert = std.debug.assert;
|
||||||
|
const mem = std.mem;
|
||||||
const wlr = @import("wlroots");
|
const wlr = @import("wlroots");
|
||||||
const wl = @import("wayland").server.wl;
|
const wl = @import("wayland").server.wl;
|
||||||
|
|
||||||
@ -450,58 +451,30 @@ fn processOutputConfig(
|
|||||||
const wlr_output = head.state.output;
|
const wlr_output = head.state.output;
|
||||||
const output = @intToPtr(*Output, wlr_output.data);
|
const output = @intToPtr(*Output, wlr_output.data);
|
||||||
|
|
||||||
if (head.state.enabled) {
|
var proposed_state = wlr.Output.State.init();
|
||||||
wlr_output.enable(true);
|
head.state.apply(&proposed_state);
|
||||||
|
|
||||||
if (head.state.mode) |mode| {
|
switch (action) {
|
||||||
wlr_output.setMode(mode);
|
.test_only => {
|
||||||
} else {
|
if (!wlr_output.testState(&proposed_state)) success = false;
|
||||||
const custom_mode = &head.state.custom_mode;
|
},
|
||||||
wlr_output.setCustomMode(custom_mode.width, custom_mode.height, custom_mode.refresh);
|
.apply => {
|
||||||
}
|
if (wlr_output.commitState(&proposed_state)) {
|
||||||
wlr_output.setScale(head.state.scale);
|
if (head.state.enabled) {
|
||||||
wlr_output.setTransform(head.state.transform);
|
|
||||||
wlr_output.enableAdaptiveSync(head.state.adaptive_sync_enabled);
|
|
||||||
|
|
||||||
switch (action) {
|
|
||||||
.test_only => {
|
|
||||||
if (!output.wlr_output.testCommit()) success = false;
|
|
||||||
output.wlr_output.rollback();
|
|
||||||
},
|
|
||||||
.apply => {
|
|
||||||
if (output.wlr_output.commit()) {
|
|
||||||
// Just updates the output's position if it is already in the layout
|
// Just updates the output's position if it is already in the layout
|
||||||
self.output_layout.add(output.wlr_output, head.state.x, head.state.y);
|
self.output_layout.add(output.wlr_output, head.state.x, head.state.y);
|
||||||
output.arrangeLayers(.mapped);
|
output.arrangeLayers(.mapped);
|
||||||
} else |_| {
|
} else {
|
||||||
std.log.scoped(.output_manager).err("failed to apply config to output {s}", .{output.wlr_output.name});
|
|
||||||
success = false;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// The output is already disabled, so there's nothing to do
|
|
||||||
if (!wlr_output.enabled) continue;
|
|
||||||
|
|
||||||
wlr_output.enable(false);
|
|
||||||
|
|
||||||
switch (action) {
|
|
||||||
.test_only => {
|
|
||||||
if (!output.wlr_output.testCommit()) success = false;
|
|
||||||
output.wlr_output.rollback();
|
|
||||||
},
|
|
||||||
.apply => {
|
|
||||||
if (output.wlr_output.commit()) {
|
|
||||||
self.removeOutput(output);
|
self.removeOutput(output);
|
||||||
self.output_layout.remove(output.wlr_output);
|
self.output_layout.remove(output.wlr_output);
|
||||||
} else |_| {
|
|
||||||
std.log.scoped(.output_manager).err("failed to apply config to output {s}", .{
|
|
||||||
output.wlr_output.name,
|
|
||||||
});
|
|
||||||
success = false;
|
|
||||||
}
|
}
|
||||||
},
|
} else |_| {
|
||||||
}
|
std.log.scoped(.output_manager).err("failed to apply config to output {s}", .{
|
||||||
|
output.wlr_output.name,
|
||||||
|
});
|
||||||
|
success = false;
|
||||||
|
}
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user