const std = @import("std"); const xlib = @import("xlib.zig"); pub const EventType = enum(c_int) { key_press = xlib.KeyPress, key_release = xlib.KeyRelease, button_press = xlib.ButtonPress, button_release = xlib.ButtonRelease, motion_notify = xlib.MotionNotify, enter_notify = xlib.EnterNotify, leave_notify = xlib.LeaveNotify, focus_in = xlib.FocusIn, focus_out = xlib.FocusOut, keymap_notify = xlib.KeymapNotify, expose = xlib.Expose, graphics_expose = xlib.GraphicsExpose, no_expose = xlib.NoExpose, visibility_notify = xlib.VisibilityNotify, create_notify = xlib.CreateNotify, destroy_notify = xlib.DestroyNotify, unmap_notify = xlib.UnmapNotify, map_notify = xlib.MapNotify, map_request = xlib.MapRequest, reparent_notify = xlib.ReparentNotify, configure_notify = xlib.ConfigureNotify, configure_request = xlib.ConfigureRequest, gravity_notify = xlib.GravityNotify, resize_request = xlib.ResizeRequest, circulate_notify = xlib.CirculateNotify, circulate_request = xlib.CirculateRequest, property_notify = xlib.PropertyNotify, selection_clear = xlib.SelectionClear, selection_request = xlib.SelectionRequest, selection_notify = xlib.SelectionNotify, colormap_notify = xlib.ColormapNotify, client_message = xlib.ClientMessage, mapping_notify = xlib.MappingNotify, generic_event = xlib.GenericEvent, _, }; pub fn get_event_type(event: *const xlib.XEvent) EventType { return @enumFromInt(event.type); } pub fn event_name(event_type: EventType) []const u8 { return switch (event_type) { .key_press => "key_press", .key_release => "key_release", .button_press => "button_press", .button_release => "button_release", .motion_notify => "motion_notify", .enter_notify => "enter_notify", .leave_notify => "leave_notify", .focus_in => "focus_in", .focus_out => "focus_out", .keymap_notify => "keymap_notify", .expose => "expose", .graphics_expose => "graphics_expose", .no_expose => "no_expose", .visibility_notify => "visibility_notify", .create_notify => "create_notify", .destroy_notify => "destroy_notify", .unmap_notify => "unmap_notify", .map_notify => "map_notify", .map_request => "map_request", .reparent_notify => "reparent_notify", .configure_notify => "configure_notify", .configure_request => "configure_request", .gravity_notify => "gravity_notify", .resize_request => "resize_request", .circulate_notify => "circulate_notify", .circulate_request => "circulate_request", .property_notify => "property_notify", .selection_clear => "selection_clear", .selection_request => "selection_request", .selection_notify => "selection_notify", .colormap_notify => "colormap_notify", .client_message => "client_message", .mapping_notify => "mapping_notify", .generic_event => "generic_event", _ => "unknown", }; }