nandi/jolt-nativepublic Fork 0
0fb017593acce485b16f9756141b599beb49dc76
Commits
Clone
git clone https://git.rickub.com/nandi/jolt-native.git
git clone ssh://git@rickub.com/nandi/jolt-native.git

Host key fingerprint (ed25519): SHA256:iycHnxEyq0Q7uyVpB7JlznP0G7JrTPXLYRcAU5CSLhc — verify it before your first connect.

gen-offsets.c · 115 lines · 5.6 KBC Blame HistoryRaw
wayland-bar-compositor: a wlroots compositor in jolt, for panels on X11 1d16366 nandi 8d ago1/*
2 * Prints the wlroots struct layout facts the jolt compositor needs, as EDN.
3 * wlroots changes struct layouts between minor versions, so these are read
4 * from the installed headers rather than written down by hand.
5 *
6 * cc -o gen-offsets gen-offsets.c $(pkg-config --cflags wlroots-0.20 wayland-server pixman-1 xkbcommon)
7 * ./gen-offsets > offsets.edn
8 */
9#define WLR_USE_UNSTABLE
10#include <stdio.h>
11#include <stddef.h>
12#include <time.h>
13#include <wayland-server-core.h>
14#include <wlr/backend.h>
15#include <wlr/types/wlr_buffer.h>
16#include <wlr/types/wlr_cursor.h>
17#include <wlr/types/wlr_input_device.h>
18#include <wlr/types/wlr_keyboard.h>
19#include <wlr/types/wlr_layer_shell_v1.h>
20#include <wlr/types/wlr_output.h>
21#include <wlr/types/wlr_pointer.h>
22#include <wlr/types/wlr_scene.h>
23#include <wlr/types/wlr_seat.h>
24#include <wlr/types/wlr_xdg_shell.h>
25#include <wlr/render/pass.h>
26#include <wlr/util/box.h>
27
28#define O(t, f) printf(" :%s/%s %zu\n", #t, name(#f), offsetof(struct t, f))
29#define Z(t) printf(" :%s/sizeof %zu\n", #t, sizeof(struct t))
30#define E(k, v) printf(" :enum/%s %d\n", k, (int)(v))
31
32/* "events.new_output" -> "events.new_output" is a valid keyword name already;
33 * keep dots, they read as paths. */
34static const char *name(const char *f) { return f; }
35
36int main(void) {
37 printf("{\n");
38 Z(wl_listener); O(wl_listener, link); O(wl_listener, notify);
39 Z(wl_signal); Z(wl_list);
40 Z(timespec);
41
42 O(wlr_backend, events.new_input); O(wlr_backend, events.new_output);
43
44 O(wlr_output, name); O(wlr_output, width); O(wlr_output, height);
45 O(wlr_output, events.frame); O(wlr_output, events.request_state); O(wlr_output, events.destroy);
46 Z(wlr_output_state);
47 O(wlr_output_state, committed); O(wlr_output_state, buffer);
48 E("output-state-buffer", WLR_OUTPUT_STATE_BUFFER);
49 E("buffer-data-ptr-access-read", WLR_BUFFER_DATA_PTR_ACCESS_READ);
50 O(wlr_output_event_request_state, state);
51
52 O(wlr_scene, tree);
53 O(wlr_scene_tree, node);
54 O(wlr_scene_node, type); O(wlr_scene_node, parent); O(wlr_scene_node, enabled);
55 O(wlr_scene_node, x); O(wlr_scene_node, y); O(wlr_scene_node, data);
56 O(wlr_scene_surface, surface);
57 O(wlr_scene_layer_surface_v1, tree);
58 E("scene-node-tree", WLR_SCENE_NODE_TREE);
59 E("scene-node-rect", WLR_SCENE_NODE_RECT);
60 E("scene-node-buffer", WLR_SCENE_NODE_BUFFER);
61
62 O(wlr_xdg_shell, events.new_toplevel); O(wlr_xdg_shell, events.new_popup);
63 O(wlr_xdg_toplevel, base); O(wlr_xdg_toplevel, events.destroy);
64 O(wlr_xdg_surface, surface); O(wlr_xdg_surface, role); O(wlr_xdg_surface, data);
65 O(wlr_xdg_surface, initialized); O(wlr_xdg_surface, initial_commit); O(wlr_xdg_surface, geometry);
66 O(wlr_xdg_popup, base); O(wlr_xdg_popup, parent); O(wlr_xdg_popup, events.destroy);
67 O(wlr_xdg_popup, current.geometry);
68
69 O(wlr_surface, mapped);
70 O(wlr_surface, events.commit); O(wlr_surface, events.map); O(wlr_surface, events.unmap);
71 O(wlr_surface, events.destroy);
72
73 O(wlr_layer_shell_v1, events.new_surface);
74 O(wlr_layer_surface_v1, surface); O(wlr_layer_surface_v1, output); O(wlr_layer_surface_v1, namespace);
75 O(wlr_layer_surface_v1, current.keyboard_interactive); O(wlr_layer_surface_v1, current.layer);
76 O(wlr_layer_surface_v1, initialized); O(wlr_layer_surface_v1, initial_commit);
77 O(wlr_layer_surface_v1, events.destroy); O(wlr_layer_surface_v1, events.new_popup);
78 O(wlr_layer_surface_v1, data);
79
80 O(wlr_cursor, x); O(wlr_cursor, y);
81 O(wlr_cursor, events.motion); O(wlr_cursor, events.motion_absolute); O(wlr_cursor, events.button);
82 O(wlr_cursor, events.axis); O(wlr_cursor, events.frame);
83 O(wlr_pointer, base);
84 O(wlr_pointer_motion_event, pointer); O(wlr_pointer_motion_event, time_msec);
85 O(wlr_pointer_motion_event, delta_x); O(wlr_pointer_motion_event, delta_y);
86 O(wlr_pointer_motion_absolute_event, pointer); O(wlr_pointer_motion_absolute_event, time_msec);
87 O(wlr_pointer_motion_absolute_event, x); O(wlr_pointer_motion_absolute_event, y);
88 O(wlr_pointer_button_event, time_msec); O(wlr_pointer_button_event, button); O(wlr_pointer_button_event, state);
89 O(wlr_pointer_axis_event, time_msec); O(wlr_pointer_axis_event, source); O(wlr_pointer_axis_event, orientation);
90 O(wlr_pointer_axis_event, relative_direction); O(wlr_pointer_axis_event, delta); O(wlr_pointer_axis_event, delta_discrete);
91
92 O(wlr_input_device, type); O(wlr_input_device, events.destroy);
93 E("input-device-keyboard", WLR_INPUT_DEVICE_KEYBOARD);
94 E("input-device-pointer", WLR_INPUT_DEVICE_POINTER);
95
96 O(wlr_keyboard, keycodes); O(wlr_keyboard, num_keycodes); O(wlr_keyboard, modifiers);
97 O(wlr_keyboard, events.key); O(wlr_keyboard, events.modifiers);
98 O(wlr_keyboard_key_event, time_msec); O(wlr_keyboard_key_event, keycode); O(wlr_keyboard_key_event, state);
99
100 O(wlr_seat, pointer_state.focused_client); O(wlr_seat, pointer_state.focused_surface);
101 O(wlr_seat, keyboard_state.focused_surface);
102 O(wlr_seat, events.request_set_cursor); O(wlr_seat, events.request_set_selection);
103 O(wlr_seat, events.request_set_primary_selection);
104 O(wlr_seat_pointer_request_set_cursor_event, seat_client); O(wlr_seat_pointer_request_set_cursor_event, surface);
105 O(wlr_seat_pointer_request_set_cursor_event, hotspot_x); O(wlr_seat_pointer_request_set_cursor_event, hotspot_y);
106 O(wlr_seat_request_set_selection_event, source); O(wlr_seat_request_set_selection_event, serial);
107 O(wlr_seat_request_set_primary_selection_event, source); O(wlr_seat_request_set_primary_selection_event, serial);
108
109 Z(wlr_box); O(wlr_box, x); O(wlr_box, y); O(wlr_box, width); O(wlr_box, height);
110 E("seat-capability-pointer", WL_SEAT_CAPABILITY_POINTER);
111 E("seat-capability-keyboard", WL_SEAT_CAPABILITY_KEYBOARD);
112 E("button-pressed", WL_POINTER_BUTTON_STATE_PRESSED);
113 printf("}\n");
114 return 0;
115}