Skip to content

Commit

Permalink
core: implement flush and poll
Browse files Browse the repository at this point in the history
Triggers the following error:
```
Segmentation fault at address 0x520
/home/josh/zig/0.14.0-dev.1911+3bf89f55c/files/lib/std/fifo.zig:245:24: 0x134f3e8 in writableLength (core-triangle)
            return self.buf.len - self.count;
                       ^
/home/josh/zig/0.14.0-dev.1911+3bf89f55c/files/lib/std/fifo.zig:136:36: 0x125e015 in ensureUnusedCapacity (core-triangle)
            if (self.writableLength() >= size) return;
                                   ^
/home/josh/zig/0.14.0-dev.1911+3bf89f55c/files/lib/std/fifo.zig:299:42: 0x125df76 in writeItem (core-triangle)
            try self.ensureUnusedCapacity(1);
                                         ^
/home/josh/dev/open-source/mach/src/Core.zig:379:26: 0x13763b7 in keyboardHandleEnter (core-triangle)
    core.events.writeItem(event) catch {
                         ^
???:?:?: 0x7d27dc80a595 in ??? (libffi.so.8)
Unwind information for `libffi.so.8:0x7d27dc80a595` was not available, trace may be incomplete
```
  • Loading branch information
joshua-holmes committed Oct 25, 2024
1 parent 404cf1c commit ea6e027
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/core/linux/Wayland.zig
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,27 @@ pub fn deinit(
}

pub fn update(wl: *Wayland) !void {
while (wl.libwaylandclient.wl_display_flush(wl.display) == -1) {
if (std.posix.errno(-1) == std.posix.E.AGAIN) {
log.err("flush error", .{});
return error.FlushError;
}
var pollfd = [_]std.posix.pollfd{
std.posix.pollfd{
.fd = wl.libwaylandclient.wl_display_get_fd(wl.display),
.events = std.posix.POLL.OUT,
.revents = 0,
},
};
while (try std.posix.poll(&pollfd, 1) == -1) {
const errno = std.posix.errno(-1);
if (errno == std.posix.E.INTR or errno == std.posix.E.AGAIN) {
log.err("poll error", .{});
return error.PollError;
}
}
}

_ = wl.libwaylandclient.wl_display_roundtrip(wl.display);

wl.core.input.tick();
Expand Down

0 comments on commit ea6e027

Please sign in to comment.