wayland_client_core.zig(1)

glfmn.io wayland_client_core.zig(1)
Name

wayland_client_core.zig

Bindings to libwayland functionality that does not depend on generated interfaces.

Description

Ziggified bindings to the wayland-client libraries.

Will be included in the wayland.client.wl namespace:

const wayland = @import("wayland");
const wl = wayland.client.wl;

Contents

1const assert = @import("std").debug.assert;
2const client = @import("wayland.zig").client;
3const common = @import("common.zig");
4pub const Object = common.Object;
5pub const Message = common.Message;
6pub const Interface = common.Interface;
7pub const Array = common.Array;
8pub const Fixed = common.Fixed;
9pub const Argument = common.Argument;
10
11pub const Proxy = opaque {
12 extern fn wl_proxy_create(factory: *Proxy, interface: *const Interface) ?*Proxy;
13 pub fn create(factory: *Proxy, interface: *const Interface) error{OutOfMemory}!*Proxy {
14 return wl_proxy_create(factory, interface) orelse error.OutOfMemory;
15 }
16
17 extern fn wl_proxy_destroy(proxy: *Proxy) void;
18 pub const destroy = wl_proxy_destroy;
19
20 extern fn wl_proxy_marshal_array(proxy: *Proxy, opcode: u32, args: ?[*]Argument) void;
21 pub const marshal = wl_proxy_marshal_array;
22
23 extern fn wl_proxy_marshal_array_constructor(
24 proxy: *Proxy,
25 opcode: u32,
26 args: [*]Argument,
27 interface: *const Interface,
28 ) ?*Proxy;
29 pub fn marshalConstructor(
30 proxy: *Proxy,
31 opcode: u32,
32 args: [*]Argument,
33 interface: *const Interface,
34 ) error{OutOfMemory}!*Proxy {
35 return wl_proxy_marshal_array_constructor(proxy, opcode, args, interface) orelse
36 error.OutOfMemory;
37 }
38
39 extern fn wl_proxy_marshal_array_constructor_versioned(
40 proxy: *Proxy,
41 opcode: u32,
42 args: [*]Argument,
43 interface: *const Interface,
44 version: u32,
45 ) ?*Proxy;
46 pub fn marshalConstructorVersioned(
47 proxy: *Proxy,
48 opcode: u32,
49 args: [*]Argument,
50 interface: *const Interface,
51 version: u32,
52 ) error{OutOfMemory}!*Proxy {
53 return wl_proxy_marshal_array_constructor_versioned(proxy, opcode, args, interface, version) orelse
54 error.OutOfMemory;
55 }
56
57 const DispatcherFn = fn (
58 implementation: ?*const anyopaque,
59 proxy: *Proxy,
60 opcode: u32,
61 message: *const Message,
62 args: [*]Argument,
63 ) callconv(.C) c_int;
64 extern fn wl_proxy_add_dispatcher(
65 proxy: *Proxy,
66 dispatcher: *const DispatcherFn,
67 implementation: ?*const anyopaque,
68 data: ?*anyopaque,
69 ) c_int;
70 pub fn addDispatcher(
71 proxy: *Proxy,
72 dispatcher: *const DispatcherFn,
73 implementation: ?*const anyopaque,
74 data: ?*anyopaque,
75 ) void {
76 const ret = wl_proxy_add_dispatcher(proxy, dispatcher, implementation, data);
77 // Since there is no way to remove listeners, adding a listener to
78 // the same proxy twice is always a bug, so assert instead of returning
79 // an error.
80 assert(ret != -1); // If this fails, a listener was already added
81 }
82
83 extern fn wl_proxy_get_user_data(proxy: *Proxy) ?*anyopaque;
84 pub const getUserData = wl_proxy_get_user_data;
85
86 extern fn wl_proxy_get_version(proxy: *Proxy) u32;
87 pub const getVersion = wl_proxy_get_version;
88
89 extern fn wl_proxy_get_id(proxy: *Proxy) u32;
90 pub const getId = wl_proxy_get_id;
91
92 extern fn wl_proxy_set_queue(proxy: *Proxy, queue: *EventQueue) void;
93 pub const setQueue = wl_proxy_set_queue;
94};
95
96pub const EventQueue = opaque {
97 extern fn wl_event_queue_destroy(queue: *EventQueue) void;
98 pub const destroy = wl_event_queue_destroy;
99};
100
101pub const EglWindow = opaque {
102 extern fn wl_egl_window_create(surface: *client.wl.Surface, width: c_int, height: c_int) ?*EglWindow;
103 pub fn create(surface: *client.wl.Surface, width: c_int, height: c_int) !*EglWindow {
104 // Why do people use int when they require a positive number?
105 assert(width > 0 and height > 0);
106 return wl_egl_window_create(surface, width, height) orelse error.OutOfMemory;
107 }
108
109 extern fn wl_egl_window_destroy(egl_window: *EglWindow) void;
110 pub const destroy = wl_egl_window_destroy;
111
112 extern fn wl_egl_window_resize(egl_window: *EglWindow, width: c_int, height: c_int, dx: c_int, dy: c_int) void;
113 pub const resize = wl_egl_window_resize;
114
115 extern fn wl_egl_window_get_attached_size(egl_window: *EglWindow, width: *c_int, height: *c_int) void;
116 pub const getAttachedSize = wl_egl_window_get_attached_size;
117};
118
119pub const CursorTheme = opaque {
120 extern fn wl_cursor_theme_load(name: ?[*:0]const u8, size: c_int, shm: *client.wl.Shm) ?*CursorTheme;
121 pub fn load(name: ?[*:0]const u8, size: i32, shm: *client.wl.Shm) error{LoadThemeFailed}!*CursorTheme {
122 return wl_cursor_theme_load(name, @intCast(size), shm) orelse error.LoadThemeFailed;
123 }
124
125 extern fn wl_cursor_theme_destroy(wl_cursor_theme: *CursorTheme) void;
126 pub const destroy = wl_cursor_theme_destroy;
127
128 extern fn wl_cursor_theme_get_cursor(theme: *CursorTheme, name: [*:0]const u8) ?*Cursor;
129 pub const getCursor = wl_cursor_theme_get_cursor;
130};
131
132pub const Cursor = extern struct {
133 image_count: c_uint,
134 images: [*]*CursorImage,
135 name: [*:0]u8,
136
137 extern fn wl_cursor_frame(cursor: *Cursor, time: u32) c_int;
138 pub const frame = wl_cursor_frame;
139
140 extern fn wl_cursor_frame_and_duration(cursor: *Cursor, time: u32, duration: *u32) c_int;
141 pub const frameAndDuration = wl_cursor_frame_and_duration;
142};
143
144pub const CursorImage = extern struct {
145 width: u32,
146 height: u32,
147 hotspot_x: u32,
148 hotspot_y: u32,
149 delay: u32,
150
151 extern fn wl_cursor_image_get_buffer(image: *CursorImage) ?*client.wl.Buffer;
152 pub fn getBuffer(image: *CursorImage) error{OutOfMemory}!*client.wl.Buffer {
153 return wl_cursor_image_get_buffer(image) orelse error.OutOfMemory;
154 }
155};

References

This page is referenced by the following documents: