tony / oxwm

Branch: a8a8323
Switch branches/tags
master
tonybanters Zig port. e95e4af 2026-02-02
84 lines · 3.1 KB Raw Blame History
1 const std = @import("std");
2 const xlib = @import("xlib.zig");
3
4 pub const EventType = enum(c_int) {
5 key_press = xlib.KeyPress,
6 key_release = xlib.KeyRelease,
7 button_press = xlib.ButtonPress,
8 button_release = xlib.ButtonRelease,
9 motion_notify = xlib.MotionNotify,
10 enter_notify = xlib.EnterNotify,
11 leave_notify = xlib.LeaveNotify,
12 focus_in = xlib.FocusIn,
13 focus_out = xlib.FocusOut,
14 keymap_notify = xlib.KeymapNotify,
15 expose = xlib.Expose,
16 graphics_expose = xlib.GraphicsExpose,
17 no_expose = xlib.NoExpose,
18 visibility_notify = xlib.VisibilityNotify,
19 create_notify = xlib.CreateNotify,
20 destroy_notify = xlib.DestroyNotify,
21 unmap_notify = xlib.UnmapNotify,
22 map_notify = xlib.MapNotify,
23 map_request = xlib.MapRequest,
24 reparent_notify = xlib.ReparentNotify,
25 configure_notify = xlib.ConfigureNotify,
26 configure_request = xlib.ConfigureRequest,
27 gravity_notify = xlib.GravityNotify,
28 resize_request = xlib.ResizeRequest,
29 circulate_notify = xlib.CirculateNotify,
30 circulate_request = xlib.CirculateRequest,
31 property_notify = xlib.PropertyNotify,
32 selection_clear = xlib.SelectionClear,
33 selection_request = xlib.SelectionRequest,
34 selection_notify = xlib.SelectionNotify,
35 colormap_notify = xlib.ColormapNotify,
36 client_message = xlib.ClientMessage,
37 mapping_notify = xlib.MappingNotify,
38 generic_event = xlib.GenericEvent,
39 _,
40 };
41
42 pub fn get_event_type(event: *const xlib.XEvent) EventType {
43 return @enumFromInt(event.type);
44 }
45
46 pub fn event_name(event_type: EventType) []const u8 {
47 return switch (event_type) {
48 .key_press => "key_press",
49 .key_release => "key_release",
50 .button_press => "button_press",
51 .button_release => "button_release",
52 .motion_notify => "motion_notify",
53 .enter_notify => "enter_notify",
54 .leave_notify => "leave_notify",
55 .focus_in => "focus_in",
56 .focus_out => "focus_out",
57 .keymap_notify => "keymap_notify",
58 .expose => "expose",
59 .graphics_expose => "graphics_expose",
60 .no_expose => "no_expose",
61 .visibility_notify => "visibility_notify",
62 .create_notify => "create_notify",
63 .destroy_notify => "destroy_notify",
64 .unmap_notify => "unmap_notify",
65 .map_notify => "map_notify",
66 .map_request => "map_request",
67 .reparent_notify => "reparent_notify",
68 .configure_notify => "configure_notify",
69 .configure_request => "configure_request",
70 .gravity_notify => "gravity_notify",
71 .resize_request => "resize_request",
72 .circulate_notify => "circulate_notify",
73 .circulate_request => "circulate_request",
74 .property_notify => "property_notify",
75 .selection_clear => "selection_clear",
76 .selection_request => "selection_request",
77 .selection_notify => "selection_notify",
78 .colormap_notify => "colormap_notify",
79 .client_message => "client_message",
80 .mapping_notify => "mapping_notify",
81 .generic_event => "generic_event",
82 _ => "unknown",
83 };
84 }