aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIsaac Freund <ifreund@ifreund.xyz>2020-04-28 19:16:01 +0200
committerIsaac Freund <ifreund@ifreund.xyz>2020-04-28 19:16:01 +0200
commitd962e6a9a584e21623ee1cb2439c74d166aceaa0 (patch)
tree97b8c8b52fc1221de15c99459c43346fb5b39744
parent7988a2e9348ddbe60a24cbead76ae7c662f3c73a (diff)
downloadriver-d962e6a9a584e21623ee1cb2439c74d166aceaa0.tar.gz
river-d962e6a9a584e21623ee1cb2439c74d166aceaa0.tar.xz
Workaround global anonymous field name counter
Fixes https://github.com/ifreund/river/issues/17
-rw-r--r--src/c.zig6
-rw-r--r--src/keyboard.zig4
-rw-r--r--src/xdg_toplevel.zig5
3 files changed, 12 insertions, 3 deletions
diff --git a/src/c.zig b/src/c.zig
index a551d8e..72bbc04 100644
--- a/src/c.zig
+++ b/src/c.zig
@@ -30,3 +30,9 @@ pub usingnamespace @cImport({
// that can be automatically imported
@cInclude("include/bindings.h");
});
+
+// These are needed because zig currently names translated anonymous unions
+// with a global counter, which makes code unportable.
+// See https://github.com/ifreund/river/issues/17
+pub const wlr_xdg_surface_union = @typeInfo(wlr_xdg_surface).Struct.fields[5].name;
+pub const wlr_input_device_union = @typeInfo(wlr_input_device).Struct.fields[8].name;
diff --git a/src/keyboard.zig b/src/keyboard.zig
index 86d40d6..c1a46dc 100644
--- a/src/keyboard.zig
+++ b/src/keyboard.zig
@@ -17,7 +17,7 @@ pub const Keyboard = struct {
pub fn init(self: *Self, seat: *Seat, device: *c.wlr_input_device) !void {
self.seat = seat;
self.device = device;
- self.wlr_keyboard = device.unnamed_134.keyboard;
+ self.wlr_keyboard = @field(device, c.wlr_input_device_union).keyboard;
// We need to prepare an XKB keymap and assign it to the keyboard. This
// assumes the defaults (e.g. layout = "us").
@@ -60,7 +60,7 @@ pub const Keyboard = struct {
@alignCast(@alignOf(*c.wlr_event_keyboard_key), data),
);
- const wlr_keyboard: *c.wlr_keyboard = self.device.unnamed_134.keyboard;
+ const wlr_keyboard = self.wlr_keyboard;
// Translate libinput keycode -> xkbcommon
const keycode = event.keycode + 8;
diff --git a/src/xdg_toplevel.zig b/src/xdg_toplevel.zig
index 7abcd6e..8f20af0 100644
--- a/src/xdg_toplevel.zig
+++ b/src/xdg_toplevel.zig
@@ -110,7 +110,10 @@ fn handleMap(listener: ?*c.wl_listener, data: ?*c_void) callconv(.C) void {
view.natural_height = @intCast(u32, self.wlr_xdg_surface.surface.*.current.height);
}
- const wlr_xdg_toplevel: *c.wlr_xdg_toplevel = self.wlr_xdg_surface.unnamed_166.toplevel;
+ const wlr_xdg_toplevel: *c.wlr_xdg_toplevel = @field(
+ self.wlr_xdg_surface,
+ c.wlr_xdg_surface_union,
+ ).toplevel;
const state = &wlr_xdg_toplevel.current;
const app_id: [*:0]const u8 = if (wlr_xdg_toplevel.app_id) |id| id else "NULL";