Clean up some code using c imported enums

This commit is contained in:
Isaac Freund 2020-04-27 11:21:49 +02:00
parent 9b1197feb3
commit c1b885dd64
No known key found for this signature in database
GPG key ID: 86DED400DDFD7A11
6 changed files with 9 additions and 13 deletions

View file

@ -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;
}
}

View file

@ -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])) {

View file

@ -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", .{});

View file

@ -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,
);

View file

@ -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);

View file

@ -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;
}