Skip to content

Commit

Permalink
build: update to wlroots 0.18.0
Browse files Browse the repository at this point in the history
  • Loading branch information
ifreund committed Jul 16, 2024
1 parent ccd676e commit 99ef96a
Show file tree
Hide file tree
Showing 21 changed files with 130 additions and 145 deletions.
10 changes: 6 additions & 4 deletions .builds/alpine.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,17 @@ sources:
tasks:
- install_deps: |
cd wayland
git checkout 1.22.0
git checkout 1.23.0
meson setup build -Ddocumentation=false -Dtests=false --prefix /usr
sudo ninja -C build install
cd ..
cd wlroots
git checkout 0.17.2
meson setup build --auto-features=enabled -Drenderers=gles2 -Dexamples=false \
-Dwerror=false -Db_ndebug=false -Dxcb-errors=disabled --prefix /usr
git checkout 0.18.0
meson setup build --auto-features=enabled -Drenderers=gles2 \
-Dcolor-management=disabled -Dlibliftoff=disabled \
-Dexamples=false -Dwerror=false -Db_ndebug=false \
-Dxcb-errors=disabled --prefix /usr
sudo ninja -C build/ install
cd ..
Expand Down
10 changes: 6 additions & 4 deletions .builds/archlinux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,17 @@ sources:
tasks:
- install_deps: |
cd wayland
git checkout 1.22.0
git checkout 1.23.0
meson setup build -Ddocumentation=false -Dtests=false --prefix /usr
sudo ninja -C build install
cd ..
cd wlroots
git checkout 0.17.2
meson setup build --auto-features=enabled -Drenderers=gles2 -Dexamples=false \
-Dwerror=false -Db_ndebug=false --prefix /usr
git checkout 0.18.0
meson setup build --auto-features=enabled -Drenderers=gles2 \
-Dcolor-management=disabled -Dlibliftoff=disabled \
-Dexamples=false -Dwerror=false -Db_ndebug=false \
-Dxcb-errors=disabled --prefix /usr
sudo ninja -C build/ install
cd ..
Expand Down
10 changes: 6 additions & 4 deletions .builds/freebsd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,17 @@ sources:
tasks:
- install_deps: |
cd wayland
git checkout 1.22.0
git checkout 1.23.0
meson setup build -Ddocumentation=false -Dtests=false --prefix /usr
sudo ninja -C build install
cd ..
cd wlroots
git checkout 0.17.2
meson setup build --auto-features=enabled -Drenderers=gles2 -Dexamples=false \
-Dwerror=false -Db_ndebug=false --prefix /usr
git checkout 0.18.0
meson setup build --auto-features=enabled -Drenderers=gles2 \
-Dcolor-management=disabled -Dlibliftoff=disabled \
-Dexamples=false -Dwerror=false -Db_ndebug=false \
-Dxcb-errors=disabled --prefix /usr
sudo ninja -C build/ install
cd ..
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ distribution.
- [zig](https://ziglang.org/download/) 0.13
- wayland
- wayland-protocols
- [wlroots](https://gitlab.freedesktop.org/wlroots/wlroots) 0.17.2
- [wlroots](https://gitlab.freedesktop.org/wlroots/wlroots) 0.18
- xkbcommon
- libevdev
- pixman
Expand Down
4 changes: 2 additions & 2 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ pub fn build(b: *Build) !void {
// exposed to the wlroots module for @cImport() to work. This seems to be
// the best way to do so with the current std.Build API.
wlroots.resolved_target = target;
wlroots.linkSystemLibrary("wlroots", .{});
wlroots.linkSystemLibrary("wlroots-0.18", .{});

const flags = b.createModule(.{ .root_source_file = b.path("common/flags.zig") });
const globber = b.createModule(.{ .root_source_file = b.path("common/globber.zig") });
Expand All @@ -167,7 +167,7 @@ pub fn build(b: *Build) !void {
river.linkSystemLibrary("libevdev");
river.linkSystemLibrary("libinput");
river.linkSystemLibrary("wayland-server");
river.linkSystemLibrary("wlroots");
river.linkSystemLibrary("wlroots-0.18");
river.linkSystemLibrary("xkbcommon");
river.linkSystemLibrary("pixman-1");

Expand Down
4 changes: 2 additions & 2 deletions build.zig.zon
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
.hash = "1220687c8c47a48ba285d26a05600f8700d37fc637e223ced3aa8324f3650bf52242",
},
.@"zig-wlroots" = .{
.url = "https://codeberg.org/ifreund/zig-wlroots/archive/084736cd92364b5fa7d8161611d085ce272fa707.tar.gz",
.hash = "12208383c1cf42e9b932b90f68cd4f378582cf966355a6377fd8f913852e7bc2d7c6",
.url = "https://codeberg.org/ifreund/zig-wlroots/archive/ae6151f22ceb4ccd7efb1291dea573785918a7ec.tar.gz",
.hash = "12204d99aebfbf88f1ff3ab197362937b3d4bef4f45fde9c4ee0d569e095a2a25889",
},
.@"zig-xkbcommon" = .{
.url = "https://codeberg.org/ifreund/zig-xkbcommon/archive/v0.2.0.tar.gz",
Expand Down
32 changes: 5 additions & 27 deletions river/Cursor.zig
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,7 @@ fn handleAxis(listener: *wl.Listener(*wlr.Pointer.event.Axis), event: *wlr.Point
math.maxInt(i32) / 2,
)),
event.source,
event.relative_direction,
);
}

Expand Down Expand Up @@ -568,7 +569,7 @@ fn handleTouchUp(
cursor.seat.handleActivity();

if (cursor.touch_points.remove(event.touch_id)) {
cursor.seat.wlr_seat.touchNotifyUp(event.time_msec, event.touch_id);
_ = cursor.seat.wlr_seat.touchNotifyUp(event.time_msec, event.touch_id);
}
}

Expand All @@ -582,32 +583,9 @@ fn handleTouchCancel(

cursor.touch_points.clearRetainingCapacity();

// We can't call touchNotifyCancel() from inside the loop over touch points as it also loops
// over touch points and may destroy multiple touch points in a single call.
//
// What we should do here is `while (touch_points.first()) |point| cancel()` but since the
// surface may be null we can't rely on the fact tha all touch points will be destroyed
// and risk an infinite loop if the surface of any wlr_touch_point is null.
//
// This is all really silly and totally unnecessary since all touchNotifyCancel() does with
// the surface argument is obtain a seat client and touch_point.seat_client is never null.
// TODO(wlroots) clean this up after the wlroots MR fixing this is merged:
// https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/4613

// The upper bound of 32 comes from an implementation detail of libinput which uses
// a 32-bit integer as a map to keep track of touch points.
var surfaces: std.BoundedArray(*wlr.Surface, 32) = .{};
{
var it = cursor.seat.wlr_seat.touch_state.touch_points.iterator(.forward);
while (it.next()) |touch_point| {
if (touch_point.surface) |surface| {
surfaces.append(surface) catch break;
}
}
}

for (surfaces.slice()) |surface| {
cursor.seat.wlr_seat.touchNotifyCancel(surface);
const wlr_seat = cursor.seat.wlr_seat;
while (wlr_seat.touch_state.touch_points.first()) |touch_point| {
wlr_seat.touchNotifyCancel(touch_point.client);
}
}

Expand Down
6 changes: 3 additions & 3 deletions river/InputConfig.zig
Original file line number Diff line number Diff line change
Expand Up @@ -232,22 +232,22 @@ pub const MapToOutput = struct {
};

switch (device.wlr_device.type) {
.pointer, .touch, .tablet_tool => {
.pointer, .touch, .tablet => {
log.debug("mapping input '{s}' -> '{s}'", .{
device.identifier,
if (wlr_output) |o| o.name else "<no output>",
});

device.seat.cursor.wlr_cursor.mapInputToOutput(device.wlr_device, wlr_output);

if (device.wlr_device.type == .tablet_tool) {
if (device.wlr_device.type == .tablet) {
const tablet: *Tablet = @fieldParentPtr("device", device);
tablet.output_mapping = wlr_output;
}
},

// These devices do not support being mapped to outputs.
.keyboard, .tablet_pad, .switch_device => {},
.keyboard, .tablet_pad, .@"switch" => {},
}
}
};
Expand Down
23 changes: 13 additions & 10 deletions river/InputDevice.zig
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const wl = @import("wayland").server.wl;

const globber = @import("globber");

const c = @import("c.zig");
const server = &@import("main.zig").server;
const util = @import("util.zig");

Expand Down Expand Up @@ -52,19 +53,21 @@ config: struct {
link: wl.list.Link,

pub fn init(device: *InputDevice, seat: *Seat, wlr_device: *wlr.InputDevice) !void {
const device_type: []const u8 = switch (wlr_device.type) {
.switch_device => "switch",
.tablet_tool => "tablet",
else => @tagName(wlr_device.type),
};
var vendor: c_uint = 0;
var product: c_uint = 0;

if (wlr_device.getLibinputDevice()) |d| {
vendor = c.libinput_device_get_id_vendor(@ptrCast(d));
product = c.libinput_device_get_id_product(@ptrCast(d));
}

const identifier = try std.fmt.allocPrint(
util.gpa,
"{s}-{}-{}-{s}",
.{
device_type,
wlr_device.vendor,
wlr_device.product,
@tagName(wlr_device.type),
vendor,
product,
mem.trim(u8, mem.sliceTo(wlr_device.name orelse "unknown", 0), &ascii.whitespace),
},
);
Expand Down Expand Up @@ -139,11 +142,11 @@ fn handleDestroy(listener: *wl.Listener(*wlr.InputDevice), _: *wlr.InputDevice)
device.deinit();
util.gpa.destroy(device);
},
.tablet_tool => {
.tablet => {
const tablet: *Tablet = @fieldParentPtr("device", device);
tablet.destroy();
},
.switch_device => {
.@"switch" => {
const switch_device: *Switch = @fieldParentPtr("device", device);
switch_device.deinit();
util.gpa.destroy(switch_device);
Expand Down
5 changes: 0 additions & 5 deletions river/LayerSurface.zig
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,6 @@ pub fn create(wlr_layer_surface: *wlr.LayerSurfaceV1) error{OutOfMemory}!void {
wlr_layer_surface.surface.events.unmap.add(&layer_surface.unmap);
wlr_layer_surface.surface.events.commit.add(&layer_surface.commit);
wlr_layer_surface.events.new_popup.add(&layer_surface.new_popup);

// wlroots only informs us of the new surface after the first commit,
// so our listener does not get called for this first commit. However,
// we do want our listener called in order to send the initial configure.
handleCommit(&layer_surface.commit, wlr_layer_surface.surface);
}

pub fn destroyPopups(layer_surface: *LayerSurface) void {
Expand Down
2 changes: 0 additions & 2 deletions river/Output.zig
Original file line number Diff line number Diff line change
Expand Up @@ -556,8 +556,6 @@ fn renderAndCommit(output: *Output, scene_output: *wlr.SceneOutput) !void {

if (!output.wlr_output.commitState(&state)) return error.CommitFailed;

// TODO(wlroots) remove this rotate() call when updating to wlroots 0.18
scene_output.damage_ring.rotate();
output.gamma_dirty = false;
} else {
if (!scene_output.commit(null)) return error.CommitFailed;
Expand Down
2 changes: 1 addition & 1 deletion river/PointerConstraint.zig
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ pub fn deactivate(constraint: *PointerConstraint) void {
fn warpToHintIfSet(constraint: *PointerConstraint) void {
const seat: *Seat = @ptrFromInt(constraint.wlr_constraint.seat.data);

if (constraint.wlr_constraint.current.committed.cursor_hint) {
if (constraint.wlr_constraint.current.cursor_hint.enabled) {
var lx: i32 = undefined;
var ly: i32 = undefined;
_ = constraint.state.active.node.coords(&lx, &ly);
Expand Down
7 changes: 2 additions & 5 deletions river/Root.zig
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ transaction_timeout: *wl.EventSource,
pending_state_dirty: bool = false,

pub fn init(root: *Root) !void {
const output_layout = try wlr.OutputLayout.create();
const output_layout = try wlr.OutputLayout.create(server.wl_server);
errdefer output_layout.destroy();

const scene = try wlr.Scene.create();
Expand All @@ -131,9 +131,6 @@ pub fn init(root: *Root) !void {
const outputs = try interactive_content.createSceneTree();
const override_redirect = if (build_options.xwayland) try interactive_content.createSceneTree();

const presentation = try wlr.Presentation.create(server.wl_server, server.backend);
scene.setPresentation(presentation);

const event_loop = server.wl_server.getEventLoop();
const transaction_timeout = try event_loop.addTimer(*Root, handleTransactionTimeout, root);
errdefer transaction_timeout.remove();
Expand Down Expand Up @@ -166,7 +163,7 @@ pub fn init(root: *Root) !void {
.all_outputs = undefined,
.active_outputs = undefined,

.presentation = presentation,
.presentation = try wlr.Presentation.create(server.wl_server, server.backend),
.xdg_output_manager = try wlr.XdgOutputManagerV1.create(server.wl_server, output_layout),
.output_manager = try wlr.OutputManagerV1.create(server.wl_server),
.power_manager = try wlr.OutputPowerManagerV1.create(server.wl_server),
Expand Down
6 changes: 3 additions & 3 deletions river/Seat.zig
Original file line number Diff line number Diff line change
Expand Up @@ -507,11 +507,11 @@ fn tryAddDevice(seat: *Seat, wlr_device: *wlr.InputDevice) !void {

seat.cursor.wlr_cursor.attachInputDevice(wlr_device);
},
.tablet_tool => {
.tablet => {
try Tablet.create(seat, wlr_device);
seat.cursor.wlr_cursor.attachInputDevice(wlr_device);
},
.switch_device => {
.@"switch" => {
const switch_device = try util.gpa.create(Switch);
errdefer util.gpa.destroy(switch_device);

Expand All @@ -534,7 +534,7 @@ pub fn updateCapabilities(seat: *Seat) void {
switch (device.wlr_device.type) {
.keyboard => capabilities.keyboard = true,
.touch => capabilities.touch = true,
.pointer, .switch_device, .tablet_tool => {},
.pointer, .@"switch", .tablet => {},
.tablet_pad => unreachable,
}
}
Expand Down
Loading

0 comments on commit 99ef96a

Please sign in to comment.