From c1b885dd64387015074b8de350a6a1659913c54c Mon Sep 17 00:00:00 2001 From: Isaac Freund Date: Mon, 27 Apr 2020 11:21:49 +0200 Subject: [PATCH] Clean up some code using c imported enums --- src/cursor.zig | 8 ++------ src/keyboard.zig | 6 +++--- src/main.zig | 2 +- src/render.zig | 2 +- src/seat.zig | 2 +- src/server.zig | 2 +- 6 files changed, 9 insertions(+), 13 deletions(-) diff --git a/src/cursor.zig b/src/cursor.zig index 0903ef8..ba1537c 100644 --- a/src/cursor.zig +++ b/src/cursor.zig @@ -144,9 +144,7 @@ pub const Cursor = struct { // focus to the view. if (c.wlr_surface_is_xdg_surface(wlr_surface)) { const wlr_xdg_surface = c.wlr_xdg_surface_from_wlr_surface(wlr_surface); - if (wlr_xdg_surface.*.role == - c.enum_wlr_xdg_surface_role.WLR_XDG_SURFACE_ROLE_TOPLEVEL) - { + if (wlr_xdg_surface.*.role == .WLR_XDG_SURFACE_ROLE_TOPLEVEL) { const view = @ptrCast(*View, @alignCast(@alignOf(*View), wlr_xdg_surface.*.data)); self.seat.focus(view); } @@ -353,9 +351,7 @@ pub const Cursor = struct { return found; } else if (c.wlr_surface_is_xdg_surface(found)) { const wlr_xdg_surface = c.wlr_xdg_surface_from_wlr_surface(found); - if (wlr_xdg_surface.*.role == - c.enum_wlr_xdg_surface_role.WLR_XDG_SURFACE_ROLE_POPUP) - { + if (wlr_xdg_surface.*.role == .WLR_XDG_SURFACE_ROLE_POPUP) { return found; } } diff --git a/src/keyboard.zig b/src/keyboard.zig index 13aac76..86d40d6 100644 --- a/src/keyboard.zig +++ b/src/keyboard.zig @@ -28,14 +28,14 @@ pub const Keyboard = struct { .variant = null, .options = null, }; - const context = c.xkb_context_new(c.enum_xkb_context_flags.XKB_CONTEXT_NO_FLAGS) orelse + const context = c.xkb_context_new(.XKB_CONTEXT_NO_FLAGS) orelse return error.CantCreateXkbContext; defer c.xkb_context_unref(context); const keymap = c.xkb_keymap_new_from_names( context, &rules, - c.enum_xkb_keymap_compile_flags.XKB_KEYMAP_COMPILE_NO_FLAGS, + .XKB_KEYMAP_COMPILE_NO_FLAGS, ) orelse return error.CantCreateXkbKeymap; defer c.xkb_keymap_unref(keymap); @@ -88,7 +88,7 @@ pub const Keyboard = struct { var handled = false; // TODO: These modifiers aren't properly handled, see sway's code const modifiers = c.wlr_keyboard_get_modifiers(wlr_keyboard); - if (event.state == c.enum_wlr_key_state.WLR_KEY_PRESSED) { + if (event.state == .WLR_KEY_PRESSED) { var i: usize = 0; while (i < translated_keysyms_len) : (i += 1) { if (self.handleBuiltinKeybind(translated_keysyms.?[i])) { diff --git a/src/main.zig b/src/main.zig index 9b581b2..9c2bd79 100644 --- a/src/main.zig +++ b/src/main.zig @@ -6,7 +6,7 @@ const Server = @import("server.zig").Server; pub fn main() !void { Log.init(Log.Debug); - c.wlr_log_init(c.enum_wlr_log_importance.WLR_ERROR, null); + c.wlr_log_init(.WLR_ERROR, null); Log.Info.log("Initializing server", .{}); diff --git a/src/render.zig b/src/render.zig index 2e4dba6..deb118e 100644 --- a/src/render.zig +++ b/src/render.zig @@ -183,7 +183,7 @@ fn renderView(output: Output, view: *View, now: *c.timespec) void { c.wlr_matrix_project_box( &matrix, &box, - c.enum_wl_output_transform.WL_OUTPUT_TRANSFORM_NORMAL, + .WL_OUTPUT_TRANSFORM_NORMAL, 0.0, &output.wlr_output.transform_matrix, ); diff --git a/src/seat.zig b/src/seat.zig index 030feb2..701f1b8 100644 --- a/src/seat.zig +++ b/src/seat.zig @@ -248,7 +248,7 @@ pub const Seat = struct { // We need to let the wlr_seat know what our capabilities are, which is // communiciated to the client. We always have a cursor, even if // there are no pointer devices, so we always include that capability. - var caps: u32 = @intCast(u32, c.WL_SEAT_CAPABILITY_POINTER); + var caps = @intCast(u32, c.WL_SEAT_CAPABILITY_POINTER); // if list not empty if (self.keyboards.len > 0) { caps |= @intCast(u32, c.WL_SEAT_CAPABILITY_KEYBOARD); diff --git a/src/server.zig b/src/server.zig index 1c7fa66..3795f07 100644 --- a/src/server.zig +++ b/src/server.zig @@ -145,7 +145,7 @@ pub const Server = struct { const self = @fieldParentPtr(Self, "listen_new_xdg_surface", listener.?); const wlr_xdg_surface = @ptrCast(*c.wlr_xdg_surface, @alignCast(@alignOf(*c.wlr_xdg_surface), data)); - if (wlr_xdg_surface.role != c.enum_wlr_xdg_surface_role.WLR_XDG_SURFACE_ROLE_TOPLEVEL) { + if (wlr_xdg_surface.role != .WLR_XDG_SURFACE_ROLE_TOPLEVEL) { // TODO: log return; }