river: update for wlroots 0.13.0

This commit is contained in:
Isaac Freund
2021-04-08 00:21:17 +02:00
parent 3c1f1df0c0
commit 9e3e92050e
10 changed files with 104 additions and 59 deletions

View File

@ -239,7 +239,7 @@ fn handleButton(listener: *wl.Listener(*wlr.Pointer.event.Button), event: *wlr.P
// give it keyboard focus.
if (surface.isLayerSurface()) {
const wlr_layer_surface = wlr.LayerSurfaceV1.fromWlrSurface(surface);
if (wlr_layer_surface.current.keyboard_interactive) {
if (wlr_layer_surface.current.keyboard_interactive == .exclusive) {
const layer_surface = @intToPtr(*LayerSurface, wlr_layer_surface.data);
self.seat.focusOutput(layer_surface.output);
self.seat.setFocusRaw(.{ .layer = layer_surface });

View File

@ -348,7 +348,7 @@ pub fn arrangeLayers(self: *Self) void {
var it = self.getLayer(layer).last;
while (it) |node| : (it = node.prev) {
const layer_surface = &node.data;
if (layer_surface.wlr_layer_surface.current.keyboard_interactive) {
if (layer_surface.wlr_layer_surface.current.keyboard_interactive == .exclusive) {
break :outer layer_surface;
}
}
@ -368,7 +368,7 @@ pub fn arrangeLayers(self: *Self) void {
} else if (seat.focused == .layer) {
// If the seat is currently focusing a layer without keyboard
// interactivity, stop focusing that layer.
if (!seat.focused.layer.wlr_layer_surface.current.keyboard_interactive) {
if (seat.focused.layer.wlr_layer_surface.current.keyboard_interactive != .exclusive) {
seat.setFocusRaw(.{ .none = {} });
seat.focus(null);
}

View File

@ -517,14 +517,10 @@ fn applyHeadToOutput(head: *wlr.OutputConfigurationV1.Head, wlr_output: *wlr.Out
if (head.state.mode) |mode| {
wlr_output.setMode(mode);
} else {
std.log.scoped(.output_manager).info("custom modes are not supported until the next wlroots release: ignoring", .{});
// TODO(wlroots) uncomment the following lines when wlroots 0.13.0 is released
// See https://github.com/swaywm/wlroots/pull/2517
//const custom_mode = &head.state.custom_mode;
//wlr_output.setCustomMode(custom_mode.width, custom_mode.height, custom_mode.refresh);
const custom_mode = &head.state.custom_mode;
wlr_output.setCustomMode(custom_mode.width, custom_mode.height, custom_mode.refresh);
}
// TODO(wlroots) Figure out if this conversion is needed or if that is a bug in wlroots
wlr_output.setScale(@floatCast(f32, head.state.scale));
wlr_output.setScale(head.state.scale);
wlr_output.setTransform(head.state.transform);
}
}

View File

@ -78,7 +78,7 @@ pub fn init(self: *Self) !void {
errdefer self.sigterm_source.remove();
// This frees itself when the wl.Server is destroyed
self.backend = try wlr.Backend.autocreate(self.wl_server, null);
self.backend = try wlr.Backend.autocreate(self.wl_server);
// This backend is used to create a noop output for use when no actual
// outputs are available. This frees itself when the wl.Server is destroyed.
@ -140,7 +140,6 @@ pub fn deinit(self: *Self) void {
self.root.deinit();
self.noop_backend.destroy();
self.wl_server.destroy();
self.input_manager.deinit();

View File

@ -333,14 +333,14 @@ pub fn close(self: Self) void {
}
}
pub inline fn forEachPopup(
pub inline fn forEachPopupSurface(
self: Self,
comptime T: type,
iterator: fn (surface: *wlr.Surface, sx: c_int, sy: c_int, data: T) callconv(.C) void,
user_data: T,
) void {
switch (self.impl) {
.xdg_toplevel => |xdg_toplevel| xdg_toplevel.forEachPopup(T, iterator, user_data),
.xdg_toplevel => |xdg_toplevel| xdg_toplevel.forEachPopupSurface(T, iterator, user_data),
.xwayland_view => {},
}
}

View File

@ -104,13 +104,13 @@ pub fn close(self: Self) void {
self.xdg_surface.role_data.toplevel.sendClose();
}
pub inline fn forEachPopup(
pub inline fn forEachPopupSurface(
self: Self,
comptime T: type,
iterator: fn (surface: *wlr.Surface, sx: c_int, sy: c_int, data: T) callconv(.C) void,
user_data: T,
) void {
self.xdg_surface.forEachPopup(T, iterator, user_data);
self.xdg_surface.forEachPopupSurface(T, iterator, user_data);
}
/// Return the surface at output coordinates ox, oy and set sx, sy to the

View File

@ -54,7 +54,7 @@ pub fn renderOutput(output: *Output) void {
output.wlr_output.attachRender(null) catch return;
renderer.begin(output.wlr_output.width, output.wlr_output.height);
renderer.begin(@intCast(u32, output.wlr_output.width), @intCast(u32, output.wlr_output.height));
// Find the first visible fullscreen view in the stack if there is one
var it = ViewStack(View).iter(output.views.first, .forward, output.current.tags, renderFilter);
@ -130,18 +130,6 @@ pub fn renderOutput(output: *Output) void {
// on-screen.
renderer.end();
// 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;
output.wlr_output.transformedResolution(&w, &h);
var damage: pixman.Region32 = undefined;
damage.init();
_ = damage.unionRect(&damage, 0, 0, @intCast(c_uint, w), @intCast(c_uint, h));
output.wlr_output.setDamage(&damage);
}
// TODO: handle failure
output.wlr_output.commit() catch
log.err("output commit failed for {}", .{output.wlr_output.name});
@ -178,7 +166,7 @@ fn renderLayer(
renderSurfaceIterator,
&rdata,
),
.popups => layer_surface.wlr_layer_surface.forEachPopup(
.popups => layer_surface.wlr_layer_surface.forEachPopupSurface(
*SurfaceRenderData,
renderSurfaceIterator,
&rdata,
@ -227,24 +215,7 @@ fn renderViewPopups(output: *const Output, view: *View, now: *os.timespec) void
.when = now,
.opacity = view.opacity,
};
view.forEachPopup(*SurfaceRenderData, renderPopupSurfaceIterator, &rdata);
}
// TODO(wlroots): replace with wlr_xdg_surface_for_each_popup_surface()
fn renderPopupSurfaceIterator(
surface: *wlr.Surface,
surface_x: c_int,
surface_y: c_int,
rdata: *SurfaceRenderData,
) callconv(.C) void {
var new_rdata = SurfaceRenderData{
.output = rdata.output,
.output_x = rdata.output_x + surface_x,
.output_y = rdata.output_y + surface_y,
.when = rdata.when,
.opacity = rdata.opacity,
};
surface.forEachSurface(*SurfaceRenderData, renderSurfaceIterator, &new_rdata);
view.forEachPopupSurface(*SurfaceRenderData, renderSurfaceIterator, &rdata);
}
fn renderDragIcons(output: *const Output, now: *os.timespec) void {