screencopy: add workaround for wlroots bug

Currently screencopy's copy_with_damage request is broken for
compositors not submitting damage. As a workaround simply damage
the whole output each frame.
This commit is contained in:
Isaac Freund 2020-12-05 01:10:06 +01:00
parent 807d4a4212
commit dae6c06e0c
No known key found for this signature in database
GPG key ID: 86DED400DDFD7A11
2 changed files with 14 additions and 0 deletions

View file

@ -124,6 +124,7 @@ fn addServerDeps(exe: *std.build.LibExeObjStep) void {
exe.linkSystemLibrary("wayland-server");
exe.linkSystemLibrary("wlroots");
exe.linkSystemLibrary("xkbcommon");
exe.linkSystemLibrary("pixman-1");
}
fn addProtocolDeps(exe: *std.build.LibExeObjStep, protocol_step: *std.build.Step) void {

View file

@ -124,6 +124,19 @@ pub fn renderOutput(output: *Output) void {
// Conclude rendering and swap the buffers, showing the final frame
// on-screen.
c.wlr_renderer_end(wlr_renderer);
// TODO(wlroots): remove this with the next release. It is here due to
// a wlroots bug in the screencopy damage implementation
{
var w: c_int = undefined;
var h: c_int = undefined;
c.wlr_output_transformed_resolution(output.wlr_output, &w, &h);
var damage: c.pixman_region32_t = undefined;
c.pixman_region32_init(&damage);
_ = c.pixman_region32_union_rect(&damage, &damage, 0, 0, @intCast(c_uint, w), @intCast(c_uint, h));
c.wlr_output_set_damage(output.wlr_output, &damage);
}
// TODO: handle failure
if (!c.wlr_output_commit(output.wlr_output)) {
log.err(.render, "wlr_output_commit failed for {}", .{output.wlr_output.name});