river: update to wlroots 0.16

This commit is contained in:
Isaac Freund
2022-11-11 20:25:21 +01:00
parent 5eb0e23780
commit 489a49735a
34 changed files with 289 additions and 369 deletions

View File

@ -32,7 +32,7 @@ pub fn borderWidth(
if (args.len < 2) return Error.NotEnoughArguments;
if (args.len > 2) return Error.TooManyArguments;
server.config.border_width = try fmt.parseInt(u32, args[1], 10);
server.config.border_width = try fmt.parseInt(u31, args[1], 10);
server.root.arrangeAll();
server.root.startTransaction();
}

View File

@ -120,7 +120,7 @@ fn csdFilterUpdateViews(kind: FilterKind, pattern: []const u8, operation: enum {
const view = @intToPtr(*View, xdg_toplevel_decoration.surface.data);
if (viewMatchesPattern(kind, pattern, view)) {
const toplevel = view.impl.xdg_toplevel.xdg_surface.role_data.toplevel;
const toplevel = view.impl.xdg_toplevel.xdg_toplevel;
switch (operation) {
.add => {
_ = xdg_toplevel_decoration.setMode(.client_side);

View File

@ -24,7 +24,6 @@ const PhysicalDirection = @import("../command.zig").PhysicalDirection;
const Orientation = @import("../command.zig").Orientation;
const Seat = @import("../Seat.zig");
const View = @import("../View.zig");
const Box = @import("../Box.zig");
pub fn move(
seat: *Seat,
@ -61,15 +60,15 @@ pub fn snap(
return Error.InvalidPhysicalDirection;
const view = getView(seat) orelse return;
const border_width = @intCast(i32, server.config.border_width);
const output_box = view.output.getEffectiveResolution();
const border_width = server.config.border_width;
var output_width: i32 = undefined;
var output_height: i32 = undefined;
view.output.wlr_output.effectiveResolution(&output_width, &output_height);
switch (direction) {
.up => view.pending.box.y = border_width,
.down => view.pending.box.y =
@intCast(i32, output_box.height - view.pending.box.height) - border_width,
.down => view.pending.box.y = output_width - view.pending.box.height - border_width,
.left => view.pending.box.x = border_width,
.right => view.pending.box.x =
@intCast(i32, output_box.width - view.pending.box.width) - border_width,
.right => view.pending.box.x = output_height - view.pending.box.width - border_width,
}
apply(view);
@ -88,44 +87,27 @@ pub fn resize(
return Error.InvalidOrientation;
const view = getView(seat) orelse return;
const border_width = @intCast(i32, server.config.border_width);
const output_box = view.output.getEffectiveResolution();
var output_width: i32 = undefined;
var output_height: i32 = undefined;
view.output.wlr_output.effectiveResolution(&output_width, &output_height);
switch (orientation) {
.horizontal => {
var real_delta: i32 = @intCast(i32, view.pending.box.width);
if (delta > 0) {
view.pending.box.width += @intCast(u32, delta);
} else {
// Prevent underflow
view.pending.box.width -=
math.min(view.pending.box.width, @intCast(u32, -1 * delta));
}
view.pending.box.width += delta;
view.applyConstraints();
// Do not grow bigger than the output
view.pending.box.width = math.min(
view.pending.box.width,
output_box.width - @intCast(u32, 2 * border_width),
output_width - 2 * server.config.border_width,
);
real_delta -= @intCast(i32, view.pending.box.width);
view.move(@divFloor(real_delta, 2), 0);
},
.vertical => {
var real_delta: i32 = @intCast(i32, view.pending.box.height);
if (delta > 0) {
view.pending.box.height += @intCast(u32, delta);
} else {
// Prevent underflow
view.pending.box.height -=
math.min(view.pending.box.height, @intCast(u32, -1 * delta));
}
view.pending.box.height += delta;
view.applyConstraints();
// Do not grow bigger than the output
view.pending.box.height = math.min(
view.pending.box.height,
output_box.height - @intCast(u32, 2 * border_width),
output_height - 2 * server.config.border_width,
);
real_delta -= @intCast(i32, view.pending.box.height);
view.move(0, @divFloor(real_delta, 2));
},
}

View File

@ -86,12 +86,15 @@ fn getOutput(seat: *Seat, str: []const u8) !?*Output {
.previous => if (focused_node.prev) |node| &node.data else &server.root.outputs.last.?.data,
};
} else if (std.meta.stringToEnum(wlr.OutputLayout.Direction, str)) |direction| { // Spacial direction
const focus_box = server.root.output_layout.getBox(seat.focused_output.wlr_output) orelse return null;
var focus_box: wlr.Box = undefined;
server.root.output_layout.getBox(seat.focused_output.wlr_output, &focus_box);
if (focus_box.empty()) return null;
const wlr_output = server.root.output_layout.adjacentOutput(
direction,
seat.focused_output.wlr_output,
@intToFloat(f64, focus_box.x + @divFloor(focus_box.width, 2)),
@intToFloat(f64, focus_box.y + @divFloor(focus_box.height, 2)),
@intToFloat(f64, focus_box.x + @divTrunc(focus_box.width, 2)),
@intToFloat(f64, focus_box.y + @divTrunc(focus_box.height, 2)),
) orelse return null;
return @intToPtr(*Output, wlr_output.data);
} else {

View File

@ -39,7 +39,7 @@ pub fn setRepeat(
var it = server.input_manager.devices.iterator(.forward);
while (it.next()) |device| {
if (device.wlr_device.type == .keyboard) {
device.wlr_device.device.keyboard.setRepeatInfo(rate, delay);
device.wlr_device.toKeyboard().setRepeatInfo(rate, delay);
}
}
}

View File

@ -18,7 +18,6 @@ const std = @import("std");
const server = &@import("../main.zig").server;
const Box = @import("../Box.zig");
const Error = @import("../command.zig").Error;
const Seat = @import("../Seat.zig");