nandi/jolt-nativepublic Fork 0
228672deff39ee418d1b734ed0920ce16985e8e1
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.

wayland-bar-compositor: a wlroots compositor in jolt, for panels on X11 1d16366 · on 228672deff39ee418d1b734ed0920ce16985e8e1 · nandi · 8d ago
gen-offsets.c · 115 lines · 5.6 KBC Blame HistoryRaw
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
/*
 * Prints the wlroots struct layout facts the jolt compositor needs, as EDN.
 * wlroots changes struct layouts between minor versions, so these are read
 * from the installed headers rather than written down by hand.
 *
 *   cc -o gen-offsets gen-offsets.c $(pkg-config --cflags wlroots-0.20 wayland-server pixman-1 xkbcommon)
 *   ./gen-offsets > offsets.edn
 */
#define WLR_USE_UNSTABLE
#include <stdio.h>
#include <stddef.h>
#include <time.h>
#include <wayland-server-core.h>
#include <wlr/backend.h>
#include <wlr/types/wlr_buffer.h>
#include <wlr/types/wlr_cursor.h>
#include <wlr/types/wlr_input_device.h>
#include <wlr/types/wlr_keyboard.h>
#include <wlr/types/wlr_layer_shell_v1.h>
#include <wlr/types/wlr_output.h>
#include <wlr/types/wlr_pointer.h>
#include <wlr/types/wlr_scene.h>
#include <wlr/types/wlr_seat.h>
#include <wlr/types/wlr_xdg_shell.h>
#include <wlr/render/pass.h>
#include <wlr/util/box.h>

#define O(t, f) printf(" :%s/%s %zu\n", #t, name(#f), offsetof(struct t, f))
#define Z(t) printf(" :%s/sizeof %zu\n", #t, sizeof(struct t))
#define E(k, v) printf(" :enum/%s %d\n", k, (int)(v))

/* "events.new_output" -> "events.new_output" is a valid keyword name already;
 * keep dots, they read as paths. */
static const char *name(const char *f) { return f; }

int main(void) {
	printf("{\n");
	Z(wl_listener); O(wl_listener, link); O(wl_listener, notify);
	Z(wl_signal); Z(wl_list);
	Z(timespec);

	O(wlr_backend, events.new_input); O(wlr_backend, events.new_output);

	O(wlr_output, name); O(wlr_output, width); O(wlr_output, height);
	O(wlr_output, events.frame); O(wlr_output, events.request_state); O(wlr_output, events.destroy);
	Z(wlr_output_state);
	O(wlr_output_state, committed); O(wlr_output_state, buffer);
	E("output-state-buffer", WLR_OUTPUT_STATE_BUFFER);
	E("buffer-data-ptr-access-read", WLR_BUFFER_DATA_PTR_ACCESS_READ);
	O(wlr_output_event_request_state, state);

	O(wlr_scene, tree);
	O(wlr_scene_tree, node);
	O(wlr_scene_node, type); O(wlr_scene_node, parent); O(wlr_scene_node, enabled);
	O(wlr_scene_node, x); O(wlr_scene_node, y); O(wlr_scene_node, data);
	O(wlr_scene_surface, surface);
	O(wlr_scene_layer_surface_v1, tree);
	E("scene-node-tree", WLR_SCENE_NODE_TREE);
	E("scene-node-rect", WLR_SCENE_NODE_RECT);
	E("scene-node-buffer", WLR_SCENE_NODE_BUFFER);

	O(wlr_xdg_shell, events.new_toplevel); O(wlr_xdg_shell, events.new_popup);
	O(wlr_xdg_toplevel, base); O(wlr_xdg_toplevel, events.destroy);
	O(wlr_xdg_surface, surface); O(wlr_xdg_surface, role); O(wlr_xdg_surface, data);
	O(wlr_xdg_surface, initialized); O(wlr_xdg_surface, initial_commit); O(wlr_xdg_surface, geometry);
	O(wlr_xdg_popup, base); O(wlr_xdg_popup, parent); O(wlr_xdg_popup, events.destroy);
	O(wlr_xdg_popup, current.geometry);

	O(wlr_surface, mapped);
	O(wlr_surface, events.commit); O(wlr_surface, events.map); O(wlr_surface, events.unmap);
	O(wlr_surface, events.destroy);

	O(wlr_layer_shell_v1, events.new_surface);
	O(wlr_layer_surface_v1, surface); O(wlr_layer_surface_v1, output); O(wlr_layer_surface_v1, namespace);
	O(wlr_layer_surface_v1, current.keyboard_interactive); O(wlr_layer_surface_v1, current.layer);
	O(wlr_layer_surface_v1, initialized); O(wlr_layer_surface_v1, initial_commit);
	O(wlr_layer_surface_v1, events.destroy); O(wlr_layer_surface_v1, events.new_popup);
	O(wlr_layer_surface_v1, data);

	O(wlr_cursor, x); O(wlr_cursor, y);
	O(wlr_cursor, events.motion); O(wlr_cursor, events.motion_absolute); O(wlr_cursor, events.button);
	O(wlr_cursor, events.axis); O(wlr_cursor, events.frame);
	O(wlr_pointer, base);
	O(wlr_pointer_motion_event, pointer); O(wlr_pointer_motion_event, time_msec);
	O(wlr_pointer_motion_event, delta_x); O(wlr_pointer_motion_event, delta_y);
	O(wlr_pointer_motion_absolute_event, pointer); O(wlr_pointer_motion_absolute_event, time_msec);
	O(wlr_pointer_motion_absolute_event, x); O(wlr_pointer_motion_absolute_event, y);
	O(wlr_pointer_button_event, time_msec); O(wlr_pointer_button_event, button); O(wlr_pointer_button_event, state);
	O(wlr_pointer_axis_event, time_msec); O(wlr_pointer_axis_event, source); O(wlr_pointer_axis_event, orientation);
	O(wlr_pointer_axis_event, relative_direction); O(wlr_pointer_axis_event, delta); O(wlr_pointer_axis_event, delta_discrete);

	O(wlr_input_device, type); O(wlr_input_device, events.destroy);
	E("input-device-keyboard", WLR_INPUT_DEVICE_KEYBOARD);
	E("input-device-pointer", WLR_INPUT_DEVICE_POINTER);

	O(wlr_keyboard, keycodes); O(wlr_keyboard, num_keycodes); O(wlr_keyboard, modifiers);
	O(wlr_keyboard, events.key); O(wlr_keyboard, events.modifiers);
	O(wlr_keyboard_key_event, time_msec); O(wlr_keyboard_key_event, keycode); O(wlr_keyboard_key_event, state);

	O(wlr_seat, pointer_state.focused_client); O(wlr_seat, pointer_state.focused_surface);
	O(wlr_seat, keyboard_state.focused_surface);
	O(wlr_seat, events.request_set_cursor); O(wlr_seat, events.request_set_selection);
	O(wlr_seat, events.request_set_primary_selection);
	O(wlr_seat_pointer_request_set_cursor_event, seat_client); O(wlr_seat_pointer_request_set_cursor_event, surface);
	O(wlr_seat_pointer_request_set_cursor_event, hotspot_x); O(wlr_seat_pointer_request_set_cursor_event, hotspot_y);
	O(wlr_seat_request_set_selection_event, source); O(wlr_seat_request_set_selection_event, serial);
	O(wlr_seat_request_set_primary_selection_event, source); O(wlr_seat_request_set_primary_selection_event, serial);

	Z(wlr_box); O(wlr_box, x); O(wlr_box, y); O(wlr_box, width); O(wlr_box, height);
	E("seat-capability-pointer", WL_SEAT_CAPABILITY_POINTER);
	E("seat-capability-keyboard", WL_SEAT_CAPABILITY_KEYBOARD);
	E("button-pressed", WL_POINTER_BUTTON_STATE_PRESSED);
	printf("}\n");
	return 0;
}